1 //===- X86ISelDAGToDAG.cpp - A DAG pattern matching inst selector for X86 -===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the Evan Cheng and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a DAG pattern matching instruction selector for X86,
11 // converting from a legalized dag to a X86 dag.
13 //===----------------------------------------------------------------------===//
15 #define DEBUG_TYPE "x86-isel"
17 #include "X86InstrBuilder.h"
18 #include "X86ISelLowering.h"
19 #include "X86RegisterInfo.h"
20 #include "X86Subtarget.h"
21 #include "X86TargetMachine.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/SSARegMap.h"
32 #include "llvm/CodeGen/SelectionDAGISel.h"
33 #include "llvm/Target/TargetMachine.h"
34 #include "llvm/Support/Compiler.h"
35 #include "llvm/Support/Debug.h"
36 #include "llvm/Support/MathExtras.h"
37 #include "llvm/ADT/Statistic.h"
42 STATISTIC(NumFPKill , "Number of FP_REG_KILL instructions added");
43 STATISTIC(NumLoadMoved, "Number of loads moved below TokenFactor");
46 //===----------------------------------------------------------------------===//
47 // Pattern Matcher Implementation
48 //===----------------------------------------------------------------------===//
51 /// X86ISelAddressMode - This corresponds to X86AddressMode, but uses
52 /// SDOperand's instead of register numbers for the leaves of the matched
54 struct X86ISelAddressMode {
60 struct { // This is really a union, discriminated by BaseType!
65 bool isRIPRel; // RIP relative?
73 unsigned Align; // CP alignment.
76 : BaseType(RegBase), isRIPRel(false), Scale(1), IndexReg(), Disp(0),
77 GV(0), CP(0), ES(0), JT(-1), Align(0) {
83 //===--------------------------------------------------------------------===//
84 /// ISel - X86 specific code to select X86 machine instructions for
85 /// SelectionDAG operations.
87 class VISIBILITY_HIDDEN X86DAGToDAGISel : public SelectionDAGISel {
88 /// ContainsFPCode - Every instruction we select that uses or defines a FP
89 /// register should set this to true.
92 /// FastISel - Enable fast(er) instruction selection.
96 /// TM - Keep a reference to X86TargetMachine.
100 /// X86Lowering - This object fully describes how to lower LLVM code to an
101 /// X86-specific SelectionDAG.
102 X86TargetLowering X86Lowering;
104 /// Subtarget - Keep a pointer to the X86Subtarget around so that we can
105 /// make the right decision when generating code for different targets.
106 const X86Subtarget *Subtarget;
108 /// GlobalBaseReg - keeps track of the virtual register mapped onto global
110 unsigned GlobalBaseReg;
113 X86DAGToDAGISel(X86TargetMachine &tm, bool fast)
114 : SelectionDAGISel(X86Lowering),
115 ContainsFPCode(false), FastISel(fast), TM(tm),
116 X86Lowering(*TM.getTargetLowering()),
117 Subtarget(&TM.getSubtarget<X86Subtarget>()) {}
119 virtual bool runOnFunction(Function &Fn) {
120 // Make sure we re-emit a set of the global base reg if necessary
122 return SelectionDAGISel::runOnFunction(Fn);
125 virtual const char *getPassName() const {
126 return "X86 DAG->DAG Instruction Selection";
129 /// InstructionSelectBasicBlock - This callback is invoked by
130 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
131 virtual void InstructionSelectBasicBlock(SelectionDAG &DAG);
133 virtual bool CanBeFoldedBy(SDNode *N, SDNode *U, SDNode *Root) const;
135 // Include the pieces autogenerated from the target description.
136 #include "X86GenDAGISel.inc"
139 SDNode *Select(SDOperand N);
141 bool MatchAddress(SDOperand N, X86ISelAddressMode &AM,
142 bool isRoot = true, unsigned Depth = 0);
143 bool MatchAddressBase(SDOperand N, X86ISelAddressMode &AM,
144 bool isRoot, unsigned Depth);
145 bool SelectAddr(SDOperand Op, SDOperand N, SDOperand &Base,
146 SDOperand &Scale, SDOperand &Index, SDOperand &Disp);
147 bool SelectLEAAddr(SDOperand Op, SDOperand N, SDOperand &Base,
148 SDOperand &Scale, SDOperand &Index, SDOperand &Disp);
149 bool SelectScalarSSELoad(SDOperand Op, SDOperand Pred,
150 SDOperand N, SDOperand &Base, SDOperand &Scale,
151 SDOperand &Index, SDOperand &Disp,
152 SDOperand &InChain, SDOperand &OutChain);
153 bool TryFoldLoad(SDOperand P, SDOperand N,
154 SDOperand &Base, SDOperand &Scale,
155 SDOperand &Index, SDOperand &Disp);
156 void InstructionSelectPreprocess(SelectionDAG &DAG);
158 /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
159 /// inline asm expressions.
160 virtual bool SelectInlineAsmMemoryOperand(const SDOperand &Op,
162 std::vector<SDOperand> &OutOps,
165 inline void getAddressOperands(X86ISelAddressMode &AM, SDOperand &Base,
166 SDOperand &Scale, SDOperand &Index,
168 Base = (AM.BaseType == X86ISelAddressMode::FrameIndexBase) ?
169 CurDAG->getTargetFrameIndex(AM.Base.FrameIndex, TLI.getPointerTy()) :
171 Scale = getI8Imm(AM.Scale);
173 // These are 32-bit even in 64-bit mode since RIP relative offset
176 Disp = CurDAG->getTargetGlobalAddress(AM.GV, MVT::i32, AM.Disp);
178 Disp = CurDAG->getTargetConstantPool(AM.CP, MVT::i32, AM.Align, AM.Disp);
180 Disp = CurDAG->getTargetExternalSymbol(AM.ES, MVT::i32);
181 else if (AM.JT != -1)
182 Disp = CurDAG->getTargetJumpTable(AM.JT, MVT::i32);
184 Disp = getI32Imm(AM.Disp);
187 /// getI8Imm - Return a target constant with the specified value, of type
189 inline SDOperand getI8Imm(unsigned Imm) {
190 return CurDAG->getTargetConstant(Imm, MVT::i8);
193 /// getI16Imm - Return a target constant with the specified value, of type
195 inline SDOperand getI16Imm(unsigned Imm) {
196 return CurDAG->getTargetConstant(Imm, MVT::i16);
199 /// getI32Imm - Return a target constant with the specified value, of type
201 inline SDOperand getI32Imm(unsigned Imm) {
202 return CurDAG->getTargetConstant(Imm, MVT::i32);
205 /// getGlobalBaseReg - insert code into the entry mbb to materialize the PIC
206 /// base register. Return the virtual register that holds this value.
207 SDNode *getGlobalBaseReg();
209 /// getTruncate - return an SDNode that implements a subreg based truncate
210 /// of the specified operand to the the specified value type.
211 SDNode *getTruncate(SDOperand N0, MVT::ValueType VT);
219 static SDNode *findFlagUse(SDNode *N) {
220 unsigned FlagResNo = N->getNumValues()-1;
221 for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) {
223 for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) {
224 SDOperand Op = User->getOperand(i);
225 if (Op.Val == N && Op.ResNo == FlagResNo)
232 static void findNonImmUse(SDNode *Use, SDNode* Def, SDNode *ImmedUse,
233 SDNode *Root, SDNode *Skip, bool &found,
234 std::set<SDNode *> &Visited) {
236 Use->getNodeId() > Def->getNodeId() ||
237 !Visited.insert(Use).second)
240 for (unsigned i = 0, e = Use->getNumOperands(); !found && i != e; ++i) {
241 SDNode *N = Use->getOperand(i).Val;
246 continue; // Immediate use is ok.
248 assert(Use->getOpcode() == ISD::STORE ||
249 Use->getOpcode() == X86ISD::CMP);
255 findNonImmUse(N, Def, ImmedUse, Root, Skip, found, Visited);
259 /// isNonImmUse - Start searching from Root up the DAG to check is Def can
260 /// be reached. Return true if that's the case. However, ignore direct uses
261 /// by ImmedUse (which would be U in the example illustrated in
262 /// CanBeFoldedBy) and by Root (which can happen in the store case).
263 /// FIXME: to be really generic, we should allow direct use by any node
264 /// that is being folded. But realisticly since we only fold loads which
265 /// have one non-chain use, we only need to watch out for load/op/store
266 /// and load/op/cmp case where the root (store / cmp) may reach the load via
267 /// its chain operand.
268 static inline bool isNonImmUse(SDNode *Root, SDNode *Def, SDNode *ImmedUse,
269 SDNode *Skip = NULL) {
270 std::set<SDNode *> Visited;
272 findNonImmUse(Root, Def, ImmedUse, Root, Skip, found, Visited);
277 bool X86DAGToDAGISel::CanBeFoldedBy(SDNode *N, SDNode *U, SDNode *Root) const {
278 if (FastISel) return false;
280 // If U use can somehow reach N through another path then U can't fold N or
281 // it will create a cycle. e.g. In the following diagram, U can reach N
282 // through X. If N is folded into into U, then X is both a predecessor and
293 if (isNonImmUse(Root, N, U))
296 // If U produces a flag, then it gets (even more) interesting. Since it
297 // would have been "glued" together with its flag use, we need to check if
310 // If FU (flag use) indirectly reach N (the load), and U fold N (call it
311 // NU), then TF is a predecessor of FU and a successor of NU. But since
312 // NU and FU are flagged together, this effectively creates a cycle.
313 bool HasFlagUse = false;
314 MVT::ValueType VT = Root->getValueType(Root->getNumValues()-1);
315 while ((VT == MVT::Flag && !Root->use_empty())) {
316 SDNode *FU = findFlagUse(Root);
323 VT = Root->getValueType(Root->getNumValues()-1);
327 return !isNonImmUse(Root, N, Root, U);
331 /// MoveBelowTokenFactor - Replace TokenFactor operand with load's chain operand
332 /// and move load below the TokenFactor. Replace store's chain operand with
333 /// load's chain result.
334 static void MoveBelowTokenFactor(SelectionDAG &DAG, SDOperand Load,
335 SDOperand Store, SDOperand TF) {
336 std::vector<SDOperand> Ops;
337 for (unsigned i = 0, e = TF.Val->getNumOperands(); i != e; ++i)
338 if (Load.Val == TF.Val->getOperand(i).Val)
339 Ops.push_back(Load.Val->getOperand(0));
341 Ops.push_back(TF.Val->getOperand(i));
342 DAG.UpdateNodeOperands(TF, &Ops[0], Ops.size());
343 DAG.UpdateNodeOperands(Load, TF, Load.getOperand(1), Load.getOperand(2));
344 DAG.UpdateNodeOperands(Store, Load.getValue(1), Store.getOperand(1),
345 Store.getOperand(2), Store.getOperand(3));
348 /// InstructionSelectPreprocess - Preprocess the DAG to allow the instruction
349 /// selector to pick more load-modify-store instructions. This is a common
360 /// [TokenFactor] [Op]
367 /// The fact the store's chain operand != load's chain will prevent the
368 /// (store (op (load))) instruction from being selected. We can transform it to:
387 void X86DAGToDAGISel::InstructionSelectPreprocess(SelectionDAG &DAG) {
388 for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(),
389 E = DAG.allnodes_end(); I != E; ++I) {
390 if (!ISD::isNON_TRUNCStore(I))
392 SDOperand Chain = I->getOperand(0);
393 if (Chain.Val->getOpcode() != ISD::TokenFactor)
396 SDOperand N1 = I->getOperand(1);
397 SDOperand N2 = I->getOperand(2);
398 if (MVT::isFloatingPoint(N1.getValueType()) ||
399 MVT::isVector(N1.getValueType()) ||
405 unsigned Opcode = N1.Val->getOpcode();
414 SDOperand N10 = N1.getOperand(0);
415 SDOperand N11 = N1.getOperand(1);
416 if (ISD::isNON_EXTLoad(N10.Val))
418 else if (ISD::isNON_EXTLoad(N11.Val)) {
422 RModW = RModW && N10.Val->isOperand(Chain.Val) && N10.hasOneUse() &&
423 (N10.getOperand(1) == N2) &&
424 (N10.Val->getValueType(0) == N1.getValueType());
439 SDOperand N10 = N1.getOperand(0);
440 if (ISD::isNON_EXTLoad(N10.Val))
441 RModW = N10.Val->isOperand(Chain.Val) && N10.hasOneUse() &&
442 (N10.getOperand(1) == N2) &&
443 (N10.Val->getValueType(0) == N1.getValueType());
451 MoveBelowTokenFactor(DAG, Load, SDOperand(I, 0), Chain);
457 /// InstructionSelectBasicBlock - This callback is invoked by SelectionDAGISel
458 /// when it has created a SelectionDAG for us to codegen.
459 void X86DAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) {
461 MachineFunction::iterator FirstMBB = BB;
464 InstructionSelectPreprocess(DAG);
466 // Codegen the basic block.
468 DOUT << "===== Instruction selection begins:\n";
471 DAG.setRoot(SelectRoot(DAG.getRoot()));
473 DOUT << "===== Instruction selection ends:\n";
476 DAG.RemoveDeadNodes();
478 // Emit machine code to BB.
479 ScheduleAndEmitDAG(DAG);
481 // If we are emitting FP stack code, scan the basic block to determine if this
482 // block defines any FP values. If so, put an FP_REG_KILL instruction before
483 // the terminator of the block.
485 // Note that FP stack instructions *are* used in SSE code for long double,
486 // so we do need this check.
487 bool ContainsFPCode = false;
489 // Scan all of the machine instructions in these MBBs, checking for FP
490 // stores. (RFP32 and RFP64 will not exist in SSE mode, but RFP80 might.)
491 MachineFunction::iterator MBBI = FirstMBB;
493 for (MachineBasicBlock::iterator I = MBBI->begin(), E = MBBI->end();
494 !ContainsFPCode && I != E; ++I) {
495 if (I->getNumOperands() != 0 && I->getOperand(0).isRegister()) {
496 const TargetRegisterClass *clas;
497 for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) {
498 if (I->getOperand(op).isRegister() && I->getOperand(op).isDef() &&
499 MRegisterInfo::isVirtualRegister(I->getOperand(op).getReg()) &&
500 ((clas = RegMap->getRegClass(I->getOperand(0).getReg())) ==
501 X86::RFP32RegisterClass ||
502 clas == X86::RFP64RegisterClass ||
503 clas == X86::RFP80RegisterClass)) {
504 ContainsFPCode = true;
510 } while (!ContainsFPCode && &*(MBBI++) != BB);
512 // Check PHI nodes in successor blocks. These PHI's will be lowered to have
513 // a copy of the input value in this block. In SSE mode, we only care about
515 if (!ContainsFPCode) {
516 // Final check, check LLVM BB's that are successors to the LLVM BB
517 // corresponding to BB for FP PHI nodes.
518 const BasicBlock *LLVMBB = BB->getBasicBlock();
520 for (succ_const_iterator SI = succ_begin(LLVMBB), E = succ_end(LLVMBB);
521 !ContainsFPCode && SI != E; ++SI) {
522 for (BasicBlock::const_iterator II = SI->begin();
523 (PN = dyn_cast<PHINode>(II)); ++II) {
524 if (PN->getType()==Type::X86_FP80Ty ||
525 (!Subtarget->hasSSE2() && PN->getType()->isFloatingPoint())) {
526 ContainsFPCode = true;
533 // Finally, if we found any FP code, emit the FP_REG_KILL instruction.
534 if (ContainsFPCode) {
535 BuildMI(*BB, BB->getFirstTerminator(),
536 TM.getInstrInfo()->get(X86::FP_REG_KILL));
541 /// MatchAddress - Add the specified node to the specified addressing mode,
542 /// returning true if it cannot be done. This just pattern matches for the
544 bool X86DAGToDAGISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM,
545 bool isRoot, unsigned Depth) {
548 return MatchAddressBase(N, AM, isRoot, Depth);
550 // RIP relative addressing: %rip + 32-bit displacement!
552 if (!AM.ES && AM.JT != -1 && N.getOpcode() == ISD::Constant) {
553 int64_t Val = cast<ConstantSDNode>(N)->getSignExtended();
554 if (isInt32(AM.Disp + Val)) {
562 int id = N.Val->getNodeId();
563 bool Available = isSelected(id);
565 switch (N.getOpcode()) {
567 case ISD::Constant: {
568 int64_t Val = cast<ConstantSDNode>(N)->getSignExtended();
569 if (isInt32(AM.Disp + Val)) {
576 case X86ISD::Wrapper: {
577 bool is64Bit = Subtarget->is64Bit();
578 // Under X86-64 non-small code model, GV (and friends) are 64-bits.
579 if (is64Bit && TM.getCodeModel() != CodeModel::Small)
581 if (AM.GV != 0 || AM.CP != 0 || AM.ES != 0 || AM.JT != -1)
583 // If value is available in a register both base and index components have
584 // been picked, we can't fit the result available in the register in the
585 // addressing mode. Duplicate GlobalAddress or ConstantPool as displacement.
586 if (!Available || (AM.Base.Reg.Val && AM.IndexReg.Val)) {
587 bool isStatic = TM.getRelocationModel() == Reloc::Static;
588 SDOperand N0 = N.getOperand(0);
589 // Mac OS X X86-64 lower 4G address is not available.
590 bool isAbs32 = !is64Bit ||
591 (isStatic && Subtarget->hasLow4GUserSpaceAddress());
592 if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(N0)) {
593 GlobalValue *GV = G->getGlobal();
594 if (isAbs32 || isRoot) {
596 AM.Disp += G->getOffset();
597 AM.isRIPRel = !isAbs32;
600 } else if (ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(N0)) {
601 if (isAbs32 || isRoot) {
602 AM.CP = CP->getConstVal();
603 AM.Align = CP->getAlignment();
604 AM.Disp += CP->getOffset();
605 AM.isRIPRel = !isAbs32;
608 } else if (ExternalSymbolSDNode *S =dyn_cast<ExternalSymbolSDNode>(N0)) {
609 if (isAbs32 || isRoot) {
610 AM.ES = S->getSymbol();
611 AM.isRIPRel = !isAbs32;
614 } else if (JumpTableSDNode *J = dyn_cast<JumpTableSDNode>(N0)) {
615 if (isAbs32 || isRoot) {
616 AM.JT = J->getIndex();
617 AM.isRIPRel = !isAbs32;
625 case ISD::FrameIndex:
626 if (AM.BaseType == X86ISelAddressMode::RegBase && AM.Base.Reg.Val == 0) {
627 AM.BaseType = X86ISelAddressMode::FrameIndexBase;
628 AM.Base.FrameIndex = cast<FrameIndexSDNode>(N)->getIndex();
634 if (!Available && AM.IndexReg.Val == 0 && AM.Scale == 1)
635 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.Val->getOperand(1))) {
636 unsigned Val = CN->getValue();
637 if (Val == 1 || Val == 2 || Val == 3) {
639 SDOperand ShVal = N.Val->getOperand(0);
641 // Okay, we know that we have a scale by now. However, if the scaled
642 // value is an add of something and a constant, we can fold the
643 // constant into the disp field here.
644 if (ShVal.Val->getOpcode() == ISD::ADD && ShVal.hasOneUse() &&
645 isa<ConstantSDNode>(ShVal.Val->getOperand(1))) {
646 AM.IndexReg = ShVal.Val->getOperand(0);
647 ConstantSDNode *AddVal =
648 cast<ConstantSDNode>(ShVal.Val->getOperand(1));
649 uint64_t Disp = AM.Disp + (AddVal->getValue() << Val);
663 // X*[3,5,9] -> X+X*[2,4,8]
665 AM.BaseType == X86ISelAddressMode::RegBase &&
666 AM.Base.Reg.Val == 0 &&
667 AM.IndexReg.Val == 0) {
668 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.Val->getOperand(1)))
669 if (CN->getValue() == 3 || CN->getValue() == 5 || CN->getValue() == 9) {
670 AM.Scale = unsigned(CN->getValue())-1;
672 SDOperand MulVal = N.Val->getOperand(0);
675 // Okay, we know that we have a scale by now. However, if the scaled
676 // value is an add of something and a constant, we can fold the
677 // constant into the disp field here.
678 if (MulVal.Val->getOpcode() == ISD::ADD && MulVal.hasOneUse() &&
679 isa<ConstantSDNode>(MulVal.Val->getOperand(1))) {
680 Reg = MulVal.Val->getOperand(0);
681 ConstantSDNode *AddVal =
682 cast<ConstantSDNode>(MulVal.Val->getOperand(1));
683 uint64_t Disp = AM.Disp + AddVal->getValue() * CN->getValue();
687 Reg = N.Val->getOperand(0);
689 Reg = N.Val->getOperand(0);
692 AM.IndexReg = AM.Base.Reg = Reg;
700 X86ISelAddressMode Backup = AM;
701 if (!MatchAddress(N.Val->getOperand(0), AM, false, Depth+1) &&
702 !MatchAddress(N.Val->getOperand(1), AM, false, Depth+1))
705 if (!MatchAddress(N.Val->getOperand(1), AM, false, Depth+1) &&
706 !MatchAddress(N.Val->getOperand(0), AM, false, Depth+1))
713 // Handle "X | C" as "X + C" iff X is known to have C bits clear.
715 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
716 X86ISelAddressMode Backup = AM;
717 // Start with the LHS as an addr mode.
718 if (!MatchAddress(N.getOperand(0), AM, false) &&
719 // Address could not have picked a GV address for the displacement.
721 // On x86-64, the resultant disp must fit in 32-bits.
722 isInt32(AM.Disp + CN->getSignExtended()) &&
723 // Check to see if the LHS & C is zero.
724 CurDAG->MaskedValueIsZero(N.getOperand(0), CN->getValue())) {
725 AM.Disp += CN->getValue();
734 return MatchAddressBase(N, AM, isRoot, Depth);
737 /// MatchAddressBase - Helper for MatchAddress. Add the specified node to the
738 /// specified addressing mode without any further recursion.
739 bool X86DAGToDAGISel::MatchAddressBase(SDOperand N, X86ISelAddressMode &AM,
740 bool isRoot, unsigned Depth) {
741 // Is the base register already occupied?
742 if (AM.BaseType != X86ISelAddressMode::RegBase || AM.Base.Reg.Val) {
743 // If so, check to see if the scale index register is set.
744 if (AM.IndexReg.Val == 0) {
750 // Otherwise, we cannot select it.
754 // Default, generate it as a register.
755 AM.BaseType = X86ISelAddressMode::RegBase;
760 /// SelectAddr - returns true if it is able pattern match an addressing mode.
761 /// It returns the operands which make up the maximal addressing mode it can
762 /// match by reference.
763 bool X86DAGToDAGISel::SelectAddr(SDOperand Op, SDOperand N, SDOperand &Base,
764 SDOperand &Scale, SDOperand &Index,
766 X86ISelAddressMode AM;
767 if (MatchAddress(N, AM))
770 MVT::ValueType VT = N.getValueType();
771 if (AM.BaseType == X86ISelAddressMode::RegBase) {
772 if (!AM.Base.Reg.Val)
773 AM.Base.Reg = CurDAG->getRegister(0, VT);
776 if (!AM.IndexReg.Val)
777 AM.IndexReg = CurDAG->getRegister(0, VT);
779 getAddressOperands(AM, Base, Scale, Index, Disp);
783 /// isZeroNode - Returns true if Elt is a constant zero or a floating point
785 static inline bool isZeroNode(SDOperand Elt) {
786 return ((isa<ConstantSDNode>(Elt) &&
787 cast<ConstantSDNode>(Elt)->getValue() == 0) ||
788 (isa<ConstantFPSDNode>(Elt) &&
789 cast<ConstantFPSDNode>(Elt)->getValueAPF().isPosZero()));
793 /// SelectScalarSSELoad - Match a scalar SSE load. In particular, we want to
794 /// match a load whose top elements are either undef or zeros. The load flavor
795 /// is derived from the type of N, which is either v4f32 or v2f64.
796 bool X86DAGToDAGISel::SelectScalarSSELoad(SDOperand Op, SDOperand Pred,
797 SDOperand N, SDOperand &Base,
798 SDOperand &Scale, SDOperand &Index,
799 SDOperand &Disp, SDOperand &InChain,
800 SDOperand &OutChain) {
801 if (N.getOpcode() == ISD::SCALAR_TO_VECTOR) {
802 InChain = N.getOperand(0).getValue(1);
803 if (ISD::isNON_EXTLoad(InChain.Val) &&
804 InChain.getValue(0).hasOneUse() &&
806 CanBeFoldedBy(N.Val, Pred.Val, Op.Val)) {
807 LoadSDNode *LD = cast<LoadSDNode>(InChain);
808 if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, Disp))
810 OutChain = LD->getChain();
815 // Also handle the case where we explicitly require zeros in the top
816 // elements. This is a vector shuffle from the zero vector.
817 if (N.getOpcode() == ISD::VECTOR_SHUFFLE && N.Val->hasOneUse() &&
818 N.getOperand(0).getOpcode() == ISD::BUILD_VECTOR &&
819 N.getOperand(1).getOpcode() == ISD::SCALAR_TO_VECTOR &&
820 N.getOperand(1).Val->hasOneUse() &&
821 ISD::isNON_EXTLoad(N.getOperand(1).getOperand(0).Val) &&
822 N.getOperand(1).getOperand(0).hasOneUse()) {
823 // Check to see if the BUILD_VECTOR is building a zero vector.
824 SDOperand BV = N.getOperand(0);
825 for (unsigned i = 0, e = BV.getNumOperands(); i != e; ++i)
826 if (!isZeroNode(BV.getOperand(i)) &&
827 BV.getOperand(i).getOpcode() != ISD::UNDEF)
828 return false; // Not a zero/undef vector.
829 // Check to see if the shuffle mask is 4/L/L/L or 2/L, where L is something
831 unsigned VecWidth = BV.getNumOperands();
832 SDOperand ShufMask = N.getOperand(2);
833 assert(ShufMask.getOpcode() == ISD::BUILD_VECTOR && "Invalid shuf mask!");
834 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(ShufMask.getOperand(0))) {
835 if (C->getValue() == VecWidth) {
836 for (unsigned i = 1; i != VecWidth; ++i) {
837 if (ShufMask.getOperand(i).getOpcode() == ISD::UNDEF) {
840 ConstantSDNode *C = cast<ConstantSDNode>(ShufMask.getOperand(i));
841 if (C->getValue() >= VecWidth) return false;
846 // Okay, this is a zero extending load. Fold it.
847 LoadSDNode *LD = cast<LoadSDNode>(N.getOperand(1).getOperand(0));
848 if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, Disp))
850 OutChain = LD->getChain();
851 InChain = SDOperand(LD, 1);
859 /// SelectLEAAddr - it calls SelectAddr and determines if the maximal addressing
860 /// mode it matches can be cost effectively emitted as an LEA instruction.
861 bool X86DAGToDAGISel::SelectLEAAddr(SDOperand Op, SDOperand N,
862 SDOperand &Base, SDOperand &Scale,
863 SDOperand &Index, SDOperand &Disp) {
864 X86ISelAddressMode AM;
865 if (MatchAddress(N, AM))
868 MVT::ValueType VT = N.getValueType();
869 unsigned Complexity = 0;
870 if (AM.BaseType == X86ISelAddressMode::RegBase)
874 AM.Base.Reg = CurDAG->getRegister(0, VT);
875 else if (AM.BaseType == X86ISelAddressMode::FrameIndexBase)
881 AM.IndexReg = CurDAG->getRegister(0, VT);
883 // Don't match just leal(,%reg,2). It's cheaper to do addl %reg, %reg, or with
888 // FIXME: We are artificially lowering the criteria to turn ADD %reg, $GA
889 // to a LEA. This is determined with some expermentation but is by no means
890 // optimal (especially for code size consideration). LEA is nice because of
891 // its three-address nature. Tweak the cost function again when we can run
892 // convertToThreeAddress() at register allocation time.
893 if (AM.GV || AM.CP || AM.ES || AM.JT != -1) {
894 // For X86-64, we should always use lea to materialize RIP relative
896 if (Subtarget->is64Bit())
902 if (AM.Disp && (AM.Base.Reg.Val || AM.IndexReg.Val))
905 if (Complexity > 2) {
906 getAddressOperands(AM, Base, Scale, Index, Disp);
912 bool X86DAGToDAGISel::TryFoldLoad(SDOperand P, SDOperand N,
913 SDOperand &Base, SDOperand &Scale,
914 SDOperand &Index, SDOperand &Disp) {
915 if (ISD::isNON_EXTLoad(N.Val) &&
917 CanBeFoldedBy(N.Val, P.Val, P.Val))
918 return SelectAddr(P, N.getOperand(1), Base, Scale, Index, Disp);
922 /// getGlobalBaseReg - Output the instructions required to put the
923 /// base address to use for accessing globals into a register.
925 SDNode *X86DAGToDAGISel::getGlobalBaseReg() {
926 assert(!Subtarget->is64Bit() && "X86-64 PIC uses RIP relative addressing");
927 if (!GlobalBaseReg) {
928 // Insert the set of GlobalBaseReg into the first MBB of the function
929 MachineBasicBlock &FirstMBB = BB->getParent()->front();
930 MachineBasicBlock::iterator MBBI = FirstMBB.begin();
931 SSARegMap *RegMap = BB->getParent()->getSSARegMap();
932 unsigned PC = RegMap->createVirtualRegister(X86::GR32RegisterClass);
934 const TargetInstrInfo *TII = TM.getInstrInfo();
935 BuildMI(FirstMBB, MBBI, TII->get(X86::MovePCtoStack));
936 BuildMI(FirstMBB, MBBI, TII->get(X86::POP32r), PC);
938 // If we're using vanilla 'GOT' PIC style, we should use relative addressing
939 // not to pc, but to _GLOBAL_ADDRESS_TABLE_ external
940 if (TM.getRelocationModel() == Reloc::PIC_ &&
941 Subtarget->isPICStyleGOT()) {
942 GlobalBaseReg = RegMap->createVirtualRegister(X86::GR32RegisterClass);
943 BuildMI(FirstMBB, MBBI, TII->get(X86::ADD32ri), GlobalBaseReg).
945 addExternalSymbol("_GLOBAL_OFFSET_TABLE_");
951 return CurDAG->getRegister(GlobalBaseReg, TLI.getPointerTy()).Val;
954 static SDNode *FindCallStartFromCall(SDNode *Node) {
955 if (Node->getOpcode() == ISD::CALLSEQ_START) return Node;
956 assert(Node->getOperand(0).getValueType() == MVT::Other &&
957 "Node doesn't have a token chain argument!");
958 return FindCallStartFromCall(Node->getOperand(0).Val);
961 SDNode *X86DAGToDAGISel::getTruncate(SDOperand N0, MVT::ValueType VT) {
965 SRIdx = CurDAG->getTargetConstant(1, MVT::i32); // SubRegSet 1
966 // Ensure that the source register has an 8-bit subreg on 32-bit targets
967 if (!Subtarget->is64Bit()) {
970 switch (N0.getValueType()) {
971 default: assert(0 && "Unknown truncate!");
973 Opc = X86::MOV16to16_;
977 Opc = X86::MOV32to32_;
982 SDOperand(CurDAG->getTargetNode(Opc, VT, N0), 0);
986 SRIdx = CurDAG->getTargetConstant(2, MVT::i32); // SubRegSet 2
989 SRIdx = CurDAG->getTargetConstant(3, MVT::i32); // SubRegSet 3
991 default: assert(0 && "Unknown truncate!");
993 return CurDAG->getTargetNode(X86::EXTRACT_SUBREG,
999 SDNode *X86DAGToDAGISel::Select(SDOperand N) {
1000 SDNode *Node = N.Val;
1001 MVT::ValueType NVT = Node->getValueType(0);
1003 unsigned Opcode = Node->getOpcode();
1006 DOUT << std::string(Indent, ' ') << "Selecting: ";
1007 DEBUG(Node->dump(CurDAG));
1012 if (Opcode >= ISD::BUILTIN_OP_END && Opcode < X86ISD::FIRST_NUMBER) {
1014 DOUT << std::string(Indent-2, ' ') << "== ";
1015 DEBUG(Node->dump(CurDAG));
1019 return NULL; // Already selected.
1024 case X86ISD::GlobalBaseReg:
1025 return getGlobalBaseReg();
1028 // Turn ADD X, c to MOV32ri X+c. This cannot be done with tblgen'd
1029 // code and is matched first so to prevent it from being turned into
1031 // In 64-bit mode, use LEA to take advantage of RIP-relative addressing.
1032 MVT::ValueType PtrVT = TLI.getPointerTy();
1033 SDOperand N0 = N.getOperand(0);
1034 SDOperand N1 = N.getOperand(1);
1035 if (N.Val->getValueType(0) == PtrVT &&
1036 N0.getOpcode() == X86ISD::Wrapper &&
1037 N1.getOpcode() == ISD::Constant) {
1038 unsigned Offset = (unsigned)cast<ConstantSDNode>(N1)->getValue();
1040 // TODO: handle ExternalSymbolSDNode.
1041 if (GlobalAddressSDNode *G =
1042 dyn_cast<GlobalAddressSDNode>(N0.getOperand(0))) {
1043 C = CurDAG->getTargetGlobalAddress(G->getGlobal(), PtrVT,
1044 G->getOffset() + Offset);
1045 } else if (ConstantPoolSDNode *CP =
1046 dyn_cast<ConstantPoolSDNode>(N0.getOperand(0))) {
1047 C = CurDAG->getTargetConstantPool(CP->getConstVal(), PtrVT,
1049 CP->getOffset()+Offset);
1053 if (Subtarget->is64Bit()) {
1054 SDOperand Ops[] = { CurDAG->getRegister(0, PtrVT), getI8Imm(1),
1055 CurDAG->getRegister(0, PtrVT), C };
1056 return CurDAG->SelectNodeTo(N.Val, X86::LEA64r, MVT::i64, Ops, 4);
1058 return CurDAG->SelectNodeTo(N.Val, X86::MOV32ri, PtrVT, C);
1062 // Other cases are handled by auto-generated code.
1068 if (Opcode == ISD::MULHU)
1070 default: assert(0 && "Unsupported VT!");
1071 case MVT::i8: Opc = X86::MUL8r; MOpc = X86::MUL8m; break;
1072 case MVT::i16: Opc = X86::MUL16r; MOpc = X86::MUL16m; break;
1073 case MVT::i32: Opc = X86::MUL32r; MOpc = X86::MUL32m; break;
1074 case MVT::i64: Opc = X86::MUL64r; MOpc = X86::MUL64m; break;
1078 default: assert(0 && "Unsupported VT!");
1079 case MVT::i8: Opc = X86::IMUL8r; MOpc = X86::IMUL8m; break;
1080 case MVT::i16: Opc = X86::IMUL16r; MOpc = X86::IMUL16m; break;
1081 case MVT::i32: Opc = X86::IMUL32r; MOpc = X86::IMUL32m; break;
1082 case MVT::i64: Opc = X86::IMUL64r; MOpc = X86::IMUL64m; break;
1085 unsigned LoReg, HiReg;
1087 default: assert(0 && "Unsupported VT!");
1088 case MVT::i8: LoReg = X86::AL; HiReg = X86::AH; break;
1089 case MVT::i16: LoReg = X86::AX; HiReg = X86::DX; break;
1090 case MVT::i32: LoReg = X86::EAX; HiReg = X86::EDX; break;
1091 case MVT::i64: LoReg = X86::RAX; HiReg = X86::RDX; break;
1094 SDOperand N0 = Node->getOperand(0);
1095 SDOperand N1 = Node->getOperand(1);
1097 SDOperand Tmp0, Tmp1, Tmp2, Tmp3;
1098 bool foldedLoad = TryFoldLoad(N, N1, Tmp0, Tmp1, Tmp2, Tmp3);
1099 // MULHU and MULHS are commmutative
1101 foldedLoad = TryFoldLoad(N, N0, Tmp0, Tmp1, Tmp2, Tmp3);
1108 Chain = N1.getOperand(0);
1109 AddToISelQueue(Chain);
1111 Chain = CurDAG->getEntryNode();
1113 SDOperand InFlag(0, 0);
1115 Chain = CurDAG->getCopyToReg(Chain, CurDAG->getRegister(LoReg, NVT),
1117 InFlag = Chain.getValue(1);
1120 AddToISelQueue(Tmp0);
1121 AddToISelQueue(Tmp1);
1122 AddToISelQueue(Tmp2);
1123 AddToISelQueue(Tmp3);
1124 SDOperand Ops[] = { Tmp0, Tmp1, Tmp2, Tmp3, Chain, InFlag };
1126 CurDAG->getTargetNode(MOpc, MVT::Other, MVT::Flag, Ops, 6);
1127 Chain = SDOperand(CNode, 0);
1128 InFlag = SDOperand(CNode, 1);
1132 SDOperand(CurDAG->getTargetNode(Opc, MVT::Flag, N1, InFlag), 0);
1136 if (HiReg == X86::AH && Subtarget->is64Bit()) {
1137 // Prevent use of AH in a REX instruction by referencing AX instead.
1138 // Shift it down 8 bits.
1139 Result = CurDAG->getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag);
1140 Chain = Result.getValue(1);
1141 Result = SDOperand(CurDAG->getTargetNode(X86::SHR16ri, MVT::i16, Result,
1142 CurDAG->getTargetConstant(8, MVT::i8)), 0);
1143 // Then truncate it down to i8.
1144 SDOperand SRIdx = CurDAG->getTargetConstant(1, MVT::i32); // SubRegSet 1
1145 Result = SDOperand(CurDAG->getTargetNode(X86::EXTRACT_SUBREG,
1146 MVT::i8, Result, SRIdx), 0);
1148 Result = CurDAG->getCopyFromReg(Chain, HiReg, NVT, InFlag);
1150 ReplaceUses(N.getValue(0), Result);
1152 ReplaceUses(N1.getValue(1), Result.getValue(1));
1155 DOUT << std::string(Indent-2, ' ') << "=> ";
1156 DEBUG(Result.Val->dump(CurDAG));
1167 bool isSigned = Opcode == ISD::SDIV || Opcode == ISD::SREM;
1168 bool isDiv = Opcode == ISD::SDIV || Opcode == ISD::UDIV;
1171 default: assert(0 && "Unsupported VT!");
1172 case MVT::i8: Opc = X86::DIV8r; MOpc = X86::DIV8m; break;
1173 case MVT::i16: Opc = X86::DIV16r; MOpc = X86::DIV16m; break;
1174 case MVT::i32: Opc = X86::DIV32r; MOpc = X86::DIV32m; break;
1175 case MVT::i64: Opc = X86::DIV64r; MOpc = X86::DIV64m; break;
1179 default: assert(0 && "Unsupported VT!");
1180 case MVT::i8: Opc = X86::IDIV8r; MOpc = X86::IDIV8m; break;
1181 case MVT::i16: Opc = X86::IDIV16r; MOpc = X86::IDIV16m; break;
1182 case MVT::i32: Opc = X86::IDIV32r; MOpc = X86::IDIV32m; break;
1183 case MVT::i64: Opc = X86::IDIV64r; MOpc = X86::IDIV64m; break;
1186 unsigned LoReg, HiReg;
1187 unsigned ClrOpcode, SExtOpcode;
1189 default: assert(0 && "Unsupported VT!");
1191 LoReg = X86::AL; HiReg = X86::AH;
1193 SExtOpcode = X86::CBW;
1196 LoReg = X86::AX; HiReg = X86::DX;
1197 ClrOpcode = X86::MOV16r0;
1198 SExtOpcode = X86::CWD;
1201 LoReg = X86::EAX; HiReg = X86::EDX;
1202 ClrOpcode = X86::MOV32r0;
1203 SExtOpcode = X86::CDQ;
1206 LoReg = X86::RAX; HiReg = X86::RDX;
1207 ClrOpcode = X86::MOV64r0;
1208 SExtOpcode = X86::CQO;
1212 SDOperand N0 = Node->getOperand(0);
1213 SDOperand N1 = Node->getOperand(1);
1214 SDOperand InFlag(0, 0);
1215 if (NVT == MVT::i8 && !isSigned) {
1216 // Special case for div8, just use a move with zero extension to AX to
1217 // clear the upper 8 bits (AH).
1218 SDOperand Tmp0, Tmp1, Tmp2, Tmp3, Move, Chain;
1219 if (TryFoldLoad(N, N0, Tmp0, Tmp1, Tmp2, Tmp3)) {
1220 SDOperand Ops[] = { Tmp0, Tmp1, Tmp2, Tmp3, N0.getOperand(0) };
1221 AddToISelQueue(N0.getOperand(0));
1222 AddToISelQueue(Tmp0);
1223 AddToISelQueue(Tmp1);
1224 AddToISelQueue(Tmp2);
1225 AddToISelQueue(Tmp3);
1227 SDOperand(CurDAG->getTargetNode(X86::MOVZX16rm8, MVT::i16, MVT::Other,
1229 Chain = Move.getValue(1);
1230 ReplaceUses(N0.getValue(1), Chain);
1234 SDOperand(CurDAG->getTargetNode(X86::MOVZX16rr8, MVT::i16, N0), 0);
1235 Chain = CurDAG->getEntryNode();
1237 Chain = CurDAG->getCopyToReg(Chain, X86::AX, Move, InFlag);
1238 InFlag = Chain.getValue(1);
1242 CurDAG->getCopyToReg(CurDAG->getEntryNode(), LoReg, N0,
1243 InFlag).getValue(1);
1245 // Sign extend the low part into the high part.
1247 SDOperand(CurDAG->getTargetNode(SExtOpcode, MVT::Flag, InFlag), 0);
1249 // Zero out the high part, effectively zero extending the input.
1250 SDOperand ClrNode = SDOperand(CurDAG->getTargetNode(ClrOpcode, NVT), 0);
1251 InFlag = CurDAG->getCopyToReg(CurDAG->getEntryNode(), HiReg, ClrNode,
1252 InFlag).getValue(1);
1256 SDOperand Tmp0, Tmp1, Tmp2, Tmp3, Chain;
1257 bool foldedLoad = TryFoldLoad(N, N1, Tmp0, Tmp1, Tmp2, Tmp3);
1259 AddToISelQueue(N1.getOperand(0));
1260 AddToISelQueue(Tmp0);
1261 AddToISelQueue(Tmp1);
1262 AddToISelQueue(Tmp2);
1263 AddToISelQueue(Tmp3);
1264 SDOperand Ops[] = { Tmp0, Tmp1, Tmp2, Tmp3, N1.getOperand(0), InFlag };
1266 CurDAG->getTargetNode(MOpc, MVT::Other, MVT::Flag, Ops, 6);
1267 Chain = SDOperand(CNode, 0);
1268 InFlag = SDOperand(CNode, 1);
1271 Chain = CurDAG->getEntryNode();
1273 SDOperand(CurDAG->getTargetNode(Opc, MVT::Flag, N1, InFlag), 0);
1276 unsigned Reg = isDiv ? LoReg : HiReg;
1278 if (Reg == X86::AH && Subtarget->is64Bit()) {
1279 // Prevent use of AH in a REX instruction by referencing AX instead.
1280 // Shift it down 8 bits.
1281 Result = CurDAG->getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag);
1282 Chain = Result.getValue(1);
1283 Result = SDOperand(CurDAG->getTargetNode(X86::SHR16ri, MVT::i16, Result,
1284 CurDAG->getTargetConstant(8, MVT::i8)), 0);
1285 // Then truncate it down to i8.
1286 SDOperand SRIdx = CurDAG->getTargetConstant(1, MVT::i32); // SubRegSet 1
1287 Result = SDOperand(CurDAG->getTargetNode(X86::EXTRACT_SUBREG,
1288 MVT::i8, Result, SRIdx), 0);
1290 Result = CurDAG->getCopyFromReg(Chain, Reg, NVT, InFlag);
1291 Chain = Result.getValue(1);
1293 ReplaceUses(N.getValue(0), Result);
1295 ReplaceUses(N1.getValue(1), Chain);
1298 DOUT << std::string(Indent-2, ' ') << "=> ";
1299 DEBUG(Result.Val->dump(CurDAG));
1307 case ISD::ANY_EXTEND: {
1308 SDOperand N0 = Node->getOperand(0);
1310 if (NVT == MVT::i64 || NVT == MVT::i32 || NVT == MVT::i16) {
1312 switch(N0.getValueType()) {
1314 SRIdx = CurDAG->getTargetConstant(3, MVT::i32); // SubRegSet 3
1317 SRIdx = CurDAG->getTargetConstant(2, MVT::i32); // SubRegSet 2
1320 if (Subtarget->is64Bit())
1321 SRIdx = CurDAG->getTargetConstant(1, MVT::i32); // SubRegSet 1
1323 default: assert(0 && "Unknown any_extend!");
1326 SDNode *ResNode = CurDAG->getTargetNode(X86::INSERT_SUBREG, NVT, N0, SRIdx);
1329 DOUT << std::string(Indent-2, ' ') << "=> ";
1330 DEBUG(ResNode->dump(CurDAG));
1335 } // Otherwise let generated ISel handle it.
1340 case ISD::SIGN_EXTEND_INREG: {
1341 SDOperand N0 = Node->getOperand(0);
1344 MVT::ValueType SVT = cast<VTSDNode>(Node->getOperand(1))->getVT();
1345 SDOperand TruncOp = SDOperand(getTruncate(N0, SVT), 0);
1349 if (SVT == MVT::i8) Opc = X86::MOVSX16rr8;
1350 else assert(0 && "Unknown sign_extend_inreg!");
1354 case MVT::i8: Opc = X86::MOVSX32rr8; break;
1355 case MVT::i16: Opc = X86::MOVSX32rr16; break;
1356 default: assert(0 && "Unknown sign_extend_inreg!");
1361 case MVT::i8: Opc = X86::MOVSX64rr8; break;
1362 case MVT::i16: Opc = X86::MOVSX64rr16; break;
1363 case MVT::i32: Opc = X86::MOVSX64rr32; break;
1364 default: assert(0 && "Unknown sign_extend_inreg!");
1367 default: assert(0 && "Unknown sign_extend_inreg!");
1370 SDNode *ResNode = CurDAG->getTargetNode(Opc, NVT, TruncOp);
1373 DOUT << std::string(Indent-2, ' ') << "=> ";
1374 DEBUG(TruncOp.Val->dump(CurDAG));
1376 DOUT << std::string(Indent-2, ' ') << "=> ";
1377 DEBUG(ResNode->dump(CurDAG));
1385 case ISD::TRUNCATE: {
1386 SDOperand Input = Node->getOperand(0);
1387 AddToISelQueue(Node->getOperand(0));
1388 SDNode *ResNode = getTruncate(Input, NVT);
1391 DOUT << std::string(Indent-2, ' ') << "=> ";
1392 DEBUG(ResNode->dump(CurDAG));
1401 SDNode *ResNode = SelectCode(N);
1404 DOUT << std::string(Indent-2, ' ') << "=> ";
1405 if (ResNode == NULL || ResNode == N.Val)
1406 DEBUG(N.Val->dump(CurDAG));
1408 DEBUG(ResNode->dump(CurDAG));
1416 bool X86DAGToDAGISel::
1417 SelectInlineAsmMemoryOperand(const SDOperand &Op, char ConstraintCode,
1418 std::vector<SDOperand> &OutOps, SelectionDAG &DAG){
1419 SDOperand Op0, Op1, Op2, Op3;
1420 switch (ConstraintCode) {
1421 case 'o': // offsetable ??
1422 case 'v': // not offsetable ??
1423 default: return true;
1425 if (!SelectAddr(Op, Op, Op0, Op1, Op2, Op3))
1430 OutOps.push_back(Op0);
1431 OutOps.push_back(Op1);
1432 OutOps.push_back(Op2);
1433 OutOps.push_back(Op3);
1434 AddToISelQueue(Op0);
1435 AddToISelQueue(Op1);
1436 AddToISelQueue(Op2);
1437 AddToISelQueue(Op3);
1441 /// createX86ISelDag - This pass converts a legalized DAG into a
1442 /// X86-specific DAG, ready for instruction scheduling.
1444 FunctionPass *llvm::createX86ISelDag(X86TargetMachine &TM, bool Fast) {
1445 return new X86DAGToDAGISel(TM, Fast);