Lines Matching refs:node
8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h"
27 InstructionOperand UseOperand(Node* node, InstructionCode opcode) {
28 if (CanBeImmediate(node, opcode)) {
29 return UseImmediate(node);
31 return UseRegister(node);
34 bool CanBeImmediate(Node* node, InstructionCode opcode) {
35 Int32Matcher m(node);
65 Node* node) {
67 selector->Emit(opcode, g.DefineAsRegister(node),
68 g.UseRegister(node->InputAt(0)),
69 g.UseRegister(node->InputAt(1)));
74 Node* node) {
76 selector->Emit(opcode, g.DefineAsRegister(node),
77 g.UseRegister(node->InputAt(0)));
82 Node* node) {
84 selector->Emit(opcode, g.DefineAsRegister(node),
85 g.UseRegister(node->InputAt(0)),
86 g.UseOperand(node->InputAt(1), opcode));
90 static void VisitBinop(InstructionSelector* selector, Node* node,
93 Int32BinopMatcher m(node);
99 inputs[input_count++] = g.UseRegister(m.left().node());
100 inputs[input_count++] = g.UseOperand(m.right().node(), opcode);
107 outputs[output_count++] = g.DefineAsRegister(node);
122 static void VisitBinop(InstructionSelector* selector, Node* node,
125 VisitBinop(selector, node, opcode, &cont);
129 void InstructionSelector::VisitLoad(Node* node) {
130 LoadRepresentation load_rep = LoadRepresentationOf(node->op());
132 Node* base = node->InputAt(0);
133 Node* index = node->InputAt(1);
162 g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index));
169 g.DefineAsRegister(node), addr_reg, g.TempImmediate(0));
174 void InstructionSelector::VisitStore(Node* node) {
176 Node* base = node->InputAt(0);
177 Node* index = node->InputAt(1);
178 Node* value = node->InputAt(2);
180 StoreRepresentation store_rep = StoreRepresentationOf(node->op());
255 void InstructionSelector::VisitWord32And(Node* node) {
257 Int32BinopMatcher m(node);
258 if (m.left().IsWord32Shr() && CanCover(node, m.left().node()) &&
269 Int32BinopMatcher mleft(m.left().node());
280 Emit(kMipsExt, g.DefineAsRegister(node),
281 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb),
295 Emit(kMipsIns, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()),
300 VisitBinop(this, node, kMipsAnd);
304 void InstructionSelector::VisitWord32Or(Node* node) {
305 VisitBinop(this, node, kMipsOr);
309 void InstructionSelector::VisitWord32Xor(Node* node) {
310 Int32BinopMatcher m(node);
311 if (m.left().IsWord32Or() && CanCover(node, m.left().node()) &&
313 Int32BinopMatcher mleft(m.left().node());
316 Emit(kMipsNor, g.DefineAsRegister(node),
317 g.UseRegister(mleft.left().node()),
318 g.UseRegister(mleft.right().node()));
325 Emit(kMipsNor, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
329 VisitBinop(this, node, kMipsXor);
333 void InstructionSelector::VisitWord32Shl(Node* node) {
334 Int32BinopMatcher m(node);
335 if (m.left().IsWord32And() && CanCover(node, m.left().node()) &&
338 Int32BinopMatcher mleft(m.left().node());
352 Emit(kMipsShl, g.DefineAsRegister(node),
353 g.UseRegister(mleft.left().node()),
354 g.UseImmediate(m.right().node()));
360 VisitRRO(this, kMipsShl, node);
364 void InstructionSelector::VisitWord32Shr(Node* node) {
365 Int32BinopMatcher m(node);
368 Int32BinopMatcher mleft(m.left().node());
378 Emit(kMipsExt, g.DefineAsRegister(node),
379 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb),
385 VisitRRO(this, kMipsShr, node);
389 void InstructionSelector::VisitWord32Sar(Node* node) {
390 VisitRRO(this, kMipsSar, node);
394 void InstructionSelector::VisitWord32Ror(Node* node) {
395 VisitRRO(this, kMipsRor, node);
399 void InstructionSelector::VisitWord32Clz(Node* node) {
400 VisitRR(this, kMipsClz, node);
404 void InstructionSelector::VisitWord32Ctz(Node* node) { UNREACHABLE(); }
407 void InstructionSelector::VisitWord32Popcnt(Node* node) { UNREACHABLE(); }
410 void InstructionSelector::VisitInt32Add(Node* node) {
414 VisitBinop(this, node, kMipsAdd);
418 void InstructionSelector::VisitInt32Sub(Node* node) {
419 VisitBinop(this, node, kMipsSub);
423 void InstructionSelector::VisitInt32Mul(Node* node) {
425 Int32BinopMatcher m(node);
430 g.DefineAsRegister(node), g.UseRegister(m.left().node()),
437 g.UseRegister(m.left().node()),
440 g.DefineAsRegister(node), g.UseRegister(m.left().node()), temp);
446 g.UseRegister(m.left().node()),
449 g.DefineAsRegister(node), temp, g.UseRegister(m.left().node()));
453 VisitRRR(this, kMipsMul, node);
457 void InstructionSelector::VisitInt32MulHigh(Node* node) {
458 VisitRRR(this, kMipsMulHigh, node);
462 void InstructionSelector::VisitUint32MulHigh(Node* node) {
464 Emit(kMipsMulHighU, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
465 g.UseRegister(node->InputAt(1)));
469 void InstructionSelector::VisitInt32Div(Node* node) {
471 Int32BinopMatcher m(node);
472 Emit(kMipsDiv, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()),
473 g.UseRegister(m.right().node()));
477 void InstructionSelector::VisitUint32Div(Node* node) {
479 Int32BinopMatcher m(node);
480 Emit(kMipsDivU, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()),
481 g.UseRegister(m.right().node
485 void InstructionSelector::VisitInt32Mod(Node* node) {
487 Int32BinopMatcher m(node);
488 Emit(kMipsMod, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
489 g.UseRegister(m.right().node()));
493 void InstructionSelector::VisitUint32Mod(Node* node) {
495 Int32BinopMatcher m(node);
496 Emit(kMipsModU, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
497 g.UseRegister(m.right().node()));
501 void InstructionSelector::VisitChangeFloat32ToFloat64(Node* node) {
502 VisitRR(this, kMipsCvtDS, node);
506 void InstructionSelector::VisitChangeInt32ToFloat64(Node* node) {
507 VisitRR(this, kMipsCvtDW, node);
511 void InstructionSelector::VisitChangeUint32ToFloat64(Node* node) {
512 VisitRR(this, kMipsCvtDUw, node);
516 void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) {
518 Node* value = node->InputAt(0);
521 if (CanCover(node, value)) {
524 Emit(kMipsFloorWD, g.DefineAsRegister(node),
528 Emit(kMipsCeilWD, g.DefineAsRegister(node),
532 Emit(kMipsRoundWD, g.DefineAsRegister(node),
536 Emit(kMipsTruncWD, g.DefineAsRegister(node),
543 Node* next = value->InputAt(0);
548 Emit(kMipsFloorWS, g.DefineAsRegister(node),
552 Emit(kMipsCeilWS, g.DefineAsRegister(node),
556 Emit(kMipsRoundWS, g.DefineAsRegister(node),
560 Emit(kMipsTruncWS, g.DefineAsRegister(node),
564 Emit(kMipsTruncWS, g.DefineAsRegister(node),
570 Emit(kMipsTruncWS, g.DefineAsRegister(node),
576 VisitRR(this, kMipsTruncWD, node);
580 void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) {
581 VisitRR(this, kMipsTruncUwD, node);
585 void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) {
587 Node* value = node->InputAt(0);
590 if (CanCover(node, value) &&
592 Emit(kMipsCvtSW, g.DefineAsRegister(node),
596 VisitRR(this, kMipsCvtSD, node);
600 void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) {
601 switch (TruncationModeOf(node->op())) {
603 return VisitRR(this, kArchTruncateDoubleToI, node);
605 return VisitRR(this, kMipsTruncWD, node);
611 void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) {
612 VisitRR(this, kMipsFloat64ExtractLowWord32, node);
616 void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) {
618 Emit(kMipsFloat64InsertLowWord32, g.DefineAsRegister(node),
620 g.UseRegister(node->InputAt(0)));
624 void InstructionSelector::VisitFloat32Add(Node* node) {
625 VisitRRR(this, kMipsAddS, node);
629 void InstructionSelector::VisitFloat64Add(Node* node) {
630 VisitRRR(this, kMipsAddD, node);
634 void InstructionSelector::VisitFloat32Sub(Node* node) {
635 VisitRRR(this, kMipsSubS, node);
639 void InstructionSelector::VisitFloat64Sub(Node* node) {
641 Float64BinopMatcher m(node);
643 CanCover(m.node(), m.right().node())) {
645 CanCover(m.right().node(), m.right().InputAt(0))) {
648 Emit(kMipsFloat64RoundUp, g.DefineAsRegister(node),
649 g.UseRegister(mright0.right().node()));
654 VisitRRR(this, kMipsSubD, node);
658 void InstructionSelector::VisitFloat32Mul(Node* node) {
659 VisitRRR(this, kMipsMulS, node);
663 void InstructionSelector::VisitFloat64Mul(Node* node) {
664 VisitRRR(this, kMipsMulD, node);
668 void InstructionSelector::VisitFloat32Div(Node* node) {
669 VisitRRR(this, kMipsDivS, node);
673 void InstructionSelector::VisitFloat64Div(Node* node) {
674 VisitRRR(this, kMipsDivD, node);
678 void InstructionSelector::VisitFloat64Mod(Node* node) {
680 Emit(kMipsModD, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f12),
681 g.UseFixed(node->InputAt(1), f14))->MarkAsCall();
685 void InstructionSelector::VisitFloat32Max(Node* node) {
688 Emit(kMipsFloat32Max, g.DefineAsRegister(node),
689 g.UseUniqueRegister(node->InputAt(0)),
690 g.UseUniqueRegister(node->InputAt(1)));
694 Emit(kMipsFloat32Max, g.DefineSameAsFirst(node),
695 g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(0)));
700 void InstructionSelector::VisitFloat64Max(Node* node) {
703 Emit(kMipsFloat64Max, g.DefineAsRegister(node),
704 g.UseUniqueRegister(node->InputAt(0)),
705 g.UseUniqueRegister(node->InputAt(1)));
709 Emit(kMipsFloat64Max, g.DefineSameAsFirst(node),
710 g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(0)));
715 void InstructionSelector::VisitFloat32Min(Node* node) {
718 Emit(kMipsFloat32Min, g.DefineAsRegister(node),
719 g.UseUniqueRegister(node->InputAt(0)),
720 g.UseUniqueRegister(node->InputAt(1)));
724 Emit(kMipsFloat32Min, g.DefineSameAsFirst(node),
725 g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(0)));
730 void InstructionSelector::VisitFloat64Min(Node* node) {
733 Emit(kMipsFloat64Min, g.DefineAsRegister(node),
734 g.UseUniqueRegister(node->InputAt(0)),
735 g.UseUniqueRegister(node->InputAt(1)));
739 Emit(kMipsFloat64Min, g.DefineSameAsFirst(node),
740 g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(0)));
745 void InstructionSelector::VisitFloat32Abs(Node* node) {
746 VisitRR(this, kMipsAbsS, node);
750 void InstructionSelector::VisitFloat64Abs(Node* node) {
751 VisitRR(this, kMipsAbsD, node);
755 void InstructionSelector::VisitFloat32Sqrt(Node* node) {
756 VisitRR(this, kMipsSqrtS, node);
760 void InstructionSelector::VisitFloat64Sqrt(Node* node) {
761 VisitRR(this, kMipsSqrtD, node);
765 void InstructionSelector::VisitFloat32RoundDown(Node* node) {
766 VisitRR(this, kMipsFloat32RoundDown, node);
770 void InstructionSelector::VisitFloat64RoundDown(Node* node) {
771 VisitRR(this, kMipsFloat64RoundDown, node);
775 void InstructionSelector::VisitFloat32RoundUp(Node* node) {
776 VisitRR(this, kMipsFloat32RoundUp, node);
780 void InstructionSelector::VisitFloat64RoundUp(Node* node) {
781 VisitRR(this, kMipsFloat64RoundUp, node);
785 void InstructionSelector::VisitFloat32RoundTruncate(Node* node) {
786 VisitRR(this, kMipsFloat32RoundTruncate, node);
790 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) {
791 VisitRR(this, kMipsFloat64RoundTruncate, node);
795 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) {
800 void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) {
801 VisitRR(this, kMipsFloat32RoundTiesEven, node);
805 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) {
806 VisitRR(this, kMipsFloat64RoundTiesEven, node);
812 Node* node) {
824 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node()),
837 if (input.node()) {
838 Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node()),
849 void InstructionSelector::VisitCheckedLoad(Node* node) {
850 CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op());
852 Node* const buffer = node->InputAt(0);
853 Node* const offset = node->InputAt(1);
854 Node* const length = node->InputAt(2);
890 g.DefineAsRegister(node), offset_operand, length_operand,
895 void InstructionSelector::VisitCheckedStore(Node* node) {
896 MachineRepresentation rep = CheckedStoreRepresentationOf(node->op());
898 Node* const buffer = node->InputAt(0);
899 Node* const offset = node->InputAt(1);
900 Node* const length = node->InputAt(2);
901 Node* const value = node->InputAt(3);
958 void VisitFloat32Compare(InstructionSelector* selector, Node* node,
961 Float32BinopMatcher m(node);
964 lhs = m.left().IsZero() ? g.UseImmediate(m.left().node())
965 : g.UseRegister(m.left().node());
966 rhs = m.right().IsZero() ? g.UseImmediate(m.right().node())
967 : g.UseRegister(m.right().node());
973 void VisitFloat64Compare(InstructionSelector* selector, Node* node,
976 Float64BinopMatcher m(node);
979 lhs = m.left().IsZero() ? g.UseImmediate(m.left().node())
980 : g.UseRegister(m.left().node());
981 rhs = m.right().IsZero() ? g.UseImmediate(m.right().node())
982 : g.UseRegister(m.right().node());
988 void VisitWordCompare(InstructionSelector* selector, Node* node,
992 Node* left = node->InputAt(0);
993 Node* right = node->InputAt(1);
1050 void VisitWordCompare(InstructionSelector* selector, Node* node,
1052 VisitWordCompare(selector, node, kMipsCmp, cont, false);
1059 void VisitWordCompareZero(InstructionSelector* selector, Node* user,
1060 Node* value, FlagsContinuation* cont) {
1069 value = m.left().node();
1108 // <Operation>WithOverflow node.
1115 Node* const node = value->InputAt(0);
1116 Node* const result = NodeProperties::FindProjection(node, 0);
1118 switch (node->opcode()) {
1121 return VisitBinop(selector, node, kMipsAddOvf, cont);
1124 return VisitBinop(selector, node, kMipsSubOvf, cont);
1153 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
1160 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) {
1162 InstructionOperand value_operand = g.UseRegister(node->InputAt(0));
1188 void InstructionSelector::VisitWord32Equal(Node* const node) {
1189 FlagsContinuation cont(kEqual, node);
1190 Int32BinopMatcher m(node);
1192 return VisitWordCompareZero(this, m.node(), m.left().node(), &cont);
1194 VisitWordCompare(this, node, &cont);
1198 void InstructionSelector::VisitInt32LessThan(Node* node) {
1199 FlagsContinuation cont(kSignedLessThan, node);
1200 VisitWordCompare(this, node, &cont);
1204 void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) {
1205 FlagsContinuation cont(kSignedLessThanOrEqual, node);
1206 VisitWordCompare(this, node, &cont);
1210 void InstructionSelector::VisitUint32LessThan(Node* node) {
1211 FlagsContinuation cont(kUnsignedLessThan, node);
1212 VisitWordCompare(this, node, &cont);
1216 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) {
1217 FlagsContinuation cont(kUnsignedLessThanOrEqual, node);
1218 VisitWordCompare(this, node, &cont);
1222 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) {
1223 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1225 return VisitBinop(this, node, kMipsAddOvf, &cont);
1228 VisitBinop(this, node, kMipsAddOvf, &cont);
1232 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) {
1233 if (Node* ovf = NodeProperties::FindProjection(node, 1)) {
1235 return VisitBinop(this, node, kMipsSubOvf, &cont);
1238 VisitBinop(this, node, kMipsSubOvf, &cont);
1242 void InstructionSelector::VisitFloat32Equal(Node* node) {
1243 FlagsContinuation cont(kEqual, node);
1244 VisitFloat32Compare(this, node, &cont);
1248 void InstructionSelector::VisitFloat32LessThan(Node* node) {
1249 FlagsContinuation cont(kUnsignedLessThan, node);
1250 VisitFloat32Compare(this, node, &cont);
1254 void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) {
1255 FlagsContinuation cont(kUnsignedLessThanOrEqual, node);
1256 VisitFloat32Compare(this, node, &cont);
1260 void InstructionSelector::VisitFloat64Equal(Node* node) {
1261 FlagsContinuation cont(kEqual, node);
1262 VisitFloat64Compare(this, node, &cont);
1266 void InstructionSelector::VisitFloat64LessThan(Node* node) {
1267 FlagsContinuation cont(kUnsignedLessThan, node);
1268 VisitFloat64Compare(this, node, &cont);
1272 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) {
1273 FlagsContinuation cont(kUnsignedLessThanOrEqual, node);
1274 VisitFloat64Compare(this, node, &cont);
1278 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) {
1280 Emit(kMipsFloat64ExtractLowWord32, g.DefineAsRegister(node),
1281 g.UseRegister(node->InputAt(0)));
1285 void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) {
1287 Emit(kMipsFloat64ExtractHighWord32, g.DefineAsRegister(node),
1288 g.UseRegister(node->InputAt(0)));
1292 void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) {
1294 Node* left = node->InputAt(0);
1295 Node* right = node->InputAt(1);
1296 Emit(kMipsFloat64InsertLowWord32, g.DefineSameAsFirst(node),
1301 void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
1303 Node* left = node->InputAt(0);
1304 Node* right = node->InputAt(1);
1305 Emit(kMipsFloat64InsertHighWord32, g.DefineSameAsFirst(node),