OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 v8::HandleScope scope; | 1019 v8::HandleScope scope; |
1020 Assembler assm(Isolate::Current(), NULL, 0); | 1020 Assembler assm(Isolate::Current(), NULL, 0); |
1021 | 1021 |
1022 Label target; | 1022 Label target; |
1023 __ b(eq, &target); | 1023 __ b(eq, &target); |
1024 __ b(ne, &target); | 1024 __ b(ne, &target); |
1025 __ bind(&target); | 1025 __ bind(&target); |
1026 __ nop(); | 1026 __ nop(); |
1027 } | 1027 } |
1028 | 1028 |
| 1029 |
| 1030 TEST(13) { |
| 1031 // Test VFP instructions using registers d16-d31. |
| 1032 InitializeVM(); |
| 1033 v8::HandleScope scope; |
| 1034 |
| 1035 typedef struct { |
| 1036 double a; |
| 1037 double b; |
| 1038 double c; |
| 1039 double x; |
| 1040 double y; |
| 1041 double z; |
| 1042 } T; |
| 1043 T t; |
| 1044 |
| 1045 // Create a function that accepts &t, and loads, manipulates, and stores |
| 1046 // the doubles and floats. |
| 1047 Assembler assm(Isolate::Current(), NULL, 0); |
| 1048 Label L, C; |
| 1049 |
| 1050 |
| 1051 if (CpuFeatures::IsSupported(VFP3)) { |
| 1052 CpuFeatures::Scope scope(VFP3); |
| 1053 |
| 1054 __ mov(ip, Operand(sp)); |
| 1055 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
| 1056 __ sub(fp, ip, Operand(4)); |
| 1057 |
| 1058 // Load a, b, c into d16, d17, d18. |
| 1059 __ mov(r4, Operand(r0)); |
| 1060 __ vldr(d16, r4, OFFSET_OF(T, a)); |
| 1061 __ vldr(d17, r4, OFFSET_OF(T, b)); |
| 1062 __ vldr(d18, r4, OFFSET_OF(T, c)); |
| 1063 |
| 1064 __ vneg(d25, d16); |
| 1065 __ vadd(d25, d25, d17); |
| 1066 __ vsub(d25, d25, d18); |
| 1067 __ vmul(d25, d25, d25); |
| 1068 __ vdiv(d25, d25, d18); |
| 1069 |
| 1070 __ vmov(d16, d25); |
| 1071 __ vsqrt(d17, d25); |
| 1072 __ vneg(d17, d17); |
| 1073 __ vabs(d17, d17); |
| 1074 __ vmla(d18, d16, d17); |
| 1075 |
| 1076 // Store d16, d17, d18 into a, b, c. |
| 1077 __ mov(r4, Operand(r0)); |
| 1078 __ vstr(d16, r4, OFFSET_OF(T, a)); |
| 1079 __ vstr(d17, r4, OFFSET_OF(T, b)); |
| 1080 __ vstr(d18, r4, OFFSET_OF(T, c)); |
| 1081 |
| 1082 // Load x, y, z into d29-d31. |
| 1083 __ add(r4, r0, Operand(OFFSET_OF(T, x))); |
| 1084 __ vldm(ia_w, r4, d29, d31); |
| 1085 |
| 1086 // Swap d29 and d30 via r registers. |
| 1087 __ vmov(r1, r2, d29); |
| 1088 __ vmov(d29, d30); |
| 1089 __ vmov(d30, r1, r2); |
| 1090 |
| 1091 // Convert to and from integer. |
| 1092 __ vcvt_s32_f64(s1, d31); |
| 1093 __ vcvt_f64_u32(d31, s1); |
| 1094 |
| 1095 // Store d29-d31 into x, y, z. |
| 1096 __ add(r4, r0, Operand(OFFSET_OF(T, x))); |
| 1097 __ vstm(ia_w, r4, d29, d31); |
| 1098 |
| 1099 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); |
| 1100 |
| 1101 CodeDesc desc; |
| 1102 assm.GetCode(&desc); |
| 1103 Object* code = HEAP->CreateCode( |
| 1104 desc, |
| 1105 Code::ComputeFlags(Code::STUB), |
| 1106 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); |
| 1107 CHECK(code->IsCode()); |
| 1108 #ifdef DEBUG |
| 1109 Code::cast(code)->Print(); |
| 1110 #endif |
| 1111 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); |
| 1112 t.a = 1.5; |
| 1113 t.b = 2.75; |
| 1114 t.c = 17.17; |
| 1115 t.x = 1.5; |
| 1116 t.y = 2.75; |
| 1117 t.z = 17.17; |
| 1118 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
| 1119 USE(dummy); |
| 1120 CHECK_EQ(14.7610017472335499, t.a); |
| 1121 CHECK_EQ(3.84200491244266251, t.b); |
| 1122 CHECK_EQ(73.8818412254460241, t.c); |
| 1123 CHECK_EQ(2.75, t.x); |
| 1124 CHECK_EQ(1.5, t.y); |
| 1125 CHECK_EQ(17.0, t.z); |
| 1126 } |
| 1127 } |
| 1128 |
1029 #undef __ | 1129 #undef __ |
OLD | NEW |