| 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; | 229 double d; |
| 230 float e; | 230 double e; |
| 231 double f; |
| 232 int i; |
| 233 float x; |
| 234 float y; |
| 231 } T; | 235 } T; |
| 232 T t; | 236 T t; |
| 233 | 237 |
| 234 // Create a function that accepts &t, and loads, manipulates, and stores | 238 // Create a function that accepts &t, and loads, manipulates, and stores |
| 235 // the doubles t.a, t.b, and t.c, and floats t.d, t.e. | 239 // the doubles and floats. |
| 236 Assembler assm(NULL, 0); | 240 Assembler assm(NULL, 0); |
| 237 Label L, C; | 241 Label L, C; |
| 238 | 242 |
| 239 | 243 |
| 240 if (CpuFeatures::IsSupported(VFP3)) { | 244 if (CpuFeatures::IsSupported(VFP3)) { |
| 241 CpuFeatures::Scope scope(VFP3); | 245 CpuFeatures::Scope scope(VFP3); |
| 242 | 246 |
| 243 __ mov(ip, Operand(sp)); | 247 __ mov(ip, Operand(sp)); |
| 244 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 248 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
| 245 __ sub(fp, ip, Operand(4)); | 249 __ sub(fp, ip, Operand(4)); |
| 246 | 250 |
| 247 __ mov(r4, Operand(r0)); | 251 __ mov(r4, Operand(r0)); |
| 248 __ vldr(d6, r4, OFFSET_OF(T, a)); | 252 __ vldr(d6, r4, OFFSET_OF(T, a)); |
| 249 __ vldr(d7, r4, OFFSET_OF(T, b)); | 253 __ vldr(d7, r4, OFFSET_OF(T, b)); |
| 250 __ vadd(d5, d6, d7); | 254 __ vadd(d5, d6, d7); |
| 251 __ vstr(d5, r4, OFFSET_OF(T, c)); | 255 __ vstr(d5, r4, OFFSET_OF(T, c)); |
| 252 | 256 |
| 253 __ vmov(r2, r3, d5); | 257 __ vmov(r2, r3, d5); |
| 254 __ vmov(d4, r2, r3); | 258 __ vmov(d4, r2, r3); |
| 255 __ vstr(d4, r4, OFFSET_OF(T, b)); | 259 __ vstr(d4, r4, OFFSET_OF(T, b)); |
| 256 | 260 |
| 257 // Load t.d and t.e, switch values, and store back to the struct. | 261 // Load t.x and t.y, switch values, and store back to the struct. |
| 258 __ vldr(s0, r4, OFFSET_OF(T, d)); | 262 __ vldr(s0, r4, OFFSET_OF(T, x)); |
| 259 __ vldr(s1, r4, OFFSET_OF(T, e)); | 263 __ vldr(s31, r4, OFFSET_OF(T, y)); |
| 260 __ vmov(s2, s0); | 264 __ vmov(s16, s0); |
| 261 __ vmov(s0, s1); | 265 __ vmov(s0, s31); |
| 262 __ vmov(s1, s2); | 266 __ vmov(s31, s16); |
| 263 __ vstr(s0, r4, OFFSET_OF(T, d)); | 267 __ vstr(s0, r4, OFFSET_OF(T, x)); |
| 264 __ vstr(s1, r4, OFFSET_OF(T, e)); | 268 __ vstr(s31, r4, OFFSET_OF(T, y)); |
| 265 | 269 |
| 270 // Move a literal into a register that can be encoded in the instruction. |
| 271 __ vmov(d4, 1.0); |
| 272 __ vstr(d4, r4, OFFSET_OF(T, e)); |
| 273 |
| 274 // Move a literal into a register that requires 64 bits to encode. |
| 275 // 0x3ff0000010000000 = 1.000000059604644775390625 |
| 276 __ vmov(d4, 1.000000059604644775390625); |
| 277 __ vstr(d4, r4, OFFSET_OF(T, d)); |
| 278 |
| 279 // Convert from floating point to integer. |
| 280 __ vmov(d4, 2.0); |
| 281 __ vcvt_s32_f64(s31, d4); |
| 282 __ vstr(s31, r4, OFFSET_OF(T, i)); |
| 283 |
| 284 // Convert from integer to floating point. |
| 285 __ mov(lr, Operand(42)); |
| 286 __ vmov(s31, lr); |
| 287 __ vcvt_f64_s32(d4, s31); |
| 288 __ vstr(d4, r4, OFFSET_OF(T, f)); |
| 266 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); | 289 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); |
| 267 | 290 |
| 268 CodeDesc desc; | 291 CodeDesc desc; |
| 269 assm.GetCode(&desc); | 292 assm.GetCode(&desc); |
| 270 Object* code = Heap::CreateCode(desc, | 293 Object* code = Heap::CreateCode(desc, |
| 271 Code::ComputeFlags(Code::STUB), | 294 Code::ComputeFlags(Code::STUB), |
| 272 Handle<Object>(Heap::undefined_value())); | 295 Handle<Object>(Heap::undefined_value())); |
| 273 CHECK(code->IsCode()); | 296 CHECK(code->IsCode()); |
| 274 #ifdef DEBUG | 297 #ifdef DEBUG |
| 275 Code::cast(code)->Print(); | 298 Code::cast(code)->Print(); |
| 276 #endif | 299 #endif |
| 277 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); | 300 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); |
| 278 t.a = 1.5; | 301 t.a = 1.5; |
| 279 t.b = 2.75; | 302 t.b = 2.75; |
| 280 t.c = 17.17; | 303 t.c = 17.17; |
| 281 t.d = 4.5; | 304 t.d = 0.0; |
| 282 t.e = 9.0; | 305 t.e = 0.0; |
| 306 t.f = 0.0; |
| 307 t.i = 0; |
| 308 t.x = 4.5; |
| 309 t.y = 9.0; |
| 283 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | 310 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
| 284 USE(dummy); | 311 USE(dummy); |
| 285 CHECK_EQ(4.5, t.e); | 312 CHECK_EQ(4.5, t.y); |
| 286 CHECK_EQ(9.0, t.d); | 313 CHECK_EQ(9.0, t.x); |
| 314 CHECK_EQ(2, t.i); |
| 315 CHECK_EQ(42.0, t.f); |
| 316 CHECK_EQ(1.0, t.e); |
| 317 CHECK_EQ(1.000000059604644775390625, t.d); |
| 287 CHECK_EQ(4.25, t.c); | 318 CHECK_EQ(4.25, t.c); |
| 288 CHECK_EQ(4.25, t.b); | 319 CHECK_EQ(4.25, t.b); |
| 289 CHECK_EQ(1.5, t.a); | 320 CHECK_EQ(1.5, t.a); |
| 290 } | 321 } |
| 291 } | 322 } |
| 292 | 323 |
| 293 | 324 |
| 294 TEST(5) { | 325 TEST(5) { |
| 295 // Test the ARMv7 bitfield instructions. | 326 // Test the ARMv7 bitfield instructions. |
| 296 InitializeVM(); | 327 InitializeVM(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 #endif | 384 #endif |
| 354 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 385 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); |
| 355 int res = reinterpret_cast<int>( | 386 int res = reinterpret_cast<int>( |
| 356 CALL_GENERATED_CODE(f, 0xFFFF, 0, 0, 0, 0)); | 387 CALL_GENERATED_CODE(f, 0xFFFF, 0, 0, 0, 0)); |
| 357 ::printf("f() = %d\n", res); | 388 ::printf("f() = %d\n", res); |
| 358 CHECK_EQ(382, res); | 389 CHECK_EQ(382, res); |
| 359 } | 390 } |
| 360 } | 391 } |
| 361 | 392 |
| 362 #undef __ | 393 #undef __ |
| OLD | NEW |