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 {
inline int Bits(int hi, int lo) const {
return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1);
}
enum TypeChecks { NORMAL, EXTRA };
static constexpr uint64_t kOpcodeImmediateTypeMask =
......@@ -967,7 +966,7 @@ class InstructionBase {
inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; }
// Get the encoding type of the instruction.
inline Type InstructionType(TypeChecks checks = NORMAL) const;
inline Type InstructionType() const;
protected:
InstructionBase() {}
......@@ -1142,11 +1141,16 @@ class InstructionGetters : public T {
class Instruction : public InstructionGetters<InstructionBase> {
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) {
return reinterpret_cast<Instruction*>(pc);
}
private:
// We need to prevent the creation of instances of class Instruction.
DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction);
};
......@@ -1165,26 +1169,14 @@ const int kBArgsSlotsSize = 0 * Instruction::kInstrSize;
const int kBranchReturnOffset = 2 * Instruction::kInstrSize;
InstructionBase::Type InstructionBase::InstructionType(
TypeChecks checks) const {
if (checks == EXTRA) {
if (OpcodeToBitNumber(OpcodeFieldRaw()) & kOpcodeImmediateTypeMask) {
return kImmediateType;
}
}
InstructionBase::Type InstructionBase::InstructionType() const {
switch (OpcodeFieldRaw()) {
case SPECIAL:
if (checks == EXTRA) {
if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
kFunctionFieldRegisterTypeMask) {
return kRegisterType;
} else {
return kUnsupported;
}
} else {
if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
kFunctionFieldRegisterTypeMask) {
return kRegisterType;
}
break;
return kUnsupported;
case SPECIAL2:
switch (FunctionFieldRaw()) {
case MUL:
......@@ -1239,11 +1231,7 @@ InstructionBase::Type InstructionBase::InstructionType(
return kJumpType;
default:
if (checks == NORMAL) {
return kImmediateType;
} else {
return kUnsupported;
}
}
}
......
......@@ -1712,7 +1712,7 @@ int Decoder::InstructionDecode(byte* instr_ptr) {
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%08x ",
instr->InstructionBits());
switch (instr->InstructionType(Instruction::EXTRA)) {
switch (instr->InstructionType()) {
case Instruction::kRegisterType: {
DecodeTypeRegister(instr);
break;
......
......@@ -140,7 +140,7 @@ class SimInstruction : public InstructionGetters<SimInstructionBase> {
SimInstruction& operator=(Instruction* instr) {
operand_ = *reinterpret_cast<const int32_t*>(instr);
instr_ = instr;
type_ = InstructionBase::InstructionType(EXTRA);
type_ = InstructionBase::InstructionType();
DCHECK(reinterpret_cast<void*>(&operand_) == this);
return *this;
}
......
......@@ -932,8 +932,6 @@ class InstructionBase {
return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1);
}
enum TypeChecks { NORMAL, EXTRA };
static constexpr uint64_t kOpcodeImmediateTypeMask =
OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) |
OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) |
......@@ -1014,7 +1012,7 @@ class InstructionBase {
inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; }
// Get the encoding type of the instruction.
inline Type InstructionType(TypeChecks checks = NORMAL) const;
inline Type InstructionType() const;
protected:
InstructionBase() {}
......@@ -1226,26 +1224,14 @@ const int kCArgsSlotsSize = kCArgSlotCount * Instruction::kInstrSize * 2;
const int kInvalidStackOffset = -1;
const int kBranchReturnOffset = 2 * Instruction::kInstrSize;
InstructionBase::Type InstructionBase::InstructionType(
TypeChecks checks) const {
if (checks == EXTRA) {
if (OpcodeToBitNumber(OpcodeFieldRaw()) & kOpcodeImmediateTypeMask) {
return kImmediateType;
}
}
InstructionBase::Type InstructionBase::InstructionType() const {
switch (OpcodeFieldRaw()) {
case SPECIAL:
if (checks == EXTRA) {
if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
kFunctionFieldRegisterTypeMask) {
return kRegisterType;
} else {
return kUnsupported;
}
} else {
if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
kFunctionFieldRegisterTypeMask) {
return kRegisterType;
}
break;
return kUnsupported;
case SPECIAL2:
switch (FunctionFieldRaw()) {
case MUL:
......@@ -1322,11 +1308,7 @@ InstructionBase::Type InstructionBase::InstructionType(
return kJumpType;
default:
if (checks == NORMAL) {
return kImmediateType;
} else {
return kUnsupported;
}
return kImmediateType;
}
return kUnsupported;
}
......
......@@ -1946,7 +1946,7 @@ int Decoder::InstructionDecode(byte* instr_ptr) {
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"%08x ",
instr->InstructionBits());
switch (instr->InstructionType(Instruction::TypeChecks::EXTRA)) {
switch (instr->InstructionType()) {
case Instruction::kRegisterType: {
return DecodeTypeRegister(instr);
}
......
......@@ -149,7 +149,7 @@ class SimInstruction : public InstructionGetters<SimInstructionBase> {
SimInstruction& operator=(Instruction* instr) {
operand_ = *reinterpret_cast<const int32_t*>(instr);
instr_ = instr;
type_ = InstructionBase::InstructionType(EXTRA);
type_ = InstructionBase::InstructionType();
DCHECK(reinterpret_cast<void*>(&operand_) == 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