Convert more uses of XXXRegisterClass to &XXXRegClass. No functional change since...
[oota-llvm.git] / lib / Target / Mips / MipsISelDAGToDAG.cpp
1 //===-- MipsISelDAGToDAG.cpp - A Dag to Dag Inst Selector for Mips --------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines an instruction selector for the MIPS target.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #define DEBUG_TYPE "mips-isel"
15 #include "Mips.h"
16 #include "MipsAnalyzeImmediate.h"
17 #include "MipsMachineFunction.h"
18 #include "MipsRegisterInfo.h"
19 #include "MipsSubtarget.h"
20 #include "MipsTargetMachine.h"
21 #include "MCTargetDesc/MipsBaseInfo.h"
22 #include "llvm/GlobalValue.h"
23 #include "llvm/Instructions.h"
24 #include "llvm/Intrinsics.h"
25 #include "llvm/Support/CFG.h"
26 #include "llvm/Type.h"
27 #include "llvm/CodeGen/MachineConstantPool.h"
28 #include "llvm/CodeGen/MachineFunction.h"
29 #include "llvm/CodeGen/MachineFrameInfo.h"
30 #include "llvm/CodeGen/MachineInstrBuilder.h"
31 #include "llvm/CodeGen/MachineRegisterInfo.h"
32 #include "llvm/CodeGen/SelectionDAGISel.h"
33 #include "llvm/CodeGen/SelectionDAGNodes.h"
34 #include "llvm/Target/TargetMachine.h"
35 #include "llvm/Support/Debug.h"
36 #include "llvm/Support/ErrorHandling.h"
37 #include "llvm/Support/raw_ostream.h"
38 using namespace llvm;
39
40 //===----------------------------------------------------------------------===//
41 // Instruction Selector Implementation
42 //===----------------------------------------------------------------------===//
43
44 //===----------------------------------------------------------------------===//
45 // MipsDAGToDAGISel - MIPS specific code to select MIPS machine
46 // instructions for SelectionDAG operations.
47 //===----------------------------------------------------------------------===//
48 namespace {
49
50 class MipsDAGToDAGISel : public SelectionDAGISel {
51
52   /// TM - Keep a reference to MipsTargetMachine.
53   MipsTargetMachine &TM;
54
55   /// Subtarget - Keep a pointer to the MipsSubtarget around so that we can
56   /// make the right decision when generating code for different targets.
57   const MipsSubtarget &Subtarget;
58
59 public:
60   explicit MipsDAGToDAGISel(MipsTargetMachine &tm) :
61   SelectionDAGISel(tm),
62   TM(tm), Subtarget(tm.getSubtarget<MipsSubtarget>()) {}
63
64   // Pass Name
65   virtual const char *getPassName() const {
66     return "MIPS DAG->DAG Pattern Instruction Selection";
67   }
68
69   virtual bool runOnMachineFunction(MachineFunction &MF);
70
71 private:
72   // Include the pieces autogenerated from the target description.
73   #include "MipsGenDAGISel.inc"
74
75   /// 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();
88
89   std::pair<SDNode*, SDNode*> SelectMULT(SDNode *N, unsigned Opc, DebugLoc dl,
90                                          EVT Ty, bool HasLo, bool HasHi);
91
92   SDNode *Select(SDNode *N);
93
94   // Complex Pattern.
95   bool SelectAddr(SDNode *Parent, SDValue N, SDValue &Base, SDValue &Offset);
96
97   // getImm - Return a target constant with the specified value.
98   inline SDValue getImm(const SDNode *Node, unsigned Imm) {
99     return CurDAG->getTargetConstant(Imm, Node->getValueType(0));
100   }
101
102   void ProcessFunctionAfterISel(MachineFunction &MF);
103   bool ReplaceUsesWithZeroReg(MachineRegisterInfo *MRI, const MachineInstr&);
104   void InitGlobalBaseReg(MachineFunction &MF);
105
106   virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
107                                             char ConstraintCode,
108                                             std::vector<SDValue> &OutOps);
109 };
110
111 }
112
113 // Insert instructions to initialize the global base register in the
114 // first MBB of the function. When the ABI is O32 and the relocation model is
115 // PIC, the necessary instructions are emitted later to prevent optimization
116 // passes from moving them.
117 void MipsDAGToDAGISel::InitGlobalBaseReg(MachineFunction &MF) {
118   MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
119
120   if (!MipsFI->globalBaseRegSet())
121     return;
122
123   MachineBasicBlock &MBB = MF.front();
124   MachineBasicBlock::iterator I = MBB.begin();
125   MachineRegisterInfo &RegInfo = MF.getRegInfo();
126   const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
127   DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc();
128   unsigned V0, V1, GlobalBaseReg = MipsFI->getGlobalBaseReg();
129   bool FixGlobalBaseReg = MipsFI->globalBaseRegFixed();
130
131   if (Subtarget.isABI_O32() && FixGlobalBaseReg)
132     // $gp is the global base register.
133     V0 = V1 = GlobalBaseReg;
134   else {
135     const TargetRegisterClass *RC;
136     RC = Subtarget.isABI_N64() ?
137       (const TargetRegisterClass*)&Mips::CPU64RegsRegClass :
138       (const TargetRegisterClass*)&Mips::CPURegsRegClass;
139
140     V0 = RegInfo.createVirtualRegister(RC);
141     V1 = RegInfo.createVirtualRegister(RC);
142   }
143
144   if (Subtarget.isABI_N64()) {
145     MF.getRegInfo().addLiveIn(Mips::T9_64);
146     MBB.addLiveIn(Mips::T9_64);
147
148     // lui $v0, %hi(%neg(%gp_rel(fname)))
149     // daddu $v1, $v0, $t9
150     // daddiu $globalbasereg, $v1, %lo(%neg(%gp_rel(fname)))
151     const GlobalValue *FName = MF.getFunction();
152     BuildMI(MBB, I, DL, TII.get(Mips::LUi64), V0)
153       .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_HI);
154     BuildMI(MBB, I, DL, TII.get(Mips::DADDu), V1).addReg(V0).addReg(Mips::T9_64);
155     BuildMI(MBB, I, DL, TII.get(Mips::DADDiu), GlobalBaseReg).addReg(V1)
156       .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_LO);
157   } else if (MF.getTarget().getRelocationModel() == Reloc::Static) {
158     // Set global register to __gnu_local_gp.
159     //
160     // lui   $v0, %hi(__gnu_local_gp)
161     // addiu $globalbasereg, $v0, %lo(__gnu_local_gp)
162     BuildMI(MBB, I, DL, TII.get(Mips::LUi), V0)
163       .addExternalSymbol("__gnu_local_gp", MipsII::MO_ABS_HI);
164     BuildMI(MBB, I, DL, TII.get(Mips::ADDiu), GlobalBaseReg).addReg(V0)
165       .addExternalSymbol("__gnu_local_gp", MipsII::MO_ABS_LO);
166   } else {
167     MF.getRegInfo().addLiveIn(Mips::T9);
168     MBB.addLiveIn(Mips::T9);
169
170     if (Subtarget.isABI_N32()) {
171       // lui $v0, %hi(%neg(%gp_rel(fname)))
172       // addu $v1, $v0, $t9
173       // addiu $globalbasereg, $v1, %lo(%neg(%gp_rel(fname)))
174       const GlobalValue *FName = MF.getFunction();
175       BuildMI(MBB, I, DL, TII.get(Mips::LUi), V0)
176         .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_HI);
177       BuildMI(MBB, I, DL, TII.get(Mips::ADDu), V1).addReg(V0).addReg(Mips::T9);
178       BuildMI(MBB, I, DL, TII.get(Mips::ADDiu), GlobalBaseReg).addReg(V1)
179         .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_LO);
180     } else if (!MipsFI->globalBaseRegFixed()) {
181       assert(Subtarget.isABI_O32());
182
183       BuildMI(MBB, I, DL, TII.get(Mips::SETGP2), GlobalBaseReg)
184         .addReg(Mips::T9);
185     }
186   }
187 }
188
189 bool MipsDAGToDAGISel::ReplaceUsesWithZeroReg(MachineRegisterInfo *MRI,
190                                               const MachineInstr& MI) {
191   unsigned DstReg = 0, ZeroReg = 0;
192
193   // Check if MI is "addiu $dst, $zero, 0" or "daddiu $dst, $zero, 0".
194   if ((MI.getOpcode() == Mips::ADDiu) &&
195       (MI.getOperand(1).getReg() == Mips::ZERO) &&
196       (MI.getOperand(2).getImm() == 0)) {
197     DstReg = MI.getOperand(0).getReg();
198     ZeroReg = Mips::ZERO;
199   } else if ((MI.getOpcode() == Mips::DADDiu) &&
200              (MI.getOperand(1).getReg() == Mips::ZERO_64) &&
201              (MI.getOperand(2).getImm() == 0)) {
202     DstReg = MI.getOperand(0).getReg();
203     ZeroReg = Mips::ZERO_64;
204   }
205
206   if (!DstReg)
207     return false;
208
209   // Replace uses with ZeroReg.
210   for (MachineRegisterInfo::use_iterator U = MRI->use_begin(DstReg),
211        E = MRI->use_end(); U != E; ++U) {
212     MachineOperand &MO = U.getOperand();
213     MachineInstr *MI = MO.getParent();
214
215     // Do not replace if it is a phi's operand or is tied to def operand.
216     if (MI->isPHI() || MI->isRegTiedToDefOperand(U.getOperandNo()))
217       continue;
218
219     MO.setReg(ZeroReg);
220   }
221
222   return true;
223 }
224
225 void MipsDAGToDAGISel::ProcessFunctionAfterISel(MachineFunction &MF) {
226   InitGlobalBaseReg(MF);
227
228   MachineRegisterInfo *MRI = &MF.getRegInfo();
229
230   for (MachineFunction::iterator MFI = MF.begin(), MFE = MF.end(); MFI != MFE;
231        ++MFI)
232     for (MachineBasicBlock::iterator I = MFI->begin(); I != MFI->end(); ++I)
233       ReplaceUsesWithZeroReg(MRI, *I);
234 }
235
236 bool MipsDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
237   bool Ret = SelectionDAGISel::runOnMachineFunction(MF);
238
239   ProcessFunctionAfterISel(MF);
240
241   return Ret;
242 }
243
244 /// getGlobalBaseReg - Output the instructions required to put the
245 /// GOT address into a register.
246 SDNode *MipsDAGToDAGISel::getGlobalBaseReg() {
247   unsigned GlobalBaseReg = MF->getInfo<MipsFunctionInfo>()->getGlobalBaseReg();
248   return CurDAG->getRegister(GlobalBaseReg, TLI.getPointerTy()).getNode();
249 }
250
251 /// ComplexPattern used on MipsInstrInfo
252 /// Used on Mips Load/Store instructions
253 bool MipsDAGToDAGISel::
254 SelectAddr(SDNode *Parent, SDValue Addr, SDValue &Base, SDValue &Offset) {
255   EVT ValTy = Addr.getValueType();
256
257   // If Parent is an unaligned f32 load or store, select a (base + index)
258   // floating point load/store instruction (luxc1 or suxc1).
259   const LSBaseSDNode* LS = 0;
260
261   if (Parent && (LS = dyn_cast<LSBaseSDNode>(Parent))) {
262     EVT VT = LS->getMemoryVT();
263
264     if (VT.getSizeInBits() / 8 > LS->getAlignment()) {
265       assert(TLI.allowsUnalignedMemoryAccesses(VT) &&
266              "Unaligned loads/stores not supported for this type.");
267       if (VT == MVT::f32)
268         return false;
269     }
270   }
271
272   // if Address is FI, get the TargetFrameIndex.
273   if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) {
274     Base   = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
275     Offset = CurDAG->getTargetConstant(0, ValTy);
276     return true;
277   }
278
279   // on PIC code Load GA
280   if (Addr.getOpcode() == MipsISD::Wrapper) {
281     Base   = Addr.getOperand(0);
282     Offset = Addr.getOperand(1);
283     return true;
284   }
285
286   if (TM.getRelocationModel() != Reloc::PIC_) {
287     if ((Addr.getOpcode() == ISD::TargetExternalSymbol ||
288         Addr.getOpcode() == ISD::TargetGlobalAddress))
289       return false;
290   }
291
292   // Addresses of the form FI+const or FI|const
293   if (CurDAG->isBaseWithConstantOffset(Addr)) {
294     ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1));
295     if (isInt<16>(CN->getSExtValue())) {
296
297       // If the first operand is a FI, get the TargetFI Node
298       if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>
299                                   (Addr.getOperand(0)))
300         Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
301       else
302         Base = Addr.getOperand(0);
303
304       Offset = CurDAG->getTargetConstant(CN->getZExtValue(), ValTy);
305       return true;
306     }
307   }
308
309   // Operand is a result from an ADD.
310   if (Addr.getOpcode() == ISD::ADD) {
311     // When loading from constant pools, load the lower address part in
312     // the instruction itself. Example, instead of:
313     //  lui $2, %hi($CPI1_0)
314     //  addiu $2, $2, %lo($CPI1_0)
315     //  lwc1 $f0, 0($2)
316     // Generate:
317     //  lui $2, %hi($CPI1_0)
318     //  lwc1 $f0, %lo($CPI1_0)($2)
319     if (Addr.getOperand(1).getOpcode() == MipsISD::Lo) {
320       SDValue LoVal = Addr.getOperand(1);
321       if (isa<ConstantPoolSDNode>(LoVal.getOperand(0)) ||
322           isa<GlobalAddressSDNode>(LoVal.getOperand(0))) {
323         Base = Addr.getOperand(0);
324         Offset = LoVal.getOperand(0);
325         return true;
326       }
327     }
328
329     // If an indexed floating point load/store can be emitted, return false.
330     if (LS && (LS->getMemoryVT() == MVT::f32 || LS->getMemoryVT() == MVT::f64) &&
331         Subtarget.hasMips32r2Or64())
332       return false;
333   }
334
335   Base   = Addr;
336   Offset = CurDAG->getTargetConstant(0, ValTy);
337   return true;
338 }
339
340 /// Select multiply instructions.
341 std::pair<SDNode*, SDNode*>
342 MipsDAGToDAGISel::SelectMULT(SDNode *N, unsigned Opc, DebugLoc dl, EVT Ty,
343                              bool HasLo, bool HasHi) {
344   SDNode *Lo = 0, *Hi = 0;
345   SDNode *Mul = CurDAG->getMachineNode(Opc, dl, MVT::Glue, N->getOperand(0),
346                                        N->getOperand(1));
347   SDValue InFlag = SDValue(Mul, 0);
348
349   if (HasLo) {
350     Lo = CurDAG->getMachineNode(Ty == MVT::i32 ? Mips::MFLO : Mips::MFLO64, dl,
351                                 Ty, MVT::Glue, InFlag);
352     InFlag = SDValue(Lo, 1);
353   }
354   if (HasHi)
355     Hi = CurDAG->getMachineNode(Ty == MVT::i32 ? Mips::MFHI : Mips::MFHI64, dl,
356                                 Ty, InFlag);
357
358   return std::make_pair(Lo, Hi);
359 }
360
361
362 /// Select instructions not customized! Used for
363 /// expanded, promoted and normal instructions
364 SDNode* MipsDAGToDAGISel::Select(SDNode *Node) {
365   unsigned Opcode = Node->getOpcode();
366   DebugLoc dl = Node->getDebugLoc();
367
368   // Dump information about the Node being selected
369   DEBUG(errs() << "Selecting: "; Node->dump(CurDAG); errs() << "\n");
370
371   // If we have a custom node, we already have selected!
372   if (Node->isMachineOpcode()) {
373     DEBUG(errs() << "== "; Node->dump(CurDAG); errs() << "\n");
374     return NULL;
375   }
376
377   ///
378   // Instruction Selection not handled by the auto-generated
379   // tablegen selection should be handled here.
380   ///
381   EVT NodeTy = Node->getValueType(0);
382   unsigned MultOpc;
383
384   switch(Opcode) {
385   default: break;
386
387   case ISD::SUBE:
388   case ISD::ADDE: {
389     SDValue InFlag = Node->getOperand(2), CmpLHS;
390     unsigned Opc = InFlag.getOpcode(); (void)Opc;
391     assert(((Opc == ISD::ADDC || Opc == ISD::ADDE) ||
392             (Opc == ISD::SUBC || Opc == ISD::SUBE)) &&
393            "(ADD|SUB)E flag operand must come from (ADD|SUB)C/E insn");
394
395     unsigned MOp;
396     if (Opcode == ISD::ADDE) {
397       CmpLHS = InFlag.getValue(0);
398       MOp = Mips::ADDu;
399     } else {
400       CmpLHS = InFlag.getOperand(0);
401       MOp = Mips::SUBu;
402     }
403
404     SDValue Ops[] = { CmpLHS, InFlag.getOperand(1) };
405
406     SDValue LHS = Node->getOperand(0);
407     SDValue RHS = Node->getOperand(1);
408
409     EVT VT = LHS.getValueType();
410     SDNode *Carry = CurDAG->getMachineNode(Mips::SLTu, dl, VT, Ops, 2);
411     SDNode *AddCarry = CurDAG->getMachineNode(Mips::ADDu, dl, VT,
412                                               SDValue(Carry,0), RHS);
413
414     return CurDAG->SelectNodeTo(Node, MOp, VT, MVT::Glue,
415                                 LHS, SDValue(AddCarry,0));
416   }
417
418   /// Mul with two results
419   case ISD::SMUL_LOHI:
420   case ISD::UMUL_LOHI: {
421     if (NodeTy == MVT::i32)
422       MultOpc = (Opcode == ISD::UMUL_LOHI ? Mips::MULTu : Mips::MULT);
423     else
424       MultOpc = (Opcode == ISD::UMUL_LOHI ? Mips::DMULTu : Mips::DMULT);
425
426     std::pair<SDNode*, SDNode*> LoHi = SelectMULT(Node, MultOpc, dl, NodeTy,
427                                                   true, true);
428
429     if (!SDValue(Node, 0).use_empty())
430       ReplaceUses(SDValue(Node, 0), SDValue(LoHi.first, 0));
431
432     if (!SDValue(Node, 1).use_empty())
433       ReplaceUses(SDValue(Node, 1), SDValue(LoHi.second, 0));
434
435     return NULL;
436   }
437
438   /// Special Muls
439   case ISD::MUL: {
440     // Mips32 has a 32-bit three operand mul instruction.
441     if (Subtarget.hasMips32() && NodeTy == MVT::i32)
442       break;
443     return SelectMULT(Node, NodeTy == MVT::i32 ? Mips::MULT : Mips::DMULT,
444                       dl, NodeTy, true, false).first;
445   }
446   case ISD::MULHS:
447   case ISD::MULHU: {
448     if (NodeTy == MVT::i32)
449       MultOpc = (Opcode == ISD::MULHU ? Mips::MULTu : Mips::MULT);
450     else
451       MultOpc = (Opcode == ISD::MULHU ? Mips::DMULTu : Mips::DMULT);
452
453     return SelectMULT(Node, MultOpc, dl, NodeTy, false, true).second;
454   }
455
456   // Get target GOT address.
457   case ISD::GLOBAL_OFFSET_TABLE:
458     return getGlobalBaseReg();
459
460   case ISD::ConstantFP: {
461     ConstantFPSDNode *CN = dyn_cast<ConstantFPSDNode>(Node);
462     if (Node->getValueType(0) == MVT::f64 && CN->isExactlyValue(+0.0)) {
463       if (Subtarget.hasMips64()) {
464         SDValue Zero = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), dl,
465                                               Mips::ZERO_64, MVT::i64);
466         return CurDAG->getMachineNode(Mips::DMTC1, dl, MVT::f64, Zero);
467       }
468
469       SDValue Zero = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), dl,
470                                             Mips::ZERO, MVT::i32);
471       return CurDAG->getMachineNode(Mips::BuildPairF64, dl, MVT::f64, Zero,
472                                     Zero);
473     }
474     break;
475   }
476
477   case ISD::Constant: {
478     const ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Node);
479     unsigned Size = CN->getValueSizeInBits(0);
480
481     if (Size == 32)
482       break;
483
484     MipsAnalyzeImmediate AnalyzeImm;
485     int64_t Imm = CN->getSExtValue();
486
487     const MipsAnalyzeImmediate::InstSeq &Seq =
488       AnalyzeImm.Analyze(Imm, Size, false);
489
490     MipsAnalyzeImmediate::InstSeq::const_iterator Inst = Seq.begin();
491     DebugLoc DL = CN->getDebugLoc();
492     SDNode *RegOpnd;
493     SDValue ImmOpnd = CurDAG->getTargetConstant(SignExtend64<16>(Inst->ImmOpnd),
494                                                 MVT::i64);
495
496     // The first instruction can be a LUi which is different from other
497     // instructions (ADDiu, ORI and SLL) in that it does not have a register
498     // operand.
499     if (Inst->Opc == Mips::LUi64)
500       RegOpnd = CurDAG->getMachineNode(Inst->Opc, DL, MVT::i64, ImmOpnd);
501     else
502       RegOpnd =
503         CurDAG->getMachineNode(Inst->Opc, DL, MVT::i64,
504                                CurDAG->getRegister(Mips::ZERO_64, MVT::i64),
505                                ImmOpnd);
506
507     // The remaining instructions in the sequence are handled here.
508     for (++Inst; Inst != Seq.end(); ++Inst) {
509       ImmOpnd = CurDAG->getTargetConstant(SignExtend64<16>(Inst->ImmOpnd),
510                                           MVT::i64);
511       RegOpnd = CurDAG->getMachineNode(Inst->Opc, DL, MVT::i64,
512                                        SDValue(RegOpnd, 0), ImmOpnd);
513     }
514
515     return RegOpnd;
516   }
517
518   case MipsISD::ThreadPointer: {
519     EVT PtrVT = TLI.getPointerTy();
520     unsigned RdhwrOpc, SrcReg, DestReg;
521
522     if (PtrVT == MVT::i32) {
523       RdhwrOpc = Mips::RDHWR;
524       SrcReg = Mips::HWR29;
525       DestReg = Mips::V1;
526     } else {
527       RdhwrOpc = Mips::RDHWR64;
528       SrcReg = Mips::HWR29_64;
529       DestReg = Mips::V1_64;
530     }
531
532     SDNode *Rdhwr =
533       CurDAG->getMachineNode(RdhwrOpc, Node->getDebugLoc(),
534                              Node->getValueType(0),
535                              CurDAG->getRegister(SrcReg, PtrVT));
536     SDValue Chain = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl, DestReg,
537                                          SDValue(Rdhwr, 0));
538     SDValue ResNode = CurDAG->getCopyFromReg(Chain, dl, DestReg, PtrVT);
539     ReplaceUses(SDValue(Node, 0), ResNode);
540     return ResNode.getNode();
541   }
542   }
543
544   // Select the default instruction
545   SDNode *ResNode = SelectCode(Node);
546
547   DEBUG(errs() << "=> ");
548   if (ResNode == NULL || ResNode == Node)
549     DEBUG(Node->dump(CurDAG));
550   else
551     DEBUG(ResNode->dump(CurDAG));
552   DEBUG(errs() << "\n");
553   return ResNode;
554 }
555
556 bool MipsDAGToDAGISel::
557 SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode,
558                              std::vector<SDValue> &OutOps) {
559   assert(ConstraintCode == 'm' && "unexpected asm memory constraint");
560   OutOps.push_back(Op);
561   return false;
562 }
563
564 /// createMipsISelDag - This pass converts a legalized DAG into a
565 /// MIPS-specific DAG, ready for instruction scheduling.
566 FunctionPass *llvm::createMipsISelDag(MipsTargetMachine &TM) {
567   return new MipsDAGToDAGISel(TM);
568 }