OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 TEST(4) { | 220 TEST(4) { |
221 // Test the VFP floating point instructions. | 221 // Test the VFP floating point instructions. |
222 InitializeVM(); | 222 InitializeVM(); |
223 v8::HandleScope scope; | 223 v8::HandleScope scope; |
224 | 224 |
225 typedef struct { | 225 typedef struct { |
226 double a; | 226 double a; |
227 double b; | 227 double b; |
228 double c; | 228 double c; |
| 229 float d; |
| 230 float e; |
229 } T; | 231 } T; |
230 T t; | 232 T t; |
231 | 233 |
232 // Create a function that accepts &t, and loads, manipulates, and stores | 234 // Create a function that accepts &t, and loads, manipulates, and stores |
233 // the doubles t.a, t.b, and t.c. | 235 // the doubles t.a, t.b, and t.c, and floats t.d, t.e. |
234 Assembler assm(NULL, 0); | 236 Assembler assm(NULL, 0); |
235 Label L, C; | 237 Label L, C; |
236 | 238 |
237 | 239 |
238 if (CpuFeatures::IsSupported(VFP3)) { | 240 if (CpuFeatures::IsSupported(VFP3)) { |
239 CpuFeatures::Scope scope(VFP3); | 241 CpuFeatures::Scope scope(VFP3); |
240 | 242 |
241 __ mov(ip, Operand(sp)); | 243 __ mov(ip, Operand(sp)); |
242 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 244 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
243 __ sub(fp, ip, Operand(4)); | 245 __ sub(fp, ip, Operand(4)); |
244 | 246 |
245 __ mov(r4, Operand(r0)); | 247 __ mov(r4, Operand(r0)); |
246 __ vldr(d6, r4, OFFSET_OF(T, a)); | 248 __ vldr(d6, r4, OFFSET_OF(T, a)); |
247 __ vldr(d7, r4, OFFSET_OF(T, b)); | 249 __ vldr(d7, r4, OFFSET_OF(T, b)); |
248 __ vadd(d5, d6, d7); | 250 __ vadd(d5, d6, d7); |
249 __ vstr(d5, r4, OFFSET_OF(T, c)); | 251 __ vstr(d5, r4, OFFSET_OF(T, c)); |
250 | 252 |
251 __ vmov(r2, r3, d5); | 253 __ vmov(r2, r3, d5); |
252 __ vmov(d4, r2, r3); | 254 __ vmov(d4, r2, r3); |
253 __ vstr(d4, r4, OFFSET_OF(T, b)); | 255 __ vstr(d4, r4, OFFSET_OF(T, b)); |
254 | 256 |
| 257 // Load t.d and t.e, switch values, and store back to the struct. |
| 258 __ vldr(s0, r4, OFFSET_OF(T, d)); |
| 259 __ vldr(s1, r4, OFFSET_OF(T, e)); |
| 260 __ vmov(s2, s0); |
| 261 __ vmov(s0, s1); |
| 262 __ vmov(s1, s2); |
| 263 __ vstr(s0, r4, OFFSET_OF(T, d)); |
| 264 __ vstr(s1, r4, OFFSET_OF(T, e)); |
| 265 |
255 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); | 266 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); |
256 | 267 |
257 CodeDesc desc; | 268 CodeDesc desc; |
258 assm.GetCode(&desc); | 269 assm.GetCode(&desc); |
259 Object* code = Heap::CreateCode(desc, | 270 Object* code = Heap::CreateCode(desc, |
260 Code::ComputeFlags(Code::STUB), | 271 Code::ComputeFlags(Code::STUB), |
261 Handle<Object>(Heap::undefined_value())); | 272 Handle<Object>(Heap::undefined_value())); |
262 CHECK(code->IsCode()); | 273 CHECK(code->IsCode()); |
263 #ifdef DEBUG | 274 #ifdef DEBUG |
264 Code::cast(code)->Print(); | 275 Code::cast(code)->Print(); |
265 #endif | 276 #endif |
266 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); | 277 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); |
267 t.a = 1.5; | 278 t.a = 1.5; |
268 t.b = 2.75; | 279 t.b = 2.75; |
269 t.c = 17.17; | 280 t.c = 17.17; |
| 281 t.d = 4.5; |
| 282 t.e = 9.0; |
270 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | 283 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
271 USE(dummy); | 284 USE(dummy); |
| 285 CHECK_EQ(4.5, t.e); |
| 286 CHECK_EQ(9.0, t.d); |
272 CHECK_EQ(4.25, t.c); | 287 CHECK_EQ(4.25, t.c); |
273 CHECK_EQ(4.25, t.b); | 288 CHECK_EQ(4.25, t.b); |
274 CHECK_EQ(1.5, t.a); | 289 CHECK_EQ(1.5, t.a); |
275 } | 290 } |
276 } | 291 } |
277 | 292 |
278 | 293 |
279 TEST(5) { | 294 TEST(5) { |
280 // Test the ARMv7 bitfield instructions. | 295 // Test the ARMv7 bitfield instructions. |
281 InitializeVM(); | 296 InitializeVM(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 #endif | 353 #endif |
339 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 354 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); |
340 int res = reinterpret_cast<int>( | 355 int res = reinterpret_cast<int>( |
341 CALL_GENERATED_CODE(f, 0xFFFF, 0, 0, 0, 0)); | 356 CALL_GENERATED_CODE(f, 0xFFFF, 0, 0, 0, 0)); |
342 ::printf("f() = %d\n", res); | 357 ::printf("f() = %d\n", res); |
343 CHECK_EQ(382, res); | 358 CHECK_EQ(382, res); |
344 } | 359 } |
345 } | 360 } |
346 | 361 |
347 #undef __ | 362 #undef __ |
OLD | NEW |