summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/compiler/test-representation-change.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/compiler/test-representation-change.cc')
-rw-r--r--deps/v8/test/cctest/compiler/test-representation-change.cc387
1 files changed, 232 insertions, 155 deletions
diff --git a/deps/v8/test/cctest/compiler/test-representation-change.cc b/deps/v8/test/cctest/compiler/test-representation-change.cc
index 616c3736e1..7353e167d9 100644
--- a/deps/v8/test/cctest/compiler/test-representation-change.cc
+++ b/deps/v8/test/cctest/compiler/test-representation-change.cc
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// TODO(jochen): Remove this after the setting is turned on globally.
-#define V8_IMMINENT_DEPRECATION_WARNINGS
-
#include <limits>
#include "test/cctest/cctest.h"
@@ -64,7 +61,7 @@ class RepresentationChangerTester : public HandleAndZoneScope,
void CheckFloat32Constant(Node* n, float expected) {
CHECK_EQ(IrOpcode::kFloat32Constant, n->opcode());
float fval = OpParameter<float>(n->op());
- CHECK_EQ(expected, fval);
+ CheckDoubleEq(expected, fval);
}
void CheckHeapConstant(Node* n, HeapObject* expected) {
@@ -81,41 +78,50 @@ class RepresentationChangerTester : public HandleAndZoneScope,
}
Node* Parameter(int index = 0) {
- return graph()->NewNode(common()->Parameter(index), graph()->start());
+ Node* n = graph()->NewNode(common()->Parameter(index), graph()->start());
+ NodeProperties::SetType(n, Type::Any());
+ return n;
}
- void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) {
+ void CheckTypeError(MachineRepresentation from, Type* from_type,
+ MachineRepresentation to) {
changer()->testing_type_errors_ = true;
changer()->type_error_ = false;
Node* n = Parameter(0);
- Node* c = changer()->GetRepresentationFor(n, from, to);
+ Node* c = changer()->GetRepresentationFor(n, from, from_type, to);
CHECK(changer()->type_error_);
CHECK_EQ(n, c);
}
- void CheckNop(MachineTypeUnion from, MachineTypeUnion to) {
+ void CheckNop(MachineRepresentation from, Type* from_type,
+ MachineRepresentation to) {
Node* n = Parameter(0);
- Node* c = changer()->GetRepresentationFor(n, from, to);
+ Node* c = changer()->GetRepresentationFor(n, from, from_type, to);
CHECK_EQ(n, c);
}
};
-static const MachineType all_reps[] = {kRepBit, kRepWord32, kRepWord64,
- kRepFloat32, kRepFloat64, kRepTagged};
+const MachineType kMachineTypes[] = {
+ MachineType::Float32(), MachineType::Float64(), MachineType::Int8(),
+ MachineType::Uint8(), MachineType::Int16(), MachineType::Uint16(),
+ MachineType::Int32(), MachineType::Uint32(), MachineType::Int64(),
+ MachineType::Uint64(), MachineType::AnyTagged()};
TEST(BoolToBit_constant) {
RepresentationChangerTester r;
Node* true_node = r.jsgraph()->TrueConstant();
- Node* true_bit =
- r.changer()->GetRepresentationFor(true_node, kRepTagged, kRepBit);
+ Node* true_bit = r.changer()->GetRepresentationFor(
+ true_node, MachineRepresentation::kTagged, Type::None(),
+ MachineRepresentation::kBit);
r.CheckInt32Constant(true_bit, 1);
Node* false_node = r.jsgraph()->FalseConstant();
- Node* false_bit =
- r.changer()->GetRepresentationFor(false_node, kRepTagged, kRepBit);
+ Node* false_bit = r.changer()->GetRepresentationFor(
+ false_node, MachineRepresentation::kTagged, Type::None(),
+ MachineRepresentation::kBit);
r.CheckInt32Constant(false_bit, 0);
}
@@ -125,7 +131,9 @@ TEST(BitToBool_constant) {
for (int i = -5; i < 5; i++) {
Node* node = r.jsgraph()->Int32Constant(i);
- Node* val = r.changer()->GetRepresentationFor(node, kRepBit, kRepTagged);
+ Node* val = r.changer()->GetRepresentationFor(
+ node, MachineRepresentation::kBit, Type::Boolean(),
+ MachineRepresentation::kTagged);
r.CheckHeapConstant(val, i == 0 ? r.isolate()->heap()->false_value()
: r.isolate()->heap()->true_value());
}
@@ -138,7 +146,9 @@ TEST(ToTagged_constant) {
{
FOR_FLOAT64_INPUTS(i) {
Node* n = r.jsgraph()->Float64Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat64, Type::None(),
+ MachineRepresentation::kTagged);
r.CheckNumberConstant(c, *i);
}
}
@@ -146,7 +156,9 @@ TEST(ToTagged_constant) {
{
FOR_FLOAT64_INPUTS(i) {
Node* n = r.jsgraph()->Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat64, Type::None(),
+ MachineRepresentation::kTagged);
r.CheckNumberConstant(c, *i);
}
}
@@ -154,7 +166,9 @@ TEST(ToTagged_constant) {
{
FOR_FLOAT32_INPUTS(i) {
Node* n = r.jsgraph()->Float32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepTagged);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat32, Type::None(),
+ MachineRepresentation::kTagged);
r.CheckNumberConstant(c, *i);
}
}
@@ -162,8 +176,9 @@ TEST(ToTagged_constant) {
{
FOR_INT32_INPUTS(i) {
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32,
- kRepTagged);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kTagged);
r.CheckNumberConstant(c, *i);
}
}
@@ -171,8 +186,9 @@ TEST(ToTagged_constant) {
{
FOR_UINT32_INPUTS(i) {
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32,
- kRepTagged);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Unsigned32(),
+ MachineRepresentation::kTagged);
r.CheckNumberConstant(c, *i);
}
}
@@ -185,7 +201,9 @@ TEST(ToFloat64_constant) {
{
FOR_FLOAT64_INPUTS(i) {
Node* n = r.jsgraph()->Float64Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepFloat64);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat64, Type::None(),
+ MachineRepresentation::kFloat64);
CHECK_EQ(n, c);
}
}
@@ -193,7 +211,9 @@ TEST(ToFloat64_constant) {
{
FOR_FLOAT64_INPUTS(i) {
Node* n = r.jsgraph()->Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepTagged, kRepFloat64);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kTagged, Type::None(),
+ MachineRepresentation::kFloat64);
r.CheckFloat64Constant(c, *i);
}
}
@@ -201,7 +221,9 @@ TEST(ToFloat64_constant) {
{
FOR_FLOAT32_INPUTS(i) {
Node* n = r.jsgraph()->Float32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepFloat64);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat32, Type::None(),
+ MachineRepresentation::kFloat64);
r.CheckFloat64Constant(c, *i);
}
}
@@ -209,8 +231,9 @@ TEST(ToFloat64_constant) {
{
FOR_INT32_INPUTS(i) {
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32,
- kRepFloat64);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kFloat64);
r.CheckFloat64Constant(c, *i);
}
}
@@ -218,8 +241,9 @@ TEST(ToFloat64_constant) {
{
FOR_UINT32_INPUTS(i) {
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32,
- kRepFloat64);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Unsigned32(),
+ MachineRepresentation::kFloat64);
r.CheckFloat64Constant(c, *i);
}
}
@@ -240,7 +264,9 @@ TEST(ToFloat32_constant) {
{
FOR_FLOAT32_INPUTS(i) {
Node* n = r.jsgraph()->Float32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepFloat32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat32, Type::None(),
+ MachineRepresentation::kFloat32);
CHECK_EQ(n, c);
}
}
@@ -248,7 +274,9 @@ TEST(ToFloat32_constant) {
{
FOR_FLOAT32_INPUTS(i) {
Node* n = r.jsgraph()->Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepTagged, kRepFloat32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kTagged, Type::None(),
+ MachineRepresentation::kFloat32);
r.CheckFloat32Constant(c, *i);
}
}
@@ -256,7 +284,9 @@ TEST(ToFloat32_constant) {
{
FOR_FLOAT32_INPUTS(i) {
Node* n = r.jsgraph()->Float64Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepFloat32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat64, Type::None(),
+ MachineRepresentation::kFloat32);
r.CheckFloat32Constant(c, *i);
}
}
@@ -265,8 +295,9 @@ TEST(ToFloat32_constant) {
FOR_INT32_INPUTS(i) {
if (!IsFloat32Int32(*i)) continue;
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32,
- kRepFloat32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kFloat32);
r.CheckFloat32Constant(c, static_cast<float>(*i));
}
}
@@ -275,8 +306,9 @@ TEST(ToFloat32_constant) {
FOR_UINT32_INPUTS(i) {
if (!IsFloat32Uint32(*i)) continue;
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32,
- kRepFloat32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Unsigned32(),
+ MachineRepresentation::kFloat32);
r.CheckFloat32Constant(c, static_cast<float>(*i));
}
}
@@ -289,8 +321,9 @@ TEST(ToInt32_constant) {
{
FOR_INT32_INPUTS(i) {
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kWord32);
r.CheckInt32Constant(c, *i);
}
}
@@ -299,8 +332,9 @@ TEST(ToInt32_constant) {
FOR_INT32_INPUTS(i) {
if (!IsFloat32Int32(*i)) continue;
Node* n = r.jsgraph()->Float32Constant(static_cast<float>(*i));
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeInt32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat32, Type::Signed32(),
+ MachineRepresentation::kWord32);
r.CheckInt32Constant(c, *i);
}
}
@@ -308,8 +342,9 @@ TEST(ToInt32_constant) {
{
FOR_INT32_INPUTS(i) {
Node* n = r.jsgraph()->Float64Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeInt32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat64, Type::Signed32(),
+ MachineRepresentation::kWord32);
r.CheckInt32Constant(c, *i);
}
}
@@ -317,8 +352,9 @@ TEST(ToInt32_constant) {
{
FOR_INT32_INPUTS(i) {
Node* n = r.jsgraph()->Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepTagged | kTypeInt32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kTagged, Type::Signed32(),
+ MachineRepresentation::kWord32);
r.CheckInt32Constant(c, *i);
}
}
@@ -331,8 +367,9 @@ TEST(ToUint32_constant) {
{
FOR_UINT32_INPUTS(i) {
Node* n = r.jsgraph()->Int32Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord32, Type::Unsigned32(),
+ MachineRepresentation::kWord32);
r.CheckUint32Constant(c, *i);
}
}
@@ -341,8 +378,9 @@ TEST(ToUint32_constant) {
FOR_UINT32_INPUTS(i) {
if (!IsFloat32Uint32(*i)) continue;
Node* n = r.jsgraph()->Float32Constant(static_cast<float>(*i));
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeUint32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat32, Type::Unsigned32(),
+ MachineRepresentation::kWord32);
r.CheckUint32Constant(c, *i);
}
}
@@ -350,8 +388,9 @@ TEST(ToUint32_constant) {
{
FOR_UINT32_INPUTS(i) {
Node* n = r.jsgraph()->Float64Constant(*i);
- Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeUint32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kFloat64, Type::Unsigned32(),
+ MachineRepresentation::kWord32);
r.CheckUint32Constant(c, *i);
}
}
@@ -359,20 +398,21 @@ TEST(ToUint32_constant) {
{
FOR_UINT32_INPUTS(i) {
Node* n = r.jsgraph()->Constant(static_cast<double>(*i));
- Node* c = r.changer()->GetRepresentationFor(n, kRepTagged | kTypeUint32,
- kRepWord32);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kTagged, Type::Unsigned32(),
+ MachineRepresentation::kWord32);
r.CheckUint32Constant(c, *i);
}
}
}
-static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from,
- MachineTypeUnion to) {
+static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
+ Type* from_type, MachineRepresentation to) {
RepresentationChangerTester r;
Node* n = r.Parameter();
- Node* c = r.changer()->GetRepresentationFor(n, from, to);
+ Node* c = r.changer()->GetRepresentationFor(n, from, from_type, to);
CHECK_NE(c, n);
CHECK_EQ(expected, c->opcode());
@@ -381,12 +421,13 @@ static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from,
static void CheckTwoChanges(IrOpcode::Value expected2,
- IrOpcode::Value expected1, MachineTypeUnion from,
- MachineTypeUnion to) {
+ IrOpcode::Value expected1,
+ MachineRepresentation from, Type* from_type,
+ MachineRepresentation to) {
RepresentationChangerTester r;
Node* n = r.Parameter();
- Node* c1 = r.changer()->GetRepresentationFor(n, from, to);
+ Node* c1 = r.changer()->GetRepresentationFor(n, from, from_type, to);
CHECK_NE(c1, n);
CHECK_EQ(expected1, c1->opcode());
@@ -398,70 +439,92 @@ static void CheckTwoChanges(IrOpcode::Value expected2,
TEST(SingleChanges) {
- CheckChange(IrOpcode::kChangeBoolToBit, kRepTagged, kRepBit);
- CheckChange(IrOpcode::kChangeBitToBool, kRepBit, kRepTagged);
-
- CheckChange(IrOpcode::kChangeInt32ToTagged, kRepWord32 | kTypeInt32,
- kRepTagged);
- CheckChange(IrOpcode::kChangeUint32ToTagged, kRepWord32 | kTypeUint32,
- kRepTagged);
- CheckChange(IrOpcode::kChangeFloat64ToTagged, kRepFloat64, kRepTagged);
-
- CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged | kTypeInt32,
- kRepWord32);
- CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged | kTypeUint32,
- kRepWord32);
- CheckChange(IrOpcode::kChangeTaggedToFloat64, kRepTagged, kRepFloat64);
+ CheckChange(IrOpcode::kChangeBoolToBit, MachineRepresentation::kTagged,
+ Type::None(), MachineRepresentation::kBit);
+ CheckChange(IrOpcode::kChangeBitToBool, MachineRepresentation::kBit,
+ Type::None(), MachineRepresentation::kTagged);
+
+ CheckChange(IrOpcode::kChangeInt32ToTagged, MachineRepresentation::kWord32,
+ Type::Signed32(), MachineRepresentation::kTagged);
+ CheckChange(IrOpcode::kChangeUint32ToTagged, MachineRepresentation::kWord32,
+ Type::Unsigned32(), MachineRepresentation::kTagged);
+ CheckChange(IrOpcode::kChangeFloat64ToTagged, MachineRepresentation::kFloat64,
+ Type::None(), MachineRepresentation::kTagged);
+
+ CheckChange(IrOpcode::kChangeTaggedToInt32, MachineRepresentation::kTagged,
+ Type::Signed32(), MachineRepresentation::kWord32);
+ CheckChange(IrOpcode::kChangeTaggedToUint32, MachineRepresentation::kTagged,
+ Type::Unsigned32(), MachineRepresentation::kWord32);
+ CheckChange(IrOpcode::kChangeTaggedToFloat64, MachineRepresentation::kTagged,
+ Type::None(), MachineRepresentation::kFloat64);
// Int32,Uint32 <-> Float64 are actually machine conversions.
- CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32 | kTypeInt32,
- kRepFloat64);
- CheckChange(IrOpcode::kChangeUint32ToFloat64, kRepWord32 | kTypeUint32,
- kRepFloat64);
- CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64 | kTypeInt32,
- kRepWord32);
- CheckChange(IrOpcode::kChangeFloat64ToUint32, kRepFloat64 | kTypeUint32,
- kRepWord32);
-
- CheckChange(IrOpcode::kTruncateFloat64ToFloat32, kRepFloat64, kRepFloat32);
+ CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32,
+ Type::Signed32(), MachineRepresentation::kFloat64);
+ CheckChange(IrOpcode::kChangeUint32ToFloat64, MachineRepresentation::kWord32,
+ Type::Unsigned32(), MachineRepresentation::kFloat64);
+ CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64,
+ Type::Signed32(), MachineRepresentation::kWord32);
+ CheckChange(IrOpcode::kChangeFloat64ToUint32, MachineRepresentation::kFloat64,
+ Type::Unsigned32(), MachineRepresentation::kWord32);
+
+ CheckChange(IrOpcode::kTruncateFloat64ToFloat32,
+ MachineRepresentation::kFloat64, Type::None(),
+ MachineRepresentation::kFloat32);
// Int32,Uint32 <-> Float32 require two changes.
CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64,
- IrOpcode::kTruncateFloat64ToFloat32, kRepWord32 | kTypeInt32,
- kRepFloat32);
+ IrOpcode::kTruncateFloat64ToFloat32,
+ MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kFloat32);
CheckTwoChanges(IrOpcode::kChangeUint32ToFloat64,
- IrOpcode::kTruncateFloat64ToFloat32, kRepWord32 | kTypeUint32,
- kRepFloat32);
+ IrOpcode::kTruncateFloat64ToFloat32,
+ MachineRepresentation::kWord32, Type::Unsigned32(),
+ MachineRepresentation::kFloat32);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
- IrOpcode::kChangeFloat64ToInt32, kRepFloat32 | kTypeInt32,
- kRepWord32);
+ IrOpcode::kChangeFloat64ToInt32,
+ MachineRepresentation::kFloat32, Type::Signed32(),
+ MachineRepresentation::kWord32);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
- IrOpcode::kChangeFloat64ToUint32, kRepFloat32 | kTypeUint32,
- kRepWord32);
+ IrOpcode::kChangeFloat64ToUint32,
+ MachineRepresentation::kFloat32, Type::Unsigned32(),
+ MachineRepresentation::kWord32);
// Float32 <-> Tagged require two changes.
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
- IrOpcode::kChangeFloat64ToTagged, kRepFloat32, kRepTagged);
+ IrOpcode::kChangeFloat64ToTagged,
+ MachineRepresentation::kFloat32, Type::None(),
+ MachineRepresentation::kTagged);
CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64,
- IrOpcode::kTruncateFloat64ToFloat32, kRepTagged, kRepFloat32);
+ IrOpcode::kTruncateFloat64ToFloat32,
+ MachineRepresentation::kTagged, Type::None(),
+ MachineRepresentation::kFloat32);
}
TEST(SignednessInWord32) {
RepresentationChangerTester r;
- // TODO(titzer): assume that uses of a word32 without a sign mean kTypeInt32.
- CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged,
- kRepWord32 | kTypeInt32);
- CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged,
- kRepWord32 | kTypeUint32);
- CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64);
- CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64, kRepWord32);
+ CheckChange(IrOpcode::kChangeTaggedToInt32, MachineRepresentation::kTagged,
+ Type::Signed32(), MachineRepresentation::kWord32);
+ CheckChange(IrOpcode::kChangeTaggedToUint32, MachineRepresentation::kTagged,
+ Type::Unsigned32(), MachineRepresentation::kWord32);
+ CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32,
+ Type::None(), MachineRepresentation::kFloat64);
+ CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64,
+ Type::Signed32(), MachineRepresentation::kWord32);
+ CheckChange(IrOpcode::kTruncateFloat64ToInt32,
+ MachineRepresentation::kFloat64, Type::Number(),
+ MachineRepresentation::kWord32);
CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64,
- IrOpcode::kTruncateFloat64ToFloat32, kRepWord32, kRepFloat32);
+ IrOpcode::kTruncateFloat64ToFloat32,
+ MachineRepresentation::kWord32, Type::None(),
+ MachineRepresentation::kFloat32);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
- IrOpcode::kChangeFloat64ToInt32, kRepFloat32, kRepWord32);
+ IrOpcode::kTruncateFloat64ToInt32,
+ MachineRepresentation::kFloat32, Type::Number(),
+ MachineRepresentation::kWord32);
}
@@ -469,33 +532,48 @@ TEST(Nops) {
RepresentationChangerTester r;
// X -> X is always a nop for any single representation X.
- for (size_t i = 0; i < arraysize(all_reps); i++) {
- r.CheckNop(all_reps[i], all_reps[i]);
+ for (size_t i = 0; i < arraysize(kMachineTypes); i++) {
+ r.CheckNop(kMachineTypes[i].representation(), Type::None(),
+ kMachineTypes[i].representation());
}
// 32-bit floats.
- r.CheckNop(kRepFloat32, kRepFloat32);
- r.CheckNop(kRepFloat32 | kTypeNumber, kRepFloat32);
- r.CheckNop(kRepFloat32, kRepFloat32 | kTypeNumber);
+ r.CheckNop(MachineRepresentation::kFloat32, Type::None(),
+ MachineRepresentation::kFloat32);
+ r.CheckNop(MachineRepresentation::kFloat32, Type::Number(),
+ MachineRepresentation::kFloat32);
// 32-bit words can be used as smaller word sizes and vice versa, because
// loads from memory implicitly sign or zero extend the value to the
// full machine word size, and stores implicitly truncate.
- r.CheckNop(kRepWord32, kRepWord8);
- r.CheckNop(kRepWord32, kRepWord16);
- r.CheckNop(kRepWord32, kRepWord32);
- r.CheckNop(kRepWord8, kRepWord32);
- r.CheckNop(kRepWord16, kRepWord32);
+ r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kWord8);
+ r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kWord16);
+ r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kWord32);
+ r.CheckNop(MachineRepresentation::kWord8, Type::Signed32(),
+ MachineRepresentation::kWord32);
+ r.CheckNop(MachineRepresentation::kWord16, Type::Signed32(),
+ MachineRepresentation::kWord32);
// kRepBit (result of comparison) is implicitly a wordish thing.
- r.CheckNop(kRepBit, kRepWord8);
- r.CheckNop(kRepBit | kTypeBool, kRepWord8);
- r.CheckNop(kRepBit, kRepWord16);
- r.CheckNop(kRepBit | kTypeBool, kRepWord16);
- r.CheckNop(kRepBit, kRepWord32);
- r.CheckNop(kRepBit | kTypeBool, kRepWord32);
- r.CheckNop(kRepBit, kRepWord64);
- r.CheckNop(kRepBit | kTypeBool, kRepWord64);
+ r.CheckNop(MachineRepresentation::kBit, Type::None(),
+ MachineRepresentation::kWord8);
+ r.CheckNop(MachineRepresentation::kBit, Type::None(),
+ MachineRepresentation::kWord16);
+ r.CheckNop(MachineRepresentation::kBit, Type::None(),
+ MachineRepresentation::kWord32);
+ r.CheckNop(MachineRepresentation::kBit, Type::None(),
+ MachineRepresentation::kWord64);
+ r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
+ MachineRepresentation::kWord8);
+ r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
+ MachineRepresentation::kWord16);
+ r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
+ MachineRepresentation::kWord32);
+ r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
+ MachineRepresentation::kWord64);
}
@@ -503,49 +581,48 @@ TEST(TypeErrors) {
RepresentationChangerTester r;
// Wordish cannot be implicitly converted to/from comparison conditions.
- r.CheckTypeError(kRepWord8, kRepBit);
- r.CheckTypeError(kRepWord8, kRepBit | kTypeBool);
- r.CheckTypeError(kRepWord16, kRepBit);
- r.CheckTypeError(kRepWord16, kRepBit | kTypeBool);
- r.CheckTypeError(kRepWord32, kRepBit);
- r.CheckTypeError(kRepWord32, kRepBit | kTypeBool);
- r.CheckTypeError(kRepWord64, kRepBit);
- r.CheckTypeError(kRepWord64, kRepBit | kTypeBool);
+ r.CheckTypeError(MachineRepresentation::kWord8, Type::None(),
+ MachineRepresentation::kBit);
+ r.CheckTypeError(MachineRepresentation::kWord16, Type::None(),
+ MachineRepresentation::kBit);
+ r.CheckTypeError(MachineRepresentation::kWord32, Type::None(),
+ MachineRepresentation::kBit);
+ r.CheckTypeError(MachineRepresentation::kWord64, Type::None(),
+ MachineRepresentation::kBit);
// Floats cannot be implicitly converted to/from comparison conditions.
- r.CheckTypeError(kRepFloat64, kRepBit);
- r.CheckTypeError(kRepFloat64, kRepBit | kTypeBool);
- r.CheckTypeError(kRepBit, kRepFloat64);
- r.CheckTypeError(kRepBit | kTypeBool, kRepFloat64);
+ r.CheckTypeError(MachineRepresentation::kFloat64, Type::None(),
+ MachineRepresentation::kBit);
+ r.CheckTypeError(MachineRepresentation::kBit, Type::None(),
+ MachineRepresentation::kFloat64);
+ r.CheckTypeError(MachineRepresentation::kBit, Type::Boolean(),
+ MachineRepresentation::kFloat64);
// Floats cannot be implicitly converted to/from comparison conditions.
- r.CheckTypeError(kRepFloat32, kRepBit);
- r.CheckTypeError(kRepFloat32, kRepBit | kTypeBool);
- r.CheckTypeError(kRepBit, kRepFloat32);
- r.CheckTypeError(kRepBit | kTypeBool, kRepFloat32);
+ r.CheckTypeError(MachineRepresentation::kFloat32, Type::None(),
+ MachineRepresentation::kBit);
+ r.CheckTypeError(MachineRepresentation::kBit, Type::None(),
+ MachineRepresentation::kFloat32);
+ r.CheckTypeError(MachineRepresentation::kBit, Type::Boolean(),
+ MachineRepresentation::kFloat32);
// Word64 is internal and shouldn't be implicitly converted.
- r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool);
- r.CheckTypeError(kRepWord64, kRepTagged);
- r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool);
- r.CheckTypeError(kRepTagged, kRepWord64);
- r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64);
+ r.CheckTypeError(MachineRepresentation::kWord64, Type::None(),
+ MachineRepresentation::kTagged);
+ r.CheckTypeError(MachineRepresentation::kTagged, Type::None(),
+ MachineRepresentation::kWord64);
+ r.CheckTypeError(MachineRepresentation::kTagged, Type::Boolean(),
+ MachineRepresentation::kWord64);
// Word64 / Word32 shouldn't be implicitly converted.
- r.CheckTypeError(kRepWord64, kRepWord32);
- r.CheckTypeError(kRepWord32, kRepWord64);
- r.CheckTypeError(kRepWord64, kRepWord32 | kTypeInt32);
- r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64);
- r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32);
- r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64);
-
- for (size_t i = 0; i < arraysize(all_reps); i++) {
- for (size_t j = 0; j < arraysize(all_reps); j++) {
- if (i == j) continue;
- // Only a single from representation is allowed.
- r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged);
- }
- }
+ r.CheckTypeError(MachineRepresentation::kWord64, Type::None(),
+ MachineRepresentation::kWord32);
+ r.CheckTypeError(MachineRepresentation::kWord32, Type::None(),
+ MachineRepresentation::kWord64);
+ r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(),
+ MachineRepresentation::kWord64);
+ r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(),
+ MachineRepresentation::kWord64);
}
} // namespace compiler