Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: unittest/AssemblerX8632/Locked.cpp

Issue 1428443002: Enhance address mode recovery (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Streamline absolute addressing support (rip-relative on x64) Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/unittest/AssemblerX8632/Locked.cpp -------------------------===// 1 //===- subzero/unittest/AssemblerX8632/Locked.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 "AssemblerX8632/TestUtil.h" 9 #include "AssemblerX8632/TestUtil.h"
10 10
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 TestImpl(edi); 190 TestImpl(edi);
191 191
192 #undef TestImpl 192 #undef TestImpl
193 #undef TestImplSize 193 #undef TestImplSize
194 #undef TestImplAddrReg 194 #undef TestImplAddrReg
195 } 195 }
196 196
197 TEST_F(AssemblerX8632LowLevelTest, Xadd) { 197 TEST_F(AssemblerX8632LowLevelTest, Xadd) {
198 static constexpr bool NotLocked = false; 198 static constexpr bool NotLocked = false;
199 static constexpr bool Locked = true; 199 static constexpr bool Locked = true;
200 static constexpr AssemblerFixup *Fixup = nullptr;
200 201
201 // Ensures that xadd emits a lock prefix accordingly. 202 // Ensures that xadd emits a lock prefix accordingly.
202 { 203 {
203 __ xadd(IceType_i8, Address::Absolute(0x1FF00), 204 __ xadd(IceType_i8, Address(0x1FF00, Fixup), GPRRegister::Encoded_Reg_esi,
204 GPRRegister::Encoded_Reg_esi, NotLocked); 205 NotLocked);
205 static constexpr uint8_t ByteCountNotLocked8 = 7; 206 static constexpr uint8_t ByteCountNotLocked8 = 7;
206 ASSERT_EQ(ByteCountNotLocked8, codeBytesSize()); 207 ASSERT_EQ(ByteCountNotLocked8, codeBytesSize());
207 verifyBytes<ByteCountNotLocked8>(codeBytes(), 0x0F, 0xC0, 0x35, 0x00, 0xFF, 208 verifyBytes<ByteCountNotLocked8>(codeBytes(), 0x0F, 0xC0, 0x35, 0x00, 0xFF,
208 0x01, 0x00); 209 0x01, 0x00);
209 reset(); 210 reset();
210 211
211 __ xadd(IceType_i8, Address::Absolute(0x1FF00), 212 __ xadd(IceType_i8, Address(0x1FF00, Fixup), GPRRegister::Encoded_Reg_esi,
212 GPRRegister::Encoded_Reg_esi, Locked); 213 Locked);
213 static constexpr uint8_t ByteCountLocked8 = 1 + ByteCountNotLocked8; 214 static constexpr uint8_t ByteCountLocked8 = 1 + ByteCountNotLocked8;
214 ASSERT_EQ(ByteCountLocked8, codeBytesSize()); 215 ASSERT_EQ(ByteCountLocked8, codeBytesSize());
215 verifyBytes<ByteCountLocked8>(codeBytes(), 0xF0, 0x0F, 0xC0, 0x35, 0x00, 216 verifyBytes<ByteCountLocked8>(codeBytes(), 0xF0, 0x0F, 0xC0, 0x35, 0x00,
216 0xFF, 0x01, 0x00); 217 0xFF, 0x01, 0x00);
217 reset(); 218 reset();
218 } 219 }
219 220
220 { 221 {
221 __ xadd(IceType_i16, Address::Absolute(0x1FF00), 222 __ xadd(IceType_i16, Address(0x1FF00, Fixup), GPRRegister::Encoded_Reg_esi,
222 GPRRegister::Encoded_Reg_esi, NotLocked); 223 NotLocked);
223 static constexpr uint8_t ByteCountNotLocked16 = 8; 224 static constexpr uint8_t ByteCountNotLocked16 = 8;
224 ASSERT_EQ(ByteCountNotLocked16, codeBytesSize()); 225 ASSERT_EQ(ByteCountNotLocked16, codeBytesSize());
225 verifyBytes<ByteCountNotLocked16>(codeBytes(), 0x66, 0x0F, 0xC1, 0x35, 0x00, 226 verifyBytes<ByteCountNotLocked16>(codeBytes(), 0x66, 0x0F, 0xC1, 0x35, 0x00,
226 0xFF, 0x01, 0x00); 227 0xFF, 0x01, 0x00);
227 reset(); 228 reset();
228 229
229 __ xadd(IceType_i16, Address::Absolute(0x1FF00), 230 __ xadd(IceType_i16, Address(0x1FF00, Fixup), GPRRegister::Encoded_Reg_esi,
230 GPRRegister::Encoded_Reg_esi, Locked); 231 Locked);
231 static constexpr uint8_t ByteCountLocked16 = 1 + ByteCountNotLocked16; 232 static constexpr uint8_t ByteCountLocked16 = 1 + ByteCountNotLocked16;
232 ASSERT_EQ(ByteCountLocked16, codeBytesSize()); 233 ASSERT_EQ(ByteCountLocked16, codeBytesSize());
233 verifyBytes<ByteCountLocked16>(codeBytes(), 0x66, 0xF0, 0x0F, 0xC1, 0x35, 234 verifyBytes<ByteCountLocked16>(codeBytes(), 0x66, 0xF0, 0x0F, 0xC1, 0x35,
234 0x00, 0xFF, 0x01, 0x00); 235 0x00, 0xFF, 0x01, 0x00);
235 reset(); 236 reset();
236 } 237 }
237 238
238 { 239 {
239 __ xadd(IceType_i32, Address::Absolute(0x1FF00), 240 __ xadd(IceType_i32, Address(0x1FF00, Fixup), GPRRegister::Encoded_Reg_esi,
240 GPRRegister::Encoded_Reg_esi, NotLocked); 241 NotLocked);
241 static constexpr uint8_t ByteCountNotLocked32 = 7; 242 static constexpr uint8_t ByteCountNotLocked32 = 7;
242 ASSERT_EQ(ByteCountNotLocked32, codeBytesSize()); 243 ASSERT_EQ(ByteCountNotLocked32, codeBytesSize());
243 verifyBytes<ByteCountNotLocked32>(codeBytes(), 0x0F, 0xC1, 0x35, 0x00, 0xFF, 244 verifyBytes<ByteCountNotLocked32>(codeBytes(), 0x0F, 0xC1, 0x35, 0x00, 0xFF,
244 0x01, 0x00); 245 0x01, 0x00);
245 reset(); 246 reset();
246 247
247 __ xadd(IceType_i32, Address::Absolute(0x1FF00), 248 __ xadd(IceType_i32, Address(0x1FF00, Fixup), GPRRegister::Encoded_Reg_esi,
248 GPRRegister::Encoded_Reg_esi, Locked); 249 Locked);
249 static constexpr uint8_t ByteCountLocked32 = 1 + ByteCountNotLocked32; 250 static constexpr uint8_t ByteCountLocked32 = 1 + ByteCountNotLocked32;
250 ASSERT_EQ(ByteCountLocked32, codeBytesSize()); 251 ASSERT_EQ(ByteCountLocked32, codeBytesSize());
251 verifyBytes<ByteCountLocked32>(codeBytes(), 0xF0, 0x0F, 0xC1, 0x35, 0x00, 252 verifyBytes<ByteCountLocked32>(codeBytes(), 0xF0, 0x0F, 0xC1, 0x35, 0x00,
252 0xFF, 0x01, 0x00); 253 0xFF, 0x01, 0x00);
253 reset(); 254 reset();
254 } 255 }
255 } 256 }
256 257
257 TEST_F(AssemblerX8632Test, Cmpxchg8b) { 258 TEST_F(AssemblerX8632Test, Cmpxchg8b) {
258 static constexpr bool NotLocked = false; 259 static constexpr bool NotLocked = false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 TestImpl(0x98987676543210ull, 0x1, 0x98987676543210ull, Locked); 299 TestImpl(0x98987676543210ull, 0x1, 0x98987676543210ull, Locked);
299 TestImpl(0x98987676543210ull, 0x1, 0x98987676543211ull, NotLocked); 300 TestImpl(0x98987676543210ull, 0x1, 0x98987676543211ull, NotLocked);
300 TestImpl(0x98987676543210ull, 0x1, 0x98987676543211ull, Locked); 301 TestImpl(0x98987676543210ull, 0x1, 0x98987676543211ull, Locked);
301 302
302 #undef TestImpl 303 #undef TestImpl
303 } 304 }
304 305
305 TEST_F(AssemblerX8632LowLevelTest, Cmpxchg8b) { 306 TEST_F(AssemblerX8632LowLevelTest, Cmpxchg8b) {
306 static constexpr bool NotLocked = false; 307 static constexpr bool NotLocked = false;
307 static constexpr bool Locked = true; 308 static constexpr bool Locked = true;
309 static constexpr AssemblerFixup *Fixup = nullptr;
308 310
309 // Ensures that cmpxchg8b emits a lock prefix accordingly. 311 // Ensures that cmpxchg8b emits a lock prefix accordingly.
310 __ cmpxchg8b(Address::Absolute(0x1FF00), NotLocked); 312 __ cmpxchg8b(Address(0x1FF00, Fixup), NotLocked);
311 static constexpr uint8_t ByteCountNotLocked = 7; 313 static constexpr uint8_t ByteCountNotLocked = 7;
312 ASSERT_EQ(ByteCountNotLocked, codeBytesSize()); 314 ASSERT_EQ(ByteCountNotLocked, codeBytesSize());
313 verifyBytes<ByteCountNotLocked>(codeBytes(), 0x0F, 0xC7, 0x0D, 0x00, 0xFF, 315 verifyBytes<ByteCountNotLocked>(codeBytes(), 0x0F, 0xC7, 0x0D, 0x00, 0xFF,
314 0x01, 0x00); 316 0x01, 0x00);
315 reset(); 317 reset();
316 318
317 __ cmpxchg8b(Address::Absolute(0x1FF00), Locked); 319 __ cmpxchg8b(Address(0x1FF00, Fixup), Locked);
318 static constexpr uint8_t ByteCountLocked = 1 + ByteCountNotLocked; 320 static constexpr uint8_t ByteCountLocked = 1 + ByteCountNotLocked;
319 ASSERT_EQ(ByteCountLocked, codeBytesSize()); 321 ASSERT_EQ(ByteCountLocked, codeBytesSize());
320 verifyBytes<ByteCountLocked>(codeBytes(), 0xF0, 0x0F, 0xC7, 0x0D, 0x00, 0xFF, 322 verifyBytes<ByteCountLocked>(codeBytes(), 0xF0, 0x0F, 0xC7, 0x0D, 0x00, 0xFF,
321 0x01, 0x00); 323 0x01, 0x00);
322 reset(); 324 reset();
323 } 325 }
324 326
325 TEST_F(AssemblerX8632Test, Cmpxchg) { 327 TEST_F(AssemblerX8632Test, Cmpxchg) {
326 static constexpr bool NotLocked = false; 328 static constexpr bool NotLocked = false;
327 static constexpr bool Locked = true; 329 static constexpr bool Locked = true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 TestImpl(edi, NotLocked); 392 TestImpl(edi, NotLocked);
391 393
392 #undef TestImpl 394 #undef TestImpl
393 #undef TestImplValue 395 #undef TestImplValue
394 #undef TestImplAddrReg 396 #undef TestImplAddrReg
395 } 397 }
396 398
397 TEST_F(AssemblerX8632LowLevelTest, Cmpxchg) { 399 TEST_F(AssemblerX8632LowLevelTest, Cmpxchg) {
398 static constexpr bool NotLocked = false; 400 static constexpr bool NotLocked = false;
399 static constexpr bool Locked = true; 401 static constexpr bool Locked = true;
402 static constexpr AssemblerFixup *Fixup = nullptr;
400 403
401 // Ensures that cmpxchg emits a lock prefix accordingly. 404 // Ensures that cmpxchg emits a lock prefix accordingly.
402 { 405 {
403 __ cmpxchg(IceType_i8, Address::Absolute(0x1FF00), 406 __ cmpxchg(IceType_i8, Address(0x1FF00, Fixup),
404 GPRRegister::Encoded_Reg_esi, NotLocked); 407 GPRRegister::Encoded_Reg_esi, NotLocked);
405 static constexpr uint8_t ByteCountNotLocked8 = 7; 408 static constexpr uint8_t ByteCountNotLocked8 = 7;
406 ASSERT_EQ(ByteCountNotLocked8, codeBytesSize()); 409 ASSERT_EQ(ByteCountNotLocked8, codeBytesSize());
407 verifyBytes<ByteCountNotLocked8>(codeBytes(), 0x0F, 0xB0, 0x35, 0x00, 0xFF, 410 verifyBytes<ByteCountNotLocked8>(codeBytes(), 0x0F, 0xB0, 0x35, 0x00, 0xFF,
408 0x01, 0x00); 411 0x01, 0x00);
409 reset(); 412 reset();
410 413
411 __ cmpxchg(IceType_i8, Address::Absolute(0x1FF00), 414 __ cmpxchg(IceType_i8, Address(0x1FF00, Fixup),
412 GPRRegister::Encoded_Reg_esi, Locked); 415 GPRRegister::Encoded_Reg_esi, Locked);
413 static constexpr uint8_t ByteCountLocked8 = 1 + ByteCountNotLocked8; 416 static constexpr uint8_t ByteCountLocked8 = 1 + ByteCountNotLocked8;
414 ASSERT_EQ(ByteCountLocked8, codeBytesSize()); 417 ASSERT_EQ(ByteCountLocked8, codeBytesSize());
415 verifyBytes<ByteCountLocked8>(codeBytes(), 0xF0, 0x0F, 0xB0, 0x35, 0x00, 418 verifyBytes<ByteCountLocked8>(codeBytes(), 0xF0, 0x0F, 0xB0, 0x35, 0x00,
416 0xFF, 0x01, 0x00); 419 0xFF, 0x01, 0x00);
417 reset(); 420 reset();
418 } 421 }
419 422
420 { 423 {
421 __ cmpxchg(IceType_i16, Address::Absolute(0x1FF00), 424 __ cmpxchg(IceType_i16, Address(0x1FF00, Fixup),
422 GPRRegister::Encoded_Reg_esi, NotLocked); 425 GPRRegister::Encoded_Reg_esi, NotLocked);
423 static constexpr uint8_t ByteCountNotLocked16 = 8; 426 static constexpr uint8_t ByteCountNotLocked16 = 8;
424 ASSERT_EQ(ByteCountNotLocked16, codeBytesSize()); 427 ASSERT_EQ(ByteCountNotLocked16, codeBytesSize());
425 verifyBytes<ByteCountNotLocked16>(codeBytes(), 0x66, 0x0F, 0xB1, 0x35, 0x00, 428 verifyBytes<ByteCountNotLocked16>(codeBytes(), 0x66, 0x0F, 0xB1, 0x35, 0x00,
426 0xFF, 0x01, 0x00); 429 0xFF, 0x01, 0x00);
427 reset(); 430 reset();
428 431
429 __ cmpxchg(IceType_i16, Address::Absolute(0x1FF00), 432 __ cmpxchg(IceType_i16, Address(0x1FF00, Fixup),
430 GPRRegister::Encoded_Reg_esi, Locked); 433 GPRRegister::Encoded_Reg_esi, Locked);
431 static constexpr uint8_t ByteCountLocked16 = 1 + ByteCountNotLocked16; 434 static constexpr uint8_t ByteCountLocked16 = 1 + ByteCountNotLocked16;
432 ASSERT_EQ(ByteCountLocked16, codeBytesSize()); 435 ASSERT_EQ(ByteCountLocked16, codeBytesSize());
433 verifyBytes<ByteCountLocked16>(codeBytes(), 0x66, 0xF0, 0x0F, 0xB1, 0x35, 436 verifyBytes<ByteCountLocked16>(codeBytes(), 0x66, 0xF0, 0x0F, 0xB1, 0x35,
434 0x00, 0xFF, 0x01, 0x00); 437 0x00, 0xFF, 0x01, 0x00);
435 reset(); 438 reset();
436 } 439 }
437 440
438 { 441 {
439 __ cmpxchg(IceType_i32, Address::Absolute(0x1FF00), 442 __ cmpxchg(IceType_i32, Address(0x1FF00, Fixup),
440 GPRRegister::Encoded_Reg_esi, NotLocked); 443 GPRRegister::Encoded_Reg_esi, NotLocked);
441 static constexpr uint8_t ByteCountNotLocked32 = 7; 444 static constexpr uint8_t ByteCountNotLocked32 = 7;
442 ASSERT_EQ(ByteCountNotLocked32, codeBytesSize()); 445 ASSERT_EQ(ByteCountNotLocked32, codeBytesSize());
443 verifyBytes<ByteCountNotLocked32>(codeBytes(), 0x0F, 0xB1, 0x35, 0x00, 0xFF, 446 verifyBytes<ByteCountNotLocked32>(codeBytes(), 0x0F, 0xB1, 0x35, 0x00, 0xFF,
444 0x01, 0x00); 447 0x01, 0x00);
445 reset(); 448 reset();
446 449
447 __ cmpxchg(IceType_i32, Address::Absolute(0x1FF00), 450 __ cmpxchg(IceType_i32, Address(0x1FF00, Fixup),
448 GPRRegister::Encoded_Reg_esi, Locked); 451 GPRRegister::Encoded_Reg_esi, Locked);
449 static constexpr uint8_t ByteCountLocked32 = 1 + ByteCountNotLocked32; 452 static constexpr uint8_t ByteCountLocked32 = 1 + ByteCountNotLocked32;
450 ASSERT_EQ(ByteCountLocked32, codeBytesSize()); 453 ASSERT_EQ(ByteCountLocked32, codeBytesSize());
451 verifyBytes<ByteCountLocked32>(codeBytes(), 0xF0, 0x0F, 0xB1, 0x35, 0x00, 454 verifyBytes<ByteCountLocked32>(codeBytes(), 0xF0, 0x0F, 0xB1, 0x35, 0x00,
452 0xFF, 0x01, 0x00); 455 0xFF, 0x01, 0x00);
453 reset(); 456 reset();
454 } 457 }
455 } 458 }
456 459
457 } // end of anonymous namespace 460 } // end of anonymous namespace
458 } // end of namespace Test 461 } // end of namespace Test
459 } // end of namespace X8632 462 } // end of namespace X8632
460 } // end of namespace Ice 463 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698