Index: src/compiler/simplified-lowering.cc |
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc |
index 9d00d44e329a39d0e60ebd22722a85d33ef81b72..bdc47879961e62fbcf8b730226b8d993789cb816 100644 |
--- a/src/compiler/simplified-lowering.cc |
+++ b/src/compiler/simplified-lowering.cc |
@@ -73,75 +73,80 @@ namespace { |
// need the signedness information to produce the correct value. |
class UseInfo { |
public: |
- UseInfo(MachineType preferred, Truncation truncation) |
- : preferred_(preferred), truncation_(truncation) { |
- DCHECK(preferred == (preferred & kRepMask)); |
- } |
+ UseInfo(MachineRepresentation preferred, Truncation truncation) |
+ : preferred_(preferred), truncation_(truncation) {} |
static UseInfo TruncatingWord32() { |
- return UseInfo(kRepWord32, Truncation::Word32()); |
+ return UseInfo(MachineRepresentation::kWord32, Truncation::Word32()); |
} |
static UseInfo TruncatingWord64() { |
- return UseInfo(kRepWord64, Truncation::Word64()); |
+ return UseInfo(MachineRepresentation::kWord64, Truncation::Word64()); |
+ } |
+ static UseInfo Bool() { |
+ return UseInfo(MachineRepresentation::kBit, Truncation::Bool()); |
} |
- static UseInfo Bool() { return UseInfo(kRepBit, Truncation::Bool()); } |
static UseInfo Float32() { |
- return UseInfo(kRepFloat32, Truncation::Float32()); |
+ return UseInfo(MachineRepresentation::kFloat32, Truncation::Float32()); |
} |
static UseInfo Float64() { |
- return UseInfo(kRepFloat64, Truncation::Float64()); |
+ return UseInfo(MachineRepresentation::kFloat64, Truncation::Float64()); |
} |
static UseInfo PointerInt() { |
return kPointerSize == 4 ? TruncatingWord32() : TruncatingWord64(); |
} |
- static UseInfo AnyTagged() { return UseInfo(kRepTagged, Truncation::Any()); } |
+ static UseInfo AnyTagged() { |
+ return UseInfo(MachineRepresentation::kTagged, Truncation::Any()); |
+ } |
// Undetermined representation. |
- static UseInfo Any() { return UseInfo(kMachNone, Truncation::Any()); } |
- static UseInfo None() { return UseInfo(kMachNone, Truncation::None()); } |
+ static UseInfo Any() { |
+ return UseInfo(MachineRepresentation::kNone, Truncation::Any()); |
+ } |
+ static UseInfo None() { |
+ return UseInfo(MachineRepresentation::kNone, Truncation::None()); |
+ } |
// Truncation to a representation that is smaller than the preferred |
// one. |
static UseInfo Float64TruncatingToWord32() { |
- return UseInfo(kRepFloat64, Truncation::Word32()); |
+ return UseInfo(MachineRepresentation::kFloat64, Truncation::Word32()); |
} |
static UseInfo Word64TruncatingToWord32() { |
- return UseInfo(kRepWord64, Truncation::Word32()); |
+ return UseInfo(MachineRepresentation::kWord64, Truncation::Word32()); |
} |
static UseInfo AnyTruncatingToBool() { |
- return UseInfo(kMachNone, Truncation::Bool()); |
+ return UseInfo(MachineRepresentation::kNone, Truncation::Bool()); |
} |
- MachineType preferred() const { return preferred_; } |
+ MachineRepresentation preferred() const { return preferred_; } |
Truncation truncation() const { return truncation_; } |
private: |
- MachineType preferred_; |
+ MachineRepresentation preferred_; |
Truncation truncation_; |
}; |
-UseInfo UseInfoFromMachineType(MachineType type) { |
- MachineTypeUnion rep = RepresentationOf(type); |
- DCHECK((rep & kTypeMask) == 0); |
- |
- if (rep & kRepTagged) return UseInfo::AnyTagged(); |
- if (rep & kRepFloat64) { |
- DCHECK((rep & kRepWord64) == 0); |
+UseInfo TruncatingUseInfoFromRepresentation(MachineRepresentation rep) { |
+ switch (rep) { |
+ case MachineRepresentation::kTagged: |
+ return UseInfo::AnyTagged(); |
+ case MachineRepresentation::kFloat64: |
return UseInfo::Float64(); |
- } |
- if (rep & kRepFloat32) { |
- if (rep == kRepFloat32) return UseInfo::Float32(); |
- return UseInfo::AnyTagged(); |
- } |
- if (rep & kRepWord64) { |
+ case MachineRepresentation::kFloat32: |
+ return UseInfo::Float32(); |
+ case MachineRepresentation::kWord64: |
return UseInfo::TruncatingWord64(); |
- } |
- if (rep & (kRepWord32 | kRepWord16 | kRepWord8)) { |
- CHECK(!(rep & kRepBit)); |
+ case MachineRepresentation::kWord8: |
+ case MachineRepresentation::kWord16: |
+ case MachineRepresentation::kWord32: |
return UseInfo::TruncatingWord32(); |
+ case MachineRepresentation::kBit: |
+ return UseInfo::Bool(); |
+ case MachineRepresentation::kNone: |
+ break; |
} |
- DCHECK(rep & kRepBit); |
- return UseInfo::Bool(); |
+ UNREACHABLE(); |
+ return UseInfo::None(); |
} |
@@ -158,24 +163,27 @@ UseInfo UseInfoForBasePointer(const ElementAccess& access) { |
#ifdef DEBUG |
// Helpers for monotonicity checking. |
-bool MachineTypeIsSubtype(MachineType t1, MachineType t2) { |
+bool MachineTypeIsSubtype(MachineSemantic t1, MachineSemantic t2) { |
switch (t1) { |
- case kMachNone: |
+ case MachineSemantic::kNone: |
return true; |
- case kTypeBool: |
- return t2 == kTypeBool || t2 == kTypeNumber || t2 == kTypeAny; |
- case kTypeInt32: |
- return t2 == kTypeInt32 || t2 == kTypeNumber || t2 == kTypeAny; |
- case kTypeUint32: |
- return t2 == kTypeUint32 || t2 == kTypeNumber || t2 == kTypeAny; |
- case kTypeInt64: |
- return t2 == kTypeInt64; |
- case kTypeUint64: |
- return t2 == kTypeUint64; |
- case kTypeNumber: |
- return t2 == kTypeNumber || t2 == kTypeAny; |
- case kTypeAny: |
- return t2 == kTypeAny; |
+ case MachineSemantic::kBool: |
+ return t2 == MachineSemantic::kBool || t2 == MachineSemantic::kNumber || |
+ t2 == MachineSemantic::kAny; |
+ case MachineSemantic::kInt32: |
+ return t2 == MachineSemantic::kInt32 || t2 == MachineSemantic::kNumber || |
+ t2 == MachineSemantic::kAny; |
+ case MachineSemantic::kUint32: |
+ return t2 == MachineSemantic::kUint32 || t2 == MachineSemantic::kNumber || |
+ t2 == MachineSemantic::kAny; |
+ case MachineSemantic::kInt64: |
+ return t2 == MachineSemantic::kInt64; |
+ case MachineSemantic::kUint64: |
+ return t2 == MachineSemantic::kUint64; |
+ case MachineSemantic::kNumber: |
+ return t2 == MachineSemantic::kNumber || t2 == MachineSemantic::kAny; |
+ case MachineSemantic::kAny: |
+ return t2 == MachineSemantic::kAny; |
default: |
break; |
} |
@@ -184,30 +192,45 @@ bool MachineTypeIsSubtype(MachineType t1, MachineType t2) { |
} |
-bool MachineRepresentationIsSubtype(MachineType r1, MachineType r2) { |
+bool MachineRepresentationIsSubtype(MachineRepresentation r1, |
+ MachineRepresentation r2) { |
switch (r1) { |
- case kMachNone: |
+ case MachineRepresentation::kNone: |
return true; |
- case kRepBit: |
- return r2 == kRepBit || r2 == kRepTagged; |
- case kRepWord8: |
- return r2 == kRepWord8 || r2 == kRepWord16 || r2 == kRepWord32 || |
- r2 == kRepWord64 || r2 == kRepFloat32 || r2 == kRepFloat64 || |
- r2 == kRepTagged; |
- case kRepWord16: |
- return r2 == kRepWord16 || r2 == kRepWord32 || r2 == kRepWord64 || |
- r2 == kRepFloat32 || r2 == kRepFloat64 || r2 == kRepTagged; |
- case kRepWord32: |
- return r2 == kRepWord32 || r2 == kRepWord64 || r2 == kRepFloat64 || |
- r2 == kRepTagged; |
- case kRepWord64: |
- return r2 == kRepWord64; |
- case kRepFloat32: |
- return r2 == kRepFloat32 || r2 == kRepFloat64 || r2 == kRepTagged; |
- case kRepFloat64: |
- return r2 == kRepFloat64 || r2 == kRepTagged; |
- case kRepTagged: |
- return r2 == kRepTagged; |
+ case MachineRepresentation::kBit: |
+ return r2 == MachineRepresentation::kBit || |
+ r2 == MachineRepresentation::kTagged; |
+ case MachineRepresentation::kWord8: |
+ return r2 == MachineRepresentation::kWord8 || |
+ r2 == MachineRepresentation::kWord16 || |
+ r2 == MachineRepresentation::kWord32 || |
+ r2 == MachineRepresentation::kWord64 || |
+ r2 == MachineRepresentation::kFloat32 || |
+ r2 == MachineRepresentation::kFloat64 || |
+ r2 == MachineRepresentation::kTagged; |
+ case MachineRepresentation::kWord16: |
+ return r2 == MachineRepresentation::kWord16 || |
+ r2 == MachineRepresentation::kWord32 || |
+ r2 == MachineRepresentation::kWord64 || |
+ r2 == MachineRepresentation::kFloat32 || |
+ r2 == MachineRepresentation::kFloat64 || |
+ r2 == MachineRepresentation::kTagged; |
+ case MachineRepresentation::kWord32: |
+ return r2 == MachineRepresentation::kWord32 || |
+ r2 == MachineRepresentation::kWord64 || |
+ r2 == MachineRepresentation::kFloat64 || |
+ r2 == MachineRepresentation::kTagged; |
+ case MachineRepresentation::kWord64: |
+ return r2 == MachineRepresentation::kWord64; |
+ case MachineRepresentation::kFloat32: |
+ return r2 == MachineRepresentation::kFloat32 || |
+ r2 == MachineRepresentation::kFloat64 || |
+ r2 == MachineRepresentation::kTagged; |
+ case MachineRepresentation::kFloat64: |
+ return r2 == MachineRepresentation::kFloat64 || |
+ r2 == MachineRepresentation::kTagged; |
+ case MachineRepresentation::kTagged: |
+ return r2 == MachineRepresentation::kTagged; |
default: |
break; |
} |
@@ -216,12 +239,10 @@ bool MachineRepresentationIsSubtype(MachineType r1, MachineType r2) { |
} |
-bool MachineTypeRepIsSubtype(MachineTypeUnion m1, MachineTypeUnion m2) { |
- return MachineTypeIsSubtype(static_cast<MachineType>(m1 & kTypeMask), |
- static_cast<MachineType>(m2 & kTypeMask)) && |
- MachineRepresentationIsSubtype( |
- static_cast<MachineType>(m1 & kRepMask), |
- static_cast<MachineType>(m2 & kRepMask)); |
+bool MachineTypeRepIsSubtype(MachineType m1, MachineType m2) { |
+ return MachineTypeIsSubtype(m1.semantic(), m2.semantic()) && |
+ MachineRepresentationIsSubtype(m1.representation(), |
+ m2.representation()); |
} |
@@ -271,13 +292,13 @@ class RepresentationSelector { |
void set_visited() { visited_ = true; } |
bool visited() const { return visited_; } |
Truncation truncation() const { return truncation_; } |
- void set_output_type(MachineTypeUnion type) { output_ = type; } |
- MachineTypeUnion output_type() const { return output_; } |
+ void set_output_type(MachineType type) { output_ = type; } |
+ MachineType output_type() const { return output_; } |
private: |
bool queued_ = false; // Bookkeeping for the traversal. |
bool visited_ = false; // Bookkeeping for the traversal. |
- MachineTypeUnion output_ = kMachNone; // Output type of the node. |
+ MachineType output_ = MachineType::None(); // Output type of the node. |
Truncation truncation_ = Truncation::None(); // Information about uses. |
}; |
@@ -394,12 +415,10 @@ class RepresentationSelector { |
bool lower() { return phase_ == LOWER; } |
- void SetOutput(Node* node, MachineTypeUnion output) { |
+ void SetOutput(Node* node, MachineType output) { |
// Every node should have at most one output representation. Note that |
// phis can have 0, if they have not been used in a representation-inducing |
// instruction. |
- DCHECK((output & kRepMask) == 0 || |
- base::bits::IsPowerOfTwo32(output & kRepMask)); |
NodeInfo* info = GetInfo(node); |
DCHECK(MachineTypeRepIsSubtype(info->output_type(), output)); |
info->set_output_type(output); |
@@ -414,10 +433,10 @@ class RepresentationSelector { |
void ConvertInput(Node* node, int index, UseInfo use) { |
Node* input = node->InputAt(index); |
// In the change phase, insert a change before the use if necessary. |
- if (use.preferred() == kMachNone) |
+ if (use.preferred() == MachineRepresentation::kNone) |
return; // No input requirement on the use. |
- MachineTypeUnion output = GetInfo(input)->output_type(); |
- if ((output & kRepMask) != use.preferred()) { |
+ MachineType output = GetInfo(input)->output_type(); |
+ if (output.representation() != use.preferred()) { |
// Output representation doesn't match usage. |
TRACE(" change: #%d:%s(@%d #%d:%s) ", node->id(), node->op()->mnemonic(), |
index, input->id(), input->op()->mnemonic()); |
@@ -472,7 +491,7 @@ class RepresentationSelector { |
// Helper for binops of the R x L -> O variety. |
void VisitBinop(Node* node, UseInfo left_use, UseInfo right_use, |
- MachineTypeUnion output) { |
+ MachineType output) { |
DCHECK_EQ(2, node->op()->ValueInputCount()); |
ProcessInput(node, 0, left_use); |
ProcessInput(node, 1, right_use); |
@@ -483,95 +502,95 @@ class RepresentationSelector { |
} |
// Helper for binops of the I x I -> O variety. |
- void VisitBinop(Node* node, UseInfo input_use, MachineTypeUnion output) { |
+ void VisitBinop(Node* node, UseInfo input_use, MachineType output) { |
VisitBinop(node, input_use, input_use, output); |
} |
// Helper for unops of the I -> O variety. |
- void VisitUnop(Node* node, UseInfo input_use, MachineTypeUnion output) { |
+ void VisitUnop(Node* node, UseInfo input_use, MachineType output) { |
DCHECK_EQ(1, node->InputCount()); |
ProcessInput(node, 0, input_use); |
SetOutput(node, output); |
} |
// Helper for leaf nodes. |
- void VisitLeaf(Node* node, MachineTypeUnion output) { |
+ void VisitLeaf(Node* node, MachineType output) { |
DCHECK_EQ(0, node->InputCount()); |
SetOutput(node, output); |
} |
// Helpers for specific types of binops. |
void VisitFloat64Binop(Node* node) { |
- VisitBinop(node, UseInfo::Float64(), kMachFloat64); |
+ VisitBinop(node, UseInfo::Float64(), MachineType::Float64()); |
} |
void VisitInt32Binop(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord32(), kMachInt32); |
+ VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Int32()); |
} |
void VisitUint32Binop(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord32(), kMachUint32); |
+ VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Uint32()); |
} |
void VisitInt64Binop(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord64(), kMachInt64); |
+ VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Int64()); |
} |
void VisitUint64Binop(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord64(), kMachUint64); |
+ VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Uint64()); |
} |
void VisitFloat64Cmp(Node* node) { |
- VisitBinop(node, UseInfo::Float64(), kMachBool); |
+ VisitBinop(node, UseInfo::Float64(), MachineType::Bool()); |
} |
void VisitInt32Cmp(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord32(), kMachBool); |
+ VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Bool()); |
} |
void VisitUint32Cmp(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord32(), kMachBool); |
+ VisitBinop(node, UseInfo::TruncatingWord32(), MachineType::Bool()); |
} |
void VisitInt64Cmp(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord64(), kMachBool); |
+ VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Bool()); |
} |
void VisitUint64Cmp(Node* node) { |
- VisitBinop(node, UseInfo::TruncatingWord64(), kMachBool); |
+ VisitBinop(node, UseInfo::TruncatingWord64(), MachineType::Bool()); |
} |
// Infer representation for phi-like nodes. |
- static MachineType GetRepresentationForPhi(Node* node, Truncation use) { |
+ static MachineRepresentation GetRepresentationForPhi(Node* node, |
+ Truncation use) { |
// Phis adapt to the output representation their uses demand. |
Type* upper = NodeProperties::GetType(node); |
if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) { |
// We are within 32 bits range => pick kRepWord32. |
- return kRepWord32; |
+ return MachineRepresentation::kWord32; |
} else if (use.TruncatesToWord32()) { |
// We only use 32 bits. |
- return kRepWord32; |
+ return MachineRepresentation::kWord32; |
} else if (upper->Is(Type::Boolean())) { |
// multiple uses => pick kRepBit. |
- return kRepBit; |
+ return MachineRepresentation::kBit; |
} else if (upper->Is(Type::Number())) { |
// multiple uses => pick kRepFloat64. |
- return kRepFloat64; |
+ return MachineRepresentation::kFloat64; |
} else if (upper->Is(Type::Internal())) { |
- return kMachPtr; |
+ return MachineType::PointerRepresentation(); |
} |
- return kRepTagged; |
+ return MachineRepresentation::kTagged; |
} |
// Helper for handling selects. |
void VisitSelect(Node* node, Truncation truncation, |
SimplifiedLowering* lowering) { |
ProcessInput(node, 0, UseInfo::Bool()); |
- MachineType output = GetRepresentationForPhi(node, truncation); |
+ MachineRepresentation output = GetRepresentationForPhi(node, truncation); |
Type* upper = NodeProperties::GetType(node); |
MachineType output_type = |
- static_cast<MachineType>(changer_->TypeFromUpperBound(upper) | output); |
+ MachineType(output, changer_->TypeFromUpperBound(upper)); |
SetOutput(node, output_type); |
if (lower()) { |
// Update the select operator. |
SelectParameters p = SelectParametersOf(node->op()); |
- MachineType type = static_cast<MachineType>(output_type); |
- if (type != p.type()) { |
+ if (output != p.representation()) { |
NodeProperties::ChangeOp(node, |
- lowering->common()->Select(type, p.hint())); |
+ lowering->common()->Select(output, p.hint())); |
} |
} |
// Convert inputs to the output representation of this phi, pass the |
@@ -584,20 +603,19 @@ class RepresentationSelector { |
// Helper for handling phis. |
void VisitPhi(Node* node, Truncation truncation, |
SimplifiedLowering* lowering) { |
- MachineType output = GetRepresentationForPhi(node, truncation); |
+ MachineRepresentation output = GetRepresentationForPhi(node, truncation); |
Type* upper = NodeProperties::GetType(node); |
MachineType output_type = |
- static_cast<MachineType>(changer_->TypeFromUpperBound(upper) | output); |
+ MachineType(output, changer_->TypeFromUpperBound(upper)); |
SetOutput(node, output_type); |
int values = node->op()->ValueInputCount(); |
if (lower()) { |
// Update the phi operator. |
- MachineType type = static_cast<MachineType>(output_type); |
- if (type != OpParameter<MachineType>(node)) { |
- NodeProperties::ChangeOp(node, lowering->common()->Phi(type, values)); |
+ if (output != PhiRepresentationOf(node->op())) { |
+ NodeProperties::ChangeOp(node, lowering->common()->Phi(output, values)); |
} |
} |
@@ -619,7 +637,8 @@ class RepresentationSelector { |
// The target of the call. |
ProcessInput(node, i, UseInfo::None()); |
} else if ((i - 1) < params) { |
- ProcessInput(node, i, UseInfoFromMachineType(sig->GetParam(i - 1))); |
+ ProcessInput(node, i, TruncatingUseInfoFromRepresentation( |
+ sig->GetParam(i - 1).representation())); |
} else { |
ProcessInput(node, i, UseInfo::None()); |
} |
@@ -628,7 +647,7 @@ class RepresentationSelector { |
if (sig->return_count() > 0) { |
SetOutput(node, desc->GetMachineSignature()->GetReturn()); |
} else { |
- SetOutput(node, kMachAnyTagged); |
+ SetOutput(node, MachineType::AnyTagged()); |
} |
} |
@@ -643,13 +662,13 @@ class RepresentationSelector { |
new (zone->New(sizeof(ZoneVector<MachineType>))) |
ZoneVector<MachineType>(node->InputCount(), zone); |
for (int i = 0; i < node->InputCount(); i++) { |
- MachineTypeUnion input_type = GetInfo(node->InputAt(i))->output_type(); |
- (*types)[i] = static_cast<MachineType>(input_type); |
+ MachineType input_type = GetInfo(node->InputAt(i))->output_type(); |
+ (*types)[i] = input_type; |
} |
NodeProperties::ChangeOp(node, |
jsgraph_->common()->TypedStateValues(types)); |
} |
- SetOutput(node, kMachAnyTagged); |
+ SetOutput(node, MachineType::AnyTagged()); |
} |
const Operator* Int32Op(Node* node) { |
@@ -700,28 +719,29 @@ class RepresentationSelector { |
//------------------------------------------------------------------ |
case IrOpcode::kStart: |
case IrOpcode::kDead: |
- return VisitLeaf(node, 0); |
+ return VisitLeaf(node, MachineType::None()); |
case IrOpcode::kParameter: { |
// TODO(titzer): use representation from linkage. |
Type* upper = NodeProperties::GetType(node); |
ProcessInput(node, 0, UseInfo::None()); |
- SetOutput(node, kRepTagged | changer_->TypeFromUpperBound(upper)); |
+ SetOutput(node, MachineType(MachineRepresentation::kTagged, |
+ changer_->TypeFromUpperBound(upper))); |
return; |
} |
case IrOpcode::kInt32Constant: |
- return VisitLeaf(node, kRepWord32); |
+ return VisitLeaf(node, MachineType::RepWord32()); |
case IrOpcode::kInt64Constant: |
- return VisitLeaf(node, kRepWord64); |
+ return VisitLeaf(node, MachineType::RepWord64()); |
case IrOpcode::kFloat32Constant: |
- return VisitLeaf(node, kRepFloat32); |
+ return VisitLeaf(node, MachineType::RepFloat32()); |
case IrOpcode::kFloat64Constant: |
- return VisitLeaf(node, kRepFloat64); |
+ return VisitLeaf(node, MachineType::RepFloat64()); |
case IrOpcode::kExternalConstant: |
- return VisitLeaf(node, kMachPtr); |
+ return VisitLeaf(node, MachineType::Pointer()); |
case IrOpcode::kNumberConstant: |
- return VisitLeaf(node, kRepTagged); |
+ return VisitLeaf(node, MachineType::RepTagged()); |
case IrOpcode::kHeapConstant: |
- return VisitLeaf(node, kRepTagged); |
+ return VisitLeaf(node, MachineType::RepTagged()); |
case IrOpcode::kBranch: |
ProcessInput(node, 0, UseInfo::Bool()); |
@@ -750,15 +770,15 @@ class RepresentationSelector { |
JS_OP_LIST(DEFINE_JS_CASE) |
#undef DEFINE_JS_CASE |
VisitInputs(node); |
- return SetOutput(node, kRepTagged); |
+ return SetOutput(node, MachineType::RepTagged()); |
//------------------------------------------------------------------ |
// Simplified operators. |
//------------------------------------------------------------------ |
case IrOpcode::kBooleanNot: { |
if (lower()) { |
- MachineTypeUnion input = GetInfo(node->InputAt(0))->output_type(); |
- if (input & kRepBit) { |
+ MachineType input = GetInfo(node->InputAt(0))->output_type(); |
+ if (input.representation() == MachineRepresentation::kBit) { |
// BooleanNot(x: kRepBit) => Word32Equal(x, #0) |
node->AppendInput(jsgraph_->zone(), jsgraph_->Int32Constant(0)); |
NodeProperties::ChangeOp(node, lowering->machine()->Word32Equal()); |
@@ -770,14 +790,14 @@ class RepresentationSelector { |
} else { |
// No input representation requirement; adapt during lowering. |
ProcessInput(node, 0, UseInfo::AnyTruncatingToBool()); |
- SetOutput(node, kRepBit); |
+ SetOutput(node, MachineType::RepBit()); |
} |
break; |
} |
case IrOpcode::kBooleanToNumber: { |
if (lower()) { |
- MachineTypeUnion input = GetInfo(node->InputAt(0))->output_type(); |
- if (input & kRepBit) { |
+ MachineType input = GetInfo(node->InputAt(0))->output_type(); |
+ if (input.representation() == MachineRepresentation::kBit) { |
// BooleanToNumber(x: kRepBit) => x |
DeferReplacement(node, node->InputAt(0)); |
} else { |
@@ -788,7 +808,7 @@ class RepresentationSelector { |
} else { |
// No input representation requirement; adapt during lowering. |
ProcessInput(node, 0, UseInfo::AnyTruncatingToBool()); |
- SetOutput(node, kMachInt32); |
+ SetOutput(node, MachineType::Int32()); |
} |
break; |
} |
@@ -887,36 +907,36 @@ class RepresentationSelector { |
} |
case IrOpcode::kNumberShiftLeft: { |
VisitBinop(node, UseInfo::TruncatingWord32(), |
- UseInfo::TruncatingWord32(), kMachInt32); |
+ UseInfo::TruncatingWord32(), MachineType::Int32()); |
if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shl()); |
break; |
} |
case IrOpcode::kNumberShiftRight: { |
VisitBinop(node, UseInfo::TruncatingWord32(), |
- UseInfo::TruncatingWord32(), kMachInt32); |
+ UseInfo::TruncatingWord32(), MachineType::Int32()); |
if (lower()) lowering->DoShift(node, lowering->machine()->Word32Sar()); |
break; |
} |
case IrOpcode::kNumberShiftRightLogical: { |
VisitBinop(node, UseInfo::TruncatingWord32(), |
- UseInfo::TruncatingWord32(), kMachUint32); |
+ UseInfo::TruncatingWord32(), MachineType::Uint32()); |
if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shr()); |
break; |
} |
case IrOpcode::kNumberToInt32: { |
// Just change representation if necessary. |
- VisitUnop(node, UseInfo::TruncatingWord32(), kMachInt32); |
+ VisitUnop(node, UseInfo::TruncatingWord32(), MachineType::Int32()); |
if (lower()) DeferReplacement(node, node->InputAt(0)); |
break; |
} |
case IrOpcode::kNumberToUint32: { |
// Just change representation if necessary. |
- VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32); |
+ VisitUnop(node, UseInfo::TruncatingWord32(), MachineType::Uint32()); |
if (lower()) DeferReplacement(node, node->InputAt(0)); |
break; |
} |
case IrOpcode::kNumberIsHoleNaN: { |
- VisitUnop(node, UseInfo::Float64(), kMachBool); |
+ VisitUnop(node, UseInfo::Float64(), MachineType::Bool()); |
if (lower()) { |
// NumberIsHoleNaN(x) => Word32Equal(Float64ExtractLowWord32(x), |
// #HoleNaNLower32) |
@@ -931,7 +951,9 @@ class RepresentationSelector { |
break; |
} |
case IrOpcode::kPlainPrimitiveToNumber: { |
- VisitUnop(node, UseInfo::AnyTagged(), kTypeNumber | kRepTagged); |
+ VisitUnop(node, UseInfo::AnyTagged(), |
+ MachineType(MachineRepresentation::kTagged, |
+ MachineSemantic::kNumber)); |
if (lower()) { |
// PlainPrimitiveToNumber(x) => Call(ToNumberStub, x, no-context) |
Operator::Properties properties = node->op()->properties(); |
@@ -948,31 +970,31 @@ class RepresentationSelector { |
break; |
} |
case IrOpcode::kReferenceEqual: { |
- VisitBinop(node, UseInfo::AnyTagged(), kMachBool); |
+ VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); |
if (lower()) { |
NodeProperties::ChangeOp(node, lowering->machine()->WordEqual()); |
} |
break; |
} |
case IrOpcode::kStringEqual: { |
- VisitBinop(node, UseInfo::AnyTagged(), kMachBool); |
+ VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); |
if (lower()) lowering->DoStringEqual(node); |
break; |
} |
case IrOpcode::kStringLessThan: { |
- VisitBinop(node, UseInfo::AnyTagged(), kMachBool); |
+ VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); |
if (lower()) lowering->DoStringLessThan(node); |
break; |
} |
case IrOpcode::kStringLessThanOrEqual: { |
- VisitBinop(node, UseInfo::AnyTagged(), kMachBool); |
+ VisitBinop(node, UseInfo::AnyTagged(), MachineType::Bool()); |
if (lower()) lowering->DoStringLessThanOrEqual(node); |
break; |
} |
case IrOpcode::kAllocate: { |
ProcessInput(node, 0, UseInfo::AnyTagged()); |
ProcessRemainingInputs(node, 1); |
- SetOutput(node, kMachAnyTagged); |
+ SetOutput(node, MachineType::AnyTagged()); |
break; |
} |
case IrOpcode::kLoadField: { |
@@ -985,9 +1007,10 @@ class RepresentationSelector { |
case IrOpcode::kStoreField: { |
FieldAccess access = FieldAccessOf(node->op()); |
ProcessInput(node, 0, UseInfoForBasePointer(access)); |
- ProcessInput(node, 1, UseInfoFromMachineType(access.machine_type)); |
+ ProcessInput(node, 1, TruncatingUseInfoFromRepresentation( |
+ access.machine_type.representation())); |
ProcessRemainingInputs(node, 2); |
- SetOutput(node, 0); |
+ SetOutput(node, MachineType::None()); |
break; |
} |
case IrOpcode::kLoadBuffer: { |
@@ -1007,16 +1030,17 @@ class RepresentationSelector { |
// If undefined is truncated to a number, but the use can |
// observe NaN, we need to output at least the float32 |
// representation. |
- if (access.machine_type() & kRepFloat32) { |
+ if (access.machine_type().representation() == |
+ MachineRepresentation::kFloat32) { |
output_type = access.machine_type(); |
} else { |
- output_type = kMachFloat64; |
+ output_type = MachineType::Float64(); |
} |
} |
} else { |
// If undefined is not truncated away, we need to have the tagged |
// representation. |
- output_type = kMachAnyTagged; |
+ output_type = MachineType::AnyTagged(); |
} |
SetOutput(node, output_type); |
if (lower()) lowering->DoLoadBuffer(node, output_type, changer_); |
@@ -1028,9 +1052,10 @@ class RepresentationSelector { |
ProcessInput(node, 1, UseInfo::TruncatingWord32()); // offset |
ProcessInput(node, 2, UseInfo::TruncatingWord32()); // length |
ProcessInput(node, 3, |
- UseInfoFromMachineType(access.machine_type())); // value |
+ TruncatingUseInfoFromRepresentation( |
+ access.machine_type().representation())); // value |
ProcessRemainingInputs(node, 4); |
- SetOutput(node, 0); |
+ SetOutput(node, MachineType::None()); |
if (lower()) lowering->DoStoreBuffer(node); |
break; |
} |
@@ -1047,20 +1072,21 @@ class RepresentationSelector { |
ProcessInput(node, 0, UseInfoForBasePointer(access)); // base |
ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index |
ProcessInput(node, 2, |
- UseInfoFromMachineType(access.machine_type)); // value |
+ TruncatingUseInfoFromRepresentation( |
+ access.machine_type.representation())); // value |
ProcessRemainingInputs(node, 3); |
- SetOutput(node, 0); |
+ SetOutput(node, MachineType::None()); |
break; |
} |
case IrOpcode::kObjectIsNumber: { |
ProcessInput(node, 0, UseInfo::AnyTagged()); |
- SetOutput(node, kMachBool); |
+ SetOutput(node, MachineType::Bool()); |
if (lower()) lowering->DoObjectIsNumber(node); |
break; |
} |
case IrOpcode::kObjectIsSmi: { |
ProcessInput(node, 0, UseInfo::AnyTagged()); |
- SetOutput(node, kMachBool); |
+ SetOutput(node, MachineType::Bool()); |
if (lower()) lowering->DoObjectIsSmi(node); |
break; |
} |
@@ -1071,7 +1097,7 @@ class RepresentationSelector { |
case IrOpcode::kLoad: { |
// TODO(jarin) Eventually, we should get rid of all machine stores |
// from the high-level phases, then this becomes UNREACHABLE. |
- LoadRepresentation rep = OpParameter<LoadRepresentation>(node); |
+ LoadRepresentation rep = LoadRepresentationOf(node->op()); |
ProcessInput(node, 0, UseInfo::AnyTagged()); // tagged pointer |
ProcessInput(node, 1, UseInfo::PointerInt()); // index |
ProcessRemainingInputs(node, 2); |
@@ -1081,17 +1107,19 @@ class RepresentationSelector { |
case IrOpcode::kStore: { |
// TODO(jarin) Eventually, we should get rid of all machine stores |
// from the high-level phases, then this becomes UNREACHABLE. |
- StoreRepresentation rep = OpParameter<StoreRepresentation>(node); |
+ StoreRepresentation rep = StoreRepresentationOf(node->op()); |
ProcessInput(node, 0, UseInfo::AnyTagged()); // tagged pointer |
ProcessInput(node, 1, UseInfo::PointerInt()); // index |
- ProcessInput(node, 2, UseInfoFromMachineType(rep.machine_type())); |
+ ProcessInput(node, 2, TruncatingUseInfoFromRepresentation( |
+ rep.machine_type().representation())); |
ProcessRemainingInputs(node, 3); |
- SetOutput(node, 0); |
+ SetOutput(node, MachineType::None()); |
break; |
} |
case IrOpcode::kWord32Shr: |
// We output unsigned int32 for shift right because JavaScript. |
- return VisitBinop(node, UseInfo::TruncatingWord32(), kMachUint32); |
+ return VisitBinop(node, UseInfo::TruncatingWord32(), |
+ MachineType::Uint32()); |
case IrOpcode::kWord32And: |
case IrOpcode::kWord32Or: |
case IrOpcode::kWord32Xor: |
@@ -1101,12 +1129,14 @@ class RepresentationSelector { |
// though the machine bits are the same for either signed or unsigned, |
// because JavaScript considers the result from these operations signed. |
return VisitBinop(node, UseInfo::TruncatingWord32(), |
- kRepWord32 | kTypeInt32); |
+ MachineType::Int32()); |
case IrOpcode::kWord32Equal: |
- return VisitBinop(node, UseInfo::TruncatingWord32(), kMachBool); |
+ return VisitBinop(node, UseInfo::TruncatingWord32(), |
+ MachineType::Bool()); |
case IrOpcode::kWord32Clz: |
- return VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32); |
+ return VisitUnop(node, UseInfo::TruncatingWord32(), |
+ MachineType::Uint32()); |
case IrOpcode::kInt32Add: |
case IrOpcode::kInt32Sub: |
@@ -1150,39 +1180,46 @@ class RepresentationSelector { |
case IrOpcode::kWord64Shl: |
case IrOpcode::kWord64Shr: |
case IrOpcode::kWord64Sar: |
- return VisitBinop(node, UseInfo::TruncatingWord64(), kRepWord64); |
+ return VisitBinop(node, UseInfo::TruncatingWord64(), |
+ MachineType(MachineRepresentation::kWord64, |
+ MachineSemantic::kNone)); |
case IrOpcode::kWord64Equal: |
- return VisitBinop(node, UseInfo::TruncatingWord64(), kMachBool); |
+ return VisitBinop(node, UseInfo::TruncatingWord64(), |
+ MachineType::Bool()); |
case IrOpcode::kChangeInt32ToInt64: |
return VisitUnop(node, UseInfo::TruncatingWord32(), |
- kTypeInt32 | kRepWord64); |
+ MachineType(MachineRepresentation::kWord64, |
+ MachineSemantic::kInt32)); |
case IrOpcode::kChangeUint32ToUint64: |
return VisitUnop(node, UseInfo::TruncatingWord32(), |
- kTypeUint32 | kRepWord64); |
+ MachineType(MachineRepresentation::kWord64, |
+ MachineSemantic::kUint32)); |
case IrOpcode::kTruncateFloat64ToFloat32: |
- return VisitUnop(node, UseInfo::Float64(), kTypeNumber | kRepFloat32); |
+ return VisitUnop(node, UseInfo::Float64(), MachineType::Float32()); |
case IrOpcode::kTruncateFloat64ToInt32: |
- return VisitUnop(node, UseInfo::Float64(), kTypeInt32 | kRepWord32); |
+ return VisitUnop(node, UseInfo::Float64(), MachineType::Int32()); |
case IrOpcode::kTruncateInt64ToInt32: |
// TODO(titzer): Is kTypeInt32 correct here? |
return VisitUnop(node, UseInfo::Word64TruncatingToWord32(), |
- kTypeInt32 | kRepWord32); |
+ MachineType::Int32()); |
case IrOpcode::kChangeFloat32ToFloat64: |
- return VisitUnop(node, UseInfo::Float32(), kTypeNumber | kRepFloat64); |
+ return VisitUnop(node, UseInfo::Float32(), MachineType::Float64()); |
case IrOpcode::kChangeInt32ToFloat64: |
return VisitUnop(node, UseInfo::TruncatingWord32(), |
- kTypeInt32 | kRepFloat64); |
+ MachineType(MachineRepresentation::kFloat64, |
+ MachineSemantic::kInt32)); |
case IrOpcode::kChangeUint32ToFloat64: |
return VisitUnop(node, UseInfo::TruncatingWord32(), |
- kTypeUint32 | kRepFloat64); |
+ MachineType(MachineRepresentation::kFloat64, |
+ MachineSemantic::kUint32)); |
case IrOpcode::kChangeFloat64ToInt32: |
return VisitUnop(node, UseInfo::Float64TruncatingToWord32(), |
- kTypeInt32 | kRepWord32); |
+ MachineType::Int32()); |
case IrOpcode::kChangeFloat64ToUint32: |
return VisitUnop(node, UseInfo::Float64TruncatingToWord32(), |
- kTypeUint32 | kRepWord32); |
+ MachineType::Uint32()); |
case IrOpcode::kFloat64Add: |
case IrOpcode::kFloat64Sub: |
@@ -1196,28 +1233,28 @@ class RepresentationSelector { |
case IrOpcode::kFloat64RoundDown: |
case IrOpcode::kFloat64RoundTruncate: |
case IrOpcode::kFloat64RoundTiesAway: |
- return VisitUnop(node, UseInfo::Float64(), kMachFloat64); |
+ return VisitUnop(node, UseInfo::Float64(), MachineType::Float64()); |
case IrOpcode::kFloat64Equal: |
case IrOpcode::kFloat64LessThan: |
case IrOpcode::kFloat64LessThanOrEqual: |
return VisitFloat64Cmp(node); |
case IrOpcode::kFloat64ExtractLowWord32: |
case IrOpcode::kFloat64ExtractHighWord32: |
- return VisitUnop(node, UseInfo::Float64(), kMachInt32); |
+ return VisitUnop(node, UseInfo::Float64(), MachineType::Int32()); |
case IrOpcode::kFloat64InsertLowWord32: |
case IrOpcode::kFloat64InsertHighWord32: |
return VisitBinop(node, UseInfo::Float64(), UseInfo::TruncatingWord32(), |
- kMachFloat64); |
+ MachineType::Float64()); |
case IrOpcode::kLoadStackPointer: |
case IrOpcode::kLoadFramePointer: |
- return VisitLeaf(node, kMachPtr); |
+ return VisitLeaf(node, MachineType::Pointer()); |
case IrOpcode::kStateValues: |
VisitStateValues(node); |
break; |
default: |
VisitInputs(node); |
// Assume the output is tagged. |
- SetOutput(node, kMachAnyTagged); |
+ SetOutput(node, MachineType::AnyTagged()); |
break; |
} |
} |
@@ -1243,10 +1280,10 @@ class RepresentationSelector { |
node->NullAllInputs(); // Node is now dead. |
} |
- void PrintInfo(MachineTypeUnion info) { |
+ void PrintInfo(MachineType info) { |
if (FLAG_trace_representation) { |
OFStream os(stdout); |
- os << static_cast<MachineType>(info); |
+ os << info; |
} |
} |
@@ -1312,7 +1349,7 @@ void SimplifiedLowering::LowerAllNodes() { |
void SimplifiedLowering::DoLoadBuffer(Node* node, MachineType output_type, |
RepresentationChanger* changer) { |
DCHECK_EQ(IrOpcode::kLoadBuffer, node->opcode()); |
- DCHECK_NE(kMachNone, RepresentationOf(output_type)); |
+ DCHECK_NE(MachineRepresentation::kNone, output_type.representation()); |
MachineType const type = BufferAccessOf(node->op()).machine_type(); |
if (output_type != type) { |
Node* const buffer = node->InputAt(0); |
@@ -1333,17 +1370,19 @@ void SimplifiedLowering::DoLoadBuffer(Node* node, MachineType output_type, |
Node* etrue = |
graph()->NewNode(machine()->Load(type), buffer, index, effect, if_true); |
Node* vtrue = changer->GetRepresentationFor( |
- etrue, type, RepresentationOf(output_type), Truncation::None()); |
+ etrue, type, output_type.representation(), Truncation::None()); |
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
Node* efalse = effect; |
Node* vfalse; |
- if (output_type & kRepTagged) { |
+ if (output_type.representation() == MachineRepresentation::kTagged) { |
vfalse = jsgraph()->UndefinedConstant(); |
- } else if (output_type & kRepFloat64) { |
+ } else if (output_type.representation() == |
+ MachineRepresentation::kFloat64) { |
vfalse = |
jsgraph()->Float64Constant(std::numeric_limits<double>::quiet_NaN()); |
- } else if (output_type & kRepFloat32) { |
+ } else if (output_type.representation() == |
+ MachineRepresentation::kFloat32) { |
vfalse = |
jsgraph()->Float32Constant(std::numeric_limits<float>::quiet_NaN()); |
} else { |
@@ -1361,7 +1400,8 @@ void SimplifiedLowering::DoLoadBuffer(Node* node, MachineType output_type, |
node->ReplaceInput(1, vfalse); |
node->ReplaceInput(2, merge); |
node->TrimInputCount(3); |
- NodeProperties::ChangeOp(node, common()->Phi(output_type, 2)); |
+ NodeProperties::ChangeOp(node, |
+ common()->Phi(output_type.representation(), 2)); |
} else { |
NodeProperties::ChangeOp(node, machine()->CheckedLoad(type)); |
} |
@@ -1390,7 +1430,7 @@ void SimplifiedLowering::DoObjectIsNumber(Node* node) { |
Node* vfalse = graph()->NewNode( |
machine()->WordEqual(), |
graph()->NewNode( |
- machine()->Load(kMachAnyTagged), input, |
+ machine()->Load(MachineType::AnyTagged()), input, |
jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), |
graph()->start(), if_false), |
jsgraph()->HeapConstant(isolate()->factory()->heap_number_map())); |
@@ -1398,7 +1438,7 @@ void SimplifiedLowering::DoObjectIsNumber(Node* node) { |
node->ReplaceInput(0, vtrue); |
node->AppendInput(graph()->zone(), vfalse); |
node->AppendInput(graph()->zone(), control); |
- NodeProperties::ChangeOp(node, common()->Phi(kMachBool, 2)); |
+ NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); |
} |
@@ -1456,7 +1496,8 @@ Node* SimplifiedLowering::Int32Div(Node* const node) { |
// Note: We do not use the Diamond helper class here, because it really hurts |
// readability with nested diamonds. |
const Operator* const merge_op = common()->Merge(2); |
- const Operator* const phi_op = common()->Phi(kMachInt32, 2); |
+ const Operator* const phi_op = |
+ common()->Phi(MachineRepresentation::kWord32, 2); |
Node* check0 = graph()->NewNode(machine()->Int32LessThan(), zero, rhs); |
Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, |
@@ -1533,7 +1574,8 @@ Node* SimplifiedLowering::Int32Mod(Node* const node) { |
// Note: We do not use the Diamond helper class here, because it really hurts |
// readability with nested diamonds. |
const Operator* const merge_op = common()->Merge(2); |
- const Operator* const phi_op = common()->Phi(kMachInt32, 2); |
+ const Operator* const phi_op = |
+ common()->Phi(MachineRepresentation::kWord32, 2); |
Node* check0 = graph()->NewNode(machine()->Int32LessThan(), zero, rhs); |
Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, |
@@ -1612,7 +1654,7 @@ Node* SimplifiedLowering::Uint32Div(Node* const node) { |
Node* check = graph()->NewNode(machine()->Word32Equal(), rhs, zero); |
Diamond d(graph(), common(), check, BranchHint::kFalse); |
Node* div = graph()->NewNode(machine()->Uint32Div(), lhs, rhs, d.if_false); |
- return d.Phi(kMachUint32, zero, div); |
+ return d.Phi(MachineRepresentation::kWord32, zero, div); |
} |
@@ -1644,7 +1686,8 @@ Node* SimplifiedLowering::Uint32Mod(Node* const node) { |
// Note: We do not use the Diamond helper class here, because it really hurts |
// readability with nested diamonds. |
const Operator* const merge_op = common()->Merge(2); |
- const Operator* const phi_op = common()->Phi(kMachInt32, 2); |
+ const Operator* const phi_op = |
+ common()->Phi(MachineRepresentation::kWord32, 2); |
Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), rhs, |
graph()->start()); |