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)); | |
1058 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | |
1059 __ sub(fp, ip, Operand(4)); | |
Rodolph Perfetta
2012/12/05 21:39:34
Why is this necessary? the tests don't seem to use
hans
2012/12/11 17:08:04
You're right, I was copy-pasting too aggressively
| |
1060 | |
1061 // Load a, b, c into d16, d17, d18. | |
1062 __ mov(r4, Operand(r0)); | |
1063 __ vldr(d16, r4, OFFSET_OF(T, a)); | |
1064 __ vldr(d17, r4, OFFSET_OF(T, b)); | |
1065 __ vldr(d18, r4, OFFSET_OF(T, c)); | |
1066 | |
1067 __ vneg(d25, d16); | |
1068 __ vadd(d25, d25, d17); | |
1069 __ vsub(d25, d25, d18); | |
1070 __ vmul(d25, d25, d25); | |
1071 __ vdiv(d25, d25, d18); | |
1072 | |
1073 __ vmov(d16, d25); | |
1074 __ vsqrt(d17, d25); | |
1075 __ vneg(d17, d17); | |
1076 __ vabs(d17, d17); | |
1077 __ vmla(d18, d16, d17); | |
1078 | |
1079 // Store d16, d17, d18 into a, b, c. | |
1080 __ mov(r4, Operand(r0)); | |
1081 __ vstr(d16, r4, OFFSET_OF(T, a)); | |
1082 __ vstr(d17, r4, OFFSET_OF(T, b)); | |
1083 __ vstr(d18, r4, OFFSET_OF(T, c)); | |
1084 | |
1085 // Load x, y, z into d29-d31. | |
1086 __ add(r4, r0, Operand(OFFSET_OF(T, x))); | |
1087 __ vldm(ia_w, r4, d29, d31); | |
1088 | |
1089 // Swap d29 and d30 via r registers. | |
1090 __ vmov(r1, r2, d29); | |
1091 __ vmov(d29, d30); | |
1092 __ vmov(d30, r1, r2); | |
1093 | |
1094 // Convert to and from integer. | |
1095 __ vcvt_s32_f64(s1, d31); | |
1096 __ vcvt_f64_u32(d31, s1); | |
1097 | |
1098 // Store d29-d31 into x, y, z. | |
1099 __ add(r4, r0, Operand(OFFSET_OF(T, x))); | |
1100 __ vstm(ia_w, r4, d29, d31); | |
1101 | |
1102 // Move constants into d20, d21, d22 and store into i, j, k. | |
1103 __ vmov(d20, 14.7610017472335499); | |
1104 __ vmov(d21, 3.84200491244266251); | |
1105 __ mov(r1, Operand(372106121)); | |
1106 __ mov(r2, Operand(1079146608)); | |
1107 __ vmov(d22, 0, r1); | |
1108 __ vmov(d22, 1, r2); | |
1109 __ add(r4, r0, Operand(OFFSET_OF(T, i))); | |
1110 __ vstm(ia_w, r4, d20, d22); | |
1111 | |
1112 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); | |
1113 | |
1114 CodeDesc desc; | |
1115 assm.GetCode(&desc); | |
1116 Object* code = HEAP->CreateCode( | |
1117 desc, | |
1118 Code::ComputeFlags(Code::STUB), | |
1119 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); | |
1120 CHECK(code->IsCode()); | |
1121 #ifdef DEBUG | |
1122 Code::cast(code)->Print(); | |
1123 #endif | |
1124 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); | |
1125 t.a = 1.5; | |
1126 t.b = 2.75; | |
1127 t.c = 17.17; | |
1128 t.x = 1.5; | |
1129 t.y = 2.75; | |
1130 t.z = 17.17; | |
1131 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | |
1132 USE(dummy); | |
1133 CHECK_EQ(14.7610017472335499, t.a); | |
1134 CHECK_EQ(3.84200491244266251, t.b); | |
1135 CHECK_EQ(73.8818412254460241, t.c); | |
1136 CHECK_EQ(2.75, t.x); | |
1137 CHECK_EQ(1.5, t.y); | |
1138 CHECK_EQ(17.0, t.z); | |
1139 CHECK_EQ(14.7610017472335499, t.i); | |
1140 CHECK_EQ(3.84200491244266251, t.j); | |
1141 CHECK_EQ(73.8818412254460241, t.k); | |
1142 } | |
1143 } | |
1144 | |
1145 TEST(14) { | |
1146 // Test VFP instructions using registers d16-d31. | |
1147 InitializeVM(); | |
1148 v8::HandleScope scope; | |
1149 | |
1150 typedef struct { | |
1151 double a; | |
1152 double b; | |
1153 double c; | |
1154 } T; | |
1155 T t; | |
1156 | |
1157 // Create a function that accepts &t, and loads, manipulates, and stores | |
1158 // the doubles and floats. | |
1159 Assembler assm(Isolate::Current(), NULL, 0); | |
1160 Label L, C; | |
1161 | |
1162 | |
1163 if (CpuFeatures::IsSupported(VFP3)) { | |
1164 CpuFeatures::Scope scope(VFP3); | |
1165 | |
1166 __ mov(ip, Operand(sp)); | |
1167 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | |
1168 __ sub(fp, ip, Operand(4)); | |
Rodolph Perfetta
2012/12/05 21:39:34
fp is not used.
hans
2012/12/11 17:08:04
I didn't mean to upload this test. I've updated te
| |
1169 | |
1170 // Load a, b, c into d16, d17, d18. | |
Rodolph Perfetta
2012/12/05 21:39:34
The values loaded do not get used. Is this intenti
| |
1171 __ mov(r4, Operand(r0)); | |
1172 __ vldr(d16, r4, OFFSET_OF(T, a)); | |
1173 __ vldr(d17, r4, OFFSET_OF(T, b)); | |
1174 __ vldr(d18, r4, OFFSET_OF(T, c)); | |
1175 | |
1176 __ vmov(d16, 14.7610017472335499); | |
1177 __ vmov(d17, 3.84200491244266251); | |
1178 __ vmov(d18, 73.8818412254460241); | |
1179 | |
1180 // Store d16, d17, d18 into a, b, c. | |
1181 __ mov(r4, Operand(r0)); | |
1182 __ vstr(d16, r4, OFFSET_OF(T, a)); | |
1183 __ vstr(d17, r4, OFFSET_OF(T, b)); | |
1184 __ vstr(d18, r4, OFFSET_OF(T, c)); | |
1185 | |
1186 __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); | |
1187 | |
1188 CodeDesc desc; | |
1189 assm.GetCode(&desc); | |
1190 Object* code = HEAP->CreateCode( | |
1191 desc, | |
1192 Code::ComputeFlags(Code::STUB), | |
1193 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); | |
1194 CHECK(code->IsCode()); | |
1195 #ifdef DEBUG | |
1196 Code::cast(code)->Print(); | |
1197 #endif | |
1198 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); | |
1199 t.a = 1.5; | |
1200 t.b = 2.75; | |
1201 t.c = 17.17; | |
1202 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | |
1203 USE(dummy); | |
1204 CHECK_EQ(14.7610017472335499, t.a); | |
1205 CHECK_EQ(3.84200491244266251, t.b); | |
1206 CHECK_EQ(73.8818412254460241, t.c); | |
1207 } | |
1208 } | |
1209 | |
1029 #undef __ | 1210 #undef __ |
OLD | NEW |