Commit ee605756 authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: Remove EXTRA, NORMAL instruction type check.

BUG=

Review-Url: https://codereview.chromium.org/2374013004
Cr-Commit-Position: refs/heads/master@{#39904}
parent e5001447
...@@ -898,7 +898,6 @@ class InstructionBase { ...@@ -898,7 +898,6 @@ class InstructionBase {
inline int Bits(int hi, int lo) const { inline int Bits(int hi, int lo) const {
return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1); return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1);
} }
enum TypeChecks { NORMAL, EXTRA };
static constexpr uint64_t kOpcodeImmediateTypeMask = static constexpr uint64_t kOpcodeImmediateTypeMask =
...@@ -967,7 +966,7 @@ class InstructionBase { ...@@ -967,7 +966,7 @@ class InstructionBase {
inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; } inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; }
// Get the encoding type of the instruction. // Get the encoding type of the instruction.
inline Type InstructionType(TypeChecks checks = NORMAL) const; inline Type InstructionType() const;
protected: protected:
InstructionBase() {} InstructionBase() {}
...@@ -1142,11 +1141,16 @@ class InstructionGetters : public T { ...@@ -1142,11 +1141,16 @@ class InstructionGetters : public T {
class Instruction : public InstructionGetters<InstructionBase> { class Instruction : public InstructionGetters<InstructionBase> {
public: public:
// Instructions are read of out a code stream. The only way to get a
// reference to an instruction is to convert a pointer. There is no way
// to allocate or create instances of class Instruction.
// Use the At(pc) function to create references to Instruction.
static Instruction* At(byte* pc) { static Instruction* At(byte* pc) {
return reinterpret_cast<Instruction*>(pc); return reinterpret_cast<Instruction*>(pc);
} }
private: private:
// We need to prevent the creation of instances of class Instruction.
DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction);
}; };
...@@ -1165,26 +1169,14 @@ const int kBArgsSlotsSize = 0 * Instruction::kInstrSize; ...@@ -1165,26 +1169,14 @@ const int kBArgsSlotsSize = 0 * Instruction::kInstrSize;
const int kBranchReturnOffset = 2 * Instruction::kInstrSize; const int kBranchReturnOffset = 2 * Instruction::kInstrSize;
InstructionBase::Type InstructionBase::InstructionType( InstructionBase::Type InstructionBase::InstructionType() const {
TypeChecks checks) const {
if (checks == EXTRA) {
if (OpcodeToBitNumber(OpcodeFieldRaw()) & kOpcodeImmediateTypeMask) {
return kImmediateType;
}
}
switch (OpcodeFieldRaw()) { switch (OpcodeFieldRaw()) {
case SPECIAL: case SPECIAL:
if (checks == EXTRA) { if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
if (FunctionFieldToBitNumber(FunctionFieldRaw()) & kFunctionFieldRegisterTypeMask) {
kFunctionFieldRegisterTypeMask) {
return kRegisterType;
} else {
return kUnsupported;
}
} else {
return kRegisterType; return kRegisterType;
} }
break; return kUnsupported;
case SPECIAL2: case SPECIAL2:
switch (FunctionFieldRaw()) { switch (FunctionFieldRaw()) {
case MUL: case MUL:
...@@ -1239,11 +1231,7 @@ InstructionBase::Type InstructionBase::InstructionType( ...@@ -1239,11 +1231,7 @@ InstructionBase::Type InstructionBase::InstructionType(
return kJumpType; return kJumpType;
default: default:
if (checks == NORMAL) {
return kImmediateType; return kImmediateType;
} else {
return kUnsupported;
}
} }
} }
......
...@@ -1712,7 +1712,7 @@ int Decoder::InstructionDecode(byte* instr_ptr) { ...@@ -1712,7 +1712,7 @@ int Decoder::InstructionDecode(byte* instr_ptr) {
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%08x ", "%08x ",
instr->InstructionBits()); instr->InstructionBits());
switch (instr->InstructionType(Instruction::EXTRA)) { switch (instr->InstructionType()) {
case Instruction::kRegisterType: { case Instruction::kRegisterType: {
DecodeTypeRegister(instr); DecodeTypeRegister(instr);
break; break;
......
...@@ -140,7 +140,7 @@ class SimInstruction : public InstructionGetters<SimInstructionBase> { ...@@ -140,7 +140,7 @@ class SimInstruction : public InstructionGetters<SimInstructionBase> {
SimInstruction& operator=(Instruction* instr) { SimInstruction& operator=(Instruction* instr) {
operand_ = *reinterpret_cast<const int32_t*>(instr); operand_ = *reinterpret_cast<const int32_t*>(instr);
instr_ = instr; instr_ = instr;
type_ = InstructionBase::InstructionType(EXTRA); type_ = InstructionBase::InstructionType();
DCHECK(reinterpret_cast<void*>(&operand_) == this); DCHECK(reinterpret_cast<void*>(&operand_) == this);
return *this; return *this;
} }
......
...@@ -932,8 +932,6 @@ class InstructionBase { ...@@ -932,8 +932,6 @@ class InstructionBase {
return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1); return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1);
} }
enum TypeChecks { NORMAL, EXTRA };
static constexpr uint64_t kOpcodeImmediateTypeMask = static constexpr uint64_t kOpcodeImmediateTypeMask =
OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) | OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) |
OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) | OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) |
...@@ -1014,7 +1012,7 @@ class InstructionBase { ...@@ -1014,7 +1012,7 @@ class InstructionBase {
inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; } inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; }
// Get the encoding type of the instruction. // Get the encoding type of the instruction.
inline Type InstructionType(TypeChecks checks = NORMAL) const; inline Type InstructionType() const;
protected: protected:
InstructionBase() {} InstructionBase() {}
...@@ -1226,26 +1224,14 @@ const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2; ...@@ -1226,26 +1224,14 @@ const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2;
const int kInvalidStackOffset = -1; const int kInvalidStackOffset = -1;
const int kBranchReturnOffset = 2 * Instruction::kInstrSize; const int kBranchReturnOffset = 2 * Instruction::kInstrSize;
InstructionBase::Type InstructionBase::InstructionType( InstructionBase::Type InstructionBase::InstructionType() const {
TypeChecks checks) const {
if (checks == EXTRA) {
if (OpcodeToBitNumber(OpcodeFieldRaw()) & kOpcodeImmediateTypeMask) {
return kImmediateType;
}
}
switch (OpcodeFieldRaw()) { switch (OpcodeFieldRaw()) {
case SPECIAL: case SPECIAL:
if (checks == EXTRA) { if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
if (FunctionFieldToBitNumber(FunctionFieldRaw()) & kFunctionFieldRegisterTypeMask) {
kFunctionFieldRegisterTypeMask) {
return kRegisterType;
} else {
return kUnsupported;
}
} else {
return kRegisterType; return kRegisterType;
} }
break; return kUnsupported;
case SPECIAL2: case SPECIAL2:
switch (FunctionFieldRaw()) { switch (FunctionFieldRaw()) {
case MUL: case MUL:
...@@ -1322,11 +1308,7 @@ InstructionBase::Type InstructionBase::InstructionType( ...@@ -1322,11 +1308,7 @@ InstructionBase::Type InstructionBase::InstructionType(
return kJumpType; return kJumpType;
default: default:
if (checks == NORMAL) { return kImmediateType;
return kImmediateType;
} else {
return kUnsupported;
}
} }
return kUnsupported; return kUnsupported;
} }
......
...@@ -1946,7 +1946,7 @@ int Decoder::InstructionDecode(byte* instr_ptr) { ...@@ -1946,7 +1946,7 @@ int Decoder::InstructionDecode(byte* instr_ptr) {
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%08x ", "%08x ",
instr->InstructionBits()); instr->InstructionBits());
switch (instr->InstructionType(Instruction::TypeChecks::EXTRA)) { switch (instr->InstructionType()) {
case Instruction::kRegisterType: { case Instruction::kRegisterType: {
return DecodeTypeRegister(instr); return DecodeTypeRegister(instr);
} }
......
...@@ -149,7 +149,7 @@ class SimInstruction : public InstructionGetters<SimInstructionBase> { ...@@ -149,7 +149,7 @@ class SimInstruction : public InstructionGetters<SimInstructionBase> {
SimInstruction& operator=(Instruction* instr) { SimInstruction& operator=(Instruction* instr) {
operand_ = *reinterpret_cast<const int32_t*>(instr); operand_ = *reinterpret_cast<const int32_t*>(instr);
instr_ = instr; instr_ = instr;
type_ = InstructionBase::InstructionType(EXTRA); type_ = InstructionBase::InstructionType();
DCHECK(reinterpret_cast<void*>(&operand_) == this); DCHECK(reinterpret_cast<void*>(&operand_) == this);
return *this; return *this;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment