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

Side by Side Diff: runtime/vm/assembler_arm64_test.cc

Issue 227593012: Adds ldr and str to arm64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_arm64.h ('k') | runtime/vm/constants_arm64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
301
302
303 ASSEMBLER_TEST_GENERATE(SimpleLoadStoreHeapTag, assembler) {
304 __ movz(R0, 43, 0);
305 __ movz(R1, 42, 0);
306 __ add(R2, SP, Operand(1));
307 __ str(R1, Address(R2, -1, Address::PreIndex));
308 __ ldr(R0, Address(R2, -1, Address::PostIndex));
309 __ ret();
310 }
311
312
313 ASSEMBLER_TEST_RUN(SimpleLoadStoreHeapTag, test) {
314 typedef int (*SimpleCode)();
315 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
316 }
317
318
319 ASSEMBLER_TEST_GENERATE(LoadStoreLargeIndex, assembler) {
320 __ movz(R0, 43, 0);
321 __ movz(R1, 42, 0);
322 // Largest negative offset that can fit in the signed 9-bit immediate field.
323 __ str(R1, Address(SP, -32*kWordSize, Address::PreIndex));
324 // Largest positive kWordSize aligned offset that we can fit.
325 __ ldr(R0, Address(SP, 31*kWordSize, Address::PostIndex));
326 // Correction.
327 __ add(SP, SP, Operand(kWordSize)); // Restore SP.
328 __ ret();
329 }
330
331
332 ASSEMBLER_TEST_RUN(LoadStoreLargeIndex, test) {
333 typedef int (*SimpleCode)();
334 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
335 }
336
337
338 ASSEMBLER_TEST_GENERATE(LoadStoreLargeOffset, assembler) {
339 __ movz(R0, 43, 0);
340 __ movz(R1, 42, 0);
341 __ sub(SP, SP, Operand(512*kWordSize));
342 __ str(R1, Address(SP, 512*kWordSize, Address::Offset));
343 __ add(SP, SP, Operand(512*kWordSize));
344 __ ldr(R0, Address(SP));
345 __ ret();
346 }
347
348
349 ASSEMBLER_TEST_RUN(LoadStoreLargeOffset, test) {
350 typedef int (*SimpleCode)();
351 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
352 }
353
354
355 ASSEMBLER_TEST_GENERATE(LoadStoreExtReg, assembler) {
356 __ movz(R0, 43, 0);
357 __ movz(R1, 42, 0);
358 __ movz(R2, 0xfff8, 0);
359 __ movk(R2, 0xffff, 1); // R2 <- -8 (int32_t).
360 // This should sign extend R2, and add to SP to get address,
361 // i.e. SP - kWordSize.
362 __ str(R1, Address(SP, R2, SXTW));
363 __ sub(SP, SP, Operand(kWordSize));
364 __ ldr(R0, Address(SP));
365 __ add(SP, SP, Operand(kWordSize));
366 __ ret();
367 }
368
369
370 ASSEMBLER_TEST_RUN(LoadStoreExtReg, test) {
371 typedef int (*SimpleCode)();
372 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
373 }
374
375
376 ASSEMBLER_TEST_GENERATE(LoadStoreScaledReg, assembler) {
377 __ movz(R0, 43, 0);
378 __ movz(R1, 42, 0);
379 __ movz(R2, 10, 0);
380 __ sub(SP, SP, Operand(10*kWordSize));
381 // Store R1 into SP + R2 * kWordSize.
382 __ str(R1, Address(SP, R2, UXTX, true));
383 __ ldr(R0, Address(SP, R2, UXTX, true));
384 __ add(SP, SP, Operand(10*kWordSize));
385 __ ret();
386 }
387
388
389 ASSEMBLER_TEST_RUN(LoadStoreScaledReg, test) {
390 typedef int (*SimpleCode)();
391 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
392 }
393
286 } // namespace dart 394 } // namespace dart
287 395
288 #endif // defined(TARGET_ARCH_ARM64) 396 #endif // defined(TARGET_ARCH_ARM64)
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm64.h ('k') | runtime/vm/constants_arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698