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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 1356913002: [turbofan] Add support for reinterpreting integers as floating point and vice versa. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename ReinterpretAs to BitcastTo Created 5 years, 3 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
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 5304 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 CHECK_EQ(before, buffer[1]); 5315 CHECK_EQ(before, buffer[1]);
5316 5316
5317 CHECK_EQ(11, m.Call(0)); 5317 CHECK_EQ(11, m.Call(0));
5318 CHECK_EQ(write, buffer[0]); 5318 CHECK_EQ(write, buffer[0]);
5319 CHECK_EQ(before, buffer[1]); 5319 CHECK_EQ(before, buffer[1]);
5320 5320
5321 CHECK_EQ(11, m.Call(8)); 5321 CHECK_EQ(11, m.Call(8));
5322 CHECK_EQ(write, buffer[0]); 5322 CHECK_EQ(write, buffer[0]);
5323 CHECK_EQ(write, buffer[1]); 5323 CHECK_EQ(write, buffer[1]);
5324 } 5324 }
5325
5326
5327 TEST(RunBitcastInt64ToFloat64) {
5328 // TODO(titzer): run int64 tests on all platforms when supported.
5329 int64_t input = 1;
5330 double output = 0.0;
5331 RawMachineAssemblerTester<int32_t> m;
5332 m.StoreToPointer(
5333 &output, kMachFloat64,
5334 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64)));
5335 m.Return(m.Int32Constant(11));
5336 FOR_INT32_INPUTS(i) {
5337 input = static_cast<int64_t>(*i) * 14444;
5338 CHECK_EQ(11, m.Call());
5339 double expected = bit_cast<double>(input);
5340 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output));
5341 }
5342 }
5343
5344
5345 TEST(RunBitcastFloat64ToInt64) {
5346 // TODO(titzer): run int64 tests on all platforms when supported.
5347 double input = 0;
5348 int64_t output = 0;
5349 RawMachineAssemblerTester<int32_t> m;
5350 m.StoreToPointer(
5351 &output, kMachInt64,
5352 m.BitcastFloat64ToInt64(m.LoadFromPointer(&input, kMachFloat64)));
5353 m.Return(m.Int32Constant(11));
5354 FOR_FLOAT64_INPUTS(i) {
5355 input = *i;
5356 CHECK_EQ(11, m.Call());
5357 double expected = bit_cast<int64_t>(input);
5358 CHECK_EQ(expected, output);
5359 }
5360 }
5325 #endif 5361 #endif
5362
5363
5364 TEST(RunBitcastFloat32ToInt32) {
5365 float input = 32.25;
5366 RawMachineAssemblerTester<int32_t> m;
5367 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32)));
5368 FOR_FLOAT32_INPUTS(i) {
5369 input = *i;
5370 int32_t expected = bit_cast<int32_t>(input);
5371 CHECK_EQ(expected, m.Call());
5372 }
5373 }
5374
5375
5376 TEST(RunBitcastInt32ToFloat32) {
5377 int32_t input = 1;
5378 float output = 0.0;
5379 RawMachineAssemblerTester<int32_t> m;
5380 m.StoreToPointer(
5381 &output, kMachFloat32,
5382 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32)));
5383 m.Return(m.Int32Constant(11));
5384 FOR_INT32_INPUTS(i) {
5385 input = *i;
5386 CHECK_EQ(11, m.Call());
5387 float expected = bit_cast<float>(input);
5388 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output));
5389 }
5390 }
OLDNEW
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698