Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: src/compiler/representation-change.h

Issue 636283009: [turbofan] Use range types to type and lower arithmetic ops. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename MaybeWeaken and rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/representation-change.h
diff --git a/src/compiler/representation-change.h b/src/compiler/representation-change.h
index 3b6f183056fe57e4433f772b62e20b60df60f117..5e7a8d04c687fe8152a92e2484d9c20336e23e4d 100644
--- a/src/compiler/representation-change.h
+++ b/src/compiler/representation-change.h
@@ -216,6 +216,37 @@ class RepresentationChanger {
}
}
+ Node* GetTruncatedWord32For(Node* node, MachineTypeUnion output_type) {
+ // Eagerly fold truncations for constants.
+ switch (node->opcode()) {
+ case IrOpcode::kInt32Constant:
+ return node; // No change necessary.
+ case IrOpcode::kFloat32Constant:
+ return jsgraph()->Int32Constant(
+ DoubleToInt32(OpParameter<float>(node)));
+ case IrOpcode::kNumberConstant:
+ case IrOpcode::kFloat64Constant:
+ return jsgraph()->Int32Constant(
+ DoubleToInt32(OpParameter<double>(node)));
+ default:
+ break;
+ }
+ // Select the correct X -> Word32 truncation operator.
+ const Operator* op = NULL;
+ if (output_type & kRepFloat64) {
+ op = machine()->TruncateFloat64ToInt32();
+ } else if (output_type & kRepFloat32) {
+ node = InsertChangeFloat32ToFloat64(node);
+ op = machine()->TruncateFloat64ToInt32();
+ } else if (output_type & kRepTagged) {
+ node = InsertChangeTaggedToFloat64(node);
+ op = machine()->TruncateFloat64ToInt32();
+ } else {
+ return TypeError(node, output_type, kRepWord32);
+ }
+ return jsgraph()->graph()->NewNode(op, node);
+ }
+
Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type,
bool use_unsigned) {
// Eagerly fold representation changes for constants.
@@ -421,6 +452,11 @@ class RepresentationChanger {
node);
}
+ Node* InsertChangeTaggedToFloat64(Node* node) {
+ return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
+ node);
+ }
+
JSGraph* jsgraph() { return jsgraph_; }
Isolate* isolate() { return isolate_; }
SimplifiedOperatorBuilder* simplified() { return simplified_; }
« no previous file with comments | « no previous file | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698