llvm.org GIT mirror llvm / c1d6f75
[RISCV][NFC] Refactor RISCVDAGToDAGISel::Select Introduce and use a switch on the opcode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343688 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Bradbury 1 year, 9 months ago
1 changed file(s) with 13 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
6565 }
6666
6767 void RISCVDAGToDAGISel::Select(SDNode *Node) {
68 unsigned Opcode = Node->getOpcode();
69 MVT XLenVT = Subtarget->getXLenVT();
70
71 // If we have a custom node, we have already selected
68 // If we have a custom node, we have already selected.
7269 if (Node->isMachineOpcode()) {
7370 LLVM_DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << "\n");
7471 Node->setNodeId(-1);
7774
7875 // Instruction Selection not handled by the auto-generated tablegen selection
7976 // should be handled here.
77 unsigned Opcode = Node->getOpcode();
78 MVT XLenVT = Subtarget->getXLenVT();
79 SDLoc DL(Node);
8080 EVT VT = Node->getValueType(0);
81 if (Opcode == ISD::Constant && VT == XLenVT) {
82 auto *ConstNode = cast(Node);
83 // Materialize zero constants as copies from X0. This allows the coalescer
84 // to propagate these into other instructions.
85 if (ConstNode->isNullValue()) {
81
82 switch (Opcode) {
83 case ISD::Constant: {
84 auto ConstNode = cast(Node);
85 if (VT == XLenVT && ConstNode->isNullValue()) {
8686 SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), SDLoc(Node),
8787 RISCV::X0, XLenVT);
8888 ReplaceNode(Node, New.getNode());
8989 return;
9090 }
91 }
92 if (Opcode == ISD::FrameIndex) {
93 SDLoc DL(Node);
91 break;
92 }
93 case ISD::FrameIndex: {
9494 SDValue Imm = CurDAG->getTargetConstant(0, DL, XLenVT);
9595 int FI = cast(Node)->getIndex();
96 EVT VT = Node->getValueType(0);
9796 SDValue TFI = CurDAG->getTargetFrameIndex(FI, VT);
9897 ReplaceNode(Node, CurDAG->getMachineNode(RISCV::ADDI, DL, VT, TFI, Imm));
9998 return;
99 }
100100 }
101101
102102 // Select the default instruction.