Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: test/cctest/test-assembler-arm.cc

Issue 14109010: ARM: Enable VFP default NaN mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/arm/simulator-arm.cc ('K') | « src/arm/stub-cache-arm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 CHECK_EQ(73.8818412254460241, t.c); 1130 CHECK_EQ(73.8818412254460241, t.c);
1131 CHECK_EQ(2.75, t.x); 1131 CHECK_EQ(2.75, t.x);
1132 CHECK_EQ(1.5, t.y); 1132 CHECK_EQ(1.5, t.y);
1133 CHECK_EQ(17.0, t.z); 1133 CHECK_EQ(17.0, t.z);
1134 CHECK_EQ(14.7610017472335499, t.i); 1134 CHECK_EQ(14.7610017472335499, t.i);
1135 CHECK_EQ(16.0, t.j); 1135 CHECK_EQ(16.0, t.j);
1136 CHECK_EQ(73.8818412254460241, t.k); 1136 CHECK_EQ(73.8818412254460241, t.k);
1137 } 1137 }
1138 } 1138 }
1139 1139
1140
1141 TEST(14) {
1142 // Test the VFP Canonicalized Nan mode.
1143 CcTest::InitializeVM();
1144 Isolate* isolate = Isolate::Current();
1145 HandleScope scope(isolate);
1146
1147 typedef struct {
1148 double left;
1149 double right;
1150 double add_result;
1151 double sub_result;
1152 double mul_result;
1153 double div_result;
1154 } T;
1155 T t;
1156
1157 // Create a function that makes the four basic operations.
1158 Assembler assm(isolate, NULL, 0);
1159
1160 // Ensure FPSCR state (as JSEntryStub does).
1161 Label fpscr_done;
1162 __ vmrs(r1);
1163 __ tst(r1, Operand(kVFPDefaultNaNModeControlBit));
1164 __ b(ne, &fpscr_done);
1165 __ orr(r1, r1, Operand(kVFPDefaultNaNModeControlBit));
1166 __ vmsr(r1);
1167 __ bind(&fpscr_done);
1168
1169 __ vldr(d0, r0, OFFSET_OF(T, left));
1170 __ vldr(d1, r0, OFFSET_OF(T, right));
1171 __ vadd(d2, d0, d1);
1172 __ vstr(d2, r0, OFFSET_OF(T, add_result));
1173 __ vsub(d2, d0, d1);
1174 __ vstr(d2, r0, OFFSET_OF(T, sub_result));
1175 __ vmul(d2, d0, d1);
1176 __ vstr(d2, r0, OFFSET_OF(T, mul_result));
1177 __ vdiv(d2, d0, d1);
1178 __ vstr(d2, r0, OFFSET_OF(T, div_result));
1179
1180 __ mov(pc, Operand(lr));
1181
1182 CodeDesc desc;
1183 assm.GetCode(&desc);
1184 Object* code = isolate->heap()->CreateCode(
1185 desc,
1186 Code::ComputeFlags(Code::STUB),
1187 Handle<Code>())->ToObjectChecked();
1188 CHECK(code->IsCode());
1189 #ifdef DEBUG
1190 Code::cast(code)->Print();
1191 #endif
1192 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry());
1193 t.left = BitCast<double>(kHoleNanInt64);
1194 t.right = 1;
1195 t.add_result = 0;
1196 t.sub_result = 0;
1197 t.mul_result = 0;
1198 t.div_result = 0;
1199 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0);
1200 USE(dummy);
1201 const uint32_t kArmNanUpper32 = 0x7ff80000;
1202 const uint32_t kArmNanLower32 = 0x00000000;
1203 #ifdef DEBUG
1204 const uint64_t kArmNanInt64 =
1205 (static_cast<uint64_t>(kArmNanUpper32) << 32) | kArmNanLower32;
1206 ASSERT(kArmNanInt64 != kHoleNanInt64);
1207 #endif
1208 // With VFP2 the sign of the canonicalized Nan is undefined. So
1209 // we remove the sign bit for the upper tests.
1210 CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.add_result) >> 32) & 0x7fffffff);
1211 CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.add_result) & 0xffffffffu);
1212 CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.sub_result) >> 32) & 0x7fffffff);
1213 CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.sub_result) & 0xffffffffu);
1214 CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.mul_result) >> 32) & 0x7fffffff);
1215 CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.mul_result) & 0xffffffffu);
1216 CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.div_result) >> 32) & 0x7fffffff);
1217 CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.div_result) & 0xffffffffu);
1218 }
1219
1140 #undef __ 1220 #undef __
OLDNEW
« src/arm/simulator-arm.cc ('K') | « src/arm/stub-cache-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698