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

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

Issue 6993054: MIPS: Fixed FPU rounding checks and related errors in the Simulator. (Closed)
Patch Set: Created 9 years, 6 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
« src/mips/constants-mips.h ('K') | « src/mips/stub-cache-mips.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1213
1214 RUN_ROUND_TEST(round) 1214 RUN_ROUND_TEST(round)
1215 RUN_ROUND_TEST(floor) 1215 RUN_ROUND_TEST(floor)
1216 RUN_ROUND_TEST(ceil) 1216 RUN_ROUND_TEST(ceil)
1217 RUN_ROUND_TEST(trunc) 1217 RUN_ROUND_TEST(trunc)
1218 RUN_ROUND_TEST(cvt) 1218 RUN_ROUND_TEST(cvt)
1219 1219
1220 // Restore FCSR. 1220 // Restore FCSR.
1221 __ ctc1(a1, FCSR); 1221 __ ctc1(a1, FCSR);
1222 1222
1223 #undef RUN_ROUND_TEST
1224
1225 __ jr(ra); 1223 __ jr(ra);
1226 __ nop(); 1224 __ nop();
1227 1225
1228 CodeDesc desc; 1226 CodeDesc desc;
1229 assm.GetCode(&desc); 1227 assm.GetCode(&desc);
1230 Object* code = HEAP->CreateCode( 1228 Object* code = HEAP->CreateCode(
1231 desc, 1229 desc,
1232 Code::ComputeFlags(Code::STUB), 1230 Code::ComputeFlags(Code::STUB),
1233 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); 1231 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked();
1234 CHECK(code->IsCode()); 1232 CHECK(code->IsCode());
1235 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); 1233 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry());
1236 1234
1237 t.round_up_in = 123.51; 1235 t.round_up_in = 123.51;
1238 t.round_down_in = 123.49; 1236 t.round_down_in = 123.49;
1239 t.neg_round_up_in = -123.5; 1237 t.neg_round_up_in = -123.5;
1240 t.neg_round_down_in = -123.49; 1238 t.neg_round_down_in = -123.49;
1241 t.err1_in = 123.51; 1239 t.err1_in = 123.51;
1242 t.err2_in = 1; 1240 t.err2_in = 1;
1243 t.err3_in = static_cast<double>(1) + 0xFFFFFFFF; 1241 t.err3_in = static_cast<double>(1) + 0xFFFFFFFF;
1244 t.err4_in = NAN; 1242 t.err4_in = NAN;
1245 1243
1246 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); 1244 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0);
1247 USE(dummy); 1245 USE(dummy);
1248 1246
1249 #define GET_FPU_ERR(x) (static_cast<int>((x >> kFCSRFlagShift) & kFCSRFlagMask)) 1247 #define GET_FPU_ERR(x) (static_cast<int>(x & kFCSRFlagMask))
1248 #define CHECK_ROUND_RESULT(type) \
1249 CHECK(GET_FPU_ERR(t.type##_err1_out) & kFCSRInexactFlagMask); \
1250 CHECK_EQ(0, GET_FPU_ERR(t.type##_err2_out)); \
1251 CHECK(GET_FPU_ERR(t.type##_err3_out) & kFCSRInvalidOpFlagMask); \
1252 CHECK(GET_FPU_ERR(t.type##_err4_out) & kFCSRInvalidOpFlagMask); \
1253 CHECK_EQ(kFPUInvalidResult, t.type##_invalid_result);
1250 1254
1251 CHECK_EQ(124, t.round_up_out); 1255 CHECK_ROUND_RESULT(round);
1252 CHECK_EQ(123, t.round_down_out); 1256 CHECK_ROUND_RESULT(floor);
1253 CHECK_EQ(-124, t.neg_round_up_out); 1257 CHECK_ROUND_RESULT(ceil);
1254 CHECK_EQ(-123, t.neg_round_down_out); 1258 CHECK_ROUND_RESULT(cvt);
1255
1256 // Inexact.
1257 CHECK_EQ(kFCSRInexactFlagBit, GET_FPU_ERR(t.round_err1_out));
1258 // No error.
1259 CHECK_EQ(0, GET_FPU_ERR(t.round_err2_out));
1260 // Invalid operation.
1261 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.round_err3_out));
1262 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.round_err4_out));
1263 CHECK_EQ(kFPUInvalidResult, t.round_invalid_result);
1264
1265 CHECK_EQ(123, t.floor_up_out);
1266 CHECK_EQ(123, t.floor_down_out);
1267 CHECK_EQ(-124, t.neg_floor_up_out);
1268 CHECK_EQ(-124, t.neg_floor_down_out);
1269
1270 // Inexact.
1271 CHECK_EQ(kFCSRInexactFlagBit, GET_FPU_ERR(t.floor_err1_out));
1272 // No error.
1273 CHECK_EQ(0, GET_FPU_ERR(t.floor_err2_out));
1274 // Invalid operation.
1275 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.floor_err3_out));
1276 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.floor_err4_out));
1277 CHECK_EQ(kFPUInvalidResult, t.floor_invalid_result);
1278
1279 CHECK_EQ(124, t.ceil_up_out);
1280 CHECK_EQ(124, t.ceil_down_out);
1281 CHECK_EQ(-123, t.neg_ceil_up_out);
1282 CHECK_EQ(-123, t.neg_ceil_down_out);
1283
1284 // Inexact.
1285 CHECK_EQ(kFCSRInexactFlagBit, GET_FPU_ERR(t.ceil_err1_out));
1286 // No error.
1287 CHECK_EQ(0, GET_FPU_ERR(t.ceil_err2_out));
1288 // Invalid operation.
1289 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.ceil_err3_out));
1290 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.ceil_err4_out));
1291 CHECK_EQ(kFPUInvalidResult, t.ceil_invalid_result);
1292
1293 // In rounding mode 0 cvt should behave like round.
1294 CHECK_EQ(t.round_up_out, t.cvt_up_out);
1295 CHECK_EQ(t.round_down_out, t.cvt_down_out);
1296 CHECK_EQ(t.neg_round_up_out, t.neg_cvt_up_out);
1297 CHECK_EQ(t.neg_round_down_out, t.neg_cvt_down_out);
1298
1299 // Inexact.
1300 CHECK_EQ(kFCSRInexactFlagBit, GET_FPU_ERR(t.cvt_err1_out));
1301 // No error.
1302 CHECK_EQ(0, GET_FPU_ERR(t.cvt_err2_out));
1303 // Invalid operation.
1304 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.cvt_err3_out));
1305 CHECK_EQ(kFCSRInvalidOpFlagBit, GET_FPU_ERR(t.cvt_err4_out));
1306 CHECK_EQ(kFPUInvalidResult, t.cvt_invalid_result);
1307 } 1259 }
1308 } 1260 }
1309 1261
1310
1311 #undef __ 1262 #undef __
OLDNEW
« src/mips/constants-mips.h ('K') | « src/mips/stub-cache-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698