blob: bce8e3d9d37746a25726f68f46712594d9da1bf6 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- MipsISelDAGToDAG.cpp - A dag to dag inst selector for Mips --------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines an instruction selector for the MIPS target.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "mips-isel"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015#include "Mips.h"
16#include "MipsISelLowering.h"
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +000017#include "MipsMachineFunction.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018#include "MipsRegisterInfo.h"
19#include "MipsSubtarget.h"
20#include "MipsTargetMachine.h"
21#include "llvm/GlobalValue.h"
22#include "llvm/Instructions.h"
23#include "llvm/Intrinsics.h"
24#include "llvm/Support/CFG.h"
25#include "llvm/Type.h"
26#include "llvm/CodeGen/MachineConstantPool.h"
27#include "llvm/CodeGen/MachineFunction.h"
28#include "llvm/CodeGen/MachineFrameInfo.h"
29#include "llvm/CodeGen/MachineInstrBuilder.h"
Chris Lattner1b989192007-12-31 04:13:23 +000030#include "llvm/CodeGen/MachineRegisterInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000031#include "llvm/CodeGen/SelectionDAGISel.h"
32#include "llvm/Target/TargetMachine.h"
33#include "llvm/Support/Compiler.h"
34#include "llvm/Support/Debug.h"
Edwin Török4d9756a2009-07-08 20:53:28 +000035#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/raw_ostream.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037using namespace llvm;
38
39//===----------------------------------------------------------------------===//
40// Instruction Selector Implementation
41//===----------------------------------------------------------------------===//
42
43//===----------------------------------------------------------------------===//
44// MipsDAGToDAGISel - MIPS specific code to select MIPS machine
45// instructions for SelectionDAG operations.
46//===----------------------------------------------------------------------===//
47namespace {
48
49class VISIBILITY_HIDDEN MipsDAGToDAGISel : public SelectionDAGISel {
50
51 /// TM - Keep a reference to MipsTargetMachine.
52 MipsTargetMachine &TM;
53
Dan Gohmanf17a25c2007-07-18 16:29:46 +000054 /// Subtarget - Keep a pointer to the MipsSubtarget around so that we can
55 /// make the right decision when generating code for different targets.
Bruno Cardoso Lopes4fb1f542008-07-05 19:05:21 +000056 const MipsSubtarget &Subtarget;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
58public:
Dan Gohmane887fdf2008-07-07 18:00:37 +000059 explicit MipsDAGToDAGISel(MipsTargetMachine &tm) :
Dan Gohman96eb47a2009-01-15 19:20:50 +000060 SelectionDAGISel(tm),
Dan Gohmanf2b29572008-10-03 16:55:19 +000061 TM(tm), Subtarget(tm.getSubtarget<MipsSubtarget>()) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062
Dan Gohman14a66442008-08-23 02:25:05 +000063 virtual void InstructionSelect();
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064
65 // Pass Name
66 virtual const char *getPassName() const {
67 return "MIPS DAG->DAG Pattern Instruction Selection";
68 }
69
70
71private:
72 // Include the pieces autogenerated from the target description.
73 #include "MipsGenDAGISel.inc"
74
Dan Gohman40653f32009-06-03 20:30:14 +000075 /// getTargetMachine - Return a reference to the TargetMachine, casted
76 /// to the target-specific type.
77 const MipsTargetMachine &getTargetMachine() {
78 return static_cast<const MipsTargetMachine &>(TM);
79 }
80
81 /// getInstrInfo - Return a reference to the TargetInstrInfo, casted
82 /// to the target-specific type.
83 const MipsInstrInfo *getInstrInfo() {
84 return getTargetMachine().getInstrInfo();
85 }
86
87 SDNode *getGlobalBaseReg();
Dan Gohman8181bd12008-07-27 21:46:04 +000088 SDNode *Select(SDValue N);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000089
90 // Complex Pattern.
Dan Gohman8181bd12008-07-27 21:46:04 +000091 bool SelectAddr(SDValue Op, SDValue N,
92 SDValue &Base, SDValue &Offset);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000093
94
95 // getI32Imm - Return a target constant with the specified
96 // value, of type i32.
Dan Gohman8181bd12008-07-27 21:46:04 +000097 inline SDValue getI32Imm(unsigned Imm) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098 return CurDAG->getTargetConstant(Imm, MVT::i32);
99 }
100
101
102 #ifndef NDEBUG
103 unsigned Indent;
104 #endif
105};
106
107}
108
Evan Cheng34fd4f32008-06-30 20:45:06 +0000109/// InstructionSelect - This callback is invoked by
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000110/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
111void MipsDAGToDAGISel::
Dan Gohman14a66442008-08-23 02:25:05 +0000112InstructionSelect()
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000113{
114 DEBUG(BB->dump());
115 // Codegen the basic block.
116 #ifndef NDEBUG
117 DOUT << "===== Instruction selection begins:\n";
118 Indent = 0;
119 #endif
120
121 // Select target instructions for the DAG.
David Greene932618b2008-10-27 21:56:29 +0000122 SelectRoot(*CurDAG);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
124 #ifndef NDEBUG
125 DOUT << "===== Instruction selection ends:\n";
126 #endif
127
Dan Gohman14a66442008-08-23 02:25:05 +0000128 CurDAG->RemoveDeadNodes();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129}
130
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000131/// getGlobalBaseReg - Output the instructions required to put the
132/// GOT address into a register.
Dan Gohman40653f32009-06-03 20:30:14 +0000133SDNode *MipsDAGToDAGISel::getGlobalBaseReg() {
134 MachineFunction *MF = BB->getParent();
135 unsigned GlobalBaseReg = getInstrInfo()->getGlobalBaseReg(MF);
136 return CurDAG->getRegister(GlobalBaseReg, TLI.getPointerTy()).getNode();
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000137}
138
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139/// ComplexPattern used on MipsInstrInfo
140/// Used on Mips Load/Store instructions
141bool MipsDAGToDAGISel::
Dan Gohman8181bd12008-07-27 21:46:04 +0000142SelectAddr(SDValue Op, SDValue Addr, SDValue &Offset, SDValue &Base)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143{
144 // if Address is FI, get the TargetFrameIndex.
145 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) {
146 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32);
147 Offset = CurDAG->getTargetConstant(0, MVT::i32);
148 return true;
149 }
150
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000151 // on PIC code Load GA
152 if (TM.getRelocationModel() == Reloc::PIC_) {
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000153 if ((Addr.getOpcode() == ISD::TargetGlobalAddress) ||
154 (Addr.getOpcode() == ISD::TargetJumpTable)){
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000155 Base = CurDAG->getRegister(Mips::GP, MVT::i32);
156 Offset = Addr;
157 return true;
158 }
159 } else {
Bill Wendlingfef06052008-09-16 21:48:12 +0000160 if ((Addr.getOpcode() == ISD::TargetExternalSymbol ||
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000161 Addr.getOpcode() == ISD::TargetGlobalAddress))
162 return false;
163 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164
Bruno Cardoso Lopes77ba7152007-08-18 02:16:30 +0000165 // Operand is a result from an ADD.
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000166 if (Addr.getOpcode() == ISD::ADD) {
167 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1))) {
168 if (Predicate_immSExt16(CN)) {
169
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170 // If the first operand is a FI, get the TargetFI Node
171 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>
172 (Addr.getOperand(0))) {
173 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32);
174 } else {
175 Base = Addr.getOperand(0);
176 }
177
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000178 Offset = CurDAG->getTargetConstant(CN->getZExtValue(), MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 return true;
180 }
181 }
182 }
183
184 Base = Addr;
185 Offset = CurDAG->getTargetConstant(0, MVT::i32);
186 return true;
187}
188
189/// Select instructions not customized! Used for
190/// expanded, promoted and normal instructions
191SDNode* MipsDAGToDAGISel::
Dan Gohman8181bd12008-07-27 21:46:04 +0000192Select(SDValue N)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193{
Gabor Greif1c80d112008-08-28 21:40:38 +0000194 SDNode *Node = N.getNode();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 unsigned Opcode = Node->getOpcode();
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000196 DebugLoc dl = Node->getDebugLoc();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197
198 // Dump information about the Node being selected
199 #ifndef NDEBUG
200 DOUT << std::string(Indent, ' ') << "Selecting: ";
201 DEBUG(Node->dump(CurDAG));
202 DOUT << "\n";
203 Indent += 2;
204 #endif
205
206 // If we have a custom node, we already have selected!
Dan Gohmanbd68c792008-07-17 19:10:17 +0000207 if (Node->isMachineOpcode()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208 #ifndef NDEBUG
209 DOUT << std::string(Indent-2, ' ') << "== ";
210 DEBUG(Node->dump(CurDAG));
211 DOUT << "\n";
212 Indent -= 2;
213 #endif
214 return NULL;
215 }
216
217 ///
Bruno Cardoso Lopes96433662007-09-24 20:15:11 +0000218 // Instruction Selection not handled by the auto-generated
219 // tablegen selection should be handled here.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220 ///
221 switch(Opcode) {
222
223 default: break;
224
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000225 case ISD::SUBE:
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000226 case ISD::ADDE: {
Dan Gohman8181bd12008-07-27 21:46:04 +0000227 SDValue InFlag = Node->getOperand(2), CmpLHS;
Chris Lattner871ec4e2008-12-14 21:38:24 +0000228 unsigned Opc = InFlag.getOpcode(); Opc=Opc;
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000229 assert(((Opc == ISD::ADDC || Opc == ISD::ADDE) ||
230 (Opc == ISD::SUBC || Opc == ISD::SUBE)) &&
231 "(ADD|SUB)E flag operand must come from (ADD|SUB)C/E insn");
232
Chris Lattner871ec4e2008-12-14 21:38:24 +0000233 unsigned MOp;
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000234 if (Opcode == ISD::ADDE) {
235 CmpLHS = InFlag.getValue(0);
236 MOp = Mips::ADDu;
237 } else {
238 CmpLHS = InFlag.getOperand(0);
239 MOp = Mips::SUBu;
240 }
241
Dan Gohman8181bd12008-07-27 21:46:04 +0000242 SDValue Ops[] = { CmpLHS, InFlag.getOperand(1) };
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000243
Dan Gohman8181bd12008-07-27 21:46:04 +0000244 SDValue LHS = Node->getOperand(0);
245 SDValue RHS = Node->getOperand(1);
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000246
Duncan Sands92c43912008-06-06 12:08:01 +0000247 MVT VT = LHS.getValueType();
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000248 SDNode *Carry = CurDAG->getTargetNode(Mips::SLTu, dl, VT, Ops, 2);
249 SDNode *AddCarry = CurDAG->getTargetNode(Mips::ADDu, dl, VT,
Dan Gohman8181bd12008-07-27 21:46:04 +0000250 SDValue(Carry,0), RHS);
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000251
Dale Johannesen3c6df7e2009-06-01 23:12:52 +0000252 return CurDAG->SelectNodeTo(N.getNode(), MOp, VT, MVT::Flag,
Dan Gohman8181bd12008-07-27 21:46:04 +0000253 LHS, SDValue(AddCarry,0));
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000254 }
255
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000256 /// Mul/Div with two results
257 case ISD::SDIVREM:
258 case ISD::UDIVREM:
259 case ISD::SMUL_LOHI:
260 case ISD::UMUL_LOHI: {
Dan Gohman8181bd12008-07-27 21:46:04 +0000261 SDValue Op1 = Node->getOperand(0);
262 SDValue Op2 = Node->getOperand(1);
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000263
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000264 unsigned Op;
265 if (Opcode == ISD::UMUL_LOHI || Opcode == ISD::SMUL_LOHI)
266 Op = (Opcode == ISD::UMUL_LOHI ? Mips::MULTu : Mips::MULT);
267 else
268 Op = (Opcode == ISD::UDIVREM ? Mips::DIVu : Mips::DIV);
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000269
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000270 SDNode *Node = CurDAG->getTargetNode(Op, dl, MVT::Flag, Op1, Op2);
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000271
Dan Gohman8181bd12008-07-27 21:46:04 +0000272 SDValue InFlag = SDValue(Node, 0);
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000273 SDNode *Lo = CurDAG->getTargetNode(Mips::MFLO, dl, MVT::i32,
Bruno Cardoso Lopes68011702008-07-09 04:45:36 +0000274 MVT::Flag, InFlag);
Dan Gohman8181bd12008-07-27 21:46:04 +0000275 InFlag = SDValue(Lo,1);
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000276 SDNode *Hi = CurDAG->getTargetNode(Mips::MFHI, dl, MVT::i32, InFlag);
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000277
278 if (!N.getValue(0).use_empty())
Dan Gohman8181bd12008-07-27 21:46:04 +0000279 ReplaceUses(N.getValue(0), SDValue(Lo,0));
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000280
281 if (!N.getValue(1).use_empty())
Dan Gohman8181bd12008-07-27 21:46:04 +0000282 ReplaceUses(N.getValue(1), SDValue(Hi,0));
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000283
284 return NULL;
Bruno Cardoso Lopesed7723d2008-06-06 00:58:26 +0000285 }
286
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000287 /// Special Muls
288 case ISD::MUL:
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289 case ISD::MULHS:
290 case ISD::MULHU: {
Dan Gohman8181bd12008-07-27 21:46:04 +0000291 SDValue MulOp1 = Node->getOperand(0);
292 SDValue MulOp2 = Node->getOperand(1);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293
294 unsigned MulOp = (Opcode == ISD::MULHU ? Mips::MULTu : Mips::MULT);
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000295 SDNode *MulNode = CurDAG->getTargetNode(MulOp, dl,
296 MVT::Flag, MulOp1, MulOp2);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297
Dan Gohman8181bd12008-07-27 21:46:04 +0000298 SDValue InFlag = SDValue(MulNode, 0);
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000299
300 if (MulOp == ISD::MUL)
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000301 return CurDAG->getTargetNode(Mips::MFLO, dl, MVT::i32, InFlag);
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000302 else
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000303 return CurDAG->getTargetNode(Mips::MFHI, dl, MVT::i32, InFlag);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 }
305
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000306 /// Div/Rem operations
307 case ISD::SREM:
308 case ISD::UREM:
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 case ISD::SDIV:
310 case ISD::UDIV: {
Dan Gohman8181bd12008-07-27 21:46:04 +0000311 SDValue Op1 = Node->getOperand(0);
312 SDValue Op2 = Node->getOperand(1);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313
Bruno Cardoso Lopesf2377552008-06-06 06:37:31 +0000314 unsigned Op, MOp;
315 if (Opcode == ISD::SDIV || Opcode == ISD::UDIV) {
316 Op = (Opcode == ISD::SDIV ? Mips::DIV : Mips::DIVu);
317 MOp = Mips::MFLO;
318 } else {
319 Op = (Opcode == ISD::SREM ? Mips::DIV : Mips::DIVu);
320 MOp = Mips::MFHI;
321 }
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000322 SDNode *Node = CurDAG->getTargetNode(Op, dl, MVT::Flag, Op1, Op2);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323
Dan Gohman8181bd12008-07-27 21:46:04 +0000324 SDValue InFlag = SDValue(Node, 0);
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000325 return CurDAG->getTargetNode(MOp, dl, MVT::i32, InFlag);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 }
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000327
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000328 // Get target GOT address.
Dan Gohman40653f32009-06-03 20:30:14 +0000329 case ISD::GLOBAL_OFFSET_TABLE:
330 return getGlobalBaseReg();
Bruno Cardoso Lopesea377302007-11-12 19:49:57 +0000331
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000332 /// Handle direct and indirect calls when using PIC. On PIC, when
333 /// GOT is smaller than about 64k (small code) the GA target is
334 /// loaded with only one instruction. Otherwise GA's target must
335 /// be loaded with 3 instructions.
336 case MipsISD::JmpLink: {
337 if (TM.getRelocationModel() == Reloc::PIC_) {
338 //bool isCodeLarge = (TM.getCodeModel() == CodeModel::Large);
Dan Gohman8181bd12008-07-27 21:46:04 +0000339 SDValue Chain = Node->getOperand(0);
340 SDValue Callee = Node->getOperand(1);
Dan Gohman8181bd12008-07-27 21:46:04 +0000341 SDValue T9Reg = CurDAG->getRegister(Mips::T9, MVT::i32);
342 SDValue InFlag(0, 0);
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000343
344 if ( (isa<GlobalAddressSDNode>(Callee)) ||
Bill Wendlingfef06052008-09-16 21:48:12 +0000345 (isa<ExternalSymbolSDNode>(Callee)) )
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000346 {
347 /// Direct call for global addresses and external symbols
Dan Gohman8181bd12008-07-27 21:46:04 +0000348 SDValue GPReg = CurDAG->getRegister(Mips::GP, MVT::i32);
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000349
350 // Use load to get GOT target
Dan Gohman8181bd12008-07-27 21:46:04 +0000351 SDValue Ops[] = { Callee, GPReg, Chain };
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000352 SDValue Load = SDValue(CurDAG->getTargetNode(Mips::LW, dl, MVT::i32,
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000353 MVT::Other, Ops, 3), 0);
354 Chain = Load.getValue(1);
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000355
356 // Call target must be on T9
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000357 Chain = CurDAG->getCopyToReg(Chain, dl, T9Reg, Load, InFlag);
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000358 } else
359 /// Indirect call
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000360 Chain = CurDAG->getCopyToReg(Chain, dl, T9Reg, Callee, InFlag);
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000361
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000362 // Emit Jump and Link Register
Dale Johannesenb03cc3f2009-02-04 23:02:30 +0000363 SDNode *ResNode = CurDAG->getTargetNode(Mips::JALR, dl, MVT::Other,
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000364 MVT::Flag, T9Reg, Chain);
Dan Gohman8181bd12008-07-27 21:46:04 +0000365 Chain = SDValue(ResNode, 0);
366 InFlag = SDValue(ResNode, 1);
367 ReplaceUses(SDValue(Node, 0), Chain);
368 ReplaceUses(SDValue(Node, 1), InFlag);
Bruno Cardoso Lopes218d5822007-11-05 03:02:32 +0000369 return ResNode;
370 }
371 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372 }
373
374 // Select the default instruction
375 SDNode *ResNode = SelectCode(N);
376
377 #ifndef NDEBUG
378 DOUT << std::string(Indent-2, ' ') << "=> ";
Gabor Greif1c80d112008-08-28 21:40:38 +0000379 if (ResNode == NULL || ResNode == N.getNode())
380 DEBUG(N.getNode()->dump(CurDAG));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381 else
382 DEBUG(ResNode->dump(CurDAG));
383 DOUT << "\n";
384 Indent -= 2;
385 #endif
386
387 return ResNode;
388}
389
390/// createMipsISelDag - This pass converts a legalized DAG into a
391/// MIPS-specific DAG, ready for instruction scheduling.
392FunctionPass *llvm::createMipsISelDag(MipsTargetMachine &TM) {
393 return new MipsDAGToDAGISel(TM);
394}