OLD | NEW |
1 // Copyright 2006-2008 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 t.s = 1000; | 217 t.s = 1000; |
218 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0)); | 218 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0)); |
219 ::printf("f() = %d\n", res); | 219 ::printf("f() = %d\n", res); |
220 CHECK_EQ(101010, res); | 220 CHECK_EQ(101010, res); |
221 CHECK_EQ(100000/2, t.i); | 221 CHECK_EQ(100000/2, t.i); |
222 CHECK_EQ(10*4, t.c); | 222 CHECK_EQ(10*4, t.c); |
223 CHECK_EQ(1000/8, t.s); | 223 CHECK_EQ(1000/8, t.s); |
224 } | 224 } |
225 | 225 |
226 | 226 |
| 227 TEST(4) { |
| 228 // Test the VFP floating point instructions. |
| 229 InitializeVM(); |
| 230 v8::HandleScope scope; |
| 231 |
| 232 typedef struct { |
| 233 double a; |
| 234 double b; |
| 235 double c; |
| 236 } T; |
| 237 T t; |
| 238 |
| 239 // Create a function that accepts &t, and loads, manipulates, and stores |
| 240 // the doubles t.a, t.b, and t.c. |
| 241 Assembler assm(NULL, 0); |
| 242 Label L, C; |
| 243 |
| 244 |
| 245 ASSERT(CpuFeatures::IsSupported(VFP3)); |
| 246 if (CpuFeatures::IsSupported(VFP3)) { |
| 247 CpuFeatures::Scope scope(VFP3); |
| 248 |
| 249 __ mov(ip, Operand(sp)); |
| 250 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
| 251 __ sub(fp, ip, Operand(4)); |
| 252 |
| 253 __ mov(r4, Operand(r0)); |
| 254 __ vldr(d6, r4, OFFSET_OF(T, a)); |
| 255 __ vldr(d7, r4, OFFSET_OF(T, b)); |
| 256 __ vadd(d5, d6, d7); |
| 257 __ vstr(d5, r4, OFFSET_OF(T, c)); |
| 258 |
| 259 __ vmov(r2, r3, d5); |
| 260 __ vmov(d4, r2, r3); |
| 261 __ vstr(d4, r4, OFFSET_OF(T, b)); |
| 262 |
| 263 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); |
| 264 } |
| 265 CodeDesc desc; |
| 266 assm.GetCode(&desc); |
| 267 Object* code = Heap::CreateCode(desc, |
| 268 NULL, |
| 269 Code::ComputeFlags(Code::STUB), |
| 270 Handle<Object>(Heap::undefined_value())); |
| 271 CHECK(code->IsCode()); |
| 272 #ifdef DEBUG |
| 273 Code::cast(code)->Print(); |
| 274 #endif |
| 275 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); |
| 276 t.a = 1.5; |
| 277 t.b = 2.75; |
| 278 t.c = 17.17; |
| 279 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
| 280 USE(dummy); |
| 281 CHECK_EQ(4.25, t.c); |
| 282 CHECK_EQ(4.25, t.b); |
| 283 CHECK_EQ(1.5, t.a); |
| 284 } |
| 285 |
227 #undef __ | 286 #undef __ |
OLD | NEW |