Chromium Code Reviews| 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 OutputForm { TextualOutput, BinaryOutput }; | |
|
Jim Stichnoth
2016/01/10 18:21:59
My preference (as littered throughout the code bas
John
2016/01/11 13:40:36
I am not a fan of these prefixes myself (they are
Karl
2016/01/11 17:59:44
Acknowledged.
Karl
2016/01/11 17:59:44
Done.
| |
| 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1048 Operand *getCallTarget() const { return getSrc(0); } | 1057 Operand *getCallTarget() const { return getSrc(0); } |
| 1049 void emit(const Cfg *Func) const override; | 1058 void emit(const Cfg *Func) const override; |
| 1050 void emitIAS(const Cfg *Func) const override; | 1059 void emitIAS(const Cfg *Func) const override; |
| 1051 void dump(const Cfg *Func) const override; | 1060 void dump(const Cfg *Func) const override; |
| 1052 static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } | 1061 static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } |
| 1053 | 1062 |
| 1054 private: | 1063 private: |
| 1055 InstARM32Call(Cfg *Func, Variable *Dest, Operand *CallTarget); | 1064 InstARM32Call(Cfg *Func, Variable *Dest, Operand *CallTarget); |
| 1056 }; | 1065 }; |
| 1057 | 1066 |
| 1067 class InstARM32RegisterStackOp : public InstARM32 { | |
| 1068 InstARM32RegisterStackOp() = delete; | |
| 1069 InstARM32RegisterStackOp(const InstARM32RegisterStackOp &) = delete; | |
| 1070 InstARM32RegisterStackOp & | |
| 1071 operator=(const InstARM32RegisterStackOp &) = delete; | |
| 1072 | |
| 1073 public: | |
| 1074 void emit(const Cfg *Func) const override; | |
| 1075 void emitIAS(const Cfg *Func) const override; | |
| 1076 void dump(const Cfg *Func) const override; | |
| 1077 | |
| 1078 protected: | |
| 1079 InstARM32RegisterStackOp(Cfg *Func, InstKindARM32 Kind, SizeT Maxsrcs, | |
| 1080 Variable *Dest) | |
| 1081 : InstARM32(Func, Kind, Maxsrcs, Dest) {} | |
| 1082 void emitUsingForm(const Cfg *Func, const OutputForm Form) const; | |
| 1083 void emitGPRsAsText(const Cfg *Func) const; | |
| 1084 void emitSRegsAsText(const Cfg *Func, const Variable *BaseReg, | |
| 1085 SizeT Regcount) const; | |
| 1086 virtual const char *getOpcode() const = 0; | |
| 1087 virtual Variable *getStackReg(SizeT Index) const = 0; | |
| 1088 virtual SizeT getNumStackRegs() const = 0; | |
| 1089 virtual void emitSingleGPR(const Cfg *Func, const OutputForm Form, | |
| 1090 const Variable *Reg) const = 0; | |
| 1091 virtual void emitMultipleGPRs(const Cfg *Func, const OutputForm Form, | |
| 1092 IValueT Registers) const = 0; | |
| 1093 virtual void emitSRegs(const Cfg *Func, const OutputForm Form, | |
| 1094 const Variable *BaseReg, SizeT RegCount) const = 0; | |
| 1095 }; | |
| 1096 | |
| 1058 /// Pops a list of registers. It may be a list of GPRs, or a list of VFP "s" | 1097 /// Pops a list of registers. It may be a list of GPRs, or a list of VFP "s" |
| 1059 /// regs, but not both. In any case, the list must be sorted. | 1098 /// regs, but not both. In any case, the list must be sorted. |
| 1060 class InstARM32Pop : public InstARM32 { | 1099 class InstARM32Pop : public InstARM32RegisterStackOp { |
| 1061 InstARM32Pop() = delete; | 1100 InstARM32Pop() = delete; |
| 1062 InstARM32Pop(const InstARM32Pop &) = delete; | 1101 InstARM32Pop(const InstARM32Pop &) = delete; |
| 1063 InstARM32Pop &operator=(const InstARM32Pop &) = delete; | 1102 InstARM32Pop &operator=(const InstARM32Pop &) = delete; |
| 1064 | 1103 |
| 1065 public: | 1104 public: |
| 1066 static InstARM32Pop *create(Cfg *Func, const VarList &Dests) { | 1105 static InstARM32Pop *create(Cfg *Func, const VarList &Dests) { |
| 1067 return new (Func->allocate<InstARM32Pop>()) InstARM32Pop(Func, Dests); | 1106 return new (Func->allocate<InstARM32Pop>()) InstARM32Pop(Func, Dests); |
| 1068 } | 1107 } |
| 1069 void emit(const Cfg *Func) const override; | |
| 1070 void emitIAS(const Cfg *Func) const override; | |
| 1071 void dump(const Cfg *Func) const override; | |
| 1072 static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } | 1108 static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } |
| 1073 | 1109 |
| 1074 private: | 1110 private: |
| 1075 InstARM32Pop(Cfg *Func, const VarList &Dests); | 1111 InstARM32Pop(Cfg *Func, const VarList &Dests); |
| 1112 virtual const char *getOpcode() const final; | |
| 1113 Variable *getStackReg(SizeT Index) const final; | |
| 1114 SizeT getNumStackRegs() const final; | |
| 1115 void emitSingleGPR(const Cfg *Func, const OutputForm Form, | |
| 1116 const Variable *Reg) const final; | |
| 1117 void emitMultipleGPRs(const Cfg *Func, const OutputForm Form, | |
| 1118 IValueT Registers) const final; | |
| 1119 void emitSRegs(const Cfg *Func, const OutputForm Form, | |
| 1120 const Variable *BaseReg, SizeT RegCount) const final; | |
| 1076 | 1121 |
| 1077 VarList Dests; | 1122 VarList Dests; |
| 1078 }; | 1123 }; |
| 1079 | 1124 |
| 1080 /// Pushes a list of registers. Just like Pop (see above), the list may be of | 1125 /// Pushes a list of registers. Just like Pop (see above), the list may be of |
| 1081 /// GPRs, or VFP "s" registers, but not both. | 1126 /// GPRs, or VFP "s" registers, but not both. |
| 1082 class InstARM32Push : public InstARM32 { | 1127 class InstARM32Push : public InstARM32RegisterStackOp { |
| 1083 InstARM32Push() = delete; | 1128 InstARM32Push() = delete; |
| 1084 InstARM32Push(const InstARM32Push &) = delete; | 1129 InstARM32Push(const InstARM32Push &) = delete; |
| 1085 InstARM32Push &operator=(const InstARM32Push &) = delete; | 1130 InstARM32Push &operator=(const InstARM32Push &) = delete; |
| 1086 | 1131 |
| 1087 public: | 1132 public: |
| 1088 static InstARM32Push *create(Cfg *Func, const VarList &Srcs) { | 1133 static InstARM32Push *create(Cfg *Func, const VarList &Srcs) { |
| 1089 return new (Func->allocate<InstARM32Push>()) InstARM32Push(Func, Srcs); | 1134 return new (Func->allocate<InstARM32Push>()) InstARM32Push(Func, Srcs); |
| 1090 } | 1135 } |
| 1091 void emit(const Cfg *Func) const override; | |
| 1092 void emitIAS(const Cfg *Func) const override; | |
| 1093 void dump(const Cfg *Func) const override; | |
| 1094 static bool classof(const Inst *Inst) { return isClassof(Inst, Push); } | 1136 static bool classof(const Inst *Inst) { return isClassof(Inst, Push); } |
| 1095 | 1137 |
| 1096 private: | 1138 private: |
| 1097 InstARM32Push(Cfg *Func, const VarList &Srcs); | 1139 InstARM32Push(Cfg *Func, const VarList &Srcs); |
| 1140 const char *getOpcode() const final; | |
| 1141 Variable *getStackReg(SizeT Index) const final; | |
| 1142 SizeT getNumStackRegs() const final; | |
| 1143 void emitSingleGPR(const Cfg *Func, const OutputForm Form, | |
| 1144 const Variable *Reg) const final; | |
| 1145 void emitMultipleGPRs(const Cfg *Func, const OutputForm Form, | |
| 1146 IValueT Registers) const final; | |
| 1147 void emitSRegs(const Cfg *Func, const OutputForm Form, | |
| 1148 const Variable *BaseReg, SizeT RegCount) const final; | |
| 1098 }; | 1149 }; |
| 1099 | 1150 |
| 1100 /// Ret pseudo-instruction. This is actually a "bx" instruction with an "lr" | 1151 /// Ret pseudo-instruction. This is actually a "bx" instruction with an "lr" |
| 1101 /// register operand, but epilogue lowering will search for a Ret instead of a | 1152 /// register operand, but epilogue lowering will search for a Ret instead of a |
| 1102 /// generic "bx". This instruction also takes a Source operand (for non-void | 1153 /// generic "bx". This instruction also takes a Source operand (for non-void |
| 1103 /// returning functions) for liveness analysis, though a FakeUse before the ret | 1154 /// returning functions) for liveness analysis, though a FakeUse before the ret |
| 1104 /// would do just as well. | 1155 /// would do just as well. |
| 1105 /// | 1156 /// |
| 1106 /// NOTE: Even though "bx" can be predicated, for now leave out the predication | 1157 /// NOTE: Even though "bx" can be predicated, for now leave out the predication |
| 1107 /// since it's not yet known to be useful for Ret. That may complicate finding | 1158 /// since it's not yet known to be useful for Ret. That may complicate finding |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1374 // violations and link errors. | 1425 // violations and link errors. |
| 1375 | 1426 |
| 1376 template <> void InstARM32Ldr::emit(const Cfg *Func) const; | 1427 template <> void InstARM32Ldr::emit(const Cfg *Func) const; |
| 1377 template <> void InstARM32Movw::emit(const Cfg *Func) const; | 1428 template <> void InstARM32Movw::emit(const Cfg *Func) const; |
| 1378 template <> void InstARM32Movt::emit(const Cfg *Func) const; | 1429 template <> void InstARM32Movt::emit(const Cfg *Func) const; |
| 1379 | 1430 |
| 1380 } // end of namespace ARM32 | 1431 } // end of namespace ARM32 |
| 1381 } // end of namespace Ice | 1432 } // end of namespace Ice |
| 1382 | 1433 |
| 1383 #endif // SUBZERO_SRC_ICEINSTARM32_H | 1434 #endif // SUBZERO_SRC_ICEINSTARM32_H |
| OLD | NEW |