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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // movk | 130 // movk |
131 ASSEMBLER_TEST_GENERATE(Movk0, assembler) { | 131 ASSEMBLER_TEST_GENERATE(Movk0, assembler) { |
132 __ movz(R0, Immediate(1), 3); | 132 __ movz(R0, Immediate(1), 3); |
133 __ movk(R0, Immediate(42), 0); | 133 __ movk(R0, Immediate(42), 0); |
134 __ ret(); | 134 __ ret(); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 ASSEMBLER_TEST_RUN(Movk0, test) { | 138 ASSEMBLER_TEST_RUN(Movk0, test) { |
139 typedef int64_t (*Int64Return)() DART_UNUSED; | 139 typedef int64_t (*Int64Return)() DART_UNUSED; |
140 EXPECT_EQ( | 140 EXPECT_EQ(42LL | (1LL << 48), |
141 42LL | (1LL << 48), EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 141 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 ASSEMBLER_TEST_GENERATE(Movk1, assembler) { | 145 ASSEMBLER_TEST_GENERATE(Movk1, assembler) { |
146 __ movz(R0, Immediate(1), 0); | 146 __ movz(R0, Immediate(1), 0); |
147 __ movk(R0, Immediate(42), 1); | 147 __ movk(R0, Immediate(42), 1); |
148 __ ret(); | 148 __ ret(); |
149 } | 149 } |
150 | 150 |
151 | 151 |
152 ASSEMBLER_TEST_RUN(Movk1, test) { | 152 ASSEMBLER_TEST_RUN(Movk1, test) { |
153 typedef int64_t (*Int64Return)() DART_UNUSED; | 153 typedef int64_t (*Int64Return)() DART_UNUSED; |
154 EXPECT_EQ( | 154 EXPECT_EQ((42LL << 16) | 1, |
155 (42LL << 16) | 1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 155 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 ASSEMBLER_TEST_GENERATE(Movk2, assembler) { | 159 ASSEMBLER_TEST_GENERATE(Movk2, assembler) { |
160 __ movz(R0, Immediate(1), 0); | 160 __ movz(R0, Immediate(1), 0); |
161 __ movk(R0, Immediate(42), 2); | 161 __ movk(R0, Immediate(42), 2); |
162 __ ret(); | 162 __ ret(); |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 ASSEMBLER_TEST_RUN(Movk2, test) { | 166 ASSEMBLER_TEST_RUN(Movk2, test) { |
167 typedef int64_t (*Int64Return)() DART_UNUSED; | 167 typedef int64_t (*Int64Return)() DART_UNUSED; |
168 EXPECT_EQ( | 168 EXPECT_EQ((42LL << 32) | 1, |
169 (42LL << 32) | 1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 169 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 ASSEMBLER_TEST_GENERATE(Movk3, assembler) { | 173 ASSEMBLER_TEST_GENERATE(Movk3, assembler) { |
174 __ movz(R0, Immediate(1), 0); | 174 __ movz(R0, Immediate(1), 0); |
175 __ movk(R0, Immediate(42), 3); | 175 __ movk(R0, Immediate(42), 3); |
176 __ ret(); | 176 __ ret(); |
177 } | 177 } |
178 | 178 |
179 | 179 |
180 ASSEMBLER_TEST_RUN(Movk3, test) { | 180 ASSEMBLER_TEST_RUN(Movk3, test) { |
181 typedef int64_t (*Int64Return)() DART_UNUSED; | 181 typedef int64_t (*Int64Return)() DART_UNUSED; |
182 EXPECT_EQ( | 182 EXPECT_EQ((42LL << 48) | 1, |
183 (42LL << 48) | 1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 183 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
184 } | 184 } |
185 | 185 |
186 | 186 |
187 ASSEMBLER_TEST_GENERATE(MovzBig, assembler) { | 187 ASSEMBLER_TEST_GENERATE(MovzBig, assembler) { |
188 __ movz(R0, Immediate(0x8000), 0); | 188 __ movz(R0, Immediate(0x8000), 0); |
189 __ ret(); | 189 __ ret(); |
190 } | 190 } |
191 | 191 |
192 | 192 |
193 ASSEMBLER_TEST_RUN(MovzBig, test) { | 193 ASSEMBLER_TEST_RUN(MovzBig, test) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 | 249 |
250 ASSEMBLER_TEST_RUN(AddASRReg, test) { | 250 ASSEMBLER_TEST_RUN(AddASRReg, test) { |
251 typedef int64_t (*Int64Return)() DART_UNUSED; | 251 typedef int64_t (*Int64Return)() DART_UNUSED; |
252 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 252 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
253 } | 253 } |
254 | 254 |
255 | 255 |
256 ASSEMBLER_TEST_GENERATE(AddASRNegReg, assembler) { | 256 ASSEMBLER_TEST_GENERATE(AddASRNegReg, assembler) { |
257 __ movz(R0, Immediate(43), 0); | 257 __ movz(R0, Immediate(43), 0); |
258 __ movn(R1, Immediate(0), 0); // R1 <- -1 | 258 __ movn(R1, Immediate(0), 0); // R1 <- -1 |
259 __ add(R1, ZR, Operand(R1, LSL, 3)); // R1 <- -8 | 259 __ add(R1, ZR, Operand(R1, LSL, 3)); // R1 <- -8 |
260 __ add(R0, R0, Operand(R1, ASR, 3)); // R0 <- 43 + (-8 >> 3) | 260 __ add(R0, R0, Operand(R1, ASR, 3)); // R0 <- 43 + (-8 >> 3) |
261 __ ret(); | 261 __ ret(); |
262 } | 262 } |
263 | 263 |
264 | 264 |
265 ASSEMBLER_TEST_RUN(AddASRNegReg, test) { | 265 ASSEMBLER_TEST_RUN(AddASRNegReg, test) { |
266 typedef int64_t (*Int64Return)() DART_UNUSED; | 266 typedef int64_t (*Int64Return)() DART_UNUSED; |
267 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 267 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
268 } | 268 } |
269 | 269 |
270 | 270 |
271 // TODO(zra): test other sign extension modes. | 271 // TODO(zra): test other sign extension modes. |
272 ASSEMBLER_TEST_GENERATE(AddExtReg, assembler) { | 272 ASSEMBLER_TEST_GENERATE(AddExtReg, assembler) { |
273 __ movz(R0, Immediate(43), 0); | 273 __ movz(R0, Immediate(43), 0); |
274 __ movz(R1, Immediate(0xffff), 0); | 274 __ movz(R1, Immediate(0xffff), 0); |
275 __ movk(R1, Immediate(0xffff), 1); // R1 <- -1 (32-bit) | 275 __ movk(R1, Immediate(0xffff), 1); // R1 <- -1 (32-bit) |
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 int64_t (*Int64Return)() DART_UNUSED; | 282 typedef int64_t (*Int64Return)() DART_UNUSED; |
283 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 283 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 ASSEMBLER_TEST_GENERATE(AddCarryInOut, assembler) { | 287 ASSEMBLER_TEST_GENERATE(AddCarryInOut, assembler) { |
288 __ LoadImmediate(R2, -1); | 288 __ LoadImmediate(R2, -1); |
289 __ LoadImmediate(R1, 1); | 289 __ LoadImmediate(R1, 1); |
290 __ LoadImmediate(R0, 0); | 290 __ LoadImmediate(R0, 0); |
291 __ adds(IP0, R2, Operand(R1)); // c_out = 1. | 291 __ adds(IP0, R2, Operand(R1)); // c_out = 1. |
292 __ adcs(IP0, R2, R0); // c_in = 1, c_out = 1. | 292 __ adcs(IP0, R2, R0); // c_in = 1, c_out = 1. |
293 __ adc(R0, R0, R0); // c_in = 1. | 293 __ adc(R0, R0, R0); // c_in = 1. |
294 __ ret(); | 294 __ ret(); |
295 } | 295 } |
296 | 296 |
297 | 297 |
298 ASSEMBLER_TEST_RUN(AddCarryInOut, test) { | 298 ASSEMBLER_TEST_RUN(AddCarryInOut, test) { |
299 typedef int64_t (*Int64Return)() DART_UNUSED; | 299 typedef int64_t (*Int64Return)() DART_UNUSED; |
300 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 300 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 ASSEMBLER_TEST_GENERATE(SubCarryInOut, assembler) { | 304 ASSEMBLER_TEST_GENERATE(SubCarryInOut, assembler) { |
305 __ LoadImmediate(R1, 1); | 305 __ LoadImmediate(R1, 1); |
306 __ LoadImmediate(R0, 0); | 306 __ LoadImmediate(R0, 0); |
307 __ subs(IP0, R0, Operand(R1)); // c_out = 1. | 307 __ subs(IP0, R0, Operand(R1)); // c_out = 1. |
308 __ sbcs(IP0, R0, R0); // c_in = 1, c_out = 1. | 308 __ sbcs(IP0, R0, R0); // c_in = 1, c_out = 1. |
309 __ sbc(R0, R0, R0); // c_in = 1. | 309 __ sbc(R0, R0, R0); // c_in = 1. |
310 __ ret(); | 310 __ ret(); |
311 } | 311 } |
312 | 312 |
313 | 313 |
314 ASSEMBLER_TEST_RUN(SubCarryInOut, test) { | 314 ASSEMBLER_TEST_RUN(SubCarryInOut, test) { |
315 typedef int64_t (*Int64Return)() DART_UNUSED; | 315 typedef int64_t (*Int64Return)() DART_UNUSED; |
316 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 316 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 ASSEMBLER_TEST_GENERATE(Overflow, assembler) { | 320 ASSEMBLER_TEST_GENERATE(Overflow, assembler) { |
321 __ LoadImmediate(R0, 0); | 321 __ LoadImmediate(R0, 0); |
322 __ LoadImmediate(R1, 1); | 322 __ LoadImmediate(R1, 1); |
323 __ LoadImmediate(R2, 0xFFFFFFFFFFFFFFFF); | 323 __ LoadImmediate(R2, 0xFFFFFFFFFFFFFFFF); |
324 __ LoadImmediate(R3, 0x7FFFFFFFFFFFFFFF); | 324 __ LoadImmediate(R3, 0x7FFFFFFFFFFFFFFF); |
325 __ adds(IP0, R2, Operand(R1)); // c_out = 1. | 325 __ adds(IP0, R2, Operand(R1)); // c_out = 1. |
326 __ adcs(IP0, R3, R0); // c_in = 1, c_out = 1, v = 1. | 326 __ adcs(IP0, R3, R0); // c_in = 1, c_out = 1, v = 1. |
327 __ csinc(R0, R0, R0, VS); // R0 = v ? R0 : R0 + 1. | 327 __ csinc(R0, R0, R0, VS); // R0 = v ? R0 : R0 + 1. |
328 __ ret(); | 328 __ ret(); |
329 } | 329 } |
330 | 330 |
331 | 331 |
332 ASSEMBLER_TEST_RUN(Overflow, test) { | 332 ASSEMBLER_TEST_RUN(Overflow, test) { |
333 typedef int64_t (*Int64Return)() DART_UNUSED; | 333 typedef int64_t (*Int64Return)() DART_UNUSED; |
334 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 334 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
335 } | 335 } |
336 | 336 |
337 | 337 |
338 ASSEMBLER_TEST_GENERATE(WordAddCarryInOut, assembler) { | 338 ASSEMBLER_TEST_GENERATE(WordAddCarryInOut, assembler) { |
339 __ LoadImmediate(R2, -1); | 339 __ LoadImmediate(R2, -1); |
340 __ LoadImmediate(R1, 1); | 340 __ LoadImmediate(R1, 1); |
341 __ LoadImmediate(R0, 0); | 341 __ LoadImmediate(R0, 0); |
342 __ addsw(IP0, R2, Operand(R1)); // c_out = 1. | 342 __ addsw(IP0, R2, Operand(R1)); // c_out = 1. |
343 __ adcsw(IP0, R2, R0); // c_in = 1, c_out = 1. | 343 __ adcsw(IP0, R2, R0); // c_in = 1, c_out = 1. |
344 __ adcw(R0, R0, R0); // c_in = 1. | 344 __ adcw(R0, R0, R0); // c_in = 1. |
345 __ ret(); | 345 __ ret(); |
346 } | 346 } |
347 | 347 |
348 | 348 |
349 ASSEMBLER_TEST_RUN(WordAddCarryInOut, test) { | 349 ASSEMBLER_TEST_RUN(WordAddCarryInOut, test) { |
350 typedef int64_t (*Int64Return)() DART_UNUSED; | 350 typedef int64_t (*Int64Return)() DART_UNUSED; |
351 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 351 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
352 } | 352 } |
353 | 353 |
354 | 354 |
355 ASSEMBLER_TEST_GENERATE(WordSubCarryInOut, assembler) { | 355 ASSEMBLER_TEST_GENERATE(WordSubCarryInOut, assembler) { |
356 __ LoadImmediate(R1, 1); | 356 __ LoadImmediate(R1, 1); |
357 __ LoadImmediate(R0, 0); | 357 __ LoadImmediate(R0, 0); |
358 __ subsw(IP0, R0, Operand(R1)); // c_out = 1. | 358 __ subsw(IP0, R0, Operand(R1)); // c_out = 1. |
359 __ sbcsw(IP0, R0, R0); // c_in = 1, c_out = 1. | 359 __ sbcsw(IP0, R0, R0); // c_in = 1, c_out = 1. |
360 __ sbcw(R0, R0, R0); // c_in = 1. | 360 __ sbcw(R0, R0, R0); // c_in = 1. |
361 __ ret(); | 361 __ ret(); |
362 } | 362 } |
363 | 363 |
364 | 364 |
365 ASSEMBLER_TEST_RUN(WordSubCarryInOut, test) { | 365 ASSEMBLER_TEST_RUN(WordSubCarryInOut, test) { |
366 typedef int64_t (*Int64Return)() DART_UNUSED; | 366 typedef int64_t (*Int64Return)() DART_UNUSED; |
367 EXPECT_EQ(0x0FFFFFFFF, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 367 EXPECT_EQ(0x0FFFFFFFF, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
368 } | 368 } |
369 | 369 |
370 | 370 |
371 ASSEMBLER_TEST_GENERATE(WordOverflow, assembler) { | 371 ASSEMBLER_TEST_GENERATE(WordOverflow, assembler) { |
372 __ LoadImmediate(R0, 0); | 372 __ LoadImmediate(R0, 0); |
373 __ LoadImmediate(R1, 1); | 373 __ LoadImmediate(R1, 1); |
374 __ LoadImmediate(R2, 0xFFFFFFFF); | 374 __ LoadImmediate(R2, 0xFFFFFFFF); |
375 __ LoadImmediate(R3, 0x7FFFFFFF); | 375 __ LoadImmediate(R3, 0x7FFFFFFF); |
376 __ addsw(IP0, R2, Operand(R1)); // c_out = 1. | 376 __ addsw(IP0, R2, Operand(R1)); // c_out = 1. |
377 __ adcsw(IP0, R3, R0); // c_in = 1, c_out = 1, v = 1. | 377 __ adcsw(IP0, R3, R0); // c_in = 1, c_out = 1, v = 1. |
378 __ csinc(R0, R0, R0, VS); // R0 = v ? R0 : R0 + 1. | 378 __ csinc(R0, R0, R0, VS); // R0 = v ? R0 : R0 + 1. |
379 __ ret(); | 379 __ ret(); |
380 } | 380 } |
381 | 381 |
382 | 382 |
383 ASSEMBLER_TEST_RUN(WordOverflow, test) { | 383 ASSEMBLER_TEST_RUN(WordOverflow, test) { |
384 typedef int64_t (*Int64Return)() DART_UNUSED; | 384 typedef int64_t (*Int64Return)() DART_UNUSED; |
385 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 385 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
386 } | 386 } |
387 | 387 |
388 | 388 |
389 // Loads and Stores. | 389 // Loads and Stores. |
390 ASSEMBLER_TEST_GENERATE(SimpleLoadStore, assembler) { | 390 ASSEMBLER_TEST_GENERATE(SimpleLoadStore, assembler) { |
391 __ SetupDartSP(); | 391 __ SetupDartSP(); |
392 __ movz(R0, Immediate(43), 0); | 392 __ movz(R0, Immediate(43), 0); |
393 __ movz(R1, Immediate(42), 0); | 393 __ movz(R1, Immediate(42), 0); |
394 __ str(R1, Address(SP, -1*kWordSize, Address::PreIndex)); | 394 __ str(R1, Address(SP, -1 * kWordSize, Address::PreIndex)); |
395 __ ldr(R0, Address(SP, 1*kWordSize, Address::PostIndex)); | 395 __ ldr(R0, Address(SP, 1 * kWordSize, Address::PostIndex)); |
396 __ RestoreCSP(); | 396 __ RestoreCSP(); |
397 __ ret(); | 397 __ ret(); |
398 } | 398 } |
399 | 399 |
400 | 400 |
401 ASSEMBLER_TEST_RUN(SimpleLoadStore, test) { | 401 ASSEMBLER_TEST_RUN(SimpleLoadStore, test) { |
402 typedef int64_t (*Int64Return)() DART_UNUSED; | 402 typedef int64_t (*Int64Return)() DART_UNUSED; |
403 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 403 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
404 } | 404 } |
405 | 405 |
(...skipping 14 matching lines...) Expand all Loading... |
420 typedef int64_t (*Int64Return)() DART_UNUSED; | 420 typedef int64_t (*Int64Return)() DART_UNUSED; |
421 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 421 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 ASSEMBLER_TEST_GENERATE(LoadStoreLargeIndex, assembler) { | 425 ASSEMBLER_TEST_GENERATE(LoadStoreLargeIndex, assembler) { |
426 __ SetupDartSP(); | 426 __ SetupDartSP(); |
427 __ movz(R0, Immediate(43), 0); | 427 __ movz(R0, Immediate(43), 0); |
428 __ movz(R1, Immediate(42), 0); | 428 __ movz(R1, Immediate(42), 0); |
429 // Largest negative offset that can fit in the signed 9-bit immediate field. | 429 // Largest negative offset that can fit in the signed 9-bit immediate field. |
430 __ str(R1, Address(SP, -32*kWordSize, Address::PreIndex)); | 430 __ str(R1, Address(SP, -32 * kWordSize, Address::PreIndex)); |
431 // Largest positive kWordSize aligned offset that we can fit. | 431 // Largest positive kWordSize aligned offset that we can fit. |
432 __ ldr(R0, Address(SP, 31*kWordSize, Address::PostIndex)); | 432 __ ldr(R0, Address(SP, 31 * kWordSize, Address::PostIndex)); |
433 // Correction. | 433 // Correction. |
434 __ add(SP, SP, Operand(kWordSize)); // Restore SP. | 434 __ add(SP, SP, Operand(kWordSize)); // Restore SP. |
435 __ RestoreCSP(); | 435 __ RestoreCSP(); |
436 __ ret(); | 436 __ ret(); |
437 } | 437 } |
438 | 438 |
439 | 439 |
440 ASSEMBLER_TEST_RUN(LoadStoreLargeIndex, test) { | 440 ASSEMBLER_TEST_RUN(LoadStoreLargeIndex, test) { |
441 typedef int64_t (*Int64Return)() DART_UNUSED; | 441 typedef int64_t (*Int64Return)() DART_UNUSED; |
442 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 442 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
443 } | 443 } |
444 | 444 |
445 | 445 |
446 ASSEMBLER_TEST_GENERATE(LoadStoreLargeOffset, assembler) { | 446 ASSEMBLER_TEST_GENERATE(LoadStoreLargeOffset, assembler) { |
447 __ SetupDartSP(); | 447 __ SetupDartSP(); |
448 __ movz(R0, Immediate(43), 0); | 448 __ movz(R0, Immediate(43), 0); |
449 __ movz(R1, Immediate(42), 0); | 449 __ movz(R1, Immediate(42), 0); |
450 __ sub(SP, SP, Operand(512*kWordSize)); | 450 __ sub(SP, SP, Operand(512 * kWordSize)); |
451 __ str(R1, Address(SP, 512*kWordSize, Address::Offset)); | 451 __ str(R1, Address(SP, 512 * kWordSize, Address::Offset)); |
452 __ add(SP, SP, Operand(512*kWordSize)); | 452 __ add(SP, SP, Operand(512 * kWordSize)); |
453 __ ldr(R0, Address(SP)); | 453 __ ldr(R0, Address(SP)); |
454 __ RestoreCSP(); | 454 __ RestoreCSP(); |
455 __ ret(); | 455 __ ret(); |
456 } | 456 } |
457 | 457 |
458 | 458 |
459 ASSEMBLER_TEST_RUN(LoadStoreLargeOffset, test) { | 459 ASSEMBLER_TEST_RUN(LoadStoreLargeOffset, test) { |
460 typedef int64_t (*Int64Return)() DART_UNUSED; | 460 typedef int64_t (*Int64Return)() DART_UNUSED; |
461 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 461 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
462 } | 462 } |
(...skipping 20 matching lines...) Expand all Loading... |
483 typedef int64_t (*Int64Return)() DART_UNUSED; | 483 typedef int64_t (*Int64Return)() DART_UNUSED; |
484 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 484 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
485 } | 485 } |
486 | 486 |
487 | 487 |
488 ASSEMBLER_TEST_GENERATE(LoadStoreScaledReg, assembler) { | 488 ASSEMBLER_TEST_GENERATE(LoadStoreScaledReg, assembler) { |
489 __ SetupDartSP(); | 489 __ SetupDartSP(); |
490 __ movz(R0, Immediate(43), 0); | 490 __ movz(R0, Immediate(43), 0); |
491 __ movz(R1, Immediate(42), 0); | 491 __ movz(R1, Immediate(42), 0); |
492 __ movz(R2, Immediate(10), 0); | 492 __ movz(R2, Immediate(10), 0); |
493 __ sub(SP, SP, Operand(10*kWordSize)); | 493 __ sub(SP, SP, Operand(10 * kWordSize)); |
494 // Store R1 into SP + R2 * kWordSize. | 494 // Store R1 into SP + R2 * kWordSize. |
495 __ str(R1, Address(SP, R2, UXTX, Address::Scaled)); | 495 __ str(R1, Address(SP, R2, UXTX, Address::Scaled)); |
496 __ ldr(R0, Address(SP, R2, UXTX, Address::Scaled)); | 496 __ ldr(R0, Address(SP, R2, UXTX, Address::Scaled)); |
497 __ add(SP, SP, Operand(10*kWordSize)); | 497 __ add(SP, SP, Operand(10 * kWordSize)); |
498 __ RestoreCSP(); | 498 __ RestoreCSP(); |
499 __ ret(); | 499 __ ret(); |
500 } | 500 } |
501 | 501 |
502 | 502 |
503 ASSEMBLER_TEST_RUN(LoadStoreScaledReg, test) { | 503 ASSEMBLER_TEST_RUN(LoadStoreScaledReg, test) { |
504 typedef int64_t (*Int64Return)() DART_UNUSED; | 504 typedef int64_t (*Int64Return)() DART_UNUSED; |
505 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 505 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
506 } | 506 } |
507 | 507 |
(...skipping 12 matching lines...) Expand all Loading... |
520 ASSEMBLER_TEST_RUN(LoadSigned32Bit, test) { | 520 ASSEMBLER_TEST_RUN(LoadSigned32Bit, test) { |
521 typedef int64_t (*Int64Return)() DART_UNUSED; | 521 typedef int64_t (*Int64Return)() DART_UNUSED; |
522 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 522 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
523 } | 523 } |
524 | 524 |
525 | 525 |
526 ASSEMBLER_TEST_GENERATE(SimpleLoadStorePair, assembler) { | 526 ASSEMBLER_TEST_GENERATE(SimpleLoadStorePair, assembler) { |
527 __ SetupDartSP(); | 527 __ SetupDartSP(); |
528 __ LoadImmediate(R2, 43); | 528 __ LoadImmediate(R2, 43); |
529 __ LoadImmediate(R3, 42); | 529 __ LoadImmediate(R3, 42); |
530 __ stp(R2, R3, Address(SP, -2*kWordSize, Address::PairPreIndex)); | 530 __ stp(R2, R3, Address(SP, -2 * kWordSize, Address::PairPreIndex)); |
531 __ ldp(R0, R1, Address(SP, 2*kWordSize, Address::PairPostIndex)); | 531 __ ldp(R0, R1, Address(SP, 2 * kWordSize, Address::PairPostIndex)); |
532 __ sub(R0, R0, Operand(R1)); | 532 __ sub(R0, R0, Operand(R1)); |
533 __ RestoreCSP(); | 533 __ RestoreCSP(); |
534 __ ret(); | 534 __ ret(); |
535 } | 535 } |
536 | 536 |
537 | 537 |
538 ASSEMBLER_TEST_RUN(SimpleLoadStorePair, test) { | 538 ASSEMBLER_TEST_RUN(SimpleLoadStorePair, test) { |
539 typedef int64_t (*Int64Return)() DART_UNUSED; | 539 typedef int64_t (*Int64Return)() DART_UNUSED; |
540 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 540 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
541 } | 541 } |
(...skipping 23 matching lines...) Expand all Loading... |
565 __ SetupDartSP(); | 565 __ SetupDartSP(); |
566 __ movz(R0, Immediate(40), 0); | 566 __ movz(R0, Immediate(40), 0); |
567 __ movz(R1, Immediate(42), 0); | 567 __ movz(R1, Immediate(42), 0); |
568 __ Push(R0); | 568 __ Push(R0); |
569 Label retry; | 569 Label retry; |
570 __ Bind(&retry); | 570 __ Bind(&retry); |
571 __ ldxr(R0, SP); | 571 __ ldxr(R0, SP); |
572 __ stxr(TMP, R1, SP); // IP == 0, success | 572 __ stxr(TMP, R1, SP); // IP == 0, success |
573 __ cmp(TMP, Operand(0)); | 573 __ cmp(TMP, Operand(0)); |
574 __ b(&retry, NE); // NE if context switch occurred between ldrex and strex. | 574 __ b(&retry, NE); // NE if context switch occurred between ldrex and strex. |
575 __ Pop(R0); // 42 | 575 __ Pop(R0); // 42 |
576 __ RestoreCSP(); | 576 __ RestoreCSP(); |
577 __ ret(); | 577 __ ret(); |
578 } | 578 } |
579 | 579 |
580 | 580 |
581 ASSEMBLER_TEST_RUN(Semaphore, test) { | 581 ASSEMBLER_TEST_RUN(Semaphore, test) { |
582 EXPECT(test != NULL); | 582 EXPECT(test != NULL); |
583 typedef int (*Semaphore)() DART_UNUSED; | 583 typedef int (*Semaphore)() DART_UNUSED; |
584 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Semaphore, test->entry())); | 584 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Semaphore, test->entry())); |
585 } | 585 } |
586 | 586 |
587 | 587 |
588 ASSEMBLER_TEST_GENERATE(FailedSemaphore, assembler) { | 588 ASSEMBLER_TEST_GENERATE(FailedSemaphore, assembler) { |
589 __ SetupDartSP(); | 589 __ SetupDartSP(); |
590 __ movz(R0, Immediate(40), 0); | 590 __ movz(R0, Immediate(40), 0); |
591 __ movz(R1, Immediate(42), 0); | 591 __ movz(R1, Immediate(42), 0); |
592 __ Push(R0); | 592 __ Push(R0); |
593 __ ldxr(R0, SP); | 593 __ ldxr(R0, SP); |
594 __ clrex(); // Simulate a context switch. | 594 __ clrex(); // Simulate a context switch. |
595 __ stxr(TMP, R1, SP); // IP == 1, failure | 595 __ stxr(TMP, R1, SP); // IP == 1, failure |
596 __ Pop(R0); // 40 | 596 __ Pop(R0); // 40 |
597 __ add(R0, R0, Operand(TMP)); | 597 __ add(R0, R0, Operand(TMP)); |
598 __ RestoreCSP(); | 598 __ RestoreCSP(); |
599 __ ret(); | 599 __ ret(); |
600 } | 600 } |
601 | 601 |
602 | 602 |
603 ASSEMBLER_TEST_RUN(FailedSemaphore, test) { | 603 ASSEMBLER_TEST_RUN(FailedSemaphore, test) { |
604 EXPECT(test != NULL); | 604 EXPECT(test != NULL); |
605 typedef int (*FailedSemaphore)() DART_UNUSED; | 605 typedef int (*FailedSemaphore)() DART_UNUSED; |
606 EXPECT_EQ(41, EXECUTE_TEST_CODE_INT64(FailedSemaphore, test->entry())); | 606 EXPECT_EQ(41, EXECUTE_TEST_CODE_INT64(FailedSemaphore, test->entry())); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 | 659 |
660 | 660 |
661 ASSEMBLER_TEST_RUN(OrrRegs, test) { | 661 ASSEMBLER_TEST_RUN(OrrRegs, test) { |
662 typedef int64_t (*Int64Return)() DART_UNUSED; | 662 typedef int64_t (*Int64Return)() DART_UNUSED; |
663 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 663 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
664 } | 664 } |
665 | 665 |
666 | 666 |
667 ASSEMBLER_TEST_GENERATE(OrnRegs, assembler) { | 667 ASSEMBLER_TEST_GENERATE(OrnRegs, assembler) { |
668 __ movz(R1, Immediate(32), 0); | 668 __ movz(R1, Immediate(32), 0); |
669 __ movn(R2, Immediate(0), 0); // R2 <- 0xffffffffffffffff. | 669 __ movn(R2, Immediate(0), 0); // R2 <- 0xffffffffffffffff. |
670 __ movk(R2, Immediate(0xffd5), 0); // R2 <- 0xffffffffffffffe5. | 670 __ movk(R2, Immediate(0xffd5), 0); // R2 <- 0xffffffffffffffe5. |
671 __ orn(R0, R1, Operand(R2)); | 671 __ orn(R0, R1, Operand(R2)); |
672 __ ret(); | 672 __ ret(); |
673 } | 673 } |
674 | 674 |
675 | 675 |
676 ASSEMBLER_TEST_RUN(OrnRegs, test) { | 676 ASSEMBLER_TEST_RUN(OrnRegs, test) { |
677 typedef int64_t (*Int64Return)() DART_UNUSED; | 677 typedef int64_t (*Int64Return)() DART_UNUSED; |
678 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 678 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
679 } | 679 } |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 | 1389 |
1390 ASSEMBLER_TEST_RUN(Sdiv_zero, test) { | 1390 ASSEMBLER_TEST_RUN(Sdiv_zero, test) { |
1391 EXPECT(test != NULL); | 1391 EXPECT(test != NULL); |
1392 typedef int64_t (*Int64Return)() DART_UNUSED; | 1392 typedef int64_t (*Int64Return)() DART_UNUSED; |
1393 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 1393 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
1394 } | 1394 } |
1395 | 1395 |
1396 | 1396 |
1397 ASSEMBLER_TEST_GENERATE(Udiv_corner, assembler) { | 1397 ASSEMBLER_TEST_GENERATE(Udiv_corner, assembler) { |
1398 __ movz(R0, Immediate(0x8000), 3); // R0 <- 0x8000000000000000 | 1398 __ movz(R0, Immediate(0x8000), 3); // R0 <- 0x8000000000000000 |
1399 __ movn(R1, Immediate(0), 0); // R1 <- 0xffffffffffffffff | 1399 __ movn(R1, Immediate(0), 0); // R1 <- 0xffffffffffffffff |
1400 __ udiv(R2, R0, R1); | 1400 __ udiv(R2, R0, R1); |
1401 __ mov(R0, R2); | 1401 __ mov(R0, R2); |
1402 __ ret(); | 1402 __ ret(); |
1403 } | 1403 } |
1404 | 1404 |
1405 | 1405 |
1406 ASSEMBLER_TEST_RUN(Udiv_corner, test) { | 1406 ASSEMBLER_TEST_RUN(Udiv_corner, test) { |
1407 EXPECT(test != NULL); | 1407 EXPECT(test != NULL); |
1408 typedef int64_t (*Int64Return)() DART_UNUSED; | 1408 typedef int64_t (*Int64Return)() DART_UNUSED; |
1409 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 1409 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
1410 } | 1410 } |
1411 | 1411 |
1412 | 1412 |
1413 ASSEMBLER_TEST_GENERATE(Sdiv_corner, assembler) { | 1413 ASSEMBLER_TEST_GENERATE(Sdiv_corner, assembler) { |
1414 __ movz(R3, Immediate(0x8000), 3); // R0 <- 0x8000000000000000 | 1414 __ movz(R3, Immediate(0x8000), 3); // R0 <- 0x8000000000000000 |
1415 __ movn(R1, Immediate(0), 0); // R1 <- 0xffffffffffffffff | 1415 __ movn(R1, Immediate(0), 0); // R1 <- 0xffffffffffffffff |
1416 __ sdiv(R2, R3, R1); | 1416 __ sdiv(R2, R3, R1); |
1417 __ mov(R0, R2); | 1417 __ mov(R0, R2); |
1418 __ ret(); | 1418 __ ret(); |
1419 } | 1419 } |
1420 | 1420 |
1421 | 1421 |
1422 ASSEMBLER_TEST_RUN(Sdiv_corner, test) { | 1422 ASSEMBLER_TEST_RUN(Sdiv_corner, test) { |
1423 EXPECT(test != NULL); | 1423 EXPECT(test != NULL); |
1424 typedef int64_t (*Int64Return)() DART_UNUSED; | 1424 typedef int64_t (*Int64Return)() DART_UNUSED; |
1425 EXPECT_EQ(static_cast<int64_t>(0x8000000000000000), | 1425 EXPECT_EQ(static_cast<int64_t>(0x8000000000000000), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 | 1538 |
1539 | 1539 |
1540 ASSEMBLER_TEST_RUN(Smulh_neg, test) { | 1540 ASSEMBLER_TEST_RUN(Smulh_neg, test) { |
1541 typedef int64_t (*Int64Return)() DART_UNUSED; | 1541 typedef int64_t (*Int64Return)() DART_UNUSED; |
1542 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 1542 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
1543 } | 1543 } |
1544 | 1544 |
1545 | 1545 |
1546 ASSEMBLER_TEST_GENERATE(Umulh, assembler) { | 1546 ASSEMBLER_TEST_GENERATE(Umulh, assembler) { |
1547 __ movz(R1, Immediate(-1), 3); // 0xffff000000000000 | 1547 __ movz(R1, Immediate(-1), 3); // 0xffff000000000000 |
1548 __ movz(R2, Immediate(7), 3); // 0x0007000000000000 | 1548 __ movz(R2, Immediate(7), 3); // 0x0007000000000000 |
1549 __ umulh(R0, R1, R2); // 0x0006fff900000000 | 1549 __ umulh(R0, R1, R2); // 0x0006fff900000000 |
1550 __ ret(); | 1550 __ ret(); |
1551 } | 1551 } |
1552 | 1552 |
1553 | 1553 |
1554 ASSEMBLER_TEST_RUN(Umulh, test) { | 1554 ASSEMBLER_TEST_RUN(Umulh, test) { |
1555 typedef int64_t (*Int64Return)() DART_UNUSED; | 1555 typedef int64_t (*Int64Return)() DART_UNUSED; |
1556 EXPECT_EQ(static_cast<int64_t>(0x6fff900000000), | 1556 EXPECT_EQ(static_cast<int64_t>(0x6fff900000000), |
1557 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 1557 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
1558 } | 1558 } |
1559 | 1559 |
1560 | 1560 |
1561 ASSEMBLER_TEST_GENERATE(Umaddl, assembler) { | 1561 ASSEMBLER_TEST_GENERATE(Umaddl, assembler) { |
1562 __ movn(R1, Immediate(0), 0); // W1 = 0xffffffff. | 1562 __ movn(R1, Immediate(0), 0); // W1 = 0xffffffff. |
1563 __ movz(R2, Immediate(7), 0); // W2 = 7. | 1563 __ movz(R2, Immediate(7), 0); // W2 = 7. |
1564 __ movz(R3, Immediate(8), 0); // X3 = 8. | 1564 __ movz(R3, Immediate(8), 0); // X3 = 8. |
1565 __ umaddl(R0, R1, R2, R3); // X0 = W1*W2 + X3 = 0x700000001. | 1565 __ umaddl(R0, R1, R2, R3); // X0 = W1*W2 + X3 = 0x700000001. |
1566 __ ret(); | 1566 __ ret(); |
1567 } | 1567 } |
1568 | 1568 |
1569 | 1569 |
1570 ASSEMBLER_TEST_RUN(Umaddl, test) { | 1570 ASSEMBLER_TEST_RUN(Umaddl, test) { |
1571 typedef int64_t (*Int64Return)() DART_UNUSED; | 1571 typedef int64_t (*Int64Return)() DART_UNUSED; |
1572 EXPECT_EQ(0x700000001, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 1572 EXPECT_EQ(0x700000001, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
1573 } | 1573 } |
1574 | 1574 |
1575 | 1575 |
(...skipping 23 matching lines...) Expand all Loading... |
1599 | 1599 |
1600 | 1600 |
1601 ASSEMBLER_TEST_GENERATE(LoadImmediateMed2, assembler) { | 1601 ASSEMBLER_TEST_GENERATE(LoadImmediateMed2, assembler) { |
1602 __ LoadImmediate(R0, 0x4321f1234123); | 1602 __ LoadImmediate(R0, 0x4321f1234123); |
1603 __ ret(); | 1603 __ ret(); |
1604 } | 1604 } |
1605 | 1605 |
1606 | 1606 |
1607 ASSEMBLER_TEST_RUN(LoadImmediateMed2, test) { | 1607 ASSEMBLER_TEST_RUN(LoadImmediateMed2, test) { |
1608 typedef int64_t (*Int64Return)() DART_UNUSED; | 1608 typedef int64_t (*Int64Return)() DART_UNUSED; |
1609 EXPECT_EQ( | 1609 EXPECT_EQ(0x4321f1234123, |
1610 0x4321f1234123, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 1610 EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
1611 } | 1611 } |
1612 | 1612 |
1613 | 1613 |
1614 ASSEMBLER_TEST_GENERATE(LoadImmediateLarge, assembler) { | 1614 ASSEMBLER_TEST_GENERATE(LoadImmediateLarge, assembler) { |
1615 __ LoadImmediate(R0, 0x9287436598237465); | 1615 __ LoadImmediate(R0, 0x9287436598237465); |
1616 __ ret(); | 1616 __ ret(); |
1617 } | 1617 } |
1618 | 1618 |
1619 | 1619 |
1620 ASSEMBLER_TEST_RUN(LoadImmediateLarge, test) { | 1620 ASSEMBLER_TEST_RUN(LoadImmediateLarge, test) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 __ LoadUnaligned(R1, R0, TMP, kHalfword); | 1688 __ LoadUnaligned(R1, R0, TMP, kHalfword); |
1689 __ mov(R0, R1); | 1689 __ mov(R0, R1); |
1690 __ ret(); | 1690 __ ret(); |
1691 } | 1691 } |
1692 | 1692 |
1693 | 1693 |
1694 ASSEMBLER_TEST_RUN(LoadHalfWordUnaligned, test) { | 1694 ASSEMBLER_TEST_RUN(LoadHalfWordUnaligned, test) { |
1695 EXPECT(test != NULL); | 1695 EXPECT(test != NULL); |
1696 typedef intptr_t (*LoadHalfWordUnaligned)(intptr_t) DART_UNUSED; | 1696 typedef intptr_t (*LoadHalfWordUnaligned)(intptr_t) DART_UNUSED; |
1697 uint8_t buffer[4] = { | 1697 uint8_t buffer[4] = { |
1698 0x89, 0xAB, 0xCD, 0xEF, | 1698 0x89, 0xAB, 0xCD, 0xEF, |
1699 }; | 1699 }; |
1700 | 1700 |
1701 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xAB89)), | 1701 EXPECT_EQ( |
1702 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1702 static_cast<int16_t>(static_cast<uint16_t>(0xAB89)), |
1703 LoadHalfWordUnaligned, | 1703 EXECUTE_TEST_CODE_INTPTR_INTPTR(LoadHalfWordUnaligned, test->entry(), |
1704 test->entry(), | 1704 reinterpret_cast<intptr_t>(&buffer[0]))); |
1705 reinterpret_cast<intptr_t>(&buffer[0]))); | 1705 EXPECT_EQ( |
1706 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xCDAB)), | 1706 static_cast<int16_t>(static_cast<uint16_t>(0xCDAB)), |
1707 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1707 EXECUTE_TEST_CODE_INTPTR_INTPTR(LoadHalfWordUnaligned, test->entry(), |
1708 LoadHalfWordUnaligned, | 1708 reinterpret_cast<intptr_t>(&buffer[1]))); |
1709 test->entry(), | |
1710 reinterpret_cast<intptr_t>(&buffer[1]))); | |
1711 } | 1709 } |
1712 | 1710 |
1713 | 1711 |
1714 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnsignedUnaligned, assembler) { | 1712 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnsignedUnaligned, assembler) { |
1715 __ LoadUnaligned(R1, R0, TMP, kUnsignedHalfword); | 1713 __ LoadUnaligned(R1, R0, TMP, kUnsignedHalfword); |
1716 __ mov(R0, R1); | 1714 __ mov(R0, R1); |
1717 __ ret(); | 1715 __ ret(); |
1718 } | 1716 } |
1719 | 1717 |
1720 | 1718 |
1721 ASSEMBLER_TEST_RUN(LoadHalfWordUnsignedUnaligned, test) { | 1719 ASSEMBLER_TEST_RUN(LoadHalfWordUnsignedUnaligned, test) { |
1722 EXPECT(test != NULL); | 1720 EXPECT(test != NULL); |
1723 typedef intptr_t (*LoadHalfWordUnsignedUnaligned)(intptr_t) DART_UNUSED; | 1721 typedef intptr_t (*LoadHalfWordUnsignedUnaligned)(intptr_t) DART_UNUSED; |
1724 uint8_t buffer[4] = { | 1722 uint8_t buffer[4] = { |
1725 0x89, 0xAB, 0xCD, 0xEF, | 1723 0x89, 0xAB, 0xCD, 0xEF, |
1726 }; | 1724 }; |
1727 | 1725 |
1728 EXPECT_EQ(0xAB89, | 1726 EXPECT_EQ(0xAB89, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1729 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1727 LoadHalfWordUnsignedUnaligned, test->entry(), |
1730 LoadHalfWordUnsignedUnaligned, | 1728 reinterpret_cast<intptr_t>(&buffer[0]))); |
1731 test->entry(), | 1729 EXPECT_EQ(0xCDAB, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1732 reinterpret_cast<intptr_t>(&buffer[0]))); | 1730 LoadHalfWordUnsignedUnaligned, test->entry(), |
1733 EXPECT_EQ(0xCDAB, | 1731 reinterpret_cast<intptr_t>(&buffer[1]))); |
1734 EXECUTE_TEST_CODE_INTPTR_INTPTR( | |
1735 LoadHalfWordUnsignedUnaligned, | |
1736 test->entry(), | |
1737 reinterpret_cast<intptr_t>(&buffer[1]))); | |
1738 } | 1732 } |
1739 | 1733 |
1740 | 1734 |
1741 ASSEMBLER_TEST_GENERATE(StoreHalfWordUnaligned, assembler) { | 1735 ASSEMBLER_TEST_GENERATE(StoreHalfWordUnaligned, assembler) { |
1742 __ LoadImmediate(R1, 0xABCD); | 1736 __ LoadImmediate(R1, 0xABCD); |
1743 __ StoreUnaligned(R1, R0, TMP, kHalfword); | 1737 __ StoreUnaligned(R1, R0, TMP, kHalfword); |
1744 __ mov(R0, R1); | 1738 __ mov(R0, R1); |
1745 __ ret(); | 1739 __ ret(); |
1746 } | 1740 } |
1747 | 1741 |
1748 | 1742 |
1749 ASSEMBLER_TEST_RUN(StoreHalfWordUnaligned, test) { | 1743 ASSEMBLER_TEST_RUN(StoreHalfWordUnaligned, test) { |
1750 EXPECT(test != NULL); | 1744 EXPECT(test != NULL); |
1751 typedef intptr_t (*StoreHalfWordUnaligned)(intptr_t) DART_UNUSED; | 1745 typedef intptr_t (*StoreHalfWordUnaligned)(intptr_t) DART_UNUSED; |
1752 uint8_t buffer[4] = { | 1746 uint8_t buffer[4] = { |
1753 0, 0, 0, 0, | 1747 0, 0, 0, 0, |
1754 }; | 1748 }; |
1755 | 1749 |
1756 EXPECT_EQ(0xABCD, | 1750 EXPECT_EQ(0xABCD, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1757 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1751 StoreHalfWordUnaligned, test->entry(), |
1758 StoreHalfWordUnaligned, | 1752 reinterpret_cast<intptr_t>(&buffer[0]))); |
1759 test->entry(), | |
1760 reinterpret_cast<intptr_t>(&buffer[0]))); | |
1761 EXPECT_EQ(0xCD, buffer[0]); | 1753 EXPECT_EQ(0xCD, buffer[0]); |
1762 EXPECT_EQ(0xAB, buffer[1]); | 1754 EXPECT_EQ(0xAB, buffer[1]); |
1763 EXPECT_EQ(0, buffer[2]); | 1755 EXPECT_EQ(0, buffer[2]); |
1764 | 1756 |
1765 EXPECT_EQ(0xABCD, | 1757 EXPECT_EQ(0xABCD, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1766 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1758 StoreHalfWordUnaligned, test->entry(), |
1767 StoreHalfWordUnaligned, | 1759 reinterpret_cast<intptr_t>(&buffer[1]))); |
1768 test->entry(), | |
1769 reinterpret_cast<intptr_t>(&buffer[1]))); | |
1770 EXPECT_EQ(0xCD, buffer[1]); | 1760 EXPECT_EQ(0xCD, buffer[1]); |
1771 EXPECT_EQ(0xAB, buffer[2]); | 1761 EXPECT_EQ(0xAB, buffer[2]); |
1772 EXPECT_EQ(0, buffer[3]); | 1762 EXPECT_EQ(0, buffer[3]); |
1773 } | 1763 } |
1774 | 1764 |
1775 | 1765 |
1776 ASSEMBLER_TEST_GENERATE(LoadWordUnaligned, assembler) { | 1766 ASSEMBLER_TEST_GENERATE(LoadWordUnaligned, assembler) { |
1777 __ LoadUnaligned(R1, R0, TMP, kUnsignedWord); | 1767 __ LoadUnaligned(R1, R0, TMP, kUnsignedWord); |
1778 __ mov(R0, R1); | 1768 __ mov(R0, R1); |
1779 __ ret(); | 1769 __ ret(); |
1780 } | 1770 } |
1781 | 1771 |
1782 | 1772 |
1783 ASSEMBLER_TEST_RUN(LoadWordUnaligned, test) { | 1773 ASSEMBLER_TEST_RUN(LoadWordUnaligned, test) { |
1784 EXPECT(test != NULL); | 1774 EXPECT(test != NULL); |
1785 typedef int32_t (*LoadWordUnaligned)(intptr_t) DART_UNUSED; | 1775 typedef int32_t (*LoadWordUnaligned)(intptr_t) DART_UNUSED; |
1786 uint8_t buffer[8] = { | 1776 uint8_t buffer[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0}; |
1787 0x12, 0x34, 0x56, 0x78, | |
1788 0x9A, 0xBC, 0xDE, 0xF0 | |
1789 }; | |
1790 | 1777 |
1791 EXPECT_EQ(static_cast<int32_t>(0x78563412), | 1778 EXPECT_EQ( |
1792 EXECUTE_TEST_CODE_INT32_INTPTR( | 1779 static_cast<int32_t>(0x78563412), |
1793 LoadWordUnaligned, | 1780 EXECUTE_TEST_CODE_INT32_INTPTR(LoadWordUnaligned, test->entry(), |
1794 test->entry(), | 1781 reinterpret_cast<intptr_t>(&buffer[0]))); |
1795 reinterpret_cast<intptr_t>(&buffer[0]))); | 1782 EXPECT_EQ( |
1796 EXPECT_EQ(static_cast<int32_t>(0x9A785634), | 1783 static_cast<int32_t>(0x9A785634), |
1797 EXECUTE_TEST_CODE_INT32_INTPTR( | 1784 EXECUTE_TEST_CODE_INT32_INTPTR(LoadWordUnaligned, test->entry(), |
1798 LoadWordUnaligned, | 1785 reinterpret_cast<intptr_t>(&buffer[1]))); |
1799 test->entry(), | 1786 EXPECT_EQ( |
1800 reinterpret_cast<intptr_t>(&buffer[1]))); | 1787 static_cast<int32_t>(0xBC9A7856), |
1801 EXPECT_EQ(static_cast<int32_t>(0xBC9A7856), | 1788 EXECUTE_TEST_CODE_INT32_INTPTR(LoadWordUnaligned, test->entry(), |
1802 EXECUTE_TEST_CODE_INT32_INTPTR( | 1789 reinterpret_cast<intptr_t>(&buffer[2]))); |
1803 LoadWordUnaligned, | 1790 EXPECT_EQ( |
1804 test->entry(), | 1791 static_cast<int32_t>(0xDEBC9A78), |
1805 reinterpret_cast<intptr_t>(&buffer[2]))); | 1792 EXECUTE_TEST_CODE_INT32_INTPTR(LoadWordUnaligned, test->entry(), |
1806 EXPECT_EQ(static_cast<int32_t>(0xDEBC9A78), | 1793 reinterpret_cast<intptr_t>(&buffer[3]))); |
1807 EXECUTE_TEST_CODE_INT32_INTPTR( | |
1808 LoadWordUnaligned, | |
1809 test->entry(), | |
1810 reinterpret_cast<intptr_t>(&buffer[3]))); | |
1811 } | 1794 } |
1812 | 1795 |
1813 | 1796 |
1814 ASSEMBLER_TEST_GENERATE(StoreWordUnaligned, assembler) { | 1797 ASSEMBLER_TEST_GENERATE(StoreWordUnaligned, assembler) { |
1815 __ LoadImmediate(R1, 0x12345678); | 1798 __ LoadImmediate(R1, 0x12345678); |
1816 __ StoreUnaligned(R1, R0, TMP, kUnsignedWord); | 1799 __ StoreUnaligned(R1, R0, TMP, kUnsignedWord); |
1817 __ mov(R0, R1); | 1800 __ mov(R0, R1); |
1818 __ ret(); | 1801 __ ret(); |
1819 } | 1802 } |
1820 | 1803 |
1821 | 1804 |
1822 ASSEMBLER_TEST_RUN(StoreWordUnaligned, test) { | 1805 ASSEMBLER_TEST_RUN(StoreWordUnaligned, test) { |
1823 EXPECT(test != NULL); | 1806 EXPECT(test != NULL); |
1824 typedef intptr_t (*StoreWordUnaligned)(intptr_t) DART_UNUSED; | 1807 typedef intptr_t (*StoreWordUnaligned)(intptr_t) DART_UNUSED; |
1825 uint8_t buffer[8] = { | 1808 uint8_t buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0}; |
1826 0, 0, 0, 0, | |
1827 0, 0, 0, 0 | |
1828 }; | |
1829 | 1809 |
1830 EXPECT_EQ(0x12345678, | 1810 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1831 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1811 StoreWordUnaligned, test->entry(), |
1832 StoreWordUnaligned, | 1812 reinterpret_cast<intptr_t>(&buffer[0]))); |
1833 test->entry(), | |
1834 reinterpret_cast<intptr_t>(&buffer[0]))); | |
1835 EXPECT_EQ(0x78, buffer[0]); | 1813 EXPECT_EQ(0x78, buffer[0]); |
1836 EXPECT_EQ(0x56, buffer[1]); | 1814 EXPECT_EQ(0x56, buffer[1]); |
1837 EXPECT_EQ(0x34, buffer[2]); | 1815 EXPECT_EQ(0x34, buffer[2]); |
1838 EXPECT_EQ(0x12, buffer[3]); | 1816 EXPECT_EQ(0x12, buffer[3]); |
1839 | 1817 |
1840 EXPECT_EQ(0x12345678, | 1818 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1841 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1819 StoreWordUnaligned, test->entry(), |
1842 StoreWordUnaligned, | 1820 reinterpret_cast<intptr_t>(&buffer[1]))); |
1843 test->entry(), | |
1844 reinterpret_cast<intptr_t>(&buffer[1]))); | |
1845 EXPECT_EQ(0x78, buffer[1]); | 1821 EXPECT_EQ(0x78, buffer[1]); |
1846 EXPECT_EQ(0x56, buffer[2]); | 1822 EXPECT_EQ(0x56, buffer[2]); |
1847 EXPECT_EQ(0x34, buffer[3]); | 1823 EXPECT_EQ(0x34, buffer[3]); |
1848 EXPECT_EQ(0x12, buffer[4]); | 1824 EXPECT_EQ(0x12, buffer[4]); |
1849 | 1825 |
1850 EXPECT_EQ(0x12345678, | 1826 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1851 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1827 StoreWordUnaligned, test->entry(), |
1852 StoreWordUnaligned, | 1828 reinterpret_cast<intptr_t>(&buffer[2]))); |
1853 test->entry(), | |
1854 reinterpret_cast<intptr_t>(&buffer[2]))); | |
1855 EXPECT_EQ(0x78, buffer[2]); | 1829 EXPECT_EQ(0x78, buffer[2]); |
1856 EXPECT_EQ(0x56, buffer[3]); | 1830 EXPECT_EQ(0x56, buffer[3]); |
1857 EXPECT_EQ(0x34, buffer[4]); | 1831 EXPECT_EQ(0x34, buffer[4]); |
1858 EXPECT_EQ(0x12, buffer[5]); | 1832 EXPECT_EQ(0x12, buffer[5]); |
1859 | 1833 |
1860 EXPECT_EQ(0x12345678, | 1834 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INTPTR_INTPTR( |
1861 EXECUTE_TEST_CODE_INTPTR_INTPTR( | 1835 StoreWordUnaligned, test->entry(), |
1862 StoreWordUnaligned, | 1836 reinterpret_cast<intptr_t>(&buffer[3]))); |
1863 test->entry(), | |
1864 reinterpret_cast<intptr_t>(&buffer[3]))); | |
1865 EXPECT_EQ(0x78, buffer[3]); | 1837 EXPECT_EQ(0x78, buffer[3]); |
1866 EXPECT_EQ(0x56, buffer[4]); | 1838 EXPECT_EQ(0x56, buffer[4]); |
1867 EXPECT_EQ(0x34, buffer[5]); | 1839 EXPECT_EQ(0x34, buffer[5]); |
1868 EXPECT_EQ(0x12, buffer[6]); | 1840 EXPECT_EQ(0x12, buffer[6]); |
1869 } | 1841 } |
1870 | 1842 |
1871 | 1843 |
1872 static void EnterTestFrame(Assembler* assembler) { | 1844 static void EnterTestFrame(Assembler* assembler) { |
1873 __ EnterFrame(0); | 1845 __ EnterFrame(0); |
1874 __ Push(CODE_REG); | 1846 __ Push(CODE_REG); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 | 2073 |
2102 ASSEMBLER_TEST_GENERATE(Fmovdi2, assembler) { | 2074 ASSEMBLER_TEST_GENERATE(Fmovdi2, assembler) { |
2103 __ LoadDImmediate(V0, 123412983.1324524315); | 2075 __ LoadDImmediate(V0, 123412983.1324524315); |
2104 __ ret(); | 2076 __ ret(); |
2105 } | 2077 } |
2106 | 2078 |
2107 | 2079 |
2108 ASSEMBLER_TEST_RUN(Fmovdi2, test) { | 2080 ASSEMBLER_TEST_RUN(Fmovdi2, test) { |
2109 typedef double (*DoubleReturn)() DART_UNUSED; | 2081 typedef double (*DoubleReturn)() DART_UNUSED; |
2110 EXPECT_FLOAT_EQ(123412983.1324524315, | 2082 EXPECT_FLOAT_EQ(123412983.1324524315, |
2111 EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()), 0.0001f); | 2083 EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()), |
| 2084 0.0001f); |
2112 } | 2085 } |
2113 | 2086 |
2114 | 2087 |
2115 ASSEMBLER_TEST_GENERATE(Fmovrd, assembler) { | 2088 ASSEMBLER_TEST_GENERATE(Fmovrd, assembler) { |
2116 __ LoadDImmediate(V1, 1.0); | 2089 __ LoadDImmediate(V1, 1.0); |
2117 __ fmovrd(R0, V1); | 2090 __ fmovrd(R0, V1); |
2118 __ ret(); | 2091 __ ret(); |
2119 } | 2092 } |
2120 | 2093 |
2121 | 2094 |
(...skipping 14 matching lines...) Expand all Loading... |
2136 | 2109 |
2137 ASSEMBLER_TEST_RUN(Fmovdr, test) { | 2110 ASSEMBLER_TEST_RUN(Fmovdr, test) { |
2138 typedef double (*DoubleReturn)() DART_UNUSED; | 2111 typedef double (*DoubleReturn)() DART_UNUSED; |
2139 EXPECT_EQ(1.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2112 EXPECT_EQ(1.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2140 } | 2113 } |
2141 | 2114 |
2142 | 2115 |
2143 ASSEMBLER_TEST_GENERATE(FldrdFstrdPrePostIndex, assembler) { | 2116 ASSEMBLER_TEST_GENERATE(FldrdFstrdPrePostIndex, assembler) { |
2144 __ SetupDartSP(); | 2117 __ SetupDartSP(); |
2145 __ LoadDImmediate(V1, 42.0); | 2118 __ LoadDImmediate(V1, 42.0); |
2146 __ fstrd(V1, Address(SP, -1*kWordSize, Address::PreIndex)); | 2119 __ fstrd(V1, Address(SP, -1 * kWordSize, Address::PreIndex)); |
2147 __ fldrd(V0, Address(SP, 1*kWordSize, Address::PostIndex)); | 2120 __ fldrd(V0, Address(SP, 1 * kWordSize, Address::PostIndex)); |
2148 __ RestoreCSP(); | 2121 __ RestoreCSP(); |
2149 __ ret(); | 2122 __ ret(); |
2150 } | 2123 } |
2151 | 2124 |
2152 | 2125 |
2153 ASSEMBLER_TEST_RUN(FldrdFstrdPrePostIndex, test) { | 2126 ASSEMBLER_TEST_RUN(FldrdFstrdPrePostIndex, test) { |
2154 typedef double (*DoubleReturn)() DART_UNUSED; | 2127 typedef double (*DoubleReturn)() DART_UNUSED; |
2155 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2128 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2156 } | 2129 } |
2157 | 2130 |
2158 | 2131 |
2159 ASSEMBLER_TEST_GENERATE(FldrsFstrsPrePostIndex, assembler) { | 2132 ASSEMBLER_TEST_GENERATE(FldrsFstrsPrePostIndex, assembler) { |
2160 __ SetupDartSP(); | 2133 __ SetupDartSP(); |
2161 __ LoadDImmediate(V1, 42.0); | 2134 __ LoadDImmediate(V1, 42.0); |
2162 __ fcvtsd(V2, V1); | 2135 __ fcvtsd(V2, V1); |
2163 __ fstrs(V2, Address(SP, -1*kWordSize, Address::PreIndex)); | 2136 __ fstrs(V2, Address(SP, -1 * kWordSize, Address::PreIndex)); |
2164 __ fldrs(V3, Address(SP, 1*kWordSize, Address::PostIndex)); | 2137 __ fldrs(V3, Address(SP, 1 * kWordSize, Address::PostIndex)); |
2165 __ fcvtds(V0, V3); | 2138 __ fcvtds(V0, V3); |
2166 __ RestoreCSP(); | 2139 __ RestoreCSP(); |
2167 __ ret(); | 2140 __ ret(); |
2168 } | 2141 } |
2169 | 2142 |
2170 | 2143 |
2171 ASSEMBLER_TEST_RUN(FldrsFstrsPrePostIndex, test) { | 2144 ASSEMBLER_TEST_RUN(FldrsFstrsPrePostIndex, test) { |
2172 typedef double (*DoubleReturn)() DART_UNUSED; | 2145 typedef double (*DoubleReturn)() DART_UNUSED; |
2173 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2146 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2174 } | 2147 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 typedef double (*DoubleReturn)() DART_UNUSED; | 2351 typedef double (*DoubleReturn)() DART_UNUSED; |
2379 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2352 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2380 } | 2353 } |
2381 | 2354 |
2382 | 2355 |
2383 ASSEMBLER_TEST_GENERATE(FldrdFstrdLargeIndex, assembler) { | 2356 ASSEMBLER_TEST_GENERATE(FldrdFstrdLargeIndex, assembler) { |
2384 __ SetupDartSP(); | 2357 __ SetupDartSP(); |
2385 __ LoadDImmediate(V0, 43.0); | 2358 __ LoadDImmediate(V0, 43.0); |
2386 __ LoadDImmediate(V1, 42.0); | 2359 __ LoadDImmediate(V1, 42.0); |
2387 // Largest negative offset that can fit in the signed 9-bit immediate field. | 2360 // Largest negative offset that can fit in the signed 9-bit immediate field. |
2388 __ fstrd(V1, Address(SP, -32*kWordSize, Address::PreIndex)); | 2361 __ fstrd(V1, Address(SP, -32 * kWordSize, Address::PreIndex)); |
2389 // Largest positive kWordSize aligned offset that we can fit. | 2362 // Largest positive kWordSize aligned offset that we can fit. |
2390 __ fldrd(V0, Address(SP, 31*kWordSize, Address::PostIndex)); | 2363 __ fldrd(V0, Address(SP, 31 * kWordSize, Address::PostIndex)); |
2391 // Correction. | 2364 // Correction. |
2392 __ add(SP, SP, Operand(kWordSize)); // Restore SP. | 2365 __ add(SP, SP, Operand(kWordSize)); // Restore SP. |
2393 __ RestoreCSP(); | 2366 __ RestoreCSP(); |
2394 __ ret(); | 2367 __ ret(); |
2395 } | 2368 } |
2396 | 2369 |
2397 | 2370 |
2398 ASSEMBLER_TEST_RUN(FldrdFstrdLargeIndex, test) { | 2371 ASSEMBLER_TEST_RUN(FldrdFstrdLargeIndex, test) { |
2399 typedef double (*DoubleReturn)() DART_UNUSED; | 2372 typedef double (*DoubleReturn)() DART_UNUSED; |
2400 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2373 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2401 } | 2374 } |
2402 | 2375 |
2403 | 2376 |
2404 ASSEMBLER_TEST_GENERATE(FldrdFstrdLargeOffset, assembler) { | 2377 ASSEMBLER_TEST_GENERATE(FldrdFstrdLargeOffset, assembler) { |
2405 __ SetupDartSP(); | 2378 __ SetupDartSP(); |
2406 __ LoadDImmediate(V0, 43.0); | 2379 __ LoadDImmediate(V0, 43.0); |
2407 __ LoadDImmediate(V1, 42.0); | 2380 __ LoadDImmediate(V1, 42.0); |
2408 __ sub(SP, SP, Operand(512*kWordSize)); | 2381 __ sub(SP, SP, Operand(512 * kWordSize)); |
2409 __ fstrd(V1, Address(SP, 512*kWordSize, Address::Offset)); | 2382 __ fstrd(V1, Address(SP, 512 * kWordSize, Address::Offset)); |
2410 __ add(SP, SP, Operand(512*kWordSize)); | 2383 __ add(SP, SP, Operand(512 * kWordSize)); |
2411 __ fldrd(V0, Address(SP)); | 2384 __ fldrd(V0, Address(SP)); |
2412 __ RestoreCSP(); | 2385 __ RestoreCSP(); |
2413 __ ret(); | 2386 __ ret(); |
2414 } | 2387 } |
2415 | 2388 |
2416 | 2389 |
2417 ASSEMBLER_TEST_RUN(FldrdFstrdLargeOffset, test) { | 2390 ASSEMBLER_TEST_RUN(FldrdFstrdLargeOffset, test) { |
2418 typedef double (*DoubleReturn)() DART_UNUSED; | 2391 typedef double (*DoubleReturn)() DART_UNUSED; |
2419 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2392 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2420 } | 2393 } |
(...skipping 20 matching lines...) Expand all Loading... |
2441 typedef double (*DoubleReturn)() DART_UNUSED; | 2414 typedef double (*DoubleReturn)() DART_UNUSED; |
2442 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2415 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2443 } | 2416 } |
2444 | 2417 |
2445 | 2418 |
2446 ASSEMBLER_TEST_GENERATE(FldrdFstrdScaledReg, assembler) { | 2419 ASSEMBLER_TEST_GENERATE(FldrdFstrdScaledReg, assembler) { |
2447 __ SetupDartSP(); | 2420 __ SetupDartSP(); |
2448 __ LoadDImmediate(V0, 43.0); | 2421 __ LoadDImmediate(V0, 43.0); |
2449 __ LoadDImmediate(V1, 42.0); | 2422 __ LoadDImmediate(V1, 42.0); |
2450 __ movz(R2, Immediate(10), 0); | 2423 __ movz(R2, Immediate(10), 0); |
2451 __ sub(SP, SP, Operand(10*kWordSize)); | 2424 __ sub(SP, SP, Operand(10 * kWordSize)); |
2452 // Store V1 into SP + R2 * kWordSize. | 2425 // Store V1 into SP + R2 * kWordSize. |
2453 __ fstrd(V1, Address(SP, R2, UXTX, Address::Scaled)); | 2426 __ fstrd(V1, Address(SP, R2, UXTX, Address::Scaled)); |
2454 __ fldrd(V0, Address(SP, R2, UXTX, Address::Scaled)); | 2427 __ fldrd(V0, Address(SP, R2, UXTX, Address::Scaled)); |
2455 __ add(SP, SP, Operand(10*kWordSize)); | 2428 __ add(SP, SP, Operand(10 * kWordSize)); |
2456 __ RestoreCSP(); | 2429 __ RestoreCSP(); |
2457 __ ret(); | 2430 __ ret(); |
2458 } | 2431 } |
2459 | 2432 |
2460 | 2433 |
2461 ASSEMBLER_TEST_RUN(FldrdFstrdScaledReg, test) { | 2434 ASSEMBLER_TEST_RUN(FldrdFstrdScaledReg, test) { |
2462 typedef double (*DoubleReturn)() DART_UNUSED; | 2435 typedef double (*DoubleReturn)() DART_UNUSED; |
2463 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 2436 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
2464 } | 2437 } |
2465 | 2438 |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 | 3544 |
3572 ASSEMBLER_TEST_RUN(Vsqrtd, test) { | 3545 ASSEMBLER_TEST_RUN(Vsqrtd, test) { |
3573 typedef double (*DoubleReturn)() DART_UNUSED; | 3546 typedef double (*DoubleReturn)() DART_UNUSED; |
3574 EXPECT_EQ(15.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); | 3547 EXPECT_EQ(15.0, EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry())); |
3575 } | 3548 } |
3576 | 3549 |
3577 | 3550 |
3578 // This is the same function as in the Simulator. | 3551 // This is the same function as in the Simulator. |
3579 static float arm_recip_estimate(float a) { | 3552 static float arm_recip_estimate(float a) { |
3580 // From the ARM Architecture Reference Manual A2-85. | 3553 // From the ARM Architecture Reference Manual A2-85. |
3581 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 3554 if (isinf(a) || (fabs(a) >= exp2f(126))) |
3582 else if (a == 0.0) return kPosInfinity; | 3555 return 0.0; |
3583 else if (isnan(a)) return a; | 3556 else if (a == 0.0) |
| 3557 return kPosInfinity; |
| 3558 else if (isnan(a)) |
| 3559 return a; |
3584 | 3560 |
3585 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 3561 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
3586 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) | 3562 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) |
3587 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | | 3563 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | |
3588 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 3564 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
3589 // result_exp = 253 - UInt(a<30:23>) | 3565 // result_exp = 253 - UInt(a<30:23>) |
3590 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); | 3566 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); |
3591 ASSERT((result_exp >= 1) && (result_exp <= 252)); | 3567 ASSERT((result_exp >= 1) && (result_exp <= 252)); |
3592 | 3568 |
3593 double scaled_d = bit_cast<double, uint64_t>(scaled); | 3569 double scaled_d = bit_cast<double, uint64_t>(scaled); |
3594 ASSERT((scaled_d >= 0.5) && (scaled_d < 1.0)); | 3570 ASSERT((scaled_d >= 0.5) && (scaled_d < 1.0)); |
3595 | 3571 |
3596 // a in units of 1/512 rounded down. | 3572 // a in units of 1/512 rounded down. |
3597 int32_t q = static_cast<int32_t>(scaled_d * 512.0); | 3573 int32_t q = static_cast<int32_t>(scaled_d * 512.0); |
3598 // reciprocal r. | 3574 // reciprocal r. |
3599 double r = 1.0 / ((static_cast<double>(q) + 0.5) / 512.0); | 3575 double r = 1.0 / ((static_cast<double>(q) + 0.5) / 512.0); |
3600 // r in units of 1/256 rounded to nearest. | 3576 // r in units of 1/256 rounded to nearest. |
3601 int32_t s = static_cast<int32_t>(256.0 * r + 0.5); | 3577 int32_t s = static_cast<int32_t>(256.0 * r + 0.5); |
3602 double estimate = static_cast<double>(s) / 256.0; | 3578 double estimate = static_cast<double>(s) / 256.0; |
3603 ASSERT((estimate >= 1.0) && (estimate <= (511.0/256.0))); | 3579 ASSERT((estimate >= 1.0) && (estimate <= (511.0 / 256.0))); |
3604 | 3580 |
3605 // result = sign : result_exp<7:0> : estimate<51:29> | 3581 // result = sign : result_exp<7:0> : estimate<51:29> |
3606 int32_t result_bits = | 3582 int32_t result_bits = |
3607 (a_bits & 0x80000000) | ((result_exp & 0xff) << 23) | | 3583 (a_bits & 0x80000000) | ((result_exp & 0xff) << 23) | |
3608 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); | 3584 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); |
3609 return bit_cast<float, int32_t>(result_bits); | 3585 return bit_cast<float, int32_t>(result_bits); |
3610 } | 3586 } |
3611 | 3587 |
3612 | 3588 |
3613 ASSEMBLER_TEST_GENERATE(Vrecpes, assembler) { | 3589 ASSEMBLER_TEST_GENERATE(Vrecpes, assembler) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3680 | 3656 |
3681 ASSEMBLER_TEST_RUN(VRecps, test) { | 3657 ASSEMBLER_TEST_RUN(VRecps, test) { |
3682 typedef double (*DoubleReturn)() DART_UNUSED; | 3658 typedef double (*DoubleReturn)() DART_UNUSED; |
3683 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); | 3659 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); |
3684 EXPECT_FLOAT_EQ(42.0, res, 0.0001); | 3660 EXPECT_FLOAT_EQ(42.0, res, 0.0001); |
3685 } | 3661 } |
3686 | 3662 |
3687 | 3663 |
3688 static float arm_reciprocal_sqrt_estimate(float a) { | 3664 static float arm_reciprocal_sqrt_estimate(float a) { |
3689 // From the ARM Architecture Reference Manual A2-87. | 3665 // From the ARM Architecture Reference Manual A2-87. |
3690 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 3666 if (isinf(a) || (fabs(a) >= exp2f(126))) |
3691 else if (a == 0.0) return kPosInfinity; | 3667 return 0.0; |
3692 else if (isnan(a)) return a; | 3668 else if (a == 0.0) |
| 3669 return kPosInfinity; |
| 3670 else if (isnan(a)) |
| 3671 return a; |
3693 | 3672 |
3694 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 3673 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
3695 uint64_t scaled; | 3674 uint64_t scaled; |
3696 if (((a_bits >> 23) & 1) != 0) { | 3675 if (((a_bits >> 23) & 1) != 0) { |
3697 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) | 3676 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) |
3698 scaled = (static_cast<uint64_t>(0x3fd) << 52) | | 3677 scaled = (static_cast<uint64_t>(0x3fd) << 52) | |
3699 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 3678 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
3700 } else { | 3679 } else { |
3701 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) | 3680 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) |
3702 scaled = (static_cast<uint64_t>(0x3fe) << 52) | | 3681 scaled = (static_cast<uint64_t>(0x3fe) << 52) | |
(...skipping 17 matching lines...) Expand all Loading... |
3720 // range 0.5 <= a < 1.0 | 3699 // range 0.5 <= a < 1.0 |
3721 | 3700 |
3722 // a in units of 1/256 rounded down. | 3701 // a in units of 1/256 rounded down. |
3723 int32_t q1 = static_cast<int32_t>(scaled_d * 256.0); | 3702 int32_t q1 = static_cast<int32_t>(scaled_d * 256.0); |
3724 // reciprocal root r. | 3703 // reciprocal root r. |
3725 r = 1.0 / sqrt((static_cast<double>(q1) + 0.5) / 256.0); | 3704 r = 1.0 / sqrt((static_cast<double>(q1) + 0.5) / 256.0); |
3726 } | 3705 } |
3727 // r in units of 1/256 rounded to nearest. | 3706 // r in units of 1/256 rounded to nearest. |
3728 int32_t s = static_cast<int>(256.0 * r + 0.5); | 3707 int32_t s = static_cast<int>(256.0 * r + 0.5); |
3729 double estimate = static_cast<double>(s) / 256.0; | 3708 double estimate = static_cast<double>(s) / 256.0; |
3730 ASSERT((estimate >= 1.0) && (estimate <= (511.0/256.0))); | 3709 ASSERT((estimate >= 1.0) && (estimate <= (511.0 / 256.0))); |
3731 | 3710 |
3732 // result = 0 : result_exp<7:0> : estimate<51:29> | 3711 // result = 0 : result_exp<7:0> : estimate<51:29> |
3733 int32_t result_bits = ((result_exp & 0xff) << 23) | | 3712 int32_t result_bits = |
| 3713 ((result_exp & 0xff) << 23) | |
3734 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); | 3714 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); |
3735 return bit_cast<float, int32_t>(result_bits); | 3715 return bit_cast<float, int32_t>(result_bits); |
3736 } | 3716 } |
3737 | 3717 |
3738 | 3718 |
3739 ASSEMBLER_TEST_GENERATE(Vrsqrtes, assembler) { | 3719 ASSEMBLER_TEST_GENERATE(Vrsqrtes, assembler) { |
3740 __ LoadDImmediate(V1, 147.0); | 3720 __ LoadDImmediate(V1, 147.0); |
3741 __ fcvtsd(V1, V1); | 3721 __ fcvtsd(V1, V1); |
3742 | 3722 |
3743 __ vrsqrtes(V0, V1); | 3723 __ vrsqrtes(V0, V1); |
3744 | 3724 |
3745 __ fcvtds(V0, V0); | 3725 __ fcvtds(V0, V0); |
3746 __ ret(); | 3726 __ ret(); |
3747 } | 3727 } |
3748 | 3728 |
3749 | 3729 |
3750 ASSEMBLER_TEST_RUN(Vrsqrtes, test) { | 3730 ASSEMBLER_TEST_RUN(Vrsqrtes, test) { |
3751 EXPECT(test != NULL); | 3731 EXPECT(test != NULL); |
3752 typedef double (*DoubleReturn)() DART_UNUSED; | 3732 typedef double (*DoubleReturn)() DART_UNUSED; |
3753 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); | 3733 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); |
3754 EXPECT_FLOAT_EQ(arm_reciprocal_sqrt_estimate(147.0), res, 0.0001); | 3734 EXPECT_FLOAT_EQ(arm_reciprocal_sqrt_estimate(147.0), res, 0.0001); |
3755 } | 3735 } |
3756 | 3736 |
3757 | 3737 |
3758 ASSEMBLER_TEST_GENERATE(Vrsqrtss, assembler) { | 3738 ASSEMBLER_TEST_GENERATE(Vrsqrtss, assembler) { |
3759 __ LoadDImmediate(V1, 5.0); | 3739 __ LoadDImmediate(V1, 5.0); |
3760 __ LoadDImmediate(V2, 10.0); | 3740 __ LoadDImmediate(V2, 10.0); |
3761 | 3741 |
3762 __ fcvtsd(V1, V1); | 3742 __ fcvtsd(V1, V1); |
3763 __ fcvtsd(V2, V2); | 3743 __ fcvtsd(V2, V2); |
3764 | 3744 |
3765 __ vrsqrtss(V0, V1, V2); | 3745 __ vrsqrtss(V0, V1, V2); |
3766 | 3746 |
3767 __ fcvtds(V0, V0); | 3747 __ fcvtds(V0, V0); |
3768 __ ret(); | 3748 __ ret(); |
3769 } | 3749 } |
3770 | 3750 |
3771 | 3751 |
3772 ASSEMBLER_TEST_RUN(Vrsqrtss, test) { | 3752 ASSEMBLER_TEST_RUN(Vrsqrtss, test) { |
3773 EXPECT(test != NULL); | 3753 EXPECT(test != NULL); |
3774 typedef double (*DoubleReturn)() DART_UNUSED; | 3754 typedef double (*DoubleReturn)() DART_UNUSED; |
3775 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); | 3755 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); |
3776 EXPECT_FLOAT_EQ((3.0 - 10.0 * 5.0)/2.0, res, 0.0001); | 3756 EXPECT_FLOAT_EQ((3.0 - 10.0 * 5.0) / 2.0, res, 0.0001); |
3777 } | 3757 } |
3778 | 3758 |
3779 | 3759 |
3780 ASSEMBLER_TEST_GENERATE(ReciprocalSqrt, assembler) { | 3760 ASSEMBLER_TEST_GENERATE(ReciprocalSqrt, assembler) { |
3781 __ LoadDImmediate(V1, 147000.0); | 3761 __ LoadDImmediate(V1, 147000.0); |
3782 __ fcvtsd(V1, V1); | 3762 __ fcvtsd(V1, V1); |
3783 | 3763 |
3784 __ VRSqrts(V0, V1); | 3764 __ VRSqrts(V0, V1); |
3785 | 3765 |
3786 __ fcvtds(V0, V0); | 3766 __ fcvtds(V0, V0); |
3787 __ ret(); | 3767 __ ret(); |
3788 } | 3768 } |
3789 | 3769 |
3790 | 3770 |
3791 ASSEMBLER_TEST_RUN(ReciprocalSqrt, test) { | 3771 ASSEMBLER_TEST_RUN(ReciprocalSqrt, test) { |
3792 EXPECT(test != NULL); | 3772 EXPECT(test != NULL); |
3793 typedef double (*DoubleReturn)() DART_UNUSED; | 3773 typedef double (*DoubleReturn)() DART_UNUSED; |
3794 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); | 3774 double res = EXECUTE_TEST_CODE_DOUBLE(DoubleReturn, test->entry()); |
3795 EXPECT_FLOAT_EQ(1.0/sqrt(147000.0), res, 0.0001); | 3775 EXPECT_FLOAT_EQ(1.0 / sqrt(147000.0), res, 0.0001); |
3796 } | 3776 } |
3797 | 3777 |
3798 | 3778 |
3799 // Called from assembler_test.cc. | 3779 // Called from assembler_test.cc. |
3800 // LR: return address. | 3780 // LR: return address. |
3801 // R0: value. | 3781 // R0: value. |
3802 // R1: growable array. | 3782 // R1: growable array. |
3803 // R2: current thread. | 3783 // R2: current thread. |
3804 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 3784 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
3805 __ SetupDartSP(); | 3785 __ SetupDartSP(); |
3806 __ Push(CODE_REG); | 3786 __ Push(CODE_REG); |
3807 __ Push(THR); | 3787 __ Push(THR); |
3808 __ Push(LR); | 3788 __ Push(LR); |
3809 __ mov(THR, R2); | 3789 __ mov(THR, R2); |
3810 __ StoreIntoObject(R1, | 3790 __ StoreIntoObject(R1, FieldAddress(R1, GrowableObjectArray::data_offset()), |
3811 FieldAddress(R1, GrowableObjectArray::data_offset()), | |
3812 R0); | 3791 R0); |
3813 __ Pop(LR); | 3792 __ Pop(LR); |
3814 __ Pop(THR); | 3793 __ Pop(THR); |
3815 __ Pop(CODE_REG); | 3794 __ Pop(CODE_REG); |
3816 __ RestoreCSP(); | 3795 __ RestoreCSP(); |
3817 __ ret(); | 3796 __ ret(); |
3818 } | 3797 } |
3819 | 3798 |
3820 } // namespace dart | 3799 } // namespace dart |
3821 | 3800 |
3822 #endif // defined(TARGET_ARCH_ARM64) | 3801 #endif // defined(TARGET_ARCH_ARM64) |
OLD | NEW |