| 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 /// \file | 10 /// \file |
| 11 /// \brief Declares the InstARM32 and OperandARM32 classes and their subclasses. | 11 /// \brief Declares the InstARM32 and OperandARM32 classes and their subclasses. |
| 12 /// | 12 /// |
| 13 /// This represents the machine instructions and operands used for ARM32 code | 13 /// This represents the machine instructions and operands used for ARM32 code |
| 14 /// selection. | 14 /// selection. |
| 15 /// | 15 /// |
| 16 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
| 17 | 17 |
| 18 #ifndef SUBZERO_SRC_ICEINSTARM32_H | 18 #ifndef SUBZERO_SRC_ICEINSTARM32_H |
| 19 #define SUBZERO_SRC_ICEINSTARM32_H | 19 #define SUBZERO_SRC_ICEINSTARM32_H |
| 20 | 20 |
| 21 #include "IceConditionCodesARM32.h" | 21 #include "IceConditionCodesARM32.h" |
| 22 #include "IceDefs.h" | 22 #include "IceDefs.h" |
| 23 #include "IceInst.h" | 23 #include "IceInst.h" |
| 24 #include "IceInstARM32.def" | 24 #include "IceInstARM32.def" |
| 25 #include "IceOperand.h" | 25 #include "IceOperand.h" |
| 26 | 26 |
| 27 namespace Ice { | 27 namespace Ice { |
| 28 namespace ARM32 { | 28 namespace ARM32 { |
| 29 | 29 |
| 30 /// Encoding of an ARM 32-bit instruction. |
| 31 using IValueT = uint32_t; |
| 32 |
| 33 /// An Offset value (+/-) used in an ARM 32-bit instruction. |
| 34 using IOffsetT = int32_t; |
| 35 |
| 30 class TargetARM32; | 36 class TargetARM32; |
| 31 | 37 |
| 32 /// OperandARM32 extends the Operand hierarchy. Its subclasses are | 38 /// OperandARM32 extends the Operand hierarchy. Its subclasses are |
| 33 /// OperandARM32Mem and OperandARM32Flex. | 39 /// OperandARM32Mem and OperandARM32Flex. |
| 34 class OperandARM32 : public Operand { | 40 class OperandARM32 : public Operand { |
| 35 OperandARM32() = delete; | 41 OperandARM32() = delete; |
| 36 OperandARM32(const OperandARM32 &) = delete; | 42 OperandARM32(const OperandARM32 &) = delete; |
| 37 OperandARM32 &operator=(const OperandARM32 &) = delete; | 43 OperandARM32 &operator=(const OperandARM32 &) = delete; |
| 38 | 44 |
| 39 public: | 45 public: |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 363 |
| 358 /// Base class for ARM instructions. While most ARM instructions can be | 364 /// Base class for ARM instructions. While most ARM instructions can be |
| 359 /// conditionally executed, a few of them are not predicable (halt, memory | 365 /// conditionally executed, a few of them are not predicable (halt, memory |
| 360 /// barriers, etc.). | 366 /// barriers, etc.). |
| 361 class InstARM32 : public InstTarget { | 367 class InstARM32 : public InstTarget { |
| 362 InstARM32() = delete; | 368 InstARM32() = delete; |
| 363 InstARM32(const InstARM32 &) = delete; | 369 InstARM32(const InstARM32 &) = delete; |
| 364 InstARM32 &operator=(const InstARM32 &) = delete; | 370 InstARM32 &operator=(const InstARM32 &) = delete; |
| 365 | 371 |
| 366 public: | 372 public: |
| 373 // Defines form that assembly instruction should be synthesized. |
| 374 enum EmitForm { Emit_Text, Emit_Binary }; |
| 375 |
| 367 enum InstKindARM32 { | 376 enum InstKindARM32 { |
| 368 k__Start = Inst::Target, | 377 k__Start = Inst::Target, |
| 369 Adc, | 378 Adc, |
| 370 Add, | 379 Add, |
| 371 And, | 380 And, |
| 372 Asr, | 381 Asr, |
| 373 Bic, | 382 Bic, |
| 374 Br, | 383 Br, |
| 375 Call, | 384 Call, |
| 376 Clz, | 385 Clz, |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 Operand *getCallTarget() const { return getSrc(0); } | 1058 Operand *getCallTarget() const { return getSrc(0); } |
| 1050 void emit(const Cfg *Func) const override; | 1059 void emit(const Cfg *Func) const override; |
| 1051 void emitIAS(const Cfg *Func) const override; | 1060 void emitIAS(const Cfg *Func) const override; |
| 1052 void dump(const Cfg *Func) const override; | 1061 void dump(const Cfg *Func) const override; |
| 1053 static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } | 1062 static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } |
| 1054 | 1063 |
| 1055 private: | 1064 private: |
| 1056 InstARM32Call(Cfg *Func, Variable *Dest, Operand *CallTarget); | 1065 InstARM32Call(Cfg *Func, Variable *Dest, Operand *CallTarget); |
| 1057 }; | 1066 }; |
| 1058 | 1067 |
| 1068 class InstARM32RegisterStackOp : public InstARM32 { |
| 1069 InstARM32RegisterStackOp() = delete; |
| 1070 InstARM32RegisterStackOp(const InstARM32RegisterStackOp &) = delete; |
| 1071 InstARM32RegisterStackOp & |
| 1072 operator=(const InstARM32RegisterStackOp &) = delete; |
| 1073 |
| 1074 public: |
| 1075 void emit(const Cfg *Func) const override; |
| 1076 void emitIAS(const Cfg *Func) const override; |
| 1077 void dump(const Cfg *Func) const override; |
| 1078 |
| 1079 protected: |
| 1080 InstARM32RegisterStackOp(Cfg *Func, InstKindARM32 Kind, SizeT Maxsrcs, |
| 1081 Variable *Dest) |
| 1082 : InstARM32(Func, Kind, Maxsrcs, Dest) {} |
| 1083 void emitUsingForm(const Cfg *Func, const EmitForm Form) const; |
| 1084 void emitGPRsAsText(const Cfg *Func) const; |
| 1085 void emitSRegsAsText(const Cfg *Func, const Variable *BaseReg, |
| 1086 SizeT Regcount) const; |
| 1087 virtual const char *getDumpOpcode() const { return getGPROpcode(); } |
| 1088 virtual const char *getGPROpcode() const = 0; |
| 1089 virtual const char *getSRegOpcode() const = 0; |
| 1090 virtual Variable *getStackReg(SizeT Index) const = 0; |
| 1091 virtual SizeT getNumStackRegs() const = 0; |
| 1092 virtual void emitSingleGPR(const Cfg *Func, const EmitForm Form, |
| 1093 const Variable *Reg) const = 0; |
| 1094 virtual void emitMultipleGPRs(const Cfg *Func, const EmitForm Form, |
| 1095 IValueT Registers) const = 0; |
| 1096 virtual void emitSRegs(const Cfg *Func, const EmitForm Form, |
| 1097 const Variable *BaseReg, SizeT RegCount) const = 0; |
| 1098 }; |
| 1099 |
| 1059 /// Pops a list of registers. It may be a list of GPRs, or a list of VFP "s" | 1100 /// Pops a list of registers. It may be a list of GPRs, or a list of VFP "s" |
| 1060 /// regs, but not both. In any case, the list must be sorted. | 1101 /// regs, but not both. In any case, the list must be sorted. |
| 1061 class InstARM32Pop : public InstARM32 { | 1102 class InstARM32Pop : public InstARM32RegisterStackOp { |
| 1062 InstARM32Pop() = delete; | 1103 InstARM32Pop() = delete; |
| 1063 InstARM32Pop(const InstARM32Pop &) = delete; | 1104 InstARM32Pop(const InstARM32Pop &) = delete; |
| 1064 InstARM32Pop &operator=(const InstARM32Pop &) = delete; | 1105 InstARM32Pop &operator=(const InstARM32Pop &) = delete; |
| 1065 | 1106 |
| 1066 public: | 1107 public: |
| 1067 static InstARM32Pop *create(Cfg *Func, const VarList &Dests) { | 1108 static InstARM32Pop *create(Cfg *Func, const VarList &Dests) { |
| 1068 return new (Func->allocate<InstARM32Pop>()) InstARM32Pop(Func, Dests); | 1109 return new (Func->allocate<InstARM32Pop>()) InstARM32Pop(Func, Dests); |
| 1069 } | 1110 } |
| 1070 void emit(const Cfg *Func) const override; | |
| 1071 void emitIAS(const Cfg *Func) const override; | |
| 1072 void dump(const Cfg *Func) const override; | |
| 1073 static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } | 1111 static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } |
| 1074 | 1112 |
| 1075 private: | 1113 private: |
| 1076 InstARM32Pop(Cfg *Func, const VarList &Dests); | 1114 InstARM32Pop(Cfg *Func, const VarList &Dests); |
| 1115 virtual const char *getGPROpcode() const final; |
| 1116 virtual const char *getSRegOpcode() const final; |
| 1117 Variable *getStackReg(SizeT Index) const final; |
| 1118 SizeT getNumStackRegs() const final; |
| 1119 void emitSingleGPR(const Cfg *Func, const EmitForm Form, |
| 1120 const Variable *Reg) const final; |
| 1121 void emitMultipleGPRs(const Cfg *Func, const EmitForm Form, |
| 1122 IValueT Registers) const final; |
| 1123 void emitSRegs(const Cfg *Func, const EmitForm Form, const Variable *BaseReg, |
| 1124 SizeT RegCount) const final; |
| 1077 | 1125 |
| 1078 VarList Dests; | 1126 VarList Dests; |
| 1079 }; | 1127 }; |
| 1080 | 1128 |
| 1081 /// Pushes a list of registers. Just like Pop (see above), the list may be of | 1129 /// Pushes a list of registers. Just like Pop (see above), the list may be of |
| 1082 /// GPRs, or VFP "s" registers, but not both. | 1130 /// GPRs, or VFP "s" registers, but not both. |
| 1083 class InstARM32Push : public InstARM32 { | 1131 class InstARM32Push : public InstARM32RegisterStackOp { |
| 1084 InstARM32Push() = delete; | 1132 InstARM32Push() = delete; |
| 1085 InstARM32Push(const InstARM32Push &) = delete; | 1133 InstARM32Push(const InstARM32Push &) = delete; |
| 1086 InstARM32Push &operator=(const InstARM32Push &) = delete; | 1134 InstARM32Push &operator=(const InstARM32Push &) = delete; |
| 1087 | 1135 |
| 1088 public: | 1136 public: |
| 1089 static InstARM32Push *create(Cfg *Func, const VarList &Srcs) { | 1137 static InstARM32Push *create(Cfg *Func, const VarList &Srcs) { |
| 1090 return new (Func->allocate<InstARM32Push>()) InstARM32Push(Func, Srcs); | 1138 return new (Func->allocate<InstARM32Push>()) InstARM32Push(Func, Srcs); |
| 1091 } | 1139 } |
| 1092 void emit(const Cfg *Func) const override; | |
| 1093 void emitIAS(const Cfg *Func) const override; | |
| 1094 void dump(const Cfg *Func) const override; | |
| 1095 static bool classof(const Inst *Inst) { return isClassof(Inst, Push); } | 1140 static bool classof(const Inst *Inst) { return isClassof(Inst, Push); } |
| 1096 | 1141 |
| 1097 private: | 1142 private: |
| 1098 InstARM32Push(Cfg *Func, const VarList &Srcs); | 1143 InstARM32Push(Cfg *Func, const VarList &Srcs); |
| 1144 const char *getGPROpcode() const final; |
| 1145 const char *getSRegOpcode() const final; |
| 1146 Variable *getStackReg(SizeT Index) const final; |
| 1147 SizeT getNumStackRegs() const final; |
| 1148 void emitSingleGPR(const Cfg *Func, const EmitForm Form, |
| 1149 const Variable *Reg) const final; |
| 1150 void emitMultipleGPRs(const Cfg *Func, const EmitForm Form, |
| 1151 IValueT Registers) const final; |
| 1152 void emitSRegs(const Cfg *Func, const EmitForm Form, const Variable *BaseReg, |
| 1153 SizeT RegCount) const final; |
| 1099 }; | 1154 }; |
| 1100 | 1155 |
| 1101 /// Ret pseudo-instruction. This is actually a "bx" instruction with an "lr" | 1156 /// Ret pseudo-instruction. This is actually a "bx" instruction with an "lr" |
| 1102 /// register operand, but epilogue lowering will search for a Ret instead of a | 1157 /// register operand, but epilogue lowering will search for a Ret instead of a |
| 1103 /// generic "bx". This instruction also takes a Source operand (for non-void | 1158 /// generic "bx". This instruction also takes a Source operand (for non-void |
| 1104 /// returning functions) for liveness analysis, though a FakeUse before the ret | 1159 /// returning functions) for liveness analysis, though a FakeUse before the ret |
| 1105 /// would do just as well. | 1160 /// would do just as well. |
| 1106 /// | 1161 /// |
| 1107 /// NOTE: Even though "bx" can be predicated, for now leave out the predication | 1162 /// NOTE: Even though "bx" can be predicated, for now leave out the predication |
| 1108 /// since it's not yet known to be useful for Ret. That may complicate finding | 1163 /// since it's not yet known to be useful for Ret. That may complicate finding |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 // violations and link errors. | 1431 // violations and link errors. |
| 1377 | 1432 |
| 1378 template <> void InstARM32Ldr::emit(const Cfg *Func) const; | 1433 template <> void InstARM32Ldr::emit(const Cfg *Func) const; |
| 1379 template <> void InstARM32Movw::emit(const Cfg *Func) const; | 1434 template <> void InstARM32Movw::emit(const Cfg *Func) const; |
| 1380 template <> void InstARM32Movt::emit(const Cfg *Func) const; | 1435 template <> void InstARM32Movt::emit(const Cfg *Func) const; |
| 1381 | 1436 |
| 1382 } // end of namespace ARM32 | 1437 } // end of namespace ARM32 |
| 1383 } // end of namespace Ice | 1438 } // end of namespace Ice |
| 1384 | 1439 |
| 1385 #endif // SUBZERO_SRC_ICEINSTARM32_H | 1440 #endif // SUBZERO_SRC_ICEINSTARM32_H |
| OLD | NEW |