1 //===-- PPCISelDAGToDAG.cpp - PPC --pattern matching inst selector --------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a pattern matching instruction selector for PowerPC,
11 // converting from a legalized dag to a PPC dag.
13 //===----------------------------------------------------------------------===//
16 #include "PPCTargetMachine.h"
17 #include "PPCISelLowering.h"
18 #include "PPCHazardRecognizers.h"
19 #include "llvm/CodeGen/MachineInstrBuilder.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/SSARegMap.h"
22 #include "llvm/CodeGen/SelectionDAG.h"
23 #include "llvm/CodeGen/SelectionDAGISel.h"
24 #include "llvm/Target/TargetOptions.h"
25 #include "llvm/ADT/Statistic.h"
26 #include "llvm/Constants.h"
27 #include "llvm/GlobalValue.h"
28 #include "llvm/Intrinsics.h"
29 #include "llvm/Support/Debug.h"
30 #include "llvm/Support/MathExtras.h"
36 Statistic<> FrameOff("ppc-codegen", "Number of frame idx offsets collapsed");
38 //===--------------------------------------------------------------------===//
39 /// PPCDAGToDAGISel - PPC specific code to select PPC machine
40 /// instructions for SelectionDAG operations.
42 class PPCDAGToDAGISel : public SelectionDAGISel {
44 PPCTargetLowering PPCLowering;
45 unsigned GlobalBaseReg;
47 PPCDAGToDAGISel(PPCTargetMachine &tm)
48 : SelectionDAGISel(PPCLowering), TM(tm),
49 PPCLowering(*TM.getTargetLowering()) {}
51 virtual bool runOnFunction(Function &Fn) {
52 // Make sure we re-emit a set of the global base reg if necessary
54 SelectionDAGISel::runOnFunction(Fn);
60 /// getI32Imm - Return a target constant with the specified value, of type
62 inline SDOperand getI32Imm(unsigned Imm) {
63 return CurDAG->getTargetConstant(Imm, MVT::i32);
66 /// getGlobalBaseReg - insert code into the entry mbb to materialize the PIC
67 /// base register. Return the virtual register that holds this value.
68 SDOperand getGlobalBaseReg();
70 // Select - Convert the specified operand from a target-independent to a
71 // target-specific node if it hasn't already been changed.
72 void Select(SDOperand &Result, SDOperand Op);
74 SDNode *SelectBitfieldInsert(SDNode *N);
76 /// SelectCC - Select a comparison of the specified values with the
77 /// specified condition code, returning the CR# of the expression.
78 SDOperand SelectCC(SDOperand LHS, SDOperand RHS, ISD::CondCode CC);
80 /// SelectAddrImm - Returns true if the address N can be represented by
81 /// a base register plus a signed 16-bit displacement [r+imm].
82 bool SelectAddrImm(SDOperand N, SDOperand &Disp, SDOperand &Base);
84 /// SelectAddrIdx - Given the specified addressed, check to see if it can be
85 /// represented as an indexed [r+r] operation. Returns false if it can
86 /// be represented by [r+imm], which are preferred.
87 bool SelectAddrIdx(SDOperand N, SDOperand &Base, SDOperand &Index);
89 /// SelectAddrIdxOnly - Given the specified addressed, force it to be
90 /// represented as an indexed [r+r] operation.
91 bool SelectAddrIdxOnly(SDOperand N, SDOperand &Base, SDOperand &Index);
93 /// SelectAddrImmShift - Returns true if the address N can be represented by
94 /// a base register plus a signed 14-bit displacement [r+imm*4]. Suitable
95 /// for use by STD and friends.
96 bool SelectAddrImmShift(SDOperand N, SDOperand &Disp, SDOperand &Base);
98 /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
99 /// inline asm expressions.
100 virtual bool SelectInlineAsmMemoryOperand(const SDOperand &Op,
102 std::vector<SDOperand> &OutOps,
105 switch (ConstraintCode) {
106 default: return true;
108 if (!SelectAddrIdx(Op, Op0, Op1))
109 SelectAddrImm(Op, Op0, Op1);
111 case 'o': // offsetable
112 if (!SelectAddrImm(Op, Op0, Op1)) {
113 Select(Op0, Op); // r+0.
117 case 'v': // not offsetable
118 SelectAddrIdxOnly(Op, Op0, Op1);
122 OutOps.push_back(Op0);
123 OutOps.push_back(Op1);
127 SDOperand BuildSDIVSequence(SDNode *N);
128 SDOperand BuildUDIVSequence(SDNode *N);
130 /// InstructionSelectBasicBlock - This callback is invoked by
131 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
132 virtual void InstructionSelectBasicBlock(SelectionDAG &DAG);
134 void InsertVRSaveCode(Function &Fn);
136 virtual const char *getPassName() const {
137 return "PowerPC DAG->DAG Pattern Instruction Selection";
140 /// CreateTargetHazardRecognizer - Return the hazard recognizer to use for this
141 /// target when scheduling the DAG.
142 virtual HazardRecognizer *CreateTargetHazardRecognizer() {
143 // Should use subtarget info to pick the right hazard recognizer. For
144 // now, always return a PPC970 recognizer.
145 const TargetInstrInfo *II = PPCLowering.getTargetMachine().getInstrInfo();
146 assert(II && "No InstrInfo?");
147 return new PPCHazardRecognizer970(*II);
150 // Include the pieces autogenerated from the target description.
151 #include "PPCGenDAGISel.inc"
154 SDOperand SelectSETCC(SDOperand Op);
155 SDOperand SelectCALL(SDOperand Op);
159 /// InstructionSelectBasicBlock - This callback is invoked by
160 /// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
161 void PPCDAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) {
164 // The selection process is inherently a bottom-up recursive process (users
165 // select their uses before themselves). Given infinite stack space, we
166 // could just start selecting on the root and traverse the whole graph. In
167 // practice however, this causes us to run out of stack space on large basic
168 // blocks. To avoid this problem, select the entry node, then all its uses,
169 // iteratively instead of recursively.
170 std::vector<SDOperand> Worklist;
171 Worklist.push_back(DAG.getEntryNode());
173 // Note that we can do this in the PPC target (scanning forward across token
174 // chain edges) because no nodes ever get folded across these edges. On a
175 // target like X86 which supports load/modify/store operations, this would
176 // have to be more careful.
177 while (!Worklist.empty()) {
178 SDOperand Node = Worklist.back();
181 // Chose from the least deep of the top two nodes.
182 if (!Worklist.empty() &&
183 Worklist.back().Val->getNodeDepth() < Node.Val->getNodeDepth())
184 std::swap(Worklist.back(), Node);
186 if ((Node.Val->getOpcode() >= ISD::BUILTIN_OP_END &&
187 Node.Val->getOpcode() < PPCISD::FIRST_NUMBER) ||
188 CodeGenMap.count(Node)) continue;
190 for (SDNode::use_iterator UI = Node.Val->use_begin(),
191 E = Node.Val->use_end(); UI != E; ++UI) {
192 // Scan the values. If this use has a value that is a token chain, add it
195 for (unsigned i = 0, e = User->getNumValues(); i != e; ++i)
196 if (User->getValueType(i) == MVT::Other) {
197 Worklist.push_back(SDOperand(User, i));
202 // Finally, legalize this node.
207 // Select target instructions for the DAG.
208 DAG.setRoot(SelectRoot(DAG.getRoot()));
210 DAG.RemoveDeadNodes();
212 // Emit machine code to BB.
213 ScheduleAndEmitDAG(DAG);
216 /// InsertVRSaveCode - Once the entire function has been instruction selected,
217 /// all virtual registers are created and all machine instructions are built,
218 /// check to see if we need to save/restore VRSAVE. If so, do it.
219 void PPCDAGToDAGISel::InsertVRSaveCode(Function &F) {
220 // Check to see if this function uses vector registers, which means we have to
221 // save and restore the VRSAVE register and update it with the regs we use.
223 // In this case, there will be virtual registers of vector type type created
224 // by the scheduler. Detect them now.
225 MachineFunction &Fn = MachineFunction::get(&F);
226 SSARegMap *RegMap = Fn.getSSARegMap();
227 bool HasVectorVReg = false;
228 for (unsigned i = MRegisterInfo::FirstVirtualRegister,
229 e = RegMap->getLastVirtReg()+1; i != e; ++i)
230 if (RegMap->getRegClass(i) == &PPC::VRRCRegClass) {
231 HasVectorVReg = true;
234 if (!HasVectorVReg) return; // nothing to do.
236 // If we have a vector register, we want to emit code into the entry and exit
237 // blocks to save and restore the VRSAVE register. We do this here (instead
238 // of marking all vector instructions as clobbering VRSAVE) for two reasons:
240 // 1. This (trivially) reduces the load on the register allocator, by not
241 // having to represent the live range of the VRSAVE register.
242 // 2. This (more significantly) allows us to create a temporary virtual
243 // register to hold the saved VRSAVE value, allowing this temporary to be
244 // register allocated, instead of forcing it to be spilled to the stack.
246 // Create two vregs - one to hold the VRSAVE register that is live-in to the
247 // function and one for the value after having bits or'd into it.
248 unsigned InVRSAVE = RegMap->createVirtualRegister(&PPC::GPRCRegClass);
249 unsigned UpdatedVRSAVE = RegMap->createVirtualRegister(&PPC::GPRCRegClass);
251 MachineBasicBlock &EntryBB = *Fn.begin();
252 // Emit the following code into the entry block:
253 // InVRSAVE = MFVRSAVE
254 // UpdatedVRSAVE = UPDATE_VRSAVE InVRSAVE
255 // MTVRSAVE UpdatedVRSAVE
256 MachineBasicBlock::iterator IP = EntryBB.begin(); // Insert Point
257 BuildMI(EntryBB, IP, PPC::MFVRSAVE, 0, InVRSAVE);
258 BuildMI(EntryBB, IP, PPC::UPDATE_VRSAVE, 1, UpdatedVRSAVE).addReg(InVRSAVE);
259 BuildMI(EntryBB, IP, PPC::MTVRSAVE, 1).addReg(UpdatedVRSAVE);
261 // Find all return blocks, outputting a restore in each epilog.
262 const TargetInstrInfo &TII = *TM.getInstrInfo();
263 for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
264 if (!BB->empty() && TII.isReturn(BB->back().getOpcode())) {
265 IP = BB->end(); --IP;
267 // Skip over all terminator instructions, which are part of the return
269 MachineBasicBlock::iterator I2 = IP;
270 while (I2 != BB->begin() && TII.isTerminatorInstr((--I2)->getOpcode()))
273 // Emit: MTVRSAVE InVRSave
274 BuildMI(*BB, IP, PPC::MTVRSAVE, 1).addReg(InVRSAVE);
280 /// getGlobalBaseReg - Output the instructions required to put the
281 /// base address to use for accessing globals into a register.
283 SDOperand PPCDAGToDAGISel::getGlobalBaseReg() {
284 if (!GlobalBaseReg) {
285 // Insert the set of GlobalBaseReg into the first MBB of the function
286 MachineBasicBlock &FirstMBB = BB->getParent()->front();
287 MachineBasicBlock::iterator MBBI = FirstMBB.begin();
288 SSARegMap *RegMap = BB->getParent()->getSSARegMap();
289 // FIXME: when we get to LP64, we will need to create the appropriate
290 // type of register here.
291 GlobalBaseReg = RegMap->createVirtualRegister(PPC::GPRCRegisterClass);
292 BuildMI(FirstMBB, MBBI, PPC::MovePCtoLR, 0, PPC::LR);
293 BuildMI(FirstMBB, MBBI, PPC::MFLR, 1, GlobalBaseReg);
295 return CurDAG->getRegister(GlobalBaseReg, MVT::i32);
299 // isIntImmediate - This method tests to see if a constant operand.
300 // If so Imm will receive the 32 bit value.
301 static bool isIntImmediate(SDNode *N, unsigned& Imm) {
302 if (N->getOpcode() == ISD::Constant) {
303 Imm = cast<ConstantSDNode>(N)->getValue();
309 // isRunOfOnes - Returns true iff Val consists of one contiguous run of 1s with
310 // any number of 0s on either side. The 1s are allowed to wrap from LSB to
311 // MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is
312 // not, since all 1s are not contiguous.
313 static bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME) {
314 if (isShiftedMask_32(Val)) {
315 // look for the first non-zero bit
316 MB = CountLeadingZeros_32(Val);
317 // look for the first zero bit after the run of ones
318 ME = CountLeadingZeros_32((Val - 1) ^ Val);
321 Val = ~Val; // invert mask
322 if (isShiftedMask_32(Val)) {
323 // effectively look for the first zero bit
324 ME = CountLeadingZeros_32(Val) - 1;
325 // effectively look for the first one bit after the run of zeros
326 MB = CountLeadingZeros_32((Val - 1) ^ Val) + 1;
334 // isRotateAndMask - Returns true if Mask and Shift can be folded into a rotate
335 // and mask opcode and mask operation.
336 static bool isRotateAndMask(SDNode *N, unsigned Mask, bool IsShiftMask,
337 unsigned &SH, unsigned &MB, unsigned &ME) {
338 // Don't even go down this path for i64, since different logic will be
339 // necessary for rldicl/rldicr/rldimi.
340 if (N->getValueType(0) != MVT::i32)
344 unsigned Indeterminant = ~0; // bit mask marking indeterminant results
345 unsigned Opcode = N->getOpcode();
346 if (N->getNumOperands() != 2 ||
347 !isIntImmediate(N->getOperand(1).Val, Shift) || (Shift > 31))
350 if (Opcode == ISD::SHL) {
351 // apply shift left to mask if it comes first
352 if (IsShiftMask) Mask = Mask << Shift;
353 // determine which bits are made indeterminant by shift
354 Indeterminant = ~(0xFFFFFFFFu << Shift);
355 } else if (Opcode == ISD::SRL) {
356 // apply shift right to mask if it comes first
357 if (IsShiftMask) Mask = Mask >> Shift;
358 // determine which bits are made indeterminant by shift
359 Indeterminant = ~(0xFFFFFFFFu >> Shift);
360 // adjust for the left rotate
366 // if the mask doesn't intersect any Indeterminant bits
367 if (Mask && !(Mask & Indeterminant)) {
369 // make sure the mask is still a mask (wrap arounds may not be)
370 return isRunOfOnes(Mask, MB, ME);
375 // isOpcWithIntImmediate - This method tests to see if the node is a specific
376 // opcode and that it has a immediate integer right operand.
377 // If so Imm will receive the 32 bit value.
378 static bool isOpcWithIntImmediate(SDNode *N, unsigned Opc, unsigned& Imm) {
379 return N->getOpcode() == Opc && isIntImmediate(N->getOperand(1).Val, Imm);
382 // isIntImmediate - This method tests to see if a constant operand.
383 // If so Imm will receive the 32 bit value.
384 static bool isIntImmediate(SDOperand N, unsigned& Imm) {
385 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N)) {
386 Imm = (unsigned)CN->getSignExtended();
392 /// SelectBitfieldInsert - turn an or of two masked values into
393 /// the rotate left word immediate then mask insert (rlwimi) instruction.
394 SDNode *PPCDAGToDAGISel::SelectBitfieldInsert(SDNode *N) {
395 unsigned TgtMask = 0xFFFFFFFF, InsMask = 0xFFFFFFFF, SH = 0;
398 SDOperand Op0 = N->getOperand(0);
399 SDOperand Op1 = N->getOperand(1);
401 unsigned Op0Opc = Op0.getOpcode();
402 unsigned Op1Opc = Op1.getOpcode();
404 uint64_t LKZ, LKO, RKZ, RKO;
405 TLI.ComputeMaskedBits(Op0, TgtMask, LKZ, LKO);
406 TLI.ComputeMaskedBits(Op1, TgtMask, RKZ, RKO);
408 // FIXME: rotrwi / rotlwi
409 if ((LKZ | RKZ) == 0x00000000FFFFFFFFULL) {
410 unsigned PInsMask = ~RKZ;
411 unsigned PTgtMask = ~LKZ;
413 // If the LHS has a foldable shift, then swap it to the RHS so that we can
414 // fold the shift into the insert.
415 if (Op0Opc == ISD::AND && Op1Opc == ISD::AND) {
416 if (Op0.getOperand(0).getOpcode() == ISD::SHL ||
417 Op0.getOperand(0).getOpcode() == ISD::SRL) {
418 if (Op1.getOperand(0).getOpcode() != ISD::SHL &&
419 Op1.getOperand(0).getOpcode() != ISD::SRL) {
421 std::swap(Op0Opc, Op1Opc);
422 std::swap(PInsMask, PTgtMask);
428 if (isRunOfOnes(PInsMask, MB, ME)) {
429 SDOperand Tmp1, Tmp2, Tmp3;
430 bool DisjointMask = (PTgtMask ^ PInsMask) == 0xFFFFFFFF;
432 if ((Op1Opc == ISD::SHL || Op1Opc == ISD::SRL) &&
433 isIntImmediate(Op1.getOperand(1), Value)) {
434 Op1 = Op1.getOperand(0);
435 SH = (Op1Opc == ISD::SHL) ? Value : 32 - Value;
437 if (Op1Opc == ISD::AND) {
438 unsigned SHOpc = Op1.getOperand(0).getOpcode();
439 if ((SHOpc == ISD::SHL || SHOpc == ISD::SRL) &&
440 isIntImmediate(Op1.getOperand(0).getOperand(1), Value)) {
441 Op1 = Op1.getOperand(0).getOperand(0);
442 SH = (SHOpc == ISD::SHL) ? Value : 32 - Value;
444 Op1 = Op1.getOperand(0);
448 Tmp3 = (Op0Opc == ISD::AND && DisjointMask) ? Op0.getOperand(0) : Op0;
451 return CurDAG->getTargetNode(PPC::RLWIMI, MVT::i32, Tmp1, Tmp2,
452 getI32Imm(SH), getI32Imm(MB), getI32Imm(ME));
458 /// SelectAddrImm - Returns true if the address N can be represented by
459 /// a base register plus a signed 16-bit displacement [r+imm].
460 bool PPCDAGToDAGISel::SelectAddrImm(SDOperand N, SDOperand &Disp,
462 // If this can be more profitably realized as r+r, fail.
463 if (SelectAddrIdx(N, Disp, Base))
466 if (N.getOpcode() == ISD::ADD) {
468 if (isIntImmediate(N.getOperand(1), imm) && isInt16(imm)) {
469 Disp = getI32Imm(imm & 0xFFFF);
470 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N.getOperand(0))) {
471 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
473 Base = N.getOperand(0);
475 return true; // [r+i]
476 } else if (N.getOperand(1).getOpcode() == PPCISD::Lo) {
477 // Match LOAD (ADD (X, Lo(G))).
478 assert(!cast<ConstantSDNode>(N.getOperand(1).getOperand(1))->getValue()
479 && "Cannot handle constant offsets yet!");
480 Disp = N.getOperand(1).getOperand(0); // The global address.
481 assert(Disp.getOpcode() == ISD::TargetGlobalAddress ||
482 Disp.getOpcode() == ISD::TargetConstantPool ||
483 Disp.getOpcode() == ISD::TargetJumpTable);
484 Base = N.getOperand(0);
485 return true; // [&g+r]
487 } else if (N.getOpcode() == ISD::OR) {
489 if (isIntImmediate(N.getOperand(1), imm) && isInt16(imm)) {
490 // If this is an or of disjoint bitfields, we can codegen this as an add
491 // (for better address arithmetic) if the LHS and RHS of the OR are
492 // provably disjoint.
493 uint64_t LHSKnownZero, LHSKnownOne;
494 PPCLowering.ComputeMaskedBits(N.getOperand(0), ~0U,
495 LHSKnownZero, LHSKnownOne);
496 if ((LHSKnownZero|~imm) == ~0U) {
497 // If all of the bits are known zero on the LHS or RHS, the add won't
499 Base = N.getOperand(0);
500 Disp = getI32Imm(imm & 0xFFFF);
504 } else if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N)) {
505 // Loading from a constant address.
506 int Addr = (int)CN->getValue();
508 // If this address fits entirely in a 16-bit sext immediate field, codegen
510 if (Addr == (short)Addr) {
511 Disp = getI32Imm(Addr);
512 Base = CurDAG->getRegister(PPC::R0, MVT::i32);
516 // Otherwise, break this down into an LIS + disp.
517 Disp = getI32Imm((short)Addr);
518 Base = CurDAG->getConstant(Addr - (signed short)Addr, MVT::i32);
523 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N))
524 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
527 return true; // [r+0]
530 /// SelectAddrIdx - Given the specified addressed, check to see if it can be
531 /// represented as an indexed [r+r] operation. Returns false if it can
532 /// be represented by [r+imm], which are preferred.
533 bool PPCDAGToDAGISel::SelectAddrIdx(SDOperand N, SDOperand &Base,
536 if (N.getOpcode() == ISD::ADD) {
537 if (isIntImmediate(N.getOperand(1), imm) && isInt16(imm))
539 if (N.getOperand(1).getOpcode() == PPCISD::Lo)
542 Base = N.getOperand(0);
543 Index = N.getOperand(1);
545 } else if (N.getOpcode() == ISD::OR) {
546 if (isIntImmediate(N.getOperand(1), imm) && isInt16(imm))
547 return false; // r+i can fold it if we can.
549 // If this is an or of disjoint bitfields, we can codegen this as an add
550 // (for better address arithmetic) if the LHS and RHS of the OR are provably
552 uint64_t LHSKnownZero, LHSKnownOne;
553 uint64_t RHSKnownZero, RHSKnownOne;
554 PPCLowering.ComputeMaskedBits(N.getOperand(0), ~0U,
555 LHSKnownZero, LHSKnownOne);
558 PPCLowering.ComputeMaskedBits(N.getOperand(1), ~0U,
559 RHSKnownZero, RHSKnownOne);
560 // If all of the bits are known zero on the LHS or RHS, the add won't
562 if ((LHSKnownZero | RHSKnownZero) == ~0U) {
563 Base = N.getOperand(0);
564 Index = N.getOperand(1);
573 /// SelectAddrIdxOnly - Given the specified addressed, force it to be
574 /// represented as an indexed [r+r] operation.
575 bool PPCDAGToDAGISel::SelectAddrIdxOnly(SDOperand N, SDOperand &Base,
577 // Check to see if we can easily represent this as an [r+r] address. This
578 // will fail if it thinks that the address is more profitably represented as
579 // reg+imm, e.g. where imm = 0.
580 if (SelectAddrIdx(N, Base, Index))
583 // If the operand is an addition, always emit this as [r+r], since this is
584 // better (for code size, and execution, as the memop does the add for free)
585 // than emitting an explicit add.
586 if (N.getOpcode() == ISD::ADD) {
587 Base = N.getOperand(0);
588 Index = N.getOperand(1);
592 // Otherwise, do it the hard way, using R0 as the base register.
593 Base = CurDAG->getRegister(PPC::R0, MVT::i32);
598 /// SelectAddrImmShift - Returns true if the address N can be represented by
599 /// a base register plus a signed 14-bit displacement [r+imm*4]. Suitable
600 /// for use by STD and friends.
601 bool PPCDAGToDAGISel::SelectAddrImmShift(SDOperand N, SDOperand &Disp,
603 // If this can be more profitably realized as r+r, fail.
604 if (SelectAddrIdx(N, Disp, Base))
607 if (N.getOpcode() == ISD::ADD) {
609 if (isIntImmediate(N.getOperand(1), imm) && isInt16(imm) &&
611 Disp = getI32Imm((imm & 0xFFFF) >> 2);
612 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N.getOperand(0))) {
613 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
615 Base = N.getOperand(0);
617 return true; // [r+i]
618 } else if (N.getOperand(1).getOpcode() == PPCISD::Lo) {
619 // Match LOAD (ADD (X, Lo(G))).
620 assert(!cast<ConstantSDNode>(N.getOperand(1).getOperand(1))->getValue()
621 && "Cannot handle constant offsets yet!");
622 Disp = N.getOperand(1).getOperand(0); // The global address.
623 assert(Disp.getOpcode() == ISD::TargetGlobalAddress ||
624 Disp.getOpcode() == ISD::TargetConstantPool ||
625 Disp.getOpcode() == ISD::TargetJumpTable);
626 Base = N.getOperand(0);
627 return true; // [&g+r]
629 } else if (N.getOpcode() == ISD::OR) {
631 if (isIntImmediate(N.getOperand(1), imm) && isInt16(imm) &&
633 // If this is an or of disjoint bitfields, we can codegen this as an add
634 // (for better address arithmetic) if the LHS and RHS of the OR are
635 // provably disjoint.
636 uint64_t LHSKnownZero, LHSKnownOne;
637 PPCLowering.ComputeMaskedBits(N.getOperand(0), ~0U,
638 LHSKnownZero, LHSKnownOne);
639 if ((LHSKnownZero|~imm) == ~0U) {
640 // If all of the bits are known zero on the LHS or RHS, the add won't
642 Base = N.getOperand(0);
643 Disp = getI32Imm((imm & 0xFFFF) >> 2);
647 } else if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N)) {
648 // Loading from a constant address.
649 int Addr = (int)CN->getValue();
650 if ((Addr & 3) == 0) {
651 // If this address fits entirely in a 16-bit sext immediate field, codegen
653 if (Addr == (short)Addr) {
654 Disp = getI32Imm(Addr >> 2);
655 Base = CurDAG->getRegister(PPC::R0, MVT::i32);
659 // Otherwise, break this down into an LIS + disp.
660 Disp = getI32Imm((short)Addr >> 2);
661 Base = CurDAG->getConstant(Addr - (signed short)Addr, MVT::i32);
667 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N))
668 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
671 return true; // [r+0]
675 /// SelectCC - Select a comparison of the specified values with the specified
676 /// condition code, returning the CR# of the expression.
677 SDOperand PPCDAGToDAGISel::SelectCC(SDOperand LHS, SDOperand RHS,
679 // Always select the LHS.
682 // Use U to determine whether the SETCC immediate range is signed or not.
683 if (MVT::isInteger(LHS.getValueType())) {
684 bool U = ISD::isUnsignedIntSetCC(CC);
686 if (isIntImmediate(RHS, Imm) &&
687 ((U && isUInt16(Imm)) || (!U && isInt16(Imm))))
688 return SDOperand(CurDAG->getTargetNode(U ? PPC::CMPLWI : PPC::CMPWI,
689 MVT::i32, LHS, getI32Imm(Imm & 0xFFFF)), 0);
691 return SDOperand(CurDAG->getTargetNode(U ? PPC::CMPLW : PPC::CMPW, MVT::i32,
693 } else if (LHS.getValueType() == MVT::f32) {
695 return SDOperand(CurDAG->getTargetNode(PPC::FCMPUS, MVT::i32, LHS, RHS), 0);
698 return SDOperand(CurDAG->getTargetNode(PPC::FCMPUD, MVT::i32, LHS, RHS), 0);
702 /// getBCCForSetCC - Returns the PowerPC condition branch mnemonic corresponding
704 static unsigned getBCCForSetCC(ISD::CondCode CC) {
706 default: assert(0 && "Unknown condition!"); abort();
707 case ISD::SETOEQ: // FIXME: This is incorrect see PR642.
708 case ISD::SETEQ: return PPC::BEQ;
709 case ISD::SETONE: // FIXME: This is incorrect see PR642.
710 case ISD::SETNE: return PPC::BNE;
711 case ISD::SETOLT: // FIXME: This is incorrect see PR642.
713 case ISD::SETLT: return PPC::BLT;
714 case ISD::SETOLE: // FIXME: This is incorrect see PR642.
716 case ISD::SETLE: return PPC::BLE;
717 case ISD::SETOGT: // FIXME: This is incorrect see PR642.
719 case ISD::SETGT: return PPC::BGT;
720 case ISD::SETOGE: // FIXME: This is incorrect see PR642.
722 case ISD::SETGE: return PPC::BGE;
724 case ISD::SETO: return PPC::BUN;
725 case ISD::SETUO: return PPC::BNU;
730 /// getCRIdxForSetCC - Return the index of the condition register field
731 /// associated with the SetCC condition, and whether or not the field is
732 /// treated as inverted. That is, lt = 0; ge = 0 inverted.
733 static unsigned getCRIdxForSetCC(ISD::CondCode CC, bool& Inv) {
735 default: assert(0 && "Unknown condition!"); abort();
736 case ISD::SETOLT: // FIXME: This is incorrect see PR642.
738 case ISD::SETLT: Inv = false; return 0;
739 case ISD::SETOGE: // FIXME: This is incorrect see PR642.
741 case ISD::SETGE: Inv = true; return 0;
742 case ISD::SETOGT: // FIXME: This is incorrect see PR642.
744 case ISD::SETGT: Inv = false; return 1;
745 case ISD::SETOLE: // FIXME: This is incorrect see PR642.
747 case ISD::SETLE: Inv = true; return 1;
748 case ISD::SETOEQ: // FIXME: This is incorrect see PR642.
749 case ISD::SETEQ: Inv = false; return 2;
750 case ISD::SETONE: // FIXME: This is incorrect see PR642.
751 case ISD::SETNE: Inv = true; return 2;
752 case ISD::SETO: Inv = true; return 3;
753 case ISD::SETUO: Inv = false; return 3;
758 SDOperand PPCDAGToDAGISel::SelectSETCC(SDOperand Op) {
761 ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(2))->get();
762 if (isIntImmediate(N->getOperand(1), Imm)) {
763 // We can codegen setcc op, imm very efficiently compared to a brcond.
764 // Check for those cases here.
768 Select(Op, N->getOperand(0));
772 Op = SDOperand(CurDAG->getTargetNode(PPC::CNTLZW, MVT::i32, Op), 0);
773 return CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, Op, getI32Imm(27),
774 getI32Imm(5), getI32Imm(31));
777 SDOperand(CurDAG->getTargetNode(PPC::ADDIC, MVT::i32, MVT::Flag,
778 Op, getI32Imm(~0U)), 0);
779 return CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32, AD, Op,
783 return CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, Op, getI32Imm(1),
784 getI32Imm(31), getI32Imm(31));
787 SDOperand(CurDAG->getTargetNode(PPC::NEG, MVT::i32, Op), 0);
788 T = SDOperand(CurDAG->getTargetNode(PPC::ANDC, MVT::i32, T, Op), 0);
789 return CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, T, getI32Imm(1),
790 getI32Imm(31), getI32Imm(31));
793 } else if (Imm == ~0U) { // setcc op, -1
795 Select(Op, N->getOperand(0));
799 Op = SDOperand(CurDAG->getTargetNode(PPC::ADDIC, MVT::i32, MVT::Flag,
800 Op, getI32Imm(1)), 0);
801 return CurDAG->SelectNodeTo(N, PPC::ADDZE, MVT::i32,
802 SDOperand(CurDAG->getTargetNode(PPC::LI, MVT::i32,
806 Op = SDOperand(CurDAG->getTargetNode(PPC::NOR, MVT::i32, Op, Op), 0);
807 SDNode *AD = CurDAG->getTargetNode(PPC::ADDIC, MVT::i32, MVT::Flag,
809 return CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32, SDOperand(AD, 0), Op,
813 SDOperand AD = SDOperand(CurDAG->getTargetNode(PPC::ADDI, MVT::i32, Op,
815 SDOperand AN = SDOperand(CurDAG->getTargetNode(PPC::AND, MVT::i32, AD,
817 return CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, AN, getI32Imm(1),
818 getI32Imm(31), getI32Imm(31));
821 Op = SDOperand(CurDAG->getTargetNode(PPC::RLWINM, MVT::i32, Op,
822 getI32Imm(1), getI32Imm(31),
824 return CurDAG->SelectNodeTo(N, PPC::XORI, MVT::i32, Op, getI32Imm(1));
830 unsigned Idx = getCRIdxForSetCC(CC, Inv);
831 SDOperand CCReg = SelectCC(N->getOperand(0), N->getOperand(1), CC);
834 // Force the ccreg into CR7.
835 SDOperand CR7Reg = CurDAG->getRegister(PPC::CR7, MVT::i32);
837 SDOperand InFlag(0, 0); // Null incoming flag value.
838 CCReg = CurDAG->getCopyToReg(CurDAG->getEntryNode(), CR7Reg, CCReg,
841 if (TLI.getTargetMachine().getSubtarget<PPCSubtarget>().isGigaProcessor())
842 IntCR = SDOperand(CurDAG->getTargetNode(PPC::MFOCRF, MVT::i32, CR7Reg,
845 IntCR = SDOperand(CurDAG->getTargetNode(PPC::MFCR, MVT::i32, CCReg), 0);
848 return CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, IntCR,
849 getI32Imm((32-(3-Idx)) & 31),
850 getI32Imm(31), getI32Imm(31));
853 SDOperand(CurDAG->getTargetNode(PPC::RLWINM, MVT::i32, IntCR,
854 getI32Imm((32-(3-Idx)) & 31),
855 getI32Imm(31),getI32Imm(31)), 0);
856 return CurDAG->SelectNodeTo(N, PPC::XORI, MVT::i32, Tmp, getI32Imm(1));
860 /// isCallCompatibleAddress - Return true if the specified 32-bit value is
861 /// representable in the immediate field of a Bx instruction.
862 static bool isCallCompatibleAddress(ConstantSDNode *C) {
863 int Addr = C->getValue();
864 if (Addr & 3) return false; // Low 2 bits are implicitly zero.
865 return (Addr << 6 >> 6) == Addr; // Top 6 bits have to be sext of immediate.
868 SDOperand PPCDAGToDAGISel::SelectCALL(SDOperand Op) {
871 Select(Chain, N->getOperand(0));
874 std::vector<SDOperand> CallOperands;
876 if (GlobalAddressSDNode *GASD =
877 dyn_cast<GlobalAddressSDNode>(N->getOperand(1))) {
878 CallOpcode = PPC::BL;
879 CallOperands.push_back(N->getOperand(1));
880 } else if (ExternalSymbolSDNode *ESSDN =
881 dyn_cast<ExternalSymbolSDNode>(N->getOperand(1))) {
882 CallOpcode = PPC::BL;
883 CallOperands.push_back(N->getOperand(1));
884 } else if (isa<ConstantSDNode>(N->getOperand(1)) &&
885 isCallCompatibleAddress(cast<ConstantSDNode>(N->getOperand(1)))) {
886 ConstantSDNode *C = cast<ConstantSDNode>(N->getOperand(1));
887 CallOpcode = PPC::BLA;
888 CallOperands.push_back(getI32Imm((int)C->getValue() >> 2));
890 // Copy the callee address into the CTR register.
892 Select(Callee, N->getOperand(1));
893 Chain = SDOperand(CurDAG->getTargetNode(PPC::MTCTR, MVT::Other, Callee,
896 // Copy the callee address into R12 on darwin.
897 SDOperand R12 = CurDAG->getRegister(PPC::R12, MVT::i32);
898 Chain = CurDAG->getNode(ISD::CopyToReg, MVT::Other, Chain, R12, Callee);
900 CallOperands.push_back(R12);
901 CallOpcode = PPC::BCTRL;
904 unsigned GPR_idx = 0, FPR_idx = 0;
905 static const unsigned GPR[] = {
906 PPC::R3, PPC::R4, PPC::R5, PPC::R6,
907 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
909 static const unsigned FPR[] = {
910 PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7,
911 PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, PPC::F13
914 SDOperand InFlag; // Null incoming flag value.
916 for (unsigned i = 2, e = N->getNumOperands(); i != e; ++i) {
917 unsigned DestReg = 0;
918 MVT::ValueType RegTy = N->getOperand(i).getValueType();
919 if (RegTy == MVT::i32) {
920 assert(GPR_idx < 8 && "Too many int args");
921 DestReg = GPR[GPR_idx++];
923 assert(MVT::isFloatingPoint(N->getOperand(i).getValueType()) &&
924 "Unpromoted integer arg?");
925 assert(FPR_idx < 13 && "Too many fp args");
926 DestReg = FPR[FPR_idx++];
929 if (N->getOperand(i).getOpcode() != ISD::UNDEF) {
931 Select(Val, N->getOperand(i));
932 Chain = CurDAG->getCopyToReg(Chain, DestReg, Val, InFlag);
933 InFlag = Chain.getValue(1);
934 CallOperands.push_back(CurDAG->getRegister(DestReg, RegTy));
938 // Finally, once everything is in registers to pass to the call, emit the
941 CallOperands.push_back(InFlag); // Strong dep on register copies.
943 CallOperands.push_back(Chain); // Weak dep on whatever occurs before
944 Chain = SDOperand(CurDAG->getTargetNode(CallOpcode, MVT::Other, MVT::Flag,
947 std::vector<SDOperand> CallResults;
949 // If the call has results, copy the values out of the ret val registers.
950 switch (N->getValueType(0)) {
951 default: assert(0 && "Unexpected ret value!");
952 case MVT::Other: break;
954 if (N->getValueType(1) == MVT::i32) {
955 Chain = CurDAG->getCopyFromReg(Chain, PPC::R4, MVT::i32,
956 Chain.getValue(1)).getValue(1);
957 CallResults.push_back(Chain.getValue(0));
958 Chain = CurDAG->getCopyFromReg(Chain, PPC::R3, MVT::i32,
959 Chain.getValue(2)).getValue(1);
960 CallResults.push_back(Chain.getValue(0));
962 Chain = CurDAG->getCopyFromReg(Chain, PPC::R3, MVT::i32,
963 Chain.getValue(1)).getValue(1);
964 CallResults.push_back(Chain.getValue(0));
969 Chain = CurDAG->getCopyFromReg(Chain, PPC::F1, N->getValueType(0),
970 Chain.getValue(1)).getValue(1);
971 CallResults.push_back(Chain.getValue(0));
975 CallResults.push_back(Chain);
976 for (unsigned i = 0, e = CallResults.size(); i != e; ++i)
977 CodeGenMap[Op.getValue(i)] = CallResults[i];
978 return CallResults[Op.ResNo];
981 // Select - Convert the specified operand from a target-independent to a
982 // target-specific node if it hasn't already been changed.
983 void PPCDAGToDAGISel::Select(SDOperand &Result, SDOperand Op) {
985 if (N->getOpcode() >= ISD::BUILTIN_OP_END &&
986 N->getOpcode() < PPCISD::FIRST_NUMBER) {
988 return; // Already selected.
991 // If this has already been converted, use it.
992 std::map<SDOperand, SDOperand>::iterator CGMI = CodeGenMap.find(Op);
993 if (CGMI != CodeGenMap.end()) {
994 Result = CGMI->second;
998 switch (N->getOpcode()) {
1001 Result = SelectSETCC(Op);
1004 Result = SelectCALL(Op);
1006 case PPCISD::GlobalBaseReg:
1007 Result = getGlobalBaseReg();
1010 case ISD::FrameIndex: {
1011 int FI = cast<FrameIndexSDNode>(N)->getIndex();
1012 if (N->hasOneUse()) {
1013 Result = CurDAG->SelectNodeTo(N, PPC::ADDI, MVT::i32,
1014 CurDAG->getTargetFrameIndex(FI, MVT::i32),
1018 Result = CodeGenMap[Op] =
1019 SDOperand(CurDAG->getTargetNode(PPC::ADDI, MVT::i32,
1020 CurDAG->getTargetFrameIndex(FI, MVT::i32),
1025 case PPCISD::MFCR: {
1027 Select(InFlag, N->getOperand(1));
1028 // Use MFOCRF if supported.
1029 if (TLI.getTargetMachine().getSubtarget<PPCSubtarget>().isGigaProcessor())
1030 Result = SDOperand(CurDAG->getTargetNode(PPC::MFOCRF, MVT::i32,
1031 N->getOperand(0), InFlag), 0);
1033 Result = SDOperand(CurDAG->getTargetNode(PPC::MFCR, MVT::i32, InFlag), 0);
1034 CodeGenMap[Op] = Result;
1039 // FIXME: since this depends on the setting of the carry flag from the srawi
1040 // we should really be making notes about that for the scheduler.
1041 // FIXME: It sure would be nice if we could cheaply recognize the
1042 // srl/add/sra pattern the dag combiner will generate for this as
1043 // sra/addze rather than having to handle sdiv ourselves. oh well.
1045 if (isIntImmediate(N->getOperand(1), Imm)) {
1047 Select(N0, N->getOperand(0));
1048 if ((signed)Imm > 0 && isPowerOf2_32(Imm)) {
1050 CurDAG->getTargetNode(PPC::SRAWI, MVT::i32, MVT::Flag,
1051 N0, getI32Imm(Log2_32(Imm)));
1052 Result = CurDAG->SelectNodeTo(N, PPC::ADDZE, MVT::i32,
1053 SDOperand(Op, 0), SDOperand(Op, 1));
1054 } else if ((signed)Imm < 0 && isPowerOf2_32(-Imm)) {
1056 CurDAG->getTargetNode(PPC::SRAWI, MVT::i32, MVT::Flag,
1057 N0, getI32Imm(Log2_32(-Imm)));
1059 SDOperand(CurDAG->getTargetNode(PPC::ADDZE, MVT::i32,
1060 SDOperand(Op, 0), SDOperand(Op, 1)),
1062 Result = CurDAG->SelectNodeTo(N, PPC::NEG, MVT::i32, PT);
1067 // Other cases are autogenerated.
1072 // If this is an and of a value rotated between 0 and 31 bits and then and'd
1073 // with a mask, emit rlwinm
1074 if (isIntImmediate(N->getOperand(1), Imm) && (isShiftedMask_32(Imm) ||
1075 isShiftedMask_32(~Imm))) {
1077 unsigned SH, MB, ME;
1078 if (isRotateAndMask(N->getOperand(0).Val, Imm, false, SH, MB, ME)) {
1079 Select(Val, N->getOperand(0).getOperand(0));
1080 } else if (Imm == 0) {
1081 // AND X, 0 -> 0, not "rlwinm 32".
1082 Select(Result, N->getOperand(1));
1085 Select(Val, N->getOperand(0));
1086 isRunOfOnes(Imm, MB, ME);
1089 Result = CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32, Val,
1090 getI32Imm(SH), getI32Imm(MB),
1094 // ISD::OR doesn't get all the bitfield insertion fun.
1095 // (and (or x, c1), c2) where isRunOfOnes(~(c1^c2)) is a bitfield insert
1096 if (isIntImmediate(N->getOperand(1), Imm) &&
1097 N->getOperand(0).getOpcode() == ISD::OR &&
1098 isIntImmediate(N->getOperand(0).getOperand(1), Imm2)) {
1101 if (isRunOfOnes(Imm, MB, ME)) {
1102 SDOperand Tmp1, Tmp2;
1103 Select(Tmp1, N->getOperand(0).getOperand(0));
1104 Select(Tmp2, N->getOperand(0).getOperand(1));
1105 Result = SDOperand(CurDAG->getTargetNode(PPC::RLWIMI, MVT::i32,
1107 getI32Imm(0), getI32Imm(MB),
1113 // Other cases are autogenerated.
1117 if (SDNode *I = SelectBitfieldInsert(N)) {
1118 Result = CodeGenMap[Op] = SDOperand(I, 0);
1122 // Other cases are autogenerated.
1125 unsigned Imm, SH, MB, ME;
1126 if (isOpcWithIntImmediate(N->getOperand(0).Val, ISD::AND, Imm) &&
1127 isRotateAndMask(N, Imm, true, SH, MB, ME)) {
1129 Select(Val, N->getOperand(0).getOperand(0));
1130 Result = CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32,
1131 Val, getI32Imm(SH), getI32Imm(MB),
1136 // Other cases are autogenerated.
1140 unsigned Imm, SH, MB, ME;
1141 if (isOpcWithIntImmediate(N->getOperand(0).Val, ISD::AND, Imm) &&
1142 isRotateAndMask(N, Imm, true, SH, MB, ME)) {
1144 Select(Val, N->getOperand(0).getOperand(0));
1145 Result = CurDAG->SelectNodeTo(N, PPC::RLWINM, MVT::i32,
1146 Val, getI32Imm(SH & 0x1F), getI32Imm(MB),
1151 // Other cases are autogenerated.
1154 case ISD::SELECT_CC: {
1155 ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(4))->get();
1157 // handle the setcc cases here. select_cc lhs, 0, 1, 0, cc
1158 if (ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N->getOperand(1)))
1159 if (ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N->getOperand(2)))
1160 if (ConstantSDNode *N3C = dyn_cast<ConstantSDNode>(N->getOperand(3)))
1161 if (N1C->isNullValue() && N3C->isNullValue() &&
1162 N2C->getValue() == 1ULL && CC == ISD::SETNE) {
1164 Select(LHS, N->getOperand(0));
1166 CurDAG->getTargetNode(PPC::ADDIC, MVT::i32, MVT::Flag,
1167 LHS, getI32Imm(~0U));
1168 Result = CurDAG->SelectNodeTo(N, PPC::SUBFE, MVT::i32,
1169 SDOperand(Tmp, 0), LHS,
1174 SDOperand CCReg = SelectCC(N->getOperand(0), N->getOperand(1), CC);
1175 unsigned BROpc = getBCCForSetCC(CC);
1177 bool isFP = MVT::isFloatingPoint(N->getValueType(0));
1178 unsigned SelectCCOp;
1179 if (MVT::isInteger(N->getValueType(0)))
1180 SelectCCOp = PPC::SELECT_CC_Int;
1181 else if (N->getValueType(0) == MVT::f32)
1182 SelectCCOp = PPC::SELECT_CC_F4;
1183 else if (N->getValueType(0) == MVT::f64)
1184 SelectCCOp = PPC::SELECT_CC_F8;
1186 SelectCCOp = PPC::SELECT_CC_VRRC;
1189 Select(N2, N->getOperand(2));
1190 Select(N3, N->getOperand(3));
1191 Result = CurDAG->SelectNodeTo(N, SelectCCOp, N->getValueType(0), CCReg,
1192 N2, N3, getI32Imm(BROpc));
1197 Select(Chain, N->getOperand(0));
1198 ISD::CondCode CC = cast<CondCodeSDNode>(N->getOperand(1))->get();
1199 SDOperand CondCode = SelectCC(N->getOperand(2), N->getOperand(3), CC);
1200 Result = CurDAG->SelectNodeTo(N, PPC::COND_BRANCH, MVT::Other,
1201 CondCode, getI32Imm(getBCCForSetCC(CC)),
1202 N->getOperand(4), Chain);
1206 SDOperand Chain, Target;
1207 Select(Chain, N->getOperand(0));
1208 Select(Target,N->getOperand(1));
1209 Chain = SDOperand(CurDAG->getTargetNode(PPC::MTCTR, MVT::Other, Target,
1211 Result = CurDAG->SelectNodeTo(N, PPC::BCTR, MVT::Other, Chain);
1216 SelectCode(Result, Op);
1220 /// createPPCISelDag - This pass converts a legalized DAG into a
1221 /// PowerPC-specific DAG, ready for instruction scheduling.
1223 FunctionPass *llvm::createPPCISelDag(PPCTargetMachine &TM) {
1224 return new PPCDAGToDAGISel(TM);