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

Side by Side Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 555283004: [turbofan] Next step towards shared operators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/test-scheduler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits> 5 #include <limits>
6 6
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/control-builders.h" 8 #include "src/compiler/control-builders.h"
9 #include "src/compiler/generic-node-inl.h" 9 #include "src/compiler/generic-node-inl.h"
10 #include "src/compiler/graph-visualizer.h" 10 #include "src/compiler/graph-visualizer.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 ret = 642 ret =
643 graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start); 643 graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start);
644 end = graph()->NewNode(common()->End(), ret); 644 end = graph()->NewNode(common()->End(), ret);
645 graph()->SetEnd(end); 645 graph()->SetEnd(end);
646 p0 = graph()->NewNode(common()->Parameter(0), start); 646 p0 = graph()->NewNode(common()->Parameter(0), start);
647 p1 = graph()->NewNode(common()->Parameter(1), start); 647 p1 = graph()->NewNode(common()->Parameter(1), start);
648 NodeProperties::SetBounds(p0, Bounds(p0_type)); 648 NodeProperties::SetBounds(p0, Bounds(p0_type));
649 NodeProperties::SetBounds(p1, Bounds(p1_type)); 649 NodeProperties::SetBounds(p1, Bounds(p1_type));
650 } 650 }
651 651
652 void CheckLoweringBinop(IrOpcode::Value expected, Operator* op) { 652 void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) {
653 Node* node = Return(graph()->NewNode(op, p0, p1)); 653 Node* node = Return(graph()->NewNode(op, p0, p1));
654 Lower(); 654 Lower();
655 CHECK_EQ(expected, node->opcode()); 655 CHECK_EQ(expected, node->opcode());
656 } 656 }
657 657
658 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, Operator* op, 658 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op,
659 Operator* trunc) { 659 const Operator* trunc) {
660 Node* node = graph()->NewNode(op, p0, p1); 660 Node* node = graph()->NewNode(op, p0, p1);
661 Return(graph()->NewNode(trunc, node)); 661 Return(graph()->NewNode(trunc, node));
662 Lower(); 662 Lower();
663 CHECK_EQ(expected, node->opcode()); 663 CHECK_EQ(expected, node->opcode());
664 } 664 }
665 665
666 void Lower() { 666 void Lower() {
667 SimplifiedLowering lowering(&jsgraph); 667 SimplifiedLowering lowering(&jsgraph);
668 lowering.LowerAllNodes(); 668 lowering.LowerAllNodes();
669 } 669 }
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 kRepFloat64); 1101 kRepFloat64);
1102 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, kTypeInt32, kRepTagged); 1102 CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, kTypeInt32, kRepTagged);
1103 1103
1104 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, kTypeUint32, 1104 CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, kTypeUint32,
1105 kRepFloat64); 1105 kRepFloat64);
1106 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, kTypeUint32, 1106 CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, kTypeUint32,
1107 kRepTagged); 1107 kRepTagged);
1108 } 1108 }
1109 1109
1110 1110
1111 static void CheckChangesAroundBinop(TestingGraph* t, Operator* op, 1111 static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op,
1112 IrOpcode::Value input_change, 1112 IrOpcode::Value input_change,
1113 IrOpcode::Value output_change) { 1113 IrOpcode::Value output_change) {
1114 Node* binop = t->graph()->NewNode(op, t->p0, t->p1); 1114 Node* binop = t->graph()->NewNode(op, t->p0, t->p1);
1115 t->Return(binop); 1115 t->Return(binop);
1116 t->Lower(); 1116 t->Lower();
1117 CHECK_EQ(input_change, binop->InputAt(0)->opcode()); 1117 CHECK_EQ(input_change, binop->InputAt(0)->opcode());
1118 CHECK_EQ(input_change, binop->InputAt(1)->opcode()); 1118 CHECK_EQ(input_change, binop->InputAt(1)->opcode());
1119 CHECK_EQ(t->p0, binop->InputAt(0)->InputAt(0)); 1119 CHECK_EQ(t->p0, binop->InputAt(0)->InputAt(0));
1120 CHECK_EQ(t->p1, binop->InputAt(1)->InputAt(0)); 1120 CHECK_EQ(t->p1, binop->InputAt(1)->InputAt(0));
1121 CHECK_EQ(output_change, t->ret->InputAt(0)->opcode()); 1121 CHECK_EQ(output_change, t->ret->InputAt(0)->opcode());
1122 CHECK_EQ(binop, t->ret->InputAt(0)->InputAt(0)); 1122 CHECK_EQ(binop, t->ret->InputAt(0)->InputAt(0));
1123 } 1123 }
1124 1124
1125 1125
1126 TEST(InsertChangesAroundInt32Binops) { 1126 TEST(InsertChangesAroundInt32Binops) {
1127 TestingGraph t(Type::Signed32(), Type::Signed32()); 1127 TestingGraph t(Type::Signed32(), Type::Signed32());
1128 1128
1129 Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), 1129 const Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(),
1130 t.machine()->Int32Mul(), t.machine()->Int32Div(), 1130 t.machine()->Int32Mul(), t.machine()->Int32Div(),
1131 t.machine()->Int32Mod(), t.machine()->Word32And(), 1131 t.machine()->Int32Mod(), t.machine()->Word32And(),
1132 t.machine()->Word32Or(), t.machine()->Word32Xor(), 1132 t.machine()->Word32Or(), t.machine()->Word32Xor(),
1133 t.machine()->Word32Shl(), t.machine()->Word32Sar()}; 1133 t.machine()->Word32Shl(), t.machine()->Word32Sar()};
1134 1134
1135 for (size_t i = 0; i < arraysize(ops); i++) { 1135 for (size_t i = 0; i < arraysize(ops); i++) {
1136 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, 1136 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
1137 IrOpcode::kChangeInt32ToTagged); 1137 IrOpcode::kChangeInt32ToTagged);
1138 } 1138 }
1139 } 1139 }
1140 1140
1141 1141
1142 TEST(InsertChangesAroundInt32Cmp) { 1142 TEST(InsertChangesAroundInt32Cmp) {
1143 TestingGraph t(Type::Signed32(), Type::Signed32()); 1143 TestingGraph t(Type::Signed32(), Type::Signed32());
1144 1144
1145 Operator* ops[] = {t.machine()->Int32LessThan(), 1145 const Operator* ops[] = {t.machine()->Int32LessThan(),
1146 t.machine()->Int32LessThanOrEqual()}; 1146 t.machine()->Int32LessThanOrEqual()};
1147 1147
1148 for (size_t i = 0; i < arraysize(ops); i++) { 1148 for (size_t i = 0; i < arraysize(ops); i++) {
1149 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, 1149 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32,
1150 IrOpcode::kChangeBitToBool); 1150 IrOpcode::kChangeBitToBool);
1151 } 1151 }
1152 } 1152 }
1153 1153
1154 1154
1155 TEST(InsertChangesAroundUint32Cmp) { 1155 TEST(InsertChangesAroundUint32Cmp) {
1156 TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); 1156 TestingGraph t(Type::Unsigned32(), Type::Unsigned32());
1157 1157
1158 Operator* ops[] = {t.machine()->Uint32LessThan(), 1158 const Operator* ops[] = {t.machine()->Uint32LessThan(),
1159 t.machine()->Uint32LessThanOrEqual()}; 1159 t.machine()->Uint32LessThanOrEqual()};
1160 1160
1161 for (size_t i = 0; i < arraysize(ops); i++) { 1161 for (size_t i = 0; i < arraysize(ops); i++) {
1162 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, 1162 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32,
1163 IrOpcode::kChangeBitToBool); 1163 IrOpcode::kChangeBitToBool);
1164 } 1164 }
1165 } 1165 }
1166 1166
1167 1167
1168 TEST(InsertChangesAroundFloat64Binops) { 1168 TEST(InsertChangesAroundFloat64Binops) {
1169 TestingGraph t(Type::Number(), Type::Number()); 1169 TestingGraph t(Type::Number(), Type::Number());
1170 1170
1171 Operator* ops[] = { 1171 const Operator* ops[] = {
1172 t.machine()->Float64Add(), t.machine()->Float64Sub(), 1172 t.machine()->Float64Add(), t.machine()->Float64Sub(),
1173 t.machine()->Float64Mul(), t.machine()->Float64Div(), 1173 t.machine()->Float64Mul(), t.machine()->Float64Div(),
1174 t.machine()->Float64Mod(), 1174 t.machine()->Float64Mod(),
1175 }; 1175 };
1176 1176
1177 for (size_t i = 0; i < arraysize(ops); i++) { 1177 for (size_t i = 0; i < arraysize(ops); i++) {
1178 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, 1178 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
1179 IrOpcode::kChangeFloat64ToTagged); 1179 IrOpcode::kChangeFloat64ToTagged);
1180 } 1180 }
1181 } 1181 }
1182 1182
1183 1183
1184 TEST(InsertChangesAroundFloat64Cmp) { 1184 TEST(InsertChangesAroundFloat64Cmp) {
1185 TestingGraph t(Type::Number(), Type::Number()); 1185 TestingGraph t(Type::Number(), Type::Number());
1186 1186
1187 Operator* ops[] = {t.machine()->Float64Equal(), 1187 const Operator* ops[] = {t.machine()->Float64Equal(),
1188 t.machine()->Float64LessThan(), 1188 t.machine()->Float64LessThan(),
1189 t.machine()->Float64LessThanOrEqual()}; 1189 t.machine()->Float64LessThanOrEqual()};
1190 1190
1191 for (size_t i = 0; i < arraysize(ops); i++) { 1191 for (size_t i = 0; i < arraysize(ops); i++) {
1192 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, 1192 CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64,
1193 IrOpcode::kChangeBitToBool); 1193 IrOpcode::kChangeBitToBool);
1194 } 1194 }
1195 } 1195 }
1196 1196
1197 1197
1198 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) { 1198 void CheckFieldAccessArithmetic(FieldAccess access, Node* load_or_store) {
1199 Int32Matcher index = Int32Matcher(load_or_store->InputAt(1)); 1199 Int32Matcher index = Int32Matcher(load_or_store->InputAt(1));
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, 1441 Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0,
1442 load1, t.start); 1442 load1, t.start);
1443 t.Return(t.Use(phi, kMachineTypes[i])); 1443 t.Return(t.Use(phi, kMachineTypes[i]));
1444 t.Lower(); 1444 t.Lower();
1445 1445
1446 CHECK_EQ(IrOpcode::kPhi, phi->opcode()); 1446 CHECK_EQ(IrOpcode::kPhi, phi->opcode());
1447 CHECK_EQ(RepresentationOf(kMachineTypes[i]), 1447 CHECK_EQ(RepresentationOf(kMachineTypes[i]),
1448 RepresentationOf(OpParameter<MachineType>(phi))); 1448 RepresentationOf(OpParameter<MachineType>(phi)));
1449 } 1449 }
1450 } 1450 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698