[turbofan] Move more type checks to the representation selector.
Get rid of further typing checks from ChangeLowering and put them into the representation selection pass instead (encoding the information in the operator instead). Drive-by-change: Rename ChangeSmiToInt32 to ChangeTaggedSignedToInt32 for consistency about naming Tagged, TaggedSigned and TaggedPointer. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1909343002 Cr-Commit-Position: refs/heads/master@{#35723}
This commit is contained in:
parent
ff7e6defff
commit
550c0f9f55
@ -33,8 +33,8 @@ Reduction ChangeLowering::Reduce(Node* node) {
|
||||
return ChangeInt31ToTagged(node->InputAt(0), control);
|
||||
case IrOpcode::kChangeInt32ToTagged:
|
||||
return ChangeInt32ToTagged(node->InputAt(0), control);
|
||||
case IrOpcode::kChangeSmiToInt32:
|
||||
return ChangeSmiToInt32(node->InputAt(0));
|
||||
case IrOpcode::kChangeTaggedSignedToInt32:
|
||||
return ChangeTaggedSignedToInt32(node->InputAt(0));
|
||||
case IrOpcode::kChangeTaggedToFloat64:
|
||||
return ChangeTaggedToFloat64(node->InputAt(0), control);
|
||||
case IrOpcode::kChangeTaggedToInt32:
|
||||
@ -272,16 +272,12 @@ Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) {
|
||||
return Replace(value);
|
||||
}
|
||||
|
||||
Reduction ChangeLowering::ChangeSmiToInt32(Node* value) {
|
||||
Reduction ChangeLowering::ChangeTaggedSignedToInt32(Node* value) {
|
||||
return Replace(ChangeSmiToWord32(value));
|
||||
}
|
||||
|
||||
Reduction ChangeLowering::ChangeTaggedToUI32(Node* value, Node* control,
|
||||
Signedness signedness) {
|
||||
if (NodeProperties::GetType(value)->Is(Type::TaggedSigned())) {
|
||||
return ChangeSmiToInt32(value);
|
||||
}
|
||||
|
||||
const Operator* op = (signedness == kSigned)
|
||||
? machine()->ChangeFloat64ToInt32()
|
||||
: machine()->ChangeFloat64ToUint32();
|
||||
|
@ -46,7 +46,7 @@ class ChangeLowering final : public Reducer {
|
||||
Reduction ChangeFloat64ToTagged(Node* value, Node* control);
|
||||
Reduction ChangeInt31ToTagged(Node* value, Node* control);
|
||||
Reduction ChangeInt32ToTagged(Node* value, Node* control);
|
||||
Reduction ChangeSmiToInt32(Node* value);
|
||||
Reduction ChangeTaggedSignedToInt32(Node* value);
|
||||
Reduction ChangeTaggedToFloat64(Node* value, Node* control);
|
||||
Reduction ChangeTaggedToUI32(Node* value, Node* control,
|
||||
Signedness signedness);
|
||||
|
@ -196,7 +196,7 @@
|
||||
V(NumberToUint32) \
|
||||
V(NumberIsHoleNaN) \
|
||||
V(StringToNumber) \
|
||||
V(ChangeSmiToInt32) \
|
||||
V(ChangeTaggedSignedToInt32) \
|
||||
V(ChangeTaggedToInt32) \
|
||||
V(ChangeTaggedToUint32) \
|
||||
V(ChangeTaggedToFloat64) \
|
||||
|
@ -322,7 +322,13 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
|
||||
op = machine()->ChangeUint32ToFloat64();
|
||||
}
|
||||
} else if (output_rep == MachineRepresentation::kTagged) {
|
||||
if (output_type->Is(Type::NumberOrUndefined())) {
|
||||
if (output_type->Is(Type::Undefined())) {
|
||||
return jsgraph()->Float64Constant(
|
||||
std::numeric_limits<double>::quiet_NaN());
|
||||
} else if (output_type->Is(Type::TaggedSigned())) {
|
||||
node = InsertChangeTaggedSignedToInt32(node);
|
||||
op = machine()->ChangeInt32ToFloat64();
|
||||
} else if (output_type->Is(Type::NumberOrUndefined())) {
|
||||
op = simplified()->ChangeTaggedToFloat64();
|
||||
}
|
||||
} else if (output_rep == MachineRepresentation::kFloat32) {
|
||||
@ -377,7 +383,9 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
|
||||
op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
|
||||
}
|
||||
} else if (output_rep == MachineRepresentation::kTagged) {
|
||||
if (output_type->Is(Type::Unsigned32())) {
|
||||
if (output_type->Is(Type::TaggedSigned())) {
|
||||
op = simplified()->ChangeTaggedSignedToInt32();
|
||||
} else if (output_type->Is(Type::Unsigned32())) {
|
||||
op = simplified()->ChangeTaggedToUint32();
|
||||
} else if (output_type->Is(Type::Signed32())) {
|
||||
op = simplified()->ChangeTaggedToInt32();
|
||||
@ -553,6 +561,11 @@ Node* RepresentationChanger::InsertChangeFloat64ToInt32(Node* node) {
|
||||
return jsgraph()->graph()->NewNode(machine()->ChangeFloat64ToInt32(), node);
|
||||
}
|
||||
|
||||
Node* RepresentationChanger::InsertChangeTaggedSignedToInt32(Node* node) {
|
||||
return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(),
|
||||
node);
|
||||
}
|
||||
|
||||
Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
|
||||
return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
|
||||
node);
|
||||
|
@ -135,6 +135,7 @@ class RepresentationChanger final {
|
||||
Node* InsertChangeFloat32ToFloat64(Node* node);
|
||||
Node* InsertChangeFloat64ToInt32(Node* node);
|
||||
Node* InsertChangeFloat64ToUint32(Node* node);
|
||||
Node* InsertChangeTaggedSignedToInt32(Node* node);
|
||||
Node* InsertChangeTaggedToFloat64(Node* node);
|
||||
|
||||
JSGraph* jsgraph() const { return jsgraph_; }
|
||||
|
@ -1486,7 +1486,7 @@ void SimplifiedLowering::DoJSToNumberTruncatesToFloat64(
|
||||
Node* etrue0 = effect;
|
||||
Node* vtrue0;
|
||||
{
|
||||
vtrue0 = graph()->NewNode(simplified()->ChangeSmiToInt32(), value);
|
||||
vtrue0 = graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value);
|
||||
vtrue0 = graph()->NewNode(machine()->ChangeInt32ToFloat64(), vtrue0);
|
||||
}
|
||||
|
||||
@ -1506,7 +1506,8 @@ void SimplifiedLowering::DoJSToNumberTruncatesToFloat64(
|
||||
Node* etrue1 = efalse0;
|
||||
Node* vtrue1;
|
||||
{
|
||||
vtrue1 = graph()->NewNode(simplified()->ChangeSmiToInt32(), vfalse0);
|
||||
vtrue1 =
|
||||
graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), vfalse0);
|
||||
vtrue1 = graph()->NewNode(machine()->ChangeInt32ToFloat64(), vtrue1);
|
||||
}
|
||||
|
||||
@ -1567,7 +1568,8 @@ void SimplifiedLowering::DoJSToNumberTruncatesToWord32(
|
||||
|
||||
Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
|
||||
Node* etrue0 = effect;
|
||||
Node* vtrue0 = graph()->NewNode(simplified()->ChangeSmiToInt32(), value);
|
||||
Node* vtrue0 =
|
||||
graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), value);
|
||||
|
||||
Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
|
||||
Node* efalse0 = effect;
|
||||
@ -1583,7 +1585,8 @@ void SimplifiedLowering::DoJSToNumberTruncatesToWord32(
|
||||
|
||||
Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
|
||||
Node* etrue1 = efalse0;
|
||||
Node* vtrue1 = graph()->NewNode(simplified()->ChangeSmiToInt32(), vfalse0);
|
||||
Node* vtrue1 =
|
||||
graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(), vfalse0);
|
||||
|
||||
Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
|
||||
Node* efalse1 = efalse0;
|
||||
|
@ -54,6 +54,9 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
|
||||
case IrOpcode::kChangeInt32ToTagged: {
|
||||
Int32Matcher m(node->InputAt(0));
|
||||
if (m.HasValue()) return ReplaceNumber(m.Value());
|
||||
if (m.IsChangeTaggedToInt32() || m.IsChangeTaggedSignedToInt32()) {
|
||||
return Replace(m.InputAt(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kChangeTaggedToFloat64: {
|
||||
|
@ -156,50 +156,50 @@ const ElementAccess& ElementAccessOf(const Operator* op) {
|
||||
return OpParameter<ElementAccess>(op);
|
||||
}
|
||||
|
||||
#define PURE_OP_LIST(V) \
|
||||
V(BooleanNot, Operator::kNoProperties, 1) \
|
||||
V(BooleanToNumber, Operator::kNoProperties, 1) \
|
||||
V(NumberEqual, Operator::kCommutative, 2) \
|
||||
V(NumberLessThan, Operator::kNoProperties, 2) \
|
||||
V(NumberLessThanOrEqual, Operator::kNoProperties, 2) \
|
||||
V(NumberAdd, Operator::kCommutative, 2) \
|
||||
V(NumberSubtract, Operator::kNoProperties, 2) \
|
||||
V(NumberMultiply, Operator::kCommutative, 2) \
|
||||
V(NumberDivide, Operator::kNoProperties, 2) \
|
||||
V(NumberModulus, Operator::kNoProperties, 2) \
|
||||
V(NumberBitwiseOr, Operator::kCommutative, 2) \
|
||||
V(NumberBitwiseXor, Operator::kCommutative, 2) \
|
||||
V(NumberBitwiseAnd, Operator::kCommutative, 2) \
|
||||
V(NumberShiftLeft, Operator::kNoProperties, 2) \
|
||||
V(NumberShiftRight, Operator::kNoProperties, 2) \
|
||||
V(NumberShiftRightLogical, Operator::kNoProperties, 2) \
|
||||
V(NumberClz32, Operator::kNoProperties, 1) \
|
||||
V(NumberCeil, Operator::kNoProperties, 1) \
|
||||
V(NumberFloor, Operator::kNoProperties, 1) \
|
||||
V(NumberRound, Operator::kNoProperties, 1) \
|
||||
V(NumberTrunc, Operator::kNoProperties, 1) \
|
||||
V(NumberToInt32, Operator::kNoProperties, 1) \
|
||||
V(NumberToUint32, Operator::kNoProperties, 1) \
|
||||
V(NumberIsHoleNaN, Operator::kNoProperties, 1) \
|
||||
V(StringToNumber, Operator::kNoProperties, 1) \
|
||||
V(ChangeSmiToInt32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \
|
||||
V(ChangeInt31ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeBoolToBit, Operator::kNoProperties, 1) \
|
||||
V(ChangeBitToBool, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsCallable, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsNumber, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsReceiver, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsSmi, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsString, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsUndetectable, Operator::kNoProperties, 1) \
|
||||
V(StringEqual, Operator::kCommutative, 2) \
|
||||
V(StringLessThan, Operator::kNoProperties, 2) \
|
||||
#define PURE_OP_LIST(V) \
|
||||
V(BooleanNot, Operator::kNoProperties, 1) \
|
||||
V(BooleanToNumber, Operator::kNoProperties, 1) \
|
||||
V(NumberEqual, Operator::kCommutative, 2) \
|
||||
V(NumberLessThan, Operator::kNoProperties, 2) \
|
||||
V(NumberLessThanOrEqual, Operator::kNoProperties, 2) \
|
||||
V(NumberAdd, Operator::kCommutative, 2) \
|
||||
V(NumberSubtract, Operator::kNoProperties, 2) \
|
||||
V(NumberMultiply, Operator::kCommutative, 2) \
|
||||
V(NumberDivide, Operator::kNoProperties, 2) \
|
||||
V(NumberModulus, Operator::kNoProperties, 2) \
|
||||
V(NumberBitwiseOr, Operator::kCommutative, 2) \
|
||||
V(NumberBitwiseXor, Operator::kCommutative, 2) \
|
||||
V(NumberBitwiseAnd, Operator::kCommutative, 2) \
|
||||
V(NumberShiftLeft, Operator::kNoProperties, 2) \
|
||||
V(NumberShiftRight, Operator::kNoProperties, 2) \
|
||||
V(NumberShiftRightLogical, Operator::kNoProperties, 2) \
|
||||
V(NumberClz32, Operator::kNoProperties, 1) \
|
||||
V(NumberCeil, Operator::kNoProperties, 1) \
|
||||
V(NumberFloor, Operator::kNoProperties, 1) \
|
||||
V(NumberRound, Operator::kNoProperties, 1) \
|
||||
V(NumberTrunc, Operator::kNoProperties, 1) \
|
||||
V(NumberToInt32, Operator::kNoProperties, 1) \
|
||||
V(NumberToUint32, Operator::kNoProperties, 1) \
|
||||
V(NumberIsHoleNaN, Operator::kNoProperties, 1) \
|
||||
V(StringToNumber, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \
|
||||
V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \
|
||||
V(ChangeInt31ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeInt32ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeUint32ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeFloat64ToTagged, Operator::kNoProperties, 1) \
|
||||
V(ChangeBoolToBit, Operator::kNoProperties, 1) \
|
||||
V(ChangeBitToBool, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsCallable, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsNumber, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsReceiver, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsSmi, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsString, Operator::kNoProperties, 1) \
|
||||
V(ObjectIsUndetectable, Operator::kNoProperties, 1) \
|
||||
V(StringEqual, Operator::kCommutative, 2) \
|
||||
V(StringLessThan, Operator::kNoProperties, 2) \
|
||||
V(StringLessThanOrEqual, Operator::kNoProperties, 2)
|
||||
|
||||
struct SimplifiedOperatorGlobalCache final {
|
||||
|
@ -159,7 +159,7 @@ class SimplifiedOperatorBuilder final : public ZoneObject {
|
||||
const Operator* StringLessThanOrEqual();
|
||||
const Operator* StringToNumber();
|
||||
|
||||
const Operator* ChangeSmiToInt32();
|
||||
const Operator* ChangeTaggedSignedToInt32();
|
||||
const Operator* ChangeTaggedToInt32();
|
||||
const Operator* ChangeTaggedToUint32();
|
||||
const Operator* ChangeTaggedToFloat64();
|
||||
|
@ -1845,7 +1845,7 @@ Type* ChangeRepresentation(Type* type, Type* rep, Zone* zone) {
|
||||
|
||||
} // namespace
|
||||
|
||||
Type* Typer::Visitor::TypeChangeSmiToInt32(Node* node) {
|
||||
Type* Typer::Visitor::TypeChangeTaggedSignedToInt32(Node* node) {
|
||||
Type* arg = Operand(node, 0);
|
||||
// TODO(neis): DCHECK(arg->Is(Type::Signed32()));
|
||||
return ChangeRepresentation(arg, Type::UntaggedIntegral32(), zone());
|
||||
|
@ -760,7 +760,7 @@ void Verifier::Visitor::Check(Node* node) {
|
||||
CheckUpperIs(node, Type::TaggedPointer());
|
||||
break;
|
||||
|
||||
case IrOpcode::kChangeSmiToInt32: {
|
||||
case IrOpcode::kChangeTaggedSignedToInt32: {
|
||||
// Signed32 /\ Tagged -> Signed32 /\ UntaggedInt32
|
||||
// TODO(neis): Activate once ChangeRepresentation works in typer.
|
||||
// Type* from = Type::Intersect(Type::Signed32(), Type::Tagged());
|
||||
|
@ -470,7 +470,13 @@ TEST(SingleChanges) {
|
||||
CheckChange(IrOpcode::kChangeTaggedToUint32, MachineRepresentation::kTagged,
|
||||
Type::Unsigned32(), MachineRepresentation::kWord32);
|
||||
CheckChange(IrOpcode::kChangeTaggedToFloat64, MachineRepresentation::kTagged,
|
||||
Type::None(), MachineRepresentation::kFloat64);
|
||||
Type::Number(), MachineRepresentation::kFloat64);
|
||||
CheckChange(IrOpcode::kChangeTaggedToFloat64, MachineRepresentation::kTagged,
|
||||
Type::NumberOrUndefined(), MachineRepresentation::kFloat64);
|
||||
CheckTwoChanges(IrOpcode::kChangeTaggedSignedToInt32,
|
||||
IrOpcode::kChangeInt32ToFloat64,
|
||||
MachineRepresentation::kTagged, Type::TaggedSigned(),
|
||||
MachineRepresentation::kFloat64);
|
||||
|
||||
// Int32,Uint32 <-> Float64 are actually machine conversions.
|
||||
CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32,
|
||||
|
@ -132,14 +132,6 @@ TARGET_TEST_P(ChangeLoweringCommonTest, ChangeInt31ToTagged) {
|
||||
EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value));
|
||||
}
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToInt32WithTaggedSigned) {
|
||||
Node* value = Parameter(Type::TaggedSigned());
|
||||
Reduction r =
|
||||
Reduce(graph()->NewNode(simplified()->ChangeTaggedToInt32(), value));
|
||||
ASSERT_TRUE(r.Changed());
|
||||
EXPECT_THAT(r.replacement(), IsChangeSmiToInt32(value));
|
||||
}
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToInt32WithTaggedNumber) {
|
||||
Node* value =
|
||||
Parameter(Type::Intersect(Type::TaggedPointer(), Type::Number(), zone()));
|
||||
@ -150,16 +142,6 @@ TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToInt32WithTaggedNumber) {
|
||||
IsLoadHeapNumber(value, graph()->start())));
|
||||
}
|
||||
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToUint32WithTaggedSigned) {
|
||||
Node* value = Parameter(Type::TaggedSigned());
|
||||
Reduction r =
|
||||
Reduce(graph()->NewNode(simplified()->ChangeTaggedToUint32(), value));
|
||||
ASSERT_TRUE(r.Changed());
|
||||
EXPECT_THAT(r.replacement(), IsChangeSmiToInt32(value));
|
||||
}
|
||||
|
||||
|
||||
TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToUint32WithTaggedPointer) {
|
||||
Node* value =
|
||||
Parameter(Type::Intersect(Type::TaggedPointer(), Type::Number(), zone()));
|
||||
|
Loading…
Reference in New Issue
Block a user