OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// | 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// |
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 implements the TargetLoweringX8632 class, which | 10 // This file implements the TargetLoweringX8632 class, which |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // ensure everything is kept in sync. | 94 // ensure everything is kept in sync. |
95 void xMacroIntegrityCheck() { | 95 void xMacroIntegrityCheck() { |
96 // Validate the enum values in FCMPX8632_TABLE. | 96 // Validate the enum values in FCMPX8632_TABLE. |
97 { | 97 { |
98 // Define a temporary set of enum values based on low-level | 98 // Define a temporary set of enum values based on low-level |
99 // table entries. | 99 // table entries. |
100 enum _tmp_enum { | 100 enum _tmp_enum { |
101 #define X(val, dflt, swap, C1, C2) _tmp_##val, | 101 #define X(val, dflt, swap, C1, C2) _tmp_##val, |
102 FCMPX8632_TABLE | 102 FCMPX8632_TABLE |
103 #undef X | 103 #undef X |
| 104 _num |
104 }; | 105 }; |
105 // Define a set of constants based on high-level table entries. | 106 // Define a set of constants based on high-level table entries. |
106 #define X(tag, str) static const int _table1_##tag = InstFcmp::tag; | 107 #define X(tag, str) static const int _table1_##tag = InstFcmp::tag; |
107 ICEINSTFCMP_TABLE; | 108 ICEINSTFCMP_TABLE; |
108 #undef X | 109 #undef X |
109 // Define a set of constants based on low-level table entries, | 110 // Define a set of constants based on low-level table entries, |
110 // and ensure the table entry keys are consistent. | 111 // and ensure the table entry keys are consistent. |
111 #define X(val, dflt, swap, C1, C2) \ | 112 #define X(val, dflt, swap, C1, C2) \ |
112 static const int _table2_##val = _tmp_##val; \ | 113 static const int _table2_##val = _tmp_##val; \ |
113 STATIC_ASSERT(_table1_##val == _table2_##val); | 114 STATIC_ASSERT(_table1_##val == _table2_##val); |
114 FCMPX8632_TABLE; | 115 FCMPX8632_TABLE; |
115 #undef X | 116 #undef X |
116 // Repeat the static asserts with respect to the high-level | 117 // Repeat the static asserts with respect to the high-level |
117 // table entries in case the high-level table has extra entries. | 118 // table entries in case the high-level table has extra entries. |
118 #define X(tag, str) STATIC_ASSERT(_table1_##tag == _table2_##tag); | 119 #define X(tag, str) STATIC_ASSERT(_table1_##tag == _table2_##tag); |
119 ICEINSTFCMP_TABLE; | 120 ICEINSTFCMP_TABLE; |
120 #undef X | 121 #undef X |
121 } | 122 } |
122 | 123 |
123 // Validate the enum values in ICMPX8632_TABLE. | 124 // Validate the enum values in ICMPX8632_TABLE. |
124 { | 125 { |
125 // Define a temporary set of enum values based on low-level | 126 // Define a temporary set of enum values based on low-level |
126 // table entries. | 127 // table entries. |
127 enum _tmp_enum { | 128 enum _tmp_enum { |
128 #define X(val, C_32, C1_64, C2_64, C3_64) _tmp_##val, | 129 #define X(val, C_32, C1_64, C2_64, C3_64) _tmp_##val, |
129 ICMPX8632_TABLE | 130 ICMPX8632_TABLE |
130 #undef X | 131 #undef X |
| 132 _num |
131 }; | 133 }; |
132 // Define a set of constants based on high-level table entries. | 134 // Define a set of constants based on high-level table entries. |
133 #define X(tag, str) static const int _table1_##tag = InstIcmp::tag; | 135 #define X(tag, str) static const int _table1_##tag = InstIcmp::tag; |
134 ICEINSTICMP_TABLE; | 136 ICEINSTICMP_TABLE; |
135 #undef X | 137 #undef X |
136 // Define a set of constants based on low-level table entries, | 138 // Define a set of constants based on low-level table entries, |
137 // and ensure the table entry keys are consistent. | 139 // and ensure the table entry keys are consistent. |
138 #define X(val, C_32, C1_64, C2_64, C3_64) \ | 140 #define X(val, C_32, C1_64, C2_64, C3_64) \ |
139 static const int _table2_##val = _tmp_##val; \ | 141 static const int _table2_##val = _tmp_##val; \ |
140 STATIC_ASSERT(_table1_##val == _table2_##val); | 142 STATIC_ASSERT(_table1_##val == _table2_##val); |
141 ICMPX8632_TABLE; | 143 ICMPX8632_TABLE; |
142 #undef X | 144 #undef X |
143 // Repeat the static asserts with respect to the high-level | 145 // Repeat the static asserts with respect to the high-level |
144 // table entries in case the high-level table has extra entries. | 146 // table entries in case the high-level table has extra entries. |
145 #define X(tag, str) STATIC_ASSERT(_table1_##tag == _table2_##tag); | 147 #define X(tag, str) STATIC_ASSERT(_table1_##tag == _table2_##tag); |
146 ICEINSTICMP_TABLE; | 148 ICEINSTICMP_TABLE; |
147 #undef X | 149 #undef X |
148 } | 150 } |
149 | 151 |
150 // Validate the enum values in ICETYPEX8632_TABLE. | 152 // Validate the enum values in ICETYPEX8632_TABLE. |
151 { | 153 { |
152 // Define a temporary set of enum values based on low-level | 154 // Define a temporary set of enum values based on low-level |
153 // table entries. | 155 // table entries. |
154 enum _tmp_enum { | 156 enum _tmp_enum { |
155 #define X(tag, cvt, sdss, width) _tmp_##tag, | 157 #define X(tag, cvt, sdss, width) _tmp_##tag, |
156 ICETYPEX8632_TABLE | 158 ICETYPEX8632_TABLE |
157 #undef X | 159 #undef X |
| 160 _num |
158 }; | 161 }; |
159 // Define a set of constants based on high-level table entries. | 162 // Define a set of constants based on high-level table entries. |
160 #define X(tag, size, align, str) static const int _table1_##tag = tag; | 163 #define X(tag, size, align, str) static const int _table1_##tag = tag; |
161 ICETYPE_TABLE; | 164 ICETYPE_TABLE; |
162 #undef X | 165 #undef X |
163 // Define a set of constants based on low-level table entries, | 166 // Define a set of constants based on low-level table entries, |
164 // and ensure the table entry keys are consistent. | 167 // and ensure the table entry keys are consistent. |
165 #define X(tag, cvt, sdss, width) \ | 168 #define X(tag, cvt, sdss, width) \ |
166 static const int _table2_##tag = _tmp_##tag; \ | 169 static const int _table2_##tag = _tmp_##tag; \ |
167 STATIC_ASSERT(_table1_##tag == _table2_##tag); | 170 STATIC_ASSERT(_table1_##tag == _table2_##tag); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 PhysicalRegisters[RegNum] = Reg; | 272 PhysicalRegisters[RegNum] = Reg; |
270 } | 273 } |
271 return Reg; | 274 return Reg; |
272 } | 275 } |
273 | 276 |
274 IceString TargetX8632::getRegName(SizeT RegNum, Type Ty) const { | 277 IceString TargetX8632::getRegName(SizeT RegNum, Type Ty) const { |
275 assert(RegNum < Reg_NUM); | 278 assert(RegNum < Reg_NUM); |
276 static IceString RegNames8[] = { | 279 static IceString RegNames8[] = { |
277 #define X(val, init, name, name16, name8, scratch, preserved, stackptr, \ | 280 #define X(val, init, name, name16, name8, scratch, preserved, stackptr, \ |
278 frameptr, isI8, isInt, isFP) \ | 281 frameptr, isI8, isInt, isFP) \ |
279 "" name8, | 282 name8, |
280 REGX8632_TABLE | 283 REGX8632_TABLE |
281 #undef X | 284 #undef X |
282 }; | 285 }; |
283 static IceString RegNames16[] = { | 286 static IceString RegNames16[] = { |
284 #define X(val, init, name, name16, name8, scratch, preserved, stackptr, \ | 287 #define X(val, init, name, name16, name8, scratch, preserved, stackptr, \ |
285 frameptr, isI8, isInt, isFP) \ | 288 frameptr, isI8, isInt, isFP) \ |
286 "" name16, | 289 name16, |
287 REGX8632_TABLE | 290 REGX8632_TABLE |
288 #undef X | 291 #undef X |
289 }; | 292 }; |
290 switch (Ty) { | 293 switch (Ty) { |
291 case IceType_i1: | 294 case IceType_i1: |
292 case IceType_i8: | 295 case IceType_i8: |
293 return RegNames8[RegNum]; | 296 return RegNames8[RegNum]; |
294 case IceType_i16: | 297 case IceType_i16: |
295 return RegNames16[RegNum]; | 298 return RegNames16[RegNum]; |
296 default: | 299 default: |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 Operand *Src1 = legalize(Inst->getSrc(1)); | 692 Operand *Src1 = legalize(Inst->getSrc(1)); |
690 if (Dest->getType() == IceType_i64) { | 693 if (Dest->getType() == IceType_i64) { |
691 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); | 694 Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); |
692 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); | 695 Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); |
693 Operand *Src0Lo = loOperand(Src0); | 696 Operand *Src0Lo = loOperand(Src0); |
694 Operand *Src0Hi = hiOperand(Src0); | 697 Operand *Src0Hi = hiOperand(Src0); |
695 Operand *Src1Lo = loOperand(Src1); | 698 Operand *Src1Lo = loOperand(Src1); |
696 Operand *Src1Hi = hiOperand(Src1); | 699 Operand *Src1Hi = hiOperand(Src1); |
697 Variable *T_Lo = NULL, *T_Hi = NULL; | 700 Variable *T_Lo = NULL, *T_Hi = NULL; |
698 switch (Inst->getOp()) { | 701 switch (Inst->getOp()) { |
| 702 case InstArithmetic::_num: |
| 703 llvm_unreachable("Unknown arithmetic operator"); |
| 704 break; |
699 case InstArithmetic::Add: | 705 case InstArithmetic::Add: |
700 _mov(T_Lo, Src0Lo); | 706 _mov(T_Lo, Src0Lo); |
701 _add(T_Lo, Src1Lo); | 707 _add(T_Lo, Src1Lo); |
702 _mov(DestLo, T_Lo); | 708 _mov(DestLo, T_Lo); |
703 _mov(T_Hi, Src0Hi); | 709 _mov(T_Hi, Src0Hi); |
704 _adc(T_Hi, Src1Hi); | 710 _adc(T_Hi, Src1Hi); |
705 _mov(DestHi, T_Hi); | 711 _mov(DestHi, T_Hi); |
706 break; | 712 break; |
707 case InstArithmetic::And: | 713 case InstArithmetic::And: |
708 _mov(T_Lo, Src0Lo); | 714 _mov(T_Lo, Src0Lo); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 case InstArithmetic::Fmul: | 913 case InstArithmetic::Fmul: |
908 case InstArithmetic::Fdiv: | 914 case InstArithmetic::Fdiv: |
909 case InstArithmetic::Frem: | 915 case InstArithmetic::Frem: |
910 llvm_unreachable("FP instruction with i64 type"); | 916 llvm_unreachable("FP instruction with i64 type"); |
911 break; | 917 break; |
912 } | 918 } |
913 } else { // Dest->getType() != IceType_i64 | 919 } else { // Dest->getType() != IceType_i64 |
914 Variable *T_edx = NULL; | 920 Variable *T_edx = NULL; |
915 Variable *T = NULL; | 921 Variable *T = NULL; |
916 switch (Inst->getOp()) { | 922 switch (Inst->getOp()) { |
| 923 case InstArithmetic::_num: |
| 924 llvm_unreachable("Unknown arithmetic operator"); |
| 925 break; |
917 case InstArithmetic::Add: | 926 case InstArithmetic::Add: |
918 _mov(T, Src0); | 927 _mov(T, Src0); |
919 _add(T, Src1); | 928 _add(T, Src1); |
920 _mov(Dest, T); | 929 _mov(Dest, T); |
921 break; | 930 break; |
922 case InstArithmetic::And: | 931 case InstArithmetic::And: |
923 _mov(T, Src0); | 932 _mov(T, Src0); |
924 _and(T, Src1); | 933 _and(T, Src1); |
925 _mov(Dest, T); | 934 _mov(Dest, T); |
926 break; | 935 break; |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 assert(AvailableTypedRegisters.any()); | 1881 assert(AvailableTypedRegisters.any()); |
1873 int32_t RegNum = AvailableTypedRegisters.find_first(); | 1882 int32_t RegNum = AvailableTypedRegisters.find_first(); |
1874 Var->setRegNum(RegNum); | 1883 Var->setRegNum(RegNum); |
1875 AvailableRegisters[RegNum] = false; | 1884 AvailableRegisters[RegNum] = false; |
1876 } | 1885 } |
1877 } | 1886 } |
1878 } | 1887 } |
1879 } | 1888 } |
1880 | 1889 |
1881 } // end of namespace Ice | 1890 } // end of namespace Ice |
OLD | NEW |