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

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

Issue 214233006: Adds subract, move wide immediate instructions 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"
11 #include "vm/unit_test.h" 11 #include "vm/unit_test.h"
12 #include "vm/virtual_memory.h" 12 #include "vm/virtual_memory.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 #define __ assembler-> 16 #define __ assembler->
17 17
18 ASSEMBLER_TEST_GENERATE(Simple, assembler) { 18 ASSEMBLER_TEST_GENERATE(Simple, assembler) {
19 __ add(R0, ZR, Operand(ZR)); 19 __ add(R0, ZR, Operand(ZR));
20 __ add(R0, R0, Operand(42)); 20 __ add(R0, R0, Operand(42));
21 __ ret(); 21 __ ret();
22 } 22 }
23 23
24 24
25 ASSEMBLER_TEST_RUN(Simple, test) { 25 ASSEMBLER_TEST_RUN(Simple, test) {
26 typedef int (*SimpleCode)(); 26 typedef int (*SimpleCode)();
27 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry())); 27 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
28 }
29
30
31 // Move wide immediate tests.
32 // movz
33 ASSEMBLER_TEST_GENERATE(Movz0, assembler) {
34 __ movz(R0, 42, 0);
35 __ ret();
36 }
37
38
39 ASSEMBLER_TEST_RUN(Movz0, test) {
40 typedef int (*SimpleCode)();
41 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
42 }
43
44
45 ASSEMBLER_TEST_GENERATE(Movz1, assembler) {
46 __ movz(R0, 42, 0); // Overwritten by next instruction.
47 __ movz(R0, 42, 1);
48 __ ret();
49 }
50
51
52 ASSEMBLER_TEST_RUN(Movz1, test) {
53 typedef int (*SimpleCode)();
54 EXPECT_EQ(42LL << 16, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
55 }
56
57
58 ASSEMBLER_TEST_GENERATE(Movz2, assembler) {
59 __ movz(R0, 42, 2);
60 __ ret();
61 }
62
63
64 ASSEMBLER_TEST_RUN(Movz2, test) {
65 typedef int (*SimpleCode)();
66 EXPECT_EQ(42LL << 32, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
67 }
68
69
70 ASSEMBLER_TEST_GENERATE(Movz3, assembler) {
71 __ movz(R0, 42, 3);
72 __ ret();
73 }
74
75
76 ASSEMBLER_TEST_RUN(Movz3, test) {
77 typedef int (*SimpleCode)();
78 EXPECT_EQ(42LL << 48, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
79 }
80
81
82 // movn
83 ASSEMBLER_TEST_GENERATE(Movn0, assembler) {
84 __ movn(R0, 42, 0);
85 __ ret();
86 }
87
88
89 ASSEMBLER_TEST_RUN(Movn0, test) {
90 typedef int (*SimpleCode)();
91 EXPECT_EQ(~42LL, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
92 }
93
94
95 ASSEMBLER_TEST_GENERATE(Movn1, assembler) {
96 __ movn(R0, 42, 1);
97 __ ret();
98 }
99
100
101 ASSEMBLER_TEST_RUN(Movn1, test) {
102 typedef int (*SimpleCode)();
103 EXPECT_EQ(~(42LL << 16), EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
104 }
105
106
107 ASSEMBLER_TEST_GENERATE(Movn2, assembler) {
108 __ movn(R0, 42, 2);
109 __ ret();
110 }
111
112
113 ASSEMBLER_TEST_RUN(Movn2, test) {
114 typedef int (*SimpleCode)();
115 EXPECT_EQ(~(42LL << 32), EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
116 }
117
118
119 ASSEMBLER_TEST_GENERATE(Movn3, assembler) {
120 __ movn(R0, 42, 3);
121 __ ret();
122 }
123
124
125 ASSEMBLER_TEST_RUN(Movn3, test) {
126 typedef int (*SimpleCode)();
127 EXPECT_EQ(~(42LL << 48), EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
128 }
129
130 // movk
131 ASSEMBLER_TEST_GENERATE(Movk0, assembler) {
132 __ movz(R0, 1, 3);
133 __ movk(R0, 42, 0);
134 __ ret();
135 }
136
137
138 ASSEMBLER_TEST_RUN(Movk0, test) {
139 typedef int (*SimpleCode)();
140 EXPECT_EQ(
141 42LL | (1LL << 48), EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
142 }
143
144
145 ASSEMBLER_TEST_GENERATE(Movk1, assembler) {
146 __ movz(R0, 1, 0);
147 __ movk(R0, 42, 1);
148 __ ret();
149 }
150
151
152 ASSEMBLER_TEST_RUN(Movk1, test) {
153 typedef int (*SimpleCode)();
154 EXPECT_EQ(
155 (42LL << 16) | 1, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
156 }
157
158
159 ASSEMBLER_TEST_GENERATE(Movk2, assembler) {
160 __ movz(R0, 1, 0);
161 __ movk(R0, 42, 2);
162 __ ret();
163 }
164
165
166 ASSEMBLER_TEST_RUN(Movk2, test) {
167 typedef int (*SimpleCode)();
168 EXPECT_EQ(
169 (42LL << 32) | 1, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
170 }
171
172
173 ASSEMBLER_TEST_GENERATE(Movk3, assembler) {
174 __ movz(R0, 1, 0);
175 __ movk(R0, 42, 3);
176 __ ret();
177 }
178
179
180 ASSEMBLER_TEST_RUN(Movk3, test) {
181 typedef int (*SimpleCode)();
182 EXPECT_EQ(
183 (42LL << 48) | 1, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
184 }
185
186
187 ASSEMBLER_TEST_GENERATE(MovzBig, assembler) {
188 __ movz(R0, 0x8000, 0);
189 __ ret();
190 }
191
192
193 ASSEMBLER_TEST_RUN(MovzBig, test) {
194 typedef int (*SimpleCode)();
195 EXPECT_EQ(0x8000, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
196 }
197
198
199 // add tests.
200 ASSEMBLER_TEST_GENERATE(AddReg, assembler) {
201 __ movz(R0, 20, 0);
202 __ movz(R1, 22, 0);
203 __ add(R0, R0, Operand(R1));
204 __ ret();
205 }
206
207
208 ASSEMBLER_TEST_RUN(AddReg, test) {
209 typedef int (*SimpleCode)();
210 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
211 }
212
213
214 ASSEMBLER_TEST_GENERATE(AddLSLReg, assembler) {
215 __ movz(R0, 20, 0);
216 __ movz(R1, 11, 0);
217 __ add(R0, R0, Operand(R1, LSL, 1));
218 __ ret();
219 }
220
221
222 ASSEMBLER_TEST_RUN(AddLSLReg, test) {
223 typedef int (*SimpleCode)();
224 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
225 }
226
227
228 ASSEMBLER_TEST_GENERATE(AddLSRReg, assembler) {
229 __ movz(R0, 20, 0);
230 __ movz(R1, 44, 0);
231 __ add(R0, R0, Operand(R1, LSR, 1));
232 __ ret();
233 }
234
235
236 ASSEMBLER_TEST_RUN(AddLSRReg, test) {
237 typedef int (*SimpleCode)();
238 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
239 }
240
241
242 ASSEMBLER_TEST_GENERATE(AddASRReg, assembler) {
243 __ movz(R0, 20, 0);
244 __ movz(R1, 44, 0);
245 __ add(R0, R0, Operand(R1, ASR, 1));
246 __ ret();
247 }
248
249
250 ASSEMBLER_TEST_RUN(AddASRReg, test) {
251 typedef int (*SimpleCode)();
252 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
253 }
254
255
256 ASSEMBLER_TEST_GENERATE(AddASRNegReg, assembler) {
257 __ movz(R0, 43, 0);
258 __ movn(R1, 0, 0); // R1 <- -1
259 __ add(R1, ZR, Operand(R1, LSL, 3)); // R1 <- -8
260 __ add(R0, R0, Operand(R1, ASR, 3)); // R0 <- 43 + (-8 >> 3)
261 __ ret();
262 }
263
264
265 ASSEMBLER_TEST_RUN(AddASRNegReg, test) {
266 typedef int (*SimpleCode)();
267 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
268 }
269
270
271 // TODO(zra): test other sign extension modes.
272 ASSEMBLER_TEST_GENERATE(AddExtReg, assembler) {
273 __ movz(R0, 43, 0);
274 __ movz(R1, 0xffff, 0);
275 __ movk(R1, 0xffff, 1); // R1 <- -1 (32-bit)
276 __ add(R0, R0, Operand(R1, SXTW, 0)); // R0 <- R0 + (sign extended R1)
277 __ ret();
278 }
279
280
281 ASSEMBLER_TEST_RUN(AddExtReg, test) {
282 typedef int (*SimpleCode)();
283 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(SimpleCode, test->entry()));
28 } 284 }
29 285
30 } // namespace dart 286 } // namespace dart
31 287
32 #endif // defined(TARGET_ARCH_ARM64) 288 #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