OLD | NEW |
1 //===- subzero/src/IceInstARM32.h - ARM32 machine instructions --*- C++ -*-===// | 1 //===- subzero/src/IceInstARM32.h - ARM32 machine 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 InstARM32 and OperandARM32 classes and | 10 // This file declares the InstARM32 and OperandARM32 classes and |
11 // their subclasses. This represents the machine instructions and | 11 // their subclasses. This represents the machine instructions and |
12 // operands used for ARM32 code selection. | 12 // operands used for ARM32 code selection. |
13 // | 13 // |
14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
15 | 15 |
16 #ifndef SUBZERO_SRC_ICEINSTARM32_H | 16 #ifndef SUBZERO_SRC_ICEINSTARM32_H |
17 #define SUBZERO_SRC_ICEINSTARM32_H | 17 #define SUBZERO_SRC_ICEINSTARM32_H |
18 | 18 |
19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
| 20 #include "IceInst.h" |
| 21 #include "IceInstARM32.def" |
| 22 #include "IceOperand.h" |
20 | 23 |
21 namespace Ice { | 24 namespace Ice { |
22 | 25 |
23 class TargetARM32; | 26 class TargetARM32; |
24 // Fill this in. | 27 |
| 28 // OperandARM32 extends the Operand hierarchy. |
| 29 // TODO(jvoung): Add the OperandARM32Mem and OperandARM32Flex. |
| 30 class OperandARM32 : public Operand { |
| 31 OperandARM32() = delete; |
| 32 OperandARM32(const OperandARM32 &) = delete; |
| 33 OperandARM32 &operator=(const OperandARM32 &) = delete; |
| 34 |
| 35 public: |
| 36 enum OperandKindARM32 { k__Start = Operand::kTarget }; |
| 37 |
| 38 enum ShiftKind { |
| 39 kNoShift = -1, |
| 40 #define X(enum, emit) enum, |
| 41 ICEINSTARM32SHIFT_TABLE |
| 42 #undef X |
| 43 }; |
| 44 |
| 45 using Operand::dump; |
| 46 void dump(const Cfg *, Ostream &Str) const override { |
| 47 if (ALLOW_DUMP) |
| 48 Str << "<OperandARM32>"; |
| 49 } |
| 50 |
| 51 protected: |
| 52 OperandARM32(OperandKindARM32 Kind, Type Ty) |
| 53 : Operand(static_cast<OperandKind>(Kind), Ty) {} |
| 54 ~OperandARM32() override {} |
| 55 }; |
| 56 |
| 57 // OperandARM32Mem represents a memory operand in any of the various ARM32 |
| 58 // addressing modes. |
| 59 // TODO(jvoung): Fill out more. |
| 60 class OperandARM32Mem : public OperandARM32 { |
| 61 OperandARM32Mem() = delete; |
| 62 OperandARM32Mem(const OperandARM32Mem &) = delete; |
| 63 OperandARM32Mem &operator=(const OperandARM32Mem &) = delete; |
| 64 |
| 65 public: |
| 66 // Return true if a load/store instruction for an element of type Ty |
| 67 // can encode the Offset directly in the immediate field of the 32-bit |
| 68 // ARM instruction. For some types, if the load is Sign extending, then |
| 69 // the range is reduced. |
| 70 static bool canHoldOffset(Type Ty, bool SignExt, int32_t Offset); |
| 71 }; |
| 72 |
| 73 class InstARM32 : public InstTarget { |
| 74 InstARM32() = delete; |
| 75 InstARM32(const InstARM32 &) = delete; |
| 76 InstARM32 &operator=(const InstARM32 &) = delete; |
| 77 |
| 78 public: |
| 79 enum InstKindARM32 { k__Start = Inst::Target, Ret }; |
| 80 |
| 81 static const char *getWidthString(Type Ty); |
| 82 |
| 83 void dump(const Cfg *Func) const override; |
| 84 |
| 85 protected: |
| 86 InstARM32(Cfg *Func, InstKindARM32 Kind, SizeT Maxsrcs, Variable *Dest) |
| 87 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
| 88 ~InstARM32() override {} |
| 89 static bool isClassof(const Inst *Inst, InstKindARM32 MyKind) { |
| 90 return Inst->getKind() == static_cast<InstKind>(MyKind); |
| 91 } |
| 92 }; |
| 93 |
| 94 // Ret pseudo-instruction. This is actually a "bx" instruction with |
| 95 // an "lr" register operand, but epilogue lowering will search for a Ret |
| 96 // instead of a generic "bx". This instruction also takes a Source |
| 97 // operand (for non-void returning functions) for liveness analysis, though |
| 98 // a FakeUse before the ret would do just as well. |
| 99 class InstARM32Ret : public InstARM32 { |
| 100 InstARM32Ret() = delete; |
| 101 InstARM32Ret(const InstARM32Ret &) = delete; |
| 102 InstARM32Ret &operator=(const InstARM32Ret &) = delete; |
| 103 |
| 104 public: |
| 105 static InstARM32Ret *create(Cfg *Func, Variable *LR, |
| 106 Variable *Source = nullptr) { |
| 107 return new (Func->allocate<InstARM32Ret>()) InstARM32Ret(Func, LR, Source); |
| 108 } |
| 109 void emit(const Cfg *Func) const override; |
| 110 void emitIAS(const Cfg *Func) const override; |
| 111 void dump(const Cfg *Func) const override; |
| 112 static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); } |
| 113 |
| 114 private: |
| 115 InstARM32Ret(Cfg *Func, Variable *LR, Variable *Source); |
| 116 ~InstARM32Ret() override {} |
| 117 }; |
25 | 118 |
26 } // end of namespace Ice | 119 } // end of namespace Ice |
27 | 120 |
28 #endif // SUBZERO_SRC_ICEINSTARM32_H | 121 #endif // SUBZERO_SRC_ICEINSTARM32_H |
OLD | NEW |