Chromium Code Reviews| Index: src/ia32/lithium-ia32.h |
| =================================================================== |
| --- src/ia32/lithium-ia32.h (revision 7679) |
| +++ src/ia32/lithium-ia32.h (working copy) |
| @@ -39,13 +39,6 @@ |
| // Forward declarations. |
| class LCodeGen; |
| - |
| -#define LITHIUM_ALL_INSTRUCTION_LIST(V) \ |
| - V(ControlInstruction) \ |
| - V(Call) \ |
| - LITHIUM_CONCRETE_INSTRUCTION_LIST(V) |
| - |
| - |
| #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ |
| V(AccessArgumentsAt) \ |
| V(AddI) \ |
| @@ -94,7 +87,6 @@ |
| V(ExternalArrayLength) \ |
| V(FixedArrayLength) \ |
| V(FunctionLiteral) \ |
| - V(Gap) \ |
| V(GetCachedArrayIndex) \ |
| V(GlobalObject) \ |
| V(GlobalReceiver) \ |
| @@ -106,6 +98,7 @@ |
| V(InstanceOf) \ |
| V(InstanceOfAndBranch) \ |
| V(InstanceOfKnownGlobal) \ |
| + V(InstructionGap) \ |
| V(Integer32ToDouble) \ |
| V(InvokeFunction) \ |
| V(IsNull) \ |
| @@ -172,20 +165,16 @@ |
| V(ValueOf) |
| -#define DECLARE_INSTRUCTION(type) \ |
| - virtual bool Is##type() const { return true; } \ |
| - static L##type* cast(LInstruction* instr) { \ |
| - ASSERT(instr->Is##type()); \ |
| - return reinterpret_cast<L##type*>(instr); \ |
| +#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
| + virtual Opcode opcode() const { return LInstruction::k##type; } \ |
| + virtual void CompileToNative(LCodeGen* generator); \ |
| + virtual const char* Mnemonic() const { return mnemonic; } \ |
| + static L##type* cast(LInstruction* instr) { \ |
| + ASSERT(instr->Is##type()); \ |
| + return reinterpret_cast<L##type*>(instr); \ |
| } |
| -#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
| - virtual void CompileToNative(LCodeGen* generator); \ |
| - virtual const char* Mnemonic() const { return mnemonic; } \ |
| - DECLARE_INSTRUCTION(type) |
| - |
| - |
| #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
| H##type* hydrogen() const { \ |
| return H##type::cast(hydrogen_value()); \ |
| @@ -207,11 +196,26 @@ |
| virtual void PrintDataTo(StringStream* stream) = 0; |
| virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
| - // Declare virtual type testers. |
| -#define DECLARE_DO(type) virtual bool Is##type() const { return false; } |
| - LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) |
| -#undef DECLARE_DO |
| + enum Opcode { |
| + // Declare a unique enum value for each instruction. |
| + #define DECLARE_OPCODE(type) k##type, |
|
Kevin Millikin (Chromium)
2011/04/26 15:06:53
I guess we usually write #define and #undef with a
|
| + LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) |
| + kNumberOfInstructions |
| + #undef DECLARE_OPCODE |
| + }; |
| + virtual Opcode opcode() const = 0; |
| + |
| + // Declare non-virtual type testers for all leaf IR classes. |
| +#define DECLARE_PREDICATE(type) \ |
| + bool Is##type() const { return opcode() == k##type; } |
| + LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| +#undef DECLARE_PREDICATE |
| + |
| + // Declare virtual predicates for instructions that don't have |
| + // an opcode. |
| + virtual bool IsGap() const { return false; } |
| + |
| virtual bool IsControl() const { return false; } |
| virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
| @@ -330,16 +334,20 @@ |
| class LGap: public LTemplateInstruction<0, 0, 0> { |
| public: |
| - explicit LGap(HBasicBlock* block) |
| - : block_(block) { |
| + explicit LGap(HBasicBlock* block) : block_(block) { |
| parallel_moves_[BEFORE] = NULL; |
| parallel_moves_[START] = NULL; |
| parallel_moves_[END] = NULL; |
| parallel_moves_[AFTER] = NULL; |
| } |
| - DECLARE_CONCRETE_INSTRUCTION(Gap, "gap") |
| + // Can't use the DECLARE-macro here because of sub-classes. |
| + virtual bool IsGap() const { return true; } |
| virtual void PrintDataTo(StringStream* stream); |
| + static LGap* cast(LInstruction* instr) { |
| + ASSERT(instr->IsGap()); |
| + return reinterpret_cast<LGap*>(instr); |
| + } |
| bool IsRedundant() const; |
| @@ -369,6 +377,36 @@ |
| }; |
| +class LInstructionGap: public LGap { |
| + public: |
| + explicit LInstructionGap(HBasicBlock* block) : LGap(block) { } |
| + |
| + DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap") |
| +}; |
| + |
| + |
| +class LLabel: public LGap { |
| + public: |
| + explicit LLabel(HBasicBlock* block) |
| + : LGap(block), replacement_(NULL) { } |
| + |
| + DECLARE_CONCRETE_INSTRUCTION(Label, "label") |
| + |
| + virtual void PrintDataTo(StringStream* stream); |
| + |
| + int block_id() const { return block()->block_id(); } |
| + bool is_loop_header() const { return block()->IsLoopHeader(); } |
| + Label* label() { return &label_; } |
| + LLabel* replacement() const { return replacement_; } |
| + void set_replacement(LLabel* label) { replacement_ = label; } |
| + bool HasReplacement() const { return replacement_ != NULL; } |
| + |
| + private: |
| + Label label_; |
| + LLabel* replacement_; |
| +}; |
| + |
| + |
| class LGoto: public LTemplateInstruction<0, 0, 0> { |
| public: |
| LGoto(int block_id, bool include_stack_check = false) |
| @@ -409,28 +447,6 @@ |
| }; |
| -class LLabel: public LGap { |
| - public: |
| - explicit LLabel(HBasicBlock* block) |
| - : LGap(block), replacement_(NULL) { } |
| - |
| - DECLARE_CONCRETE_INSTRUCTION(Label, "label") |
| - |
| - virtual void PrintDataTo(StringStream* stream); |
| - |
| - int block_id() const { return block()->block_id(); } |
| - bool is_loop_header() const { return block()->IsLoopHeader(); } |
| - Label* label() { return &label_; } |
| - LLabel* replacement() const { return replacement_; } |
| - void set_replacement(LLabel* label) { replacement_ = label; } |
| - bool HasReplacement() const { return replacement_ != NULL; } |
| - |
| - private: |
| - Label label_; |
| - LLabel* replacement_; |
| -}; |
| - |
| - |
| class LParameter: public LTemplateInstruction<1, 0, 0> { |
| public: |
| DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter") |
| @@ -463,7 +479,6 @@ |
| template<int I, int T> |
| class LControlInstruction: public LTemplateInstruction<0, I, T> { |
| public: |
| - DECLARE_INSTRUCTION(ControlInstruction) |
| virtual bool IsControl() const { return true; } |
| int true_block_id() const { return true_block_id_; } |
| @@ -1133,6 +1148,7 @@ |
| Token::Value op() const { return op_; } |
| + virtual Opcode opcode() const { return LInstruction::kArithmeticD; } |
| virtual void CompileToNative(LCodeGen* generator); |
| virtual const char* Mnemonic() const; |
| @@ -1149,6 +1165,7 @@ |
| inputs_[1] = right; |
| } |
| + virtual Opcode opcode() const { return LInstruction::kArithmeticT; } |
| virtual void CompileToNative(LCodeGen* generator); |
| virtual const char* Mnemonic() const; |
| @@ -2268,7 +2285,6 @@ |
| }; |
| #undef DECLARE_HYDROGEN_ACCESSOR |
| -#undef DECLARE_INSTRUCTION |
| #undef DECLARE_CONCRETE_INSTRUCTION |
| } } // namespace v8::internal |