Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// | 1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file declares the InstX8632 and OperandX8632 classes and | 10 // This file declares the InstX8632 and OperandX8632 classes and |
| 11 // their subclasses. This represents the machine instructions and | 11 // their subclasses. This represents the machine instructions and |
| 12 // operands used for x86-32 code selection. | 12 // operands used for x86-32 code selection. |
| 13 // | 13 // |
| 14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 15 | 15 |
| 16 #ifndef SUBZERO_SRC_ICEINSTX8632_H | 16 #ifndef SUBZERO_SRC_ICEINSTX8632_H |
| 17 #define SUBZERO_SRC_ICEINSTX8632_H | 17 #define SUBZERO_SRC_ICEINSTX8632_H |
| 18 | 18 |
| 19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceInst.h" | 20 #include "IceInst.h" |
| 21 #include "IceInstX8632.def" | 21 #include "IceInstX8632.def" |
| 22 #include "IceOperand.h" | 22 #include "IceOperand.h" |
| 23 | 23 |
| 24 namespace Ice { | 24 namespace Ice { |
| 25 | 25 |
| 26 class TargetX8632; | 26 class TargetX8632; |
| 27 | 27 |
| 28 // OperandX8632 extends the Operand hierarchy. Its subclasses are | 28 // OperandX8632 extends the Operand hierarchy. Its subclasses are |
| 29 // OperandX8632Mem and VariableSplit. | 29 // OperandX8632Mem, and VariableSplit. |
|
Jim Stichnoth
2014/06/12 20:52:07
Remove the comma. :)
jvoung (off chromium)
2014/06/16 20:51:59
Done.
| |
| 30 class OperandX8632 : public Operand { | 30 class OperandX8632 : public Operand { |
| 31 public: | 31 public: |
| 32 enum OperandKindX8632 { | 32 enum OperandKindX8632 { |
| 33 k__Start = Operand::kTarget, | 33 k__Start = Operand::kTarget, |
| 34 kMem, | 34 kMem, |
| 35 kSplit | 35 kSplit |
| 36 }; | 36 }; |
| 37 virtual void emit(const Cfg *Func) const = 0; | 37 virtual void emit(const Cfg *Func) const = 0; |
| 38 void dump(const Cfg *Func) const; | 38 void dump(const Cfg *Func) const; |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 OperandX8632(OperandKindX8632 Kind, Type Ty) | 41 OperandX8632(OperandKindX8632 Kind, Type Ty) |
| 42 : Operand(static_cast<OperandKind>(Kind), Ty) {} | 42 : Operand(static_cast<OperandKind>(Kind), Ty) {} |
| 43 virtual ~OperandX8632() {} | 43 virtual ~OperandX8632() {} |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 OperandX8632(const OperandX8632 &) LLVM_DELETED_FUNCTION; | 46 OperandX8632(const OperandX8632 &) LLVM_DELETED_FUNCTION; |
| 47 OperandX8632 &operator=(const OperandX8632 &) LLVM_DELETED_FUNCTION; | 47 OperandX8632 &operator=(const OperandX8632 &) LLVM_DELETED_FUNCTION; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // OperandX8632Mem represents the m32 addressing mode, with optional | 50 // OperandX8632Mem represents the m32 addressing mode, with optional |
| 51 // base and index registers, a constant offset, and a fixed shift | 51 // base and index registers, a constant offset, and a fixed shift |
| 52 // value for the index register. | 52 // value for the index register. |
| 53 class OperandX8632Mem : public OperandX8632 { | 53 class OperandX8632Mem : public OperandX8632 { |
| 54 public: | 54 public: |
| 55 static OperandX8632Mem *create(Cfg *Func, Type Ty, Variable *Base, | 55 enum SegmentRegisters { |
| 56 Constant *Offset, Variable *Index = NULL, | 56 DefaultSegment = -1, |
| 57 uint32_t Shift = 0) { | 57 #define X(val, name) \ |
| 58 val, | |
| 59 SEG_REGX8632_TABLE | |
| 60 #undef X | |
| 61 SegReg_NUM | |
| 62 }; | |
| 63 static OperandX8632Mem *create( | |
| 64 Cfg *Func, Type Ty, Variable *Base, | |
| 65 Constant *Offset, Variable *Index = NULL, | |
| 66 uint16_t Shift = 0, SegmentRegisters SegmentReg = DefaultSegment) { | |
| 58 return new (Func->allocate<OperandX8632Mem>()) | 67 return new (Func->allocate<OperandX8632Mem>()) |
| 59 OperandX8632Mem(Func, Ty, Base, Offset, Index, Shift); | 68 OperandX8632Mem(Func, Ty, Base, Offset, Index, Shift, SegmentReg); |
| 60 } | 69 } |
| 61 Variable *getBase() const { return Base; } | 70 Variable *getBase() const { return Base; } |
| 62 Constant *getOffset() const { return Offset; } | 71 Constant *getOffset() const { return Offset; } |
| 63 Variable *getIndex() const { return Index; } | 72 Variable *getIndex() const { return Index; } |
| 64 uint32_t getShift() const { return Shift; } | 73 uint16_t getShift() const { return Shift; } |
| 74 SegmentRegisters getSegmentRegister() const { return SegmentReg; } | |
| 65 virtual void emit(const Cfg *Func) const; | 75 virtual void emit(const Cfg *Func) const; |
| 66 virtual void dump(const Cfg *Func) const; | 76 virtual void dump(const Cfg *Func) const; |
| 67 | 77 |
| 68 static bool classof(const Operand *Operand) { | 78 static bool classof(const Operand *Operand) { |
| 69 return Operand->getKind() == static_cast<OperandKind>(kMem); | 79 return Operand->getKind() == static_cast<OperandKind>(kMem); |
| 70 } | 80 } |
| 71 | 81 |
| 72 private: | 82 private: |
| 73 OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, | 83 OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, |
| 74 Variable *Index, uint32_t Shift); | 84 Variable *Index, uint16_t Shift, |
| 85 SegmentRegisters SegmentReg); | |
| 75 OperandX8632Mem(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; | 86 OperandX8632Mem(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; |
| 76 OperandX8632Mem &operator=(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; | 87 OperandX8632Mem &operator=(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; |
| 77 virtual ~OperandX8632Mem() {} | 88 virtual ~OperandX8632Mem() {} |
| 78 Variable *Base; | 89 Variable *Base; |
| 79 Constant *Offset; | 90 Constant *Offset; |
| 80 Variable *Index; | 91 Variable *Index; |
| 81 uint32_t Shift; | 92 uint16_t Shift; |
| 93 SegmentRegisters SegmentReg : 16; | |
| 82 }; | 94 }; |
| 83 | 95 |
| 84 // VariableSplit is a way to treat an f64 memory location as a pair | 96 // VariableSplit is a way to treat an f64 memory location as a pair |
| 85 // of i32 locations (Low and High). This is needed for some cases | 97 // of i32 locations (Low and High). This is needed for some cases |
| 86 // of the Bitcast instruction. Since it's not possible for integer | 98 // of the Bitcast instruction. Since it's not possible for integer |
| 87 // registers to access the XMM registers and vice versa, the | 99 // registers to access the XMM registers and vice versa, the |
| 88 // lowering forces the f64 to be spilled to the stack and then | 100 // lowering forces the f64 to be spilled to the stack and then |
| 89 // accesses through the VariableSplit. | 101 // accesses through the VariableSplit. |
| 90 class VariableSplit : public OperandX8632 { | 102 class VariableSplit : public OperandX8632 { |
| 91 public: | 103 public: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 Sbb, | 165 Sbb, |
| 154 Shl, | 166 Shl, |
| 155 Shld, | 167 Shld, |
| 156 Shr, | 168 Shr, |
| 157 Shrd, | 169 Shrd, |
| 158 Store, | 170 Store, |
| 159 Sub, | 171 Sub, |
| 160 Subss, | 172 Subss, |
| 161 Test, | 173 Test, |
| 162 Ucomiss, | 174 Ucomiss, |
| 175 UD2, | |
| 163 Xor | 176 Xor |
| 164 }; | 177 }; |
| 165 static const char *getWidthString(Type Ty); | 178 static const char *getWidthString(Type Ty); |
| 166 virtual void emit(const Cfg *Func) const = 0; | 179 virtual void emit(const Cfg *Func) const = 0; |
| 167 virtual void dump(const Cfg *Func) const; | 180 virtual void dump(const Cfg *Func) const; |
| 168 | 181 |
| 169 protected: | 182 protected: |
| 170 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) | 183 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) |
| 171 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} | 184 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
| 172 virtual ~InstX8632() {} | 185 virtual ~InstX8632() {} |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 virtual void dump(const Cfg *Func) const; | 537 virtual void dump(const Cfg *Func) const; |
| 525 static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); } | 538 static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); } |
| 526 | 539 |
| 527 private: | 540 private: |
| 528 InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2); | 541 InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2); |
| 529 InstX8632Ucomiss(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; | 542 InstX8632Ucomiss(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; |
| 530 InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; | 543 InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; |
| 531 virtual ~InstX8632Ucomiss() {} | 544 virtual ~InstX8632Ucomiss() {} |
| 532 }; | 545 }; |
| 533 | 546 |
| 547 // UD2 instruction. | |
| 548 class InstX8632UD2 : public InstX8632 { | |
| 549 public: | |
| 550 static InstX8632UD2 *create(Cfg *Func) { | |
| 551 return new (Func->allocate<InstX8632UD2>()) | |
| 552 InstX8632UD2(Func); | |
| 553 } | |
| 554 virtual void emit(const Cfg *Func) const; | |
| 555 virtual void dump(const Cfg *Func) const; | |
| 556 static bool classof(const Inst *Inst) { return isClassof(Inst, UD2); } | |
| 557 | |
| 558 private: | |
| 559 InstX8632UD2(Cfg *Func); | |
| 560 InstX8632UD2(const InstX8632UD2 &) LLVM_DELETED_FUNCTION; | |
| 561 InstX8632UD2 &operator=(const InstX8632UD2 &) LLVM_DELETED_FUNCTION; | |
| 562 virtual ~InstX8632UD2() {} | |
| 563 }; | |
| 564 | |
| 534 // Test instruction. | 565 // Test instruction. |
| 535 class InstX8632Test : public InstX8632 { | 566 class InstX8632Test : public InstX8632 { |
| 536 public: | 567 public: |
| 537 static InstX8632Test *create(Cfg *Func, Operand *Source1, Operand *Source2) { | 568 static InstX8632Test *create(Cfg *Func, Operand *Source1, Operand *Source2) { |
| 538 return new (Func->allocate<InstX8632Test>()) | 569 return new (Func->allocate<InstX8632Test>()) |
| 539 InstX8632Test(Func, Source1, Source2); | 570 InstX8632Test(Func, Source1, Source2); |
| 540 } | 571 } |
| 541 virtual void emit(const Cfg *Func) const; | 572 virtual void emit(const Cfg *Func) const; |
| 542 virtual void dump(const Cfg *Func) const; | 573 virtual void dump(const Cfg *Func) const; |
| 543 static bool classof(const Inst *Inst) { return isClassof(Inst, Test); } | 574 static bool classof(const Inst *Inst) { return isClassof(Inst, Test); } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 private: | 742 private: |
| 712 InstX8632Ret(Cfg *Func, Variable *Source); | 743 InstX8632Ret(Cfg *Func, Variable *Source); |
| 713 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION; | 744 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION; |
| 714 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION; | 745 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION; |
| 715 virtual ~InstX8632Ret() {} | 746 virtual ~InstX8632Ret() {} |
| 716 }; | 747 }; |
| 717 | 748 |
| 718 } // end of namespace Ice | 749 } // end of namespace Ice |
| 719 | 750 |
| 720 #endif // SUBZERO_SRC_ICEINSTX8632_H | 751 #endif // SUBZERO_SRC_ICEINSTX8632_H |
| OLD | NEW |