OLD | NEW |
1 //===- subzero/unittest/AssemblerX8664/LowLevel.cpp -----------------------===// | 1 //===- subzero/unittest/AssemblerX8664/LowLevel.cpp -----------------------===// |
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 #include "AssemblerX8664/TestUtil.h" | 9 #include "AssemblerX8664/TestUtil.h" |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 << TestString; \ | 179 << TestString; \ |
180 reset(); \ | 180 reset(); \ |
181 } while (0) | 181 } while (0) |
182 | 182 |
183 #define TestRegAbsoluteAddr(Inst, Dst, Disp, OpType, ByteCountUntyped, ...) \ | 183 #define TestRegAbsoluteAddr(Inst, Dst, Disp, OpType, ByteCountUntyped, ...) \ |
184 do { \ | 184 do { \ |
185 static constexpr char TestString[] = \ | 185 static constexpr char TestString[] = \ |
186 "(" #Inst ", " #Dst ", " #Disp ", " #OpType ", " #ByteCountUntyped \ | 186 "(" #Inst ", " #Dst ", " #Disp ", " #OpType ", " #ByteCountUntyped \ |
187 ", " #__VA_ARGS__ ")"; \ | 187 ", " #__VA_ARGS__ ")"; \ |
188 static constexpr uint8_t ByteCount = ByteCountUntyped; \ | 188 static constexpr uint8_t ByteCount = ByteCountUntyped; \ |
189 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \ | 189 static constexpr AssemblerFixup *Fixup = nullptr; \ |
190 Address(Address::ABSOLUTE, Disp)); \ | 190 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), Address(Disp, Fixup)); \ |
191 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ | 191 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ |
192 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ | 192 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ |
193 << TestString; \ | 193 << TestString; \ |
194 reset(); \ | 194 reset(); \ |
195 } while (0) | 195 } while (0) |
196 | 196 |
197 #define TestRegAddrBase(Inst, Dst, Base, Disp, OpType, ByteCountUntyped, ...) \ | 197 #define TestRegAddrBase(Inst, Dst, Base, Disp, OpType, ByteCountUntyped, ...) \ |
198 do { \ | 198 do { \ |
199 static constexpr char TestString[] = \ | 199 static constexpr char TestString[] = \ |
200 "(" #Inst ", " #Dst ", " #Base ", " #Disp ", " #OpType \ | 200 "(" #Inst ", " #Dst ", " #Base ", " #Disp ", " #OpType \ |
201 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ | 201 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ |
202 static constexpr uint8_t ByteCount = ByteCountUntyped; \ | 202 static constexpr uint8_t ByteCount = ByteCountUntyped; \ |
| 203 static constexpr AssemblerFixup *Fixup = nullptr; \ |
203 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \ | 204 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \ |
204 Address(Encoded_GPR_##Base(), Disp)); \ | 205 Address(Encoded_GPR_##Base(), Disp, Fixup)); \ |
205 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ | 206 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ |
206 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ | 207 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ |
207 << TestString; \ | 208 << TestString; \ |
208 reset(); \ | 209 reset(); \ |
209 } while (0) | 210 } while (0) |
210 | 211 |
211 #define TestRegAddrScaledIndex(Inst, Dst, Index, Scale, Disp, OpType, \ | 212 #define TestRegAddrScaledIndex(Inst, Dst, Index, Scale, Disp, OpType, \ |
212 ByteCountUntyped, ...) \ | 213 ByteCountUntyped, ...) \ |
213 do { \ | 214 do { \ |
214 static constexpr char TestString[] = \ | 215 static constexpr char TestString[] = \ |
215 "(" #Inst ", " #Dst ", " #Index ", " #Scale ", " #Disp ", " #OpType \ | 216 "(" #Inst ", " #Dst ", " #Index ", " #Scale ", " #Disp ", " #OpType \ |
216 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ | 217 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ |
217 static constexpr uint8_t ByteCount = ByteCountUntyped; \ | 218 static constexpr uint8_t ByteCount = ByteCountUntyped; \ |
218 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \ | 219 static constexpr AssemblerFixup *Fixup = nullptr; \ |
219 Address(Encoded_GPR_##Index(), Traits::TIMES_##Scale, Disp)); \ | 220 __ Inst( \ |
| 221 IceType_##OpType, Encoded_GPR_##Dst(), \ |
| 222 Address(Encoded_GPR_##Index(), Traits::TIMES_##Scale, Disp, Fixup)); \ |
220 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ | 223 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ |
221 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ | 224 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ |
222 << TestString; \ | 225 << TestString; \ |
223 reset(); \ | 226 reset(); \ |
224 } while (0) | 227 } while (0) |
225 | 228 |
226 #define TestRegAddrBaseScaledIndex(Inst, Dst, Base, Index, Scale, Disp, \ | 229 #define TestRegAddrBaseScaledIndex(Inst, Dst, Base, Index, Scale, Disp, \ |
227 OpType, ByteCountUntyped, ...) \ | 230 OpType, ByteCountUntyped, ...) \ |
228 do { \ | 231 do { \ |
229 static constexpr char TestString[] = \ | 232 static constexpr char TestString[] = \ |
230 "(" #Inst ", " #Dst ", " #Base ", " #Index ", " #Scale ", " #Disp \ | 233 "(" #Inst ", " #Dst ", " #Base ", " #Index ", " #Scale ", " #Disp \ |
231 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ | 234 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ |
232 static constexpr uint8_t ByteCount = ByteCountUntyped; \ | 235 static constexpr uint8_t ByteCount = ByteCountUntyped; \ |
| 236 static constexpr AssemblerFixup *Fixup = nullptr; \ |
233 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \ | 237 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \ |
234 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \ | 238 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \ |
235 Traits::TIMES_##Scale, Disp)); \ | 239 Traits::TIMES_##Scale, Disp, Fixup)); \ |
236 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ | 240 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ |
237 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ | 241 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ |
238 << TestString; \ | 242 << TestString; \ |
239 reset(); \ | 243 reset(); \ |
240 } while (0) | 244 } while (0) |
241 | 245 |
242 #define TestAddrBaseScaledIndexImm(Inst, Base, Index, Scale, Disp, Imm, \ | 246 #define TestAddrBaseScaledIndexImm(Inst, Base, Index, Scale, Disp, Imm, \ |
243 OpType, ByteCountUntyped, ...) \ | 247 OpType, ByteCountUntyped, ...) \ |
244 do { \ | 248 do { \ |
245 static constexpr char TestString[] = \ | 249 static constexpr char TestString[] = \ |
246 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Imm \ | 250 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Imm \ |
247 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ | 251 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ |
248 static constexpr uint8_t ByteCount = ByteCountUntyped; \ | 252 static constexpr uint8_t ByteCount = ByteCountUntyped; \ |
| 253 static constexpr AssemblerFixup *Fixup = nullptr; \ |
249 __ Inst(IceType_##OpType, \ | 254 __ Inst(IceType_##OpType, \ |
250 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \ | 255 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \ |
251 Traits::TIMES_##Scale, Disp), \ | 256 Traits::TIMES_##Scale, Disp, Fixup), \ |
252 Immediate(Imm)); \ | 257 Immediate(Imm)); \ |
253 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ | 258 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ |
254 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ | 259 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ |
255 << TestString; \ | 260 << TestString; \ |
256 reset(); \ | 261 reset(); \ |
257 } while (0) | 262 } while (0) |
258 | 263 |
259 #define TestAddrBaseScaledIndexReg(Inst, Base, Index, Scale, Disp, Src, \ | 264 #define TestAddrBaseScaledIndexReg(Inst, Base, Index, Scale, Disp, Src, \ |
260 OpType, ByteCountUntyped, ...) \ | 265 OpType, ByteCountUntyped, ...) \ |
261 do { \ | 266 do { \ |
262 static constexpr char TestString[] = \ | 267 static constexpr char TestString[] = \ |
263 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Src \ | 268 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Src \ |
264 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ | 269 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ |
265 static constexpr uint8_t ByteCount = ByteCountUntyped; \ | 270 static constexpr uint8_t ByteCount = ByteCountUntyped; \ |
| 271 static constexpr AssemblerFixup *Fixup = nullptr; \ |
266 __ Inst(IceType_##OpType, \ | 272 __ Inst(IceType_##OpType, \ |
267 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \ | 273 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \ |
268 Traits::TIMES_##Scale, Disp), \ | 274 Traits::TIMES_##Scale, Disp, Fixup), \ |
269 Encoded_GPR_##Src()); \ | 275 Encoded_GPR_##Src()); \ |
270 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ | 276 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ |
271 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ | 277 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ |
272 << TestString; \ | 278 << TestString; \ |
273 reset(); \ | 279 reset(); \ |
274 } while (0) | 280 } while (0) |
275 | 281 |
276 /* cmp GPR, GPR */ | 282 /* cmp GPR, GPR */ |
277 TestRegReg(cmp, eax, ecx, i32, 2, 0x3B, 0xC1); | 283 TestRegReg(cmp, eax, ecx, i32, 2, 0x3B, 0xC1); |
278 TestRegReg(cmp, ecx, edx, i32, 2, 0x3B, 0xCA); | 284 TestRegReg(cmp, ecx, edx, i32, 2, 0x3B, 0xCA); |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 EXPECT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0)); | 1121 EXPECT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0)); |
1116 EXPECT_FLOAT_EQ(2.0f, test.contentsOfDword<float>(S1)); | 1122 EXPECT_FLOAT_EQ(2.0f, test.contentsOfDword<float>(S1)); |
1117 EXPECT_FLOAT_EQ(3.0f, test.contentsOfDword<float>(S2)); | 1123 EXPECT_FLOAT_EQ(3.0f, test.contentsOfDword<float>(S2)); |
1118 EXPECT_FLOAT_EQ(4.0f, test.contentsOfDword<float>(S3)); | 1124 EXPECT_FLOAT_EQ(4.0f, test.contentsOfDword<float>(S3)); |
1119 } | 1125 } |
1120 | 1126 |
1121 } // end of anonymous namespace | 1127 } // end of anonymous namespace |
1122 } // end of namespace Test | 1128 } // end of namespace Test |
1123 } // end of namespace X8664 | 1129 } // end of namespace X8664 |
1124 } // end of namespace Ice | 1130 } // end of namespace Ice |
OLD | NEW |