Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 __ add(R0, R0, Operand(R1, SXTW, 0)); // R0 <- R0 + (sign extended R1) | 276 __ add(R0, R0, Operand(R1, SXTW, 0)); // R0 <- R0 + (sign extended R1) |
| 277 __ ret(); | 277 __ ret(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 | 280 |
| 281 ASSEMBLER_TEST_RUN(AddExtReg, test) { | 281 ASSEMBLER_TEST_RUN(AddExtReg, test) { |
| 282 typedef int (*SimpleCode)(); | 282 typedef int (*SimpleCode)(); |
| 283 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); | 283 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); |
| 284 } | 284 } |
| 285 | 285 |
| 286 | |
| 287 // Loads and Stores. | |
| 288 ASSEMBLER_TEST_GENERATE(SimpleLoadStore, assembler) { | |
| 289 __ movz(R0, 43, 0); | |
| 290 __ movz(R1, 42, 0); | |
| 291 __ str(R1, Address(SP, -1*kWordSize, Address::PreIndex)); | |
| 292 __ ldr(R0, Address(SP, 1*kWordSize, Address::PostIndex)); | |
| 293 __ ret(); | |
| 294 } | |
| 295 | |
| 296 | |
| 297 ASSEMBLER_TEST_RUN(SimpleLoadStore, test) { | |
| 298 typedef int (*SimpleCode)(); | |
| 299 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); | |
| 300 } | |
|
regis
2014/04/07 23:38:19
It would be good to add a test with an offset of -
zra
2014/04/08 15:14:13
Yes. I notice that this will likely be pretty anno
| |
| 301 | |
| 302 | |
| 303 ASSEMBLER_TEST_GENERATE(LoadStoreLargeIndex, assembler) { | |
| 304 __ movz(R0, 43, 0); | |
| 305 __ movz(R1, 42, 0); | |
| 306 // Largest negative offset that can fit in the signed 9-bit immediate field. | |
| 307 __ str(R1, Address(SP, -32*kWordSize, Address::PreIndex)); | |
| 308 // Largest positive kWordSize aligned offset that we can fit. | |
| 309 __ ldr(R0, Address(SP, 31*kWordSize, Address::PostIndex)); | |
| 310 // Correction. | |
| 311 __ add(SP, SP, Operand(kWordSize)); // Restore SP. | |
| 312 __ ret(); | |
| 313 } | |
| 314 | |
| 315 | |
| 316 ASSEMBLER_TEST_RUN(LoadStoreLargeIndex, test) { | |
| 317 typedef int (*SimpleCode)(); | |
| 318 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); | |
| 319 } | |
| 320 | |
| 321 | |
| 322 ASSEMBLER_TEST_GENERATE(LoadStoreLargeOffset, assembler) { | |
| 323 __ movz(R0, 43, 0); | |
| 324 __ movz(R1, 42, 0); | |
| 325 __ sub(SP, SP, Operand(512*kWordSize)); | |
| 326 __ str(R1, Address(SP, 512*kWordSize, Address::Offset)); | |
| 327 __ add(SP, SP, Operand(512*kWordSize)); | |
| 328 __ ldr(R0, Address(SP)); | |
| 329 __ ret(); | |
| 330 } | |
| 331 | |
| 332 | |
| 333 ASSEMBLER_TEST_RUN(LoadStoreLargeOffset, test) { | |
| 334 typedef int (*SimpleCode)(); | |
| 335 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); | |
| 336 } | |
| 337 | |
| 338 | |
| 339 ASSEMBLER_TEST_GENERATE(LoadStoreExtReg, assembler) { | |
| 340 __ movz(R0, 43, 0); | |
| 341 __ movz(R1, 42, 0); | |
| 342 __ movz(R2, 0xfff8, 0); | |
| 343 __ movk(R2, 0xffff, 1); // R2 <- -8 (int32_t). | |
| 344 // This should sign extend R2, and add to SP to get address, | |
| 345 // i.e. SP - kWordSize. | |
| 346 __ str(R1, Address(SP, R2, SXTW)); | |
| 347 __ sub(SP, SP, Operand(kWordSize)); | |
| 348 __ ldr(R0, Address(SP)); | |
| 349 __ add(SP, SP, Operand(kWordSize)); | |
| 350 __ ret(); | |
| 351 } | |
| 352 | |
| 353 | |
| 354 ASSEMBLER_TEST_RUN(LoadStoreExtReg, test) { | |
| 355 typedef int (*SimpleCode)(); | |
| 356 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); | |
| 357 } | |
| 358 | |
| 359 | |
| 360 ASSEMBLER_TEST_GENERATE(LoadStoreScaledReg, assembler) { | |
| 361 __ movz(R0, 43, 0); | |
| 362 __ movz(R1, 42, 0); | |
| 363 __ movz(R2, 10, 0); | |
| 364 __ sub(SP, SP, Operand(10*kWordSize)); | |
| 365 // Store R1 into SP + R2 * kWordSize. | |
| 366 __ str(R1, Address(SP, R2, UXTX, true)); | |
| 367 __ ldr(R0, Address(SP, R2, UXTX, true)); | |
| 368 __ add(SP, SP, Operand(10*kWordSize)); | |
| 369 __ ret(); | |
| 370 } | |
| 371 | |
| 372 | |
| 373 ASSEMBLER_TEST_RUN(LoadStoreScaledReg, test) { | |
| 374 typedef int (*SimpleCode)(); | |
| 375 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry())); | |
| 376 } | |
| 377 | |
| 286 } // namespace dart | 378 } // namespace dart |
| 287 | 379 |
| 288 #endif // defined(TARGET_ARCH_ARM64) | 380 #endif // defined(TARGET_ARCH_ARM64) |
| OLD | NEW |