Chromium Code Reviews| 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 double i; | |
| 1043 double j; | |
| 1044 double k; | |
| 1045 } T; | |
| 1046 T t; | |
| 1047 | |
| 1048 // Create a function that accepts &t, and loads, manipulates, and stores | |
| 1049 // the doubles and floats. | |
| 1050 Assembler assm(Isolate::Current(), NULL, 0); | |
| 1051 Label L, C; | |
| 1052 | |
| 1053 | |
| 1054 if (CpuFeatures::IsSupported(VFP3)) { | |
| 1055 CpuFeatures::Scope scope(VFP3); | |
| 1056 | |
| 1057 __ mov(ip, Operand(sp)); | |
|
Rodolph Perfetta
2012/12/12 14:29:15
This is not needed/used.
hans
2012/12/12 17:58:47
Removed.
| |
| 1058 __ stm(db_w, sp, r4.bit() | lr.bit()); | |
| 1059 | |
| 1060 // Load a, b, c into d16, d17, d18. | |
| 1061 __ mov(r4, Operand(r0)); | |
| 1062 __ vldr(d16, r4, OFFSET_OF(T, a)); | |
| 1063 __ vldr(d17, r4, OFFSET_OF(T, b)); | |
| 1064 __ vldr(d18, r4, OFFSET_OF(T, c)); | |
| 1065 | |
| 1066 __ vneg(d25, d16); | |
| 1067 __ vadd(d25, d25, d17); | |
| 1068 __ vsub(d25, d25, d18); | |
| 1069 __ vmul(d25, d25, d25); | |
| 1070 __ vdiv(d25, d25, d18); | |
| 1071 | |
| 1072 __ vmov(d16, d25); | |
| 1073 __ vsqrt(d17, d25); | |
| 1074 __ vneg(d17, d17); | |
| 1075 __ vabs(d17, d17); | |
| 1076 __ vmla(d18, d16, d17); | |
| 1077 | |
| 1078 // Store d16, d17, d18 into a, b, c. | |
| 1079 __ mov(r4, Operand(r0)); | |
| 1080 __ vstr(d16, r4, OFFSET_OF(T, a)); | |
| 1081 __ vstr(d17, r4, OFFSET_OF(T, b)); | |
| 1082 __ vstr(d18, r4, OFFSET_OF(T, c)); | |
| 1083 | |
| 1084 // Load x, y, z into d29-d31. | |
| 1085 __ add(r4, r0, Operand(OFFSET_OF(T, x))); | |
| 1086 __ vldm(ia_w, r4, d29, d31); | |
| 1087 | |
| 1088 // Swap d29 and d30 via r registers. | |
| 1089 __ vmov(r1, r2, d29); | |
| 1090 __ vmov(d29, d30); | |
| 1091 __ vmov(d30, r1, r2); | |
| 1092 | |
| 1093 // Convert to and from integer. | |
| 1094 __ vcvt_s32_f64(s1, d31); | |
| 1095 __ vcvt_f64_u32(d31, s1); | |
| 1096 | |
| 1097 // Store d29-d31 into x, y, z. | |
| 1098 __ add(r4, r0, Operand(OFFSET_OF(T, x))); | |
| 1099 __ vstm(ia_w, r4, d29, d31); | |
| 1100 | |
| 1101 // Move constants into d20, d21, d22 and store into i, j, k. | |
| 1102 __ vmov(d20, 14.7610017472335499); | |
| 1103 __ vmov(d21, 16.0); | |
| 1104 __ mov(r1, Operand(372106121)); | |
| 1105 __ mov(r2, Operand(1079146608)); | |
| 1106 __ vmov(d22, 0, r1); | |
| 1107 __ vmov(d22, 1, r2); | |
| 1108 __ add(r4, r0, Operand(OFFSET_OF(T, i))); | |
| 1109 __ vstm(ia_w, r4, d20, d22); | |
| 1110 | |
| 1111 __ ldm(ia_w, sp, r4.bit() | pc.bit()); | |
| 1112 | |
| 1113 CodeDesc desc; | |
| 1114 assm.GetCode(&desc); | |
| 1115 Object* code = HEAP->CreateCode( | |
| 1116 desc, | |
| 1117 Code::ComputeFlags(Code::STUB), | |
| 1118 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); | |
| 1119 CHECK(code->IsCode()); | |
| 1120 #ifdef DEBUG | |
| 1121 Code::cast(code)->Print(); | |
| 1122 #endif | |
| 1123 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); | |
| 1124 t.a = 1.5; | |
| 1125 t.b = 2.75; | |
| 1126 t.c = 17.17; | |
| 1127 t.x = 1.5; | |
| 1128 t.y = 2.75; | |
| 1129 t.z = 17.17; | |
| 1130 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | |
| 1131 USE(dummy); | |
| 1132 CHECK_EQ(14.7610017472335499, t.a); | |
| 1133 CHECK_EQ(3.84200491244266251, t.b); | |
| 1134 CHECK_EQ(73.8818412254460241, t.c); | |
| 1135 CHECK_EQ(2.75, t.x); | |
| 1136 CHECK_EQ(1.5, t.y); | |
| 1137 CHECK_EQ(17.0, t.z); | |
| 1138 CHECK_EQ(14.7610017472335499, t.i); | |
| 1139 CHECK_EQ(16.0, t.j); | |
| 1140 CHECK_EQ(73.8818412254460241, t.k); | |
| 1141 } | |
| 1142 } | |
| 1143 | |
| 1029 #undef __ | 1144 #undef __ |
| OLD | NEW |