1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
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. |
4 | |
5 | #include "platform/assert.h" |
6 | #include "vm/globals.h" |
7 | #if defined(TARGET_ARCH_ARM) |
8 | |
9 | #include "vm/compiler/assembler/assembler.h" |
10 | #include "vm/object.h" |
11 | #include "vm/unit_test.h" |
12 | |
13 | namespace dart { |
14 | |
15 | #define __ assembler-> |
16 | |
17 | // Generate a simple dart code sequence. |
18 | // This is used to test Code and Instruction object creation. |
19 | void GenerateIncrement(compiler::Assembler* assembler) { |
20 | __ LoadImmediate(R0, 0); |
21 | __ Push(R0); |
22 | __ ldr(IP, compiler::Address(SP, 0)); |
23 | __ add(IP, IP, compiler::Operand(1)); |
24 | __ str(IP, compiler::Address(SP, 0)); |
25 | __ ldr(IP, compiler::Address(SP, 0)); |
26 | __ add(IP, IP, compiler::Operand(1)); |
27 | __ Pop(R0); |
28 | __ mov(R0, compiler::Operand(IP)); |
29 | __ Ret(); |
30 | } |
31 | |
32 | // Generate a dart code sequence that embeds a string object in it. |
33 | // This is used to test Embedded String objects in the instructions. |
34 | void GenerateEmbedStringInCode(compiler::Assembler* assembler, |
35 | const char* str) { |
36 | __ EnterDartFrame(0); // To setup pp. |
37 | const String& string_object = |
38 | String::ZoneHandle(String::New(str, Heap::kOld)); |
39 | __ LoadObject(R0, string_object); |
40 | __ LeaveDartFrameAndReturn(); |
41 | } |
42 | |
43 | // Generate a dart code sequence that embeds a smi object in it. |
44 | // This is used to test Embedded Smi objects in the instructions. |
45 | void GenerateEmbedSmiInCode(compiler::Assembler* assembler, intptr_t value) { |
46 | // No need to setup pp, since Smis are not stored in the object pool. |
47 | const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); |
48 | __ LoadObject(R0, smi_object); |
49 | __ Ret(); |
50 | } |
51 | |
52 | } // namespace dart |
53 | |
54 | #endif // defined TARGET_ARCH_ARM |
55 | |