Commit a04467f9 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Sanitize the Truncation query method names.

Use better names for the query methods on the Truncation class, that
express more clearly what you intend to query.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2171703002
Cr-Commit-Position: refs/heads/master@{#37935}
parent 4b59bf53
...@@ -278,7 +278,7 @@ Node* RepresentationChanger::GetFloat32RepresentationFor( ...@@ -278,7 +278,7 @@ Node* RepresentationChanger::GetFloat32RepresentationFor(
node = jsgraph()->graph()->NewNode(op, node); node = jsgraph()->graph()->NewNode(op, node);
op = machine()->TruncateFloat64ToFloat32(); op = machine()->TruncateFloat64ToFloat32();
} else if (output_type->Is(Type::Unsigned32()) || } else if (output_type->Is(Type::Unsigned32()) ||
truncation.TruncatesToWord32()) { truncation.IsUsedAsWord32()) {
// Either the output is uint32 or the uses only care about the // Either the output is uint32 or the uses only care about the
// low 32 bits (so we can pick uint32 safely). // low 32 bits (so we can pick uint32 safely).
...@@ -340,7 +340,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor( ...@@ -340,7 +340,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
if (output_type->Is(Type::Signed32())) { if (output_type->Is(Type::Signed32())) {
op = machine()->ChangeInt32ToFloat64(); op = machine()->ChangeInt32ToFloat64();
} else if (output_type->Is(Type::Unsigned32()) || } else if (output_type->Is(Type::Unsigned32()) ||
use_info.truncation().TruncatesToWord32()) { use_info.truncation().IsUsedAsWord32()) {
// Either the output is uint32 or the uses only care about the // Either the output is uint32 or the uses only care about the
// low 32 bits (so we can pick uint32 safely). // low 32 bits (so we can pick uint32 safely).
op = machine()->ChangeUint32ToFloat64(); op = machine()->ChangeUint32ToFloat64();
...@@ -415,7 +415,7 @@ Node* RepresentationChanger::GetWord32RepresentationFor( ...@@ -415,7 +415,7 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
op = machine()->ChangeFloat64ToUint32(); op = machine()->ChangeFloat64ToUint32();
} else if (output_type->Is(Type::Signed32())) { } else if (output_type->Is(Type::Signed32())) {
op = machine()->ChangeFloat64ToInt32(); op = machine()->ChangeFloat64ToInt32();
} else if (use_info.truncation().TruncatesToWord32()) { } else if (use_info.truncation().IsUsedAsWord32()) {
op = machine()->TruncateFloat64ToWord32(); op = machine()->TruncateFloat64ToWord32();
} else if (use_info.type_check() == TypeCheckKind::kSigned32) { } else if (use_info.type_check() == TypeCheckKind::kSigned32) {
op = simplified()->CheckedFloat64ToInt32(); op = simplified()->CheckedFloat64ToInt32();
...@@ -426,7 +426,7 @@ Node* RepresentationChanger::GetWord32RepresentationFor( ...@@ -426,7 +426,7 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
op = machine()->ChangeFloat64ToUint32(); op = machine()->ChangeFloat64ToUint32();
} else if (output_type->Is(Type::Signed32())) { } else if (output_type->Is(Type::Signed32())) {
op = machine()->ChangeFloat64ToInt32(); op = machine()->ChangeFloat64ToInt32();
} else if (use_info.truncation().TruncatesToWord32()) { } else if (use_info.truncation().IsUsedAsWord32()) {
op = machine()->TruncateFloat64ToWord32(); op = machine()->TruncateFloat64ToWord32();
} else if (use_info.type_check() == TypeCheckKind::kSigned32) { } else if (use_info.type_check() == TypeCheckKind::kSigned32) {
op = simplified()->CheckedFloat64ToInt32(); op = simplified()->CheckedFloat64ToInt32();
...@@ -438,7 +438,7 @@ Node* RepresentationChanger::GetWord32RepresentationFor( ...@@ -438,7 +438,7 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
op = simplified()->ChangeTaggedToUint32(); op = simplified()->ChangeTaggedToUint32();
} else if (output_type->Is(Type::Signed32())) { } else if (output_type->Is(Type::Signed32())) {
op = simplified()->ChangeTaggedToInt32(); op = simplified()->ChangeTaggedToInt32();
} else if (use_info.truncation().TruncatesToWord32()) { } else if (use_info.truncation().IsUsedAsWord32()) {
op = simplified()->TruncateTaggedToWord32(); op = simplified()->TruncateTaggedToWord32();
} else if (use_info.type_check() == TypeCheckKind::kSigned32) { } else if (use_info.type_check() == TypeCheckKind::kSigned32) {
op = simplified()->CheckedTaggedToInt32(); op = simplified()->CheckedTaggedToInt32();
...@@ -543,7 +543,7 @@ Node* RepresentationChanger::GetCheckedWord32RepresentationFor( ...@@ -543,7 +543,7 @@ Node* RepresentationChanger::GetCheckedWord32RepresentationFor(
op = machine()->ChangeFloat64ToUint32(); op = machine()->ChangeFloat64ToUint32();
} else if (output_type->Is(Type::Signed32())) { } else if (output_type->Is(Type::Signed32())) {
op = machine()->ChangeFloat64ToInt32(); op = machine()->ChangeFloat64ToInt32();
} else if (truncation.TruncatesToWord32()) { } else if (truncation.IsUsedAsWord32()) {
op = machine()->TruncateFloat64ToWord32(); op = machine()->TruncateFloat64ToWord32();
} else if (check == TypeCheckKind::kSigned32) { } else if (check == TypeCheckKind::kSigned32) {
op = simplified()->CheckedFloat64ToInt32(); op = simplified()->CheckedFloat64ToInt32();
...@@ -554,7 +554,7 @@ Node* RepresentationChanger::GetCheckedWord32RepresentationFor( ...@@ -554,7 +554,7 @@ Node* RepresentationChanger::GetCheckedWord32RepresentationFor(
op = machine()->ChangeFloat64ToUint32(); op = machine()->ChangeFloat64ToUint32();
} else if (output_type->Is(Type::Signed32())) { } else if (output_type->Is(Type::Signed32())) {
op = machine()->ChangeFloat64ToInt32(); op = machine()->ChangeFloat64ToInt32();
} else if (truncation.TruncatesToWord32()) { } else if (truncation.IsUsedAsWord32()) {
op = machine()->TruncateFloat64ToWord32(); op = machine()->TruncateFloat64ToWord32();
} else if (check == TypeCheckKind::kSigned32) { } else if (check == TypeCheckKind::kSigned32) {
op = simplified()->CheckedFloat64ToInt32(); op = simplified()->CheckedFloat64ToInt32();
...@@ -566,7 +566,7 @@ Node* RepresentationChanger::GetCheckedWord32RepresentationFor( ...@@ -566,7 +566,7 @@ Node* RepresentationChanger::GetCheckedWord32RepresentationFor(
op = simplified()->ChangeTaggedToUint32(); op = simplified()->ChangeTaggedToUint32();
} else if (output_type->Is(Type::Signed32())) { } else if (output_type->Is(Type::Signed32())) {
op = simplified()->ChangeTaggedToInt32(); op = simplified()->ChangeTaggedToInt32();
} else if (truncation.TruncatesToWord32()) { } else if (truncation.IsUsedAsWord32()) {
op = simplified()->TruncateTaggedToWord32(); op = simplified()->TruncateTaggedToWord32();
} else if (check == TypeCheckKind::kSigned32) { } else if (check == TypeCheckKind::kSigned32) {
op = simplified()->CheckedTaggedToInt32(); op = simplified()->CheckedTaggedToInt32();
......
...@@ -29,17 +29,17 @@ class Truncation final { ...@@ -29,17 +29,17 @@ class Truncation final {
// Queries. // Queries.
bool IsUnused() const { return kind_ == TruncationKind::kNone; } bool IsUnused() const { return kind_ == TruncationKind::kNone; }
bool TruncatesToWord32() const { bool IsUsedAsWord32() const {
return LessGeneral(kind_, TruncationKind::kWord32); return LessGeneral(kind_, TruncationKind::kWord32);
} }
bool TruncatesToFloat64() const { bool IsUsedAsFloat64() const {
return LessGeneral(kind_, TruncationKind::kFloat64); return LessGeneral(kind_, TruncationKind::kFloat64);
} }
bool TruncatesNaNToZero() { bool IdentifiesNaNAndZero() {
return LessGeneral(kind_, TruncationKind::kWord32) || return LessGeneral(kind_, TruncationKind::kWord32) ||
LessGeneral(kind_, TruncationKind::kBool); LessGeneral(kind_, TruncationKind::kBool);
} }
bool TruncatesUndefinedToZeroOrNaN() { bool IdentifiesUndefinedAndNaNAndZero() {
return LessGeneral(kind_, TruncationKind::kFloat64) || return LessGeneral(kind_, TruncationKind::kFloat64) ||
LessGeneral(kind_, TruncationKind::kWord64); LessGeneral(kind_, TruncationKind::kWord64);
} }
......
...@@ -867,13 +867,13 @@ class RepresentationSelector { ...@@ -867,13 +867,13 @@ class RepresentationSelector {
return MachineRepresentation::kNone; return MachineRepresentation::kNone;
} else if (type->Is(Type::Signed32()) || type->Is(Type::Unsigned32())) { } else if (type->Is(Type::Signed32()) || type->Is(Type::Unsigned32())) {
return MachineRepresentation::kWord32; return MachineRepresentation::kWord32;
} else if (use.TruncatesToWord32()) { } else if (use.IsUsedAsWord32()) {
return MachineRepresentation::kWord32; return MachineRepresentation::kWord32;
} else if (type->Is(Type::Boolean())) { } else if (type->Is(Type::Boolean())) {
return MachineRepresentation::kBit; return MachineRepresentation::kBit;
} else if (type->Is(Type::Number())) { } else if (type->Is(Type::Number())) {
return MachineRepresentation::kFloat64; return MachineRepresentation::kFloat64;
} else if (use.TruncatesToFloat64()) { } else if (use.IsUsedAsFloat64()) {
return MachineRepresentation::kFloat64; return MachineRepresentation::kFloat64;
} else if (type->Is(Type::Internal())) { } else if (type->Is(Type::Internal())) {
// We mark (u)int64 as Type::Internal. // We mark (u)int64 as Type::Internal.
...@@ -1103,7 +1103,7 @@ class RepresentationSelector { ...@@ -1103,7 +1103,7 @@ class RepresentationSelector {
// If one of the inputs is positive and/or truncation is being applied, // If one of the inputs is positive and/or truncation is being applied,
// there is no need to return -0. // there is no need to return -0.
CheckForMinusZeroMode mz_mode = CheckForMinusZeroMode mz_mode =
truncation.TruncatesToWord32() || truncation.IsUsedAsWord32() ||
(input0_type->Is(Type::OrderedNumber()) && (input0_type->Is(Type::OrderedNumber()) &&
input0_type->Min() > 0) || input0_type->Min() > 0) ||
(input1_type->Is(Type::OrderedNumber()) && (input1_type->Is(Type::OrderedNumber()) &&
...@@ -1135,7 +1135,7 @@ class RepresentationSelector { ...@@ -1135,7 +1135,7 @@ class RepresentationSelector {
// Use truncation if available. // Use truncation if available.
if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) && if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
truncation.TruncatesToWord32()) { truncation.IsUsedAsWord32()) {
// safe-int + safe-int = x (truncated to int32) // safe-int + safe-int = x (truncated to int32)
// => signed Int32Add/Sub (truncated) // => signed Int32Add/Sub (truncated)
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
...@@ -1247,10 +1247,10 @@ class RepresentationSelector { ...@@ -1247,10 +1247,10 @@ class RepresentationSelector {
case IrOpcode::kJSToNumber: { case IrOpcode::kJSToNumber: {
VisitInputs(node); VisitInputs(node);
// TODO(bmeurer): Optimize somewhat based on input type? // TODO(bmeurer): Optimize somewhat based on input type?
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
SetOutput(node, MachineRepresentation::kWord32); SetOutput(node, MachineRepresentation::kWord32);
if (lower()) lowering->DoJSToNumberTruncatesToWord32(node, this); if (lower()) lowering->DoJSToNumberTruncatesToWord32(node, this);
} else if (truncation.TruncatesToFloat64()) { } else if (truncation.IsUsedAsFloat64()) {
SetOutput(node, MachineRepresentation::kFloat64); SetOutput(node, MachineRepresentation::kFloat64);
if (lower()) lowering->DoJSToNumberTruncatesToFloat64(node, this); if (lower()) lowering->DoJSToNumberTruncatesToFloat64(node, this);
} else { } else {
...@@ -1352,7 +1352,7 @@ class RepresentationSelector { ...@@ -1352,7 +1352,7 @@ class RepresentationSelector {
if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
} else if (BothInputsAre(node, } else if (BothInputsAre(node,
type_cache_.kAdditiveSafeIntegerOrMinusZero) && type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
truncation.TruncatesToWord32()) { truncation.IsUsedAsWord32()) {
// safe-int + safe-int = x (truncated to int32) // safe-int + safe-int = x (truncated to int32)
// => signed Int32Add/Sub (truncated) // => signed Int32Add/Sub (truncated)
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
...@@ -1369,7 +1369,7 @@ class RepresentationSelector { ...@@ -1369,7 +1369,7 @@ class RepresentationSelector {
if (BothInputsAre(node, Type::Integral32()) && if (BothInputsAre(node, Type::Integral32()) &&
(NodeProperties::GetType(node)->Is(Type::Signed32()) || (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
NodeProperties::GetType(node)->Is(Type::Unsigned32()) || NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
(truncation.TruncatesToWord32() && (truncation.IsUsedAsWord32() &&
NodeProperties::GetType(node)->Is( NodeProperties::GetType(node)->Is(
type_cache_.kSafeIntegerOrMinusZero)))) { type_cache_.kSafeIntegerOrMinusZero)))) {
// Multiply reduces to Int32Mul if the inputs are integers, and // Multiply reduces to Int32Mul if the inputs are integers, and
...@@ -1422,7 +1422,7 @@ class RepresentationSelector { ...@@ -1422,7 +1422,7 @@ class RepresentationSelector {
if (BothInputsAre(node, Type::Integral32()) && if (BothInputsAre(node, Type::Integral32()) &&
(NodeProperties::GetType(node)->Is(Type::Signed32()) || (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
NodeProperties::GetType(node)->Is(Type::Unsigned32()) || NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
(truncation.TruncatesToWord32() && (truncation.IsUsedAsWord32() &&
NodeProperties::GetType(node)->Is( NodeProperties::GetType(node)->Is(
type_cache_.kSafeIntegerOrMinusZero)))) { type_cache_.kSafeIntegerOrMinusZero)))) {
// Multiply reduces to Int32Mul if the inputs are integers, and // Multiply reduces to Int32Mul if the inputs are integers, and
...@@ -1441,7 +1441,7 @@ class RepresentationSelector { ...@@ -1441,7 +1441,7 @@ class RepresentationSelector {
} }
case IrOpcode::kSpeculativeNumberDivide: { case IrOpcode::kSpeculativeNumberDivide: {
if (truncation.IsUnused()) return VisitUnused(node); if (truncation.IsUnused()) return VisitUnused(node);
if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
// => unsigned Uint32Div // => unsigned Uint32Div
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Uint32Div(node)); if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
...@@ -1454,7 +1454,7 @@ class RepresentationSelector { ...@@ -1454,7 +1454,7 @@ class RepresentationSelector {
if (lower()) DeferReplacement(node, lowering->Int32Div(node)); if (lower()) DeferReplacement(node, lowering->Int32Div(node));
return; return;
} }
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
// => signed Int32Div // => signed Int32Div
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Int32Div(node)); if (lower()) DeferReplacement(node, lowering->Int32Div(node));
...@@ -1493,7 +1493,7 @@ class RepresentationSelector { ...@@ -1493,7 +1493,7 @@ class RepresentationSelector {
if (hint == BinaryOperationHints::kSignedSmall || if (hint == BinaryOperationHints::kSignedSmall ||
hint == BinaryOperationHints::kSigned32) { hint == BinaryOperationHints::kSigned32) {
// If the result is truncated, we only need to check the inputs. // If the result is truncated, we only need to check the inputs.
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kWord32); MachineRepresentation::kWord32);
if (lower()) DeferReplacement(node, lowering->Int32Div(node)); if (lower()) DeferReplacement(node, lowering->Int32Div(node));
...@@ -1512,7 +1512,7 @@ class RepresentationSelector { ...@@ -1512,7 +1512,7 @@ class RepresentationSelector {
return; return;
} }
case IrOpcode::kNumberDivide: { case IrOpcode::kNumberDivide: {
if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
// => unsigned Uint32Div // => unsigned Uint32Div
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Uint32Div(node)); if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
...@@ -1525,7 +1525,7 @@ class RepresentationSelector { ...@@ -1525,7 +1525,7 @@ class RepresentationSelector {
if (lower()) DeferReplacement(node, lowering->Int32Div(node)); if (lower()) DeferReplacement(node, lowering->Int32Div(node));
return; return;
} }
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
// => signed Int32Div // => signed Int32Div
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Int32Div(node)); if (lower()) DeferReplacement(node, lowering->Int32Div(node));
...@@ -1547,7 +1547,7 @@ class RepresentationSelector { ...@@ -1547,7 +1547,7 @@ class RepresentationSelector {
} }
case IrOpcode::kSpeculativeNumberModulus: { case IrOpcode::kSpeculativeNumberModulus: {
if (truncation.IsUnused()) return VisitUnused(node); if (truncation.IsUnused()) return VisitUnused(node);
if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
// => unsigned Uint32Mod // => unsigned Uint32Mod
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
...@@ -1560,7 +1560,7 @@ class RepresentationSelector { ...@@ -1560,7 +1560,7 @@ class RepresentationSelector {
if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
return; return;
} }
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
// => signed Int32Mod // => signed Int32Mod
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
...@@ -1599,7 +1599,7 @@ class RepresentationSelector { ...@@ -1599,7 +1599,7 @@ class RepresentationSelector {
if (hint == BinaryOperationHints::kSignedSmall || if (hint == BinaryOperationHints::kSignedSmall ||
hint == BinaryOperationHints::kSigned32) { hint == BinaryOperationHints::kSigned32) {
// If the result is truncated, we only need to check the inputs. // If the result is truncated, we only need to check the inputs.
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kWord32); MachineRepresentation::kWord32);
if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
...@@ -1618,7 +1618,7 @@ class RepresentationSelector { ...@@ -1618,7 +1618,7 @@ class RepresentationSelector {
return; return;
} }
case IrOpcode::kNumberModulus: { case IrOpcode::kNumberModulus: {
if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
// => unsigned Uint32Mod // => unsigned Uint32Mod
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
...@@ -1631,7 +1631,7 @@ class RepresentationSelector { ...@@ -1631,7 +1631,7 @@ class RepresentationSelector {
if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
return; return;
} }
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
// => signed Int32Mod // => signed Int32Mod
VisitWord32TruncatingBinop(node); VisitWord32TruncatingBinop(node);
if (lower()) DeferReplacement(node, lowering->Int32Mod(node)); if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
...@@ -1675,7 +1675,7 @@ class RepresentationSelector { ...@@ -1675,7 +1675,7 @@ class RepresentationSelector {
if (hint == BinaryOperationHints::kSignedSmall || if (hint == BinaryOperationHints::kSignedSmall ||
hint == BinaryOperationHints::kSigned32) { hint == BinaryOperationHints::kSigned32) {
Type* rhs_type = GetUpperBound(node->InputAt(1)); Type* rhs_type = GetUpperBound(node->InputAt(1));
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kWord32); MachineRepresentation::kWord32);
if (lower()) { if (lower()) {
...@@ -1927,7 +1927,7 @@ class RepresentationSelector { ...@@ -1927,7 +1927,7 @@ class RepresentationSelector {
} }
case IrOpcode::kCheckNumber: { case IrOpcode::kCheckNumber: {
if (InputIs(node, Type::Number())) { if (InputIs(node, Type::Number())) {
if (truncation.TruncatesToWord32()) { if (truncation.IsUsedAsWord32()) {
VisitUnop(node, UseInfo::TruncatingWord32(), VisitUnop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32); MachineRepresentation::kWord32);
} else { } else {
...@@ -1954,7 +1954,7 @@ class RepresentationSelector { ...@@ -1954,7 +1954,7 @@ class RepresentationSelector {
return; return;
} }
case IrOpcode::kCheckTaggedSigned: { case IrOpcode::kCheckTaggedSigned: {
if (SmiValuesAre32Bits() && truncation.TruncatesToWord32()) { if (SmiValuesAre32Bits() && truncation.IsUsedAsWord32()) {
// TODO(jarin,bmeurer): Add CheckedSignedSmallAsWord32? // TODO(jarin,bmeurer): Add CheckedSignedSmallAsWord32?
VisitUnop(node, UseInfo::CheckedSigned32AsWord32(), VisitUnop(node, UseInfo::CheckedSigned32AsWord32(),
MachineRepresentation::kWord32); MachineRepresentation::kWord32);
...@@ -1981,7 +1981,7 @@ class RepresentationSelector { ...@@ -1981,7 +1981,7 @@ class RepresentationSelector {
// is exactly the Word32 we are looking for, and therefore avoid a nasty // is exactly the Word32 we are looking for, and therefore avoid a nasty
// right shift afterwards. // right shift afterwards.
// TODO(bmeurer): Introduce an appropriate tagged-signed machine rep. // TODO(bmeurer): Introduce an appropriate tagged-signed machine rep.
if (truncation.TruncatesToWord32() && if (truncation.IsUsedAsWord32() &&
representation == MachineRepresentation::kTagged && representation == MachineRepresentation::kTagged &&
access.type->Is(Type::TaggedSigned()) && SmiValuesAre32Bits()) { access.type->Is(Type::TaggedSigned()) && SmiValuesAre32Bits()) {
VisitUnop(node, UseInfoForBasePointer(access), VisitUnop(node, UseInfoForBasePointer(access),
...@@ -2029,8 +2029,8 @@ class RepresentationSelector { ...@@ -2029,8 +2029,8 @@ class RepresentationSelector {
ProcessRemainingInputs(node, 3); ProcessRemainingInputs(node, 3);
MachineRepresentation output; MachineRepresentation output;
if (truncation.TruncatesUndefinedToZeroOrNaN()) { if (truncation.IdentifiesUndefinedAndNaNAndZero()) {
if (truncation.TruncatesNaNToZero()) { if (truncation.IdentifiesNaNAndZero()) {
// If undefined is truncated to a non-NaN number, we can use // If undefined is truncated to a non-NaN number, we can use
// the load's representation. // the load's representation.
output = access.machine_type().representation(); output = access.machine_type().representation();
...@@ -2071,8 +2071,8 @@ class RepresentationSelector { ...@@ -2071,8 +2071,8 @@ class RepresentationSelector {
if (truncation.IsUnused()) return VisitUnused(node); if (truncation.IsUnused()) return VisitUnused(node);
ElementAccess access = ElementAccessOf(node->op()); ElementAccess access = ElementAccessOf(node->op());
VisitBinop(node, UseInfoForBasePointer(access), VisitBinop(node, UseInfoForBasePointer(access),
UseInfo::TruncatingWord32(), UseInfo::TruncatingWord32(),
access.machine_type.representation()); access.machine_type.representation());
return; return;
} }
case IrOpcode::kStoreElement: { case IrOpcode::kStoreElement: {
...@@ -2103,7 +2103,7 @@ class RepresentationSelector { ...@@ -2103,7 +2103,7 @@ class RepresentationSelector {
} else if (InputIs(node, Type::String())) { } else if (InputIs(node, Type::String())) {
VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
if (lower()) lowering->DoStringToNumber(node); if (lower()) lowering->DoStringToNumber(node);
} else if (truncation.TruncatesToWord32()) { } else if (truncation.IsUsedAsWord32()) {
if (InputIs(node, Type::NumberOrOddball())) { if (InputIs(node, Type::NumberOrOddball())) {
VisitUnop(node, UseInfo::TruncatingWord32(), VisitUnop(node, UseInfo::TruncatingWord32(),
MachineRepresentation::kWord32); MachineRepresentation::kWord32);
...@@ -2116,7 +2116,7 @@ class RepresentationSelector { ...@@ -2116,7 +2116,7 @@ class RepresentationSelector {
simplified()->PlainPrimitiveToWord32()); simplified()->PlainPrimitiveToWord32());
} }
} }
} else if (truncation.TruncatesToFloat64()) { } else if (truncation.IsUsedAsFloat64()) {
if (InputIs(node, Type::NumberOrOddball())) { if (InputIs(node, Type::NumberOrOddball())) {
VisitUnop(node, UseInfo::TruncatingFloat64(), VisitUnop(node, UseInfo::TruncatingFloat64(),
MachineRepresentation::kFloat64); MachineRepresentation::kFloat64);
...@@ -2150,7 +2150,7 @@ class RepresentationSelector { ...@@ -2150,7 +2150,7 @@ class RepresentationSelector {
ProcessInput(node, 0, UseInfo::TruncatingFloat64()); ProcessInput(node, 0, UseInfo::TruncatingFloat64());
ProcessRemainingInputs(node, 1); ProcessRemainingInputs(node, 1);
SetOutput(node, MachineRepresentation::kFloat64); SetOutput(node, MachineRepresentation::kFloat64);
if (truncation.TruncatesToFloat64() && if (truncation.IsUsedAsFloat64() &&
mode == CheckFloat64HoleMode::kAllowReturnHole) { mode == CheckFloat64HoleMode::kAllowReturnHole) {
if (lower()) DeferReplacement(node, node->InputAt(0)); if (lower()) DeferReplacement(node, node->InputAt(0));
} }
...@@ -2158,7 +2158,7 @@ class RepresentationSelector { ...@@ -2158,7 +2158,7 @@ class RepresentationSelector {
} }
case IrOpcode::kCheckTaggedHole: { case IrOpcode::kCheckTaggedHole: {
CheckTaggedHoleMode mode = CheckTaggedHoleModeOf(node->op()); CheckTaggedHoleMode mode = CheckTaggedHoleModeOf(node->op());
if (truncation.TruncatesToWord32() && if (truncation.IsUsedAsWord32() &&
mode == CheckTaggedHoleMode::kConvertHoleToUndefined) { mode == CheckTaggedHoleMode::kConvertHoleToUndefined) {
ProcessInput(node, 0, UseInfo::CheckedSigned32AsWord32()); ProcessInput(node, 0, UseInfo::CheckedSigned32AsWord32());
ProcessRemainingInputs(node, 1); ProcessRemainingInputs(node, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment