Commit 7296bd49 authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Remove representation changes for machine constants.

No machine constants should reach the representation selector.

Review-Url: https://chromiumcodereview.appspot.com/2431693002
Cr-Commit-Position: refs/heads/master@{#40430}
parent b7ff0d71
...@@ -1707,7 +1707,7 @@ void ReduceBuiltin(Isolate* isolate, JSGraph* jsgraph, Node* node, ...@@ -1707,7 +1707,7 @@ void ReduceBuiltin(Isolate* isolate, JSGraph* jsgraph, Node* node,
} }
const int argc = arity + BuiltinArguments::kNumExtraArgsWithReceiver; const int argc = arity + BuiltinArguments::kNumExtraArgsWithReceiver;
Node* argc_node = jsgraph->Int32Constant(argc); Node* argc_node = jsgraph->Constant(argc);
static const int kStubAndReceiver = 2; static const int kStubAndReceiver = 2;
int cursor = arity + kStubAndReceiver; int cursor = arity + kStubAndReceiver;
......
...@@ -291,17 +291,9 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor( ...@@ -291,17 +291,9 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor(
case IrOpcode::kHeapConstant: case IrOpcode::kHeapConstant:
return node; // No change necessary. return node; // No change necessary.
case IrOpcode::kInt32Constant: case IrOpcode::kInt32Constant:
if (output_type->Is(Type::Boolean())) {
return OpParameter<int32_t>(node) == 0 ? jsgraph()->FalseConstant()
: jsgraph()->TrueConstant();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTaggedPointer);
}
case IrOpcode::kFloat64Constant: case IrOpcode::kFloat64Constant:
case IrOpcode::kFloat32Constant: case IrOpcode::kFloat32Constant:
return TypeError(node, output_rep, output_type, UNREACHABLE();
MachineRepresentation::kTaggedPointer);
default: default:
break; break;
} }
...@@ -324,23 +316,10 @@ Node* RepresentationChanger::GetTaggedRepresentationFor( ...@@ -324,23 +316,10 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
case IrOpcode::kHeapConstant: case IrOpcode::kHeapConstant:
return node; // No change necessary. return node; // No change necessary.
case IrOpcode::kInt32Constant: case IrOpcode::kInt32Constant:
if (output_type->Is(Type::Signed32())) {
int32_t value = OpParameter<int32_t>(node);
return jsgraph()->Constant(value);
} else if (output_type->Is(Type::Unsigned32())) {
uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
return jsgraph()->Constant(static_cast<double>(value));
} else if (output_type->Is(Type::Boolean())) {
return OpParameter<int32_t>(node) == 0 ? jsgraph()->FalseConstant()
: jsgraph()->TrueConstant();
} else {
return TypeError(node, output_rep, output_type,
MachineRepresentation::kTagged);
}
case IrOpcode::kFloat64Constant: case IrOpcode::kFloat64Constant:
return jsgraph()->Constant(OpParameter<double>(node));
case IrOpcode::kFloat32Constant: case IrOpcode::kFloat32Constant:
return jsgraph()->Constant(OpParameter<float>(node)); UNREACHABLE();
break;
default: default:
break; break;
} }
...@@ -408,20 +387,14 @@ Node* RepresentationChanger::GetFloat32RepresentationFor( ...@@ -408,20 +387,14 @@ Node* RepresentationChanger::GetFloat32RepresentationFor(
Truncation truncation) { Truncation truncation) {
// Eagerly fold representation changes for constants. // Eagerly fold representation changes for constants.
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kFloat64Constant:
case IrOpcode::kNumberConstant: case IrOpcode::kNumberConstant:
return jsgraph()->Float32Constant( return jsgraph()->Float32Constant(
DoubleToFloat32(OpParameter<double>(node))); DoubleToFloat32(OpParameter<double>(node)));
case IrOpcode::kInt32Constant: case IrOpcode::kInt32Constant:
if (output_type->Is(Type::Unsigned32())) { case IrOpcode::kFloat64Constant:
uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
return jsgraph()->Float32Constant(static_cast<float>(value));
} else {
int32_t value = OpParameter<int32_t>(node);
return jsgraph()->Float32Constant(static_cast<float>(value));
}
case IrOpcode::kFloat32Constant: case IrOpcode::kFloat32Constant:
return node; // No change necessary. UNREACHABLE();
break;
default: default:
break; break;
} }
...@@ -479,18 +452,10 @@ Node* RepresentationChanger::GetFloat64RepresentationFor( ...@@ -479,18 +452,10 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
case IrOpcode::kNumberConstant: case IrOpcode::kNumberConstant:
return jsgraph()->Float64Constant(OpParameter<double>(node)); return jsgraph()->Float64Constant(OpParameter<double>(node));
case IrOpcode::kInt32Constant: case IrOpcode::kInt32Constant:
if (output_type->Is(Type::Signed32())) {
int32_t value = OpParameter<int32_t>(node);
return jsgraph()->Float64Constant(value);
} else {
DCHECK(output_type->Is(Type::Unsigned32()));
uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
return jsgraph()->Float64Constant(static_cast<double>(value));
}
case IrOpcode::kFloat64Constant: case IrOpcode::kFloat64Constant:
return node; // No change necessary.
case IrOpcode::kFloat32Constant: case IrOpcode::kFloat32Constant:
return jsgraph()->Float64Constant(OpParameter<float>(node)); UNREACHABLE();
break;
default: default:
break; break;
} }
...@@ -555,19 +520,11 @@ Node* RepresentationChanger::GetWord32RepresentationFor( ...@@ -555,19 +520,11 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
// Eagerly fold representation changes for constants. // Eagerly fold representation changes for constants.
switch (node->opcode()) { switch (node->opcode()) {
case IrOpcode::kInt32Constant: case IrOpcode::kInt32Constant:
return node; // No change necessary. case IrOpcode::kFloat32Constant:
case IrOpcode::kFloat32Constant: { case IrOpcode::kFloat64Constant:
float const fv = OpParameter<float>(node); UNREACHABLE();
if (use_info.type_check() == TypeCheckKind::kNone ||
((use_info.type_check() == TypeCheckKind::kSignedSmall ||
use_info.type_check() == TypeCheckKind::kSigned32) &&
IsInt32Double(fv))) {
return MakeTruncatedInt32Constant(fv);
}
break; break;
} case IrOpcode::kNumberConstant: {
case IrOpcode::kNumberConstant:
case IrOpcode::kFloat64Constant: {
double const fv = OpParameter<double>(node); double const fv = OpParameter<double>(node);
if (use_info.type_check() == TypeCheckKind::kNone || if (use_info.type_check() == TypeCheckKind::kNone ||
((use_info.type_check() == TypeCheckKind::kSignedSmall || ((use_info.type_check() == TypeCheckKind::kSignedSmall ||
......
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