1 //===-- PPCISelLowering.h - PPC32 DAG Lowering Interface --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interfaces that PPC uses to lower LLVM code into a
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H
16 #define LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H
19 #include "PPCInstrInfo.h"
20 #include "PPCRegisterInfo.h"
21 #include "llvm/CodeGen/CallingConvLower.h"
22 #include "llvm/CodeGen/SelectionDAG.h"
23 #include "llvm/Target/TargetLowering.h"
28 // Start the numbering where the builtin ops and target ops leave off.
29 FIRST_NUMBER = ISD::BUILTIN_OP_END,
31 /// FSEL - Traditional three-operand fsel node.
35 /// FCFID - The FCFID instruction, taking an f64 operand and producing
36 /// and f64 value containing the FP representation of the integer that
37 /// was temporarily in the f64 operand.
40 /// Newer FCFID[US] integer-to-floating-point conversion instructions for
41 /// unsigned integers and single-precision outputs.
42 FCFIDU, FCFIDS, FCFIDUS,
44 /// FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64
45 /// operand, producing an f64 value containing the integer representation
49 /// Newer FCTI[D,W]UZ floating-point-to-integer conversion instructions for
50 /// unsigned integers.
53 /// Reciprocal estimate instructions (unary FP ops).
56 // VMADDFP, VNMSUBFP - The VMADDFP and VNMSUBFP instructions, taking
57 // three v4f32 operands and producing a v4f32 result.
60 /// VPERM - The PPC VPERM Instruction.
64 /// The CMPB instruction (takes two operands of i32 or i64).
67 /// Hi/Lo - These represent the high and low 16-bit parts of a global
68 /// address respectively. These nodes have two operands, the first of
69 /// which must be a TargetGlobalAddress, and the second of which must be a
70 /// Constant. Selected naively, these turn into 'lis G+C' and 'li G+C',
71 /// though these are usually folded into other nodes.
76 /// The following two target-specific nodes are used for calls through
77 /// function pointers in the 64-bit SVR4 ABI.
79 /// OPRC, CHAIN = DYNALLOC(CHAIN, NEGSIZE, FRAME_INDEX)
80 /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to
81 /// compute an allocation on the stack.
84 /// GlobalBaseReg - On Darwin, this node represents the result of the mflr
85 /// at function entry, used for PIC code.
88 /// These nodes represent the 32-bit PPC shifts that operate on 6-bit
89 /// shift amounts. These nodes are generated by the multi-precision shift
93 /// The combination of sra[wd]i and addze used to implemented signed
94 /// integer division by a power of 2. The first operand is the dividend,
95 /// and the second is the constant shift amount (representing the
99 /// CALL - A direct function call.
100 /// CALL_NOP is a call with the special NOP which follows 64-bit
104 /// CALL_TLS and CALL_NOP_TLS - Versions of CALL and CALL_NOP used
105 /// to access TLS variables.
106 CALL_TLS, CALL_NOP_TLS,
108 /// CHAIN,FLAG = MTCTR(VAL, CHAIN[, INFLAG]) - Directly corresponds to a
109 /// MTCTR instruction.
112 /// CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a
113 /// BCTRL instruction.
116 /// CHAIN,FLAG = BCTRL(CHAIN, ADDR, INFLAG) - The combination of a bctrl
117 /// instruction and the TOC reload required on SVR4 PPC64.
120 /// Return with a flag operand, matched by 'blr'
123 /// R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction.
124 /// This copies the bits corresponding to the specified CRREG into the
125 /// resultant GPR. Bits corresponding to other CR regs are undefined.
128 // FIXME: Remove these once the ANDI glue bug is fixed:
129 /// i1 = ANDIo_1_[EQ|GT]_BIT(i32 or i64 x) - Represents the result of the
130 /// eq or gt bit of CR0 after executing andi. x, 1. This is used to
131 /// implement truncation of i32 or i64 to i1.
132 ANDIo_1_EQ_BIT, ANDIo_1_GT_BIT,
134 // READ_TIME_BASE - A read of the 64-bit time-base register on a 32-bit
135 // target (returns (Lo, Hi)). It takes a chain operand.
138 // EH_SJLJ_SETJMP - SjLj exception handling setjmp.
141 // EH_SJLJ_LONGJMP - SjLj exception handling longjmp.
144 /// RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP*
145 /// instructions. For lack of better number, we use the opcode number
146 /// encoding for the OPC field to identify the compare. For example, 838
150 /// RESVEC, OUTFLAG = VCMPo(LHS, RHS, OPC) - Represents one of the
151 /// altivec VCMP*o instructions. For lack of better number, we use the
152 /// opcode number encoding for the OPC field to identify the compare. For
153 /// example, 838 is VCMPGTSH.
156 /// CHAIN = COND_BRANCH CHAIN, CRRC, OPC, DESTBB [, INFLAG] - This
157 /// corresponds to the COND_BRANCH pseudo instruction. CRRC is the
158 /// condition register to branch on, OPC is the branch opcode to use (e.g.
159 /// PPC::BLE), DESTBB is the destination block to branch to, and INFLAG is
160 /// an optional input flag argument.
163 /// CHAIN = BDNZ CHAIN, DESTBB - These are used to create counter-based
167 /// F8RC = FADDRTZ F8RC, F8RC - This is an FADD done with rounding
168 /// towards zero. Used only as part of the long double-to-int
169 /// conversion sequence.
172 /// F8RC = MFFS - This moves the FPSCR (not modeled) into the register.
175 /// LARX = This corresponds to PPC l{w|d}arx instrcution: load and
176 /// reserve indexed. This is used to implement atomic operations.
179 /// STCX = This corresponds to PPC stcx. instrcution: store conditional
180 /// indexed. This is used to implement atomic operations.
183 /// TC_RETURN - A tail call return.
185 /// operand #1 callee (register or absolute)
186 /// operand #2 stack adjustment
187 /// operand #3 optional in flag
190 /// ch, gl = CR6[UN]SET ch, inglue - Toggle CR bit 6 for SVR4 vararg calls
194 /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by initial-exec TLS
198 /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by general dynamic and
199 /// local dynamic TLS on PPC32.
202 /// G8RC = ADDIS_GOT_TPREL_HA %X2, Symbol - Used by the initial-exec
203 /// TLS model, produces an ADDIS8 instruction that adds the GOT
204 /// base to sym\@got\@tprel\@ha.
207 /// G8RC = LD_GOT_TPREL_L Symbol, G8RReg - Used by the initial-exec
208 /// TLS model, produces a LD instruction with base register G8RReg
209 /// and offset sym\@got\@tprel\@l. This completes the addition that
210 /// finds the offset of "sym" relative to the thread pointer.
213 /// G8RC = ADD_TLS G8RReg, Symbol - Used by the initial-exec TLS
214 /// model, produces an ADD instruction that adds the contents of
215 /// G8RReg to the thread pointer. Symbol contains a relocation
216 /// sym\@tls which is to be replaced by the thread pointer and
217 /// identifies to the linker that the instruction is part of a
221 /// G8RC = ADDIS_TLSGD_HA %X2, Symbol - For the general-dynamic TLS
222 /// model, produces an ADDIS8 instruction that adds the GOT base
223 /// register to sym\@got\@tlsgd\@ha.
226 /// G8RC = ADDI_TLSGD_L G8RReg, Symbol - For the general-dynamic TLS
227 /// model, produces an ADDI8 instruction that adds G8RReg to
228 /// sym\@got\@tlsgd\@l.
231 /// G8RC = ADDIS_TLSLD_HA %X2, Symbol - For the local-dynamic TLS
232 /// model, produces an ADDIS8 instruction that adds the GOT base
233 /// register to sym\@got\@tlsld\@ha.
236 /// G8RC = ADDI_TLSLD_L G8RReg, Symbol - For the local-dynamic TLS
237 /// model, produces an ADDI8 instruction that adds G8RReg to
238 /// sym\@got\@tlsld\@l.
241 /// G8RC = ADDIS_DTPREL_HA %X3, Symbol, Chain - For the
242 /// local-dynamic TLS model, produces an ADDIS8 instruction
243 /// that adds X3 to sym\@dtprel\@ha. The Chain operand is needed
244 /// to tie this in place following a copy to %X3 from the result
245 /// of a GET_TLSLD_ADDR.
248 /// G8RC = ADDI_DTPREL_L G8RReg, Symbol - For the local-dynamic TLS
249 /// model, produces an ADDI8 instruction that adds G8RReg to
250 /// sym\@got\@dtprel\@l.
253 /// VRRC = VADD_SPLAT Elt, EltSize - Temporary node to be expanded
254 /// during instruction selection to optimize a BUILD_VECTOR into
255 /// operations on splats. This is necessary to avoid losing these
256 /// optimizations due to constant folding.
259 /// CHAIN = SC CHAIN, Imm128 - System call. The 7-bit unsigned
260 /// operand identifies the operating system entry point.
263 /// VSRC, CHAIN = XXSWAPD CHAIN, VSRC - Occurs only for little
264 /// endian. Maps to an xxswapd instruction that corrects an lxvd2x
265 /// or stxvd2x instruction. The chain is necessary because the
266 /// sequence replaces a load and needs to provide the same number
270 /// CHAIN = STBRX CHAIN, GPRC, Ptr, Type - This is a
271 /// byte-swapping store instruction. It byte-swaps the low "Type" bits of
272 /// the GPRC input, then stores it through Ptr. Type can be either i16 or
274 STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE,
276 /// GPRC, CHAIN = LBRX CHAIN, Ptr, Type - This is a
277 /// byte-swapping load instruction. It loads "Type" bits, byte swaps it,
278 /// then puts it in the bottom bits of the GPRC. TYPE can be either i16
282 /// STFIWX - The STFIWX instruction. The first operand is an input token
283 /// chain, then an f64 value to store, then an address to store it to.
286 /// GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point
287 /// load which sign-extends from a 32-bit integer value into the
288 /// destination 64-bit register.
291 /// GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point
292 /// load which zero-extends from a 32-bit integer value into the
293 /// destination 64-bit register.
296 /// G8RC = ADDIS_TOC_HA %X2, Symbol - For medium and large code model,
297 /// produces an ADDIS8 instruction that adds the TOC base register to
301 /// G8RC = LD_TOC_L Symbol, G8RReg - For medium and large code model,
302 /// produces a LD instruction with base register G8RReg and offset
303 /// sym\@toc\@l. Preceded by an ADDIS_TOC_HA to form a full 32-bit offset.
306 /// G8RC = ADDI_TOC_L G8RReg, Symbol - For medium code model, produces
307 /// an ADDI8 instruction that adds G8RReg to sym\@toc\@l.
308 /// Preceded by an ADDIS_TOC_HA to form a full 32-bit offset.
311 /// VSRC, CHAIN = LXVD2X_LE CHAIN, Ptr - Occurs only for little endian.
312 /// Maps directly to an lxvd2x instruction that will be followed by
316 /// CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian.
317 /// Maps directly to an stxvd2x instruction that will be preceded by
323 /// Define some predicates that are used for node matching.
325 /// isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a
326 /// VPKUHUM instruction.
327 bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
330 /// isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a
331 /// VPKUWUM instruction.
332 bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind,
335 /// isVMRGLShuffleMask - Return true if this is a shuffle mask suitable for
336 /// a VRGL* instruction with the specified unit size (1,2 or 4 bytes).
337 bool isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
338 unsigned ShuffleKind, SelectionDAG &DAG);
340 /// isVMRGHShuffleMask - Return true if this is a shuffle mask suitable for
341 /// a VRGH* instruction with the specified unit size (1,2 or 4 bytes).
342 bool isVMRGHShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize,
343 unsigned ShuffleKind, SelectionDAG &DAG);
345 /// isVSLDOIShuffleMask - If this is a vsldoi shuffle mask, return the
346 /// shift amount, otherwise return -1.
347 int isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind,
350 /// isSplatShuffleMask - Return true if the specified VECTOR_SHUFFLE operand
351 /// specifies a splat of a single element that is suitable for input to
352 /// VSPLTB/VSPLTH/VSPLTW.
353 bool isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize);
355 /// isAllNegativeZeroVector - Returns true if all elements of build_vector
357 bool isAllNegativeZeroVector(SDNode *N);
359 /// getVSPLTImmediate - Return the appropriate VSPLT* immediate to splat the
360 /// specified isSplatShuffleMask VECTOR_SHUFFLE mask.
361 unsigned getVSPLTImmediate(SDNode *N, unsigned EltSize, SelectionDAG &DAG);
363 /// get_VSPLTI_elt - If this is a build_vector of constants which can be
364 /// formed by using a vspltis[bhw] instruction of the specified element
365 /// size, return the constant being splatted. The ByteSize field indicates
366 /// the number of bytes of each element [124] -> [bhw].
367 SDValue get_VSPLTI_elt(SDNode *N, unsigned ByteSize, SelectionDAG &DAG);
370 class PPCTargetLowering : public TargetLowering {
371 const PPCSubtarget &Subtarget;
374 explicit PPCTargetLowering(const PPCTargetMachine &TM,
375 const PPCSubtarget &STI);
377 /// getTargetNodeName() - This method returns the name of a target specific
379 const char *getTargetNodeName(unsigned Opcode) const override;
381 MVT getScalarShiftAmountTy(EVT LHSTy) const override { return MVT::i32; }
383 bool isCheapToSpeculateCttz() const override {
387 bool isCheapToSpeculateCtlz() const override {
391 /// getSetCCResultType - Return the ISD::SETCC ValueType
392 EVT getSetCCResultType(LLVMContext &Context, EVT VT) const override;
394 /// Return true if target always beneficiates from combining into FMA for a
395 /// given value type. This must typically return false on targets where FMA
396 /// takes more cycles to execute than FADD.
397 bool enableAggressiveFMAFusion(EVT VT) const override;
399 /// getPreIndexedAddressParts - returns true by value, base pointer and
400 /// offset pointer and addressing mode by reference if the node's address
401 /// can be legally represented as pre-indexed load / store address.
402 bool getPreIndexedAddressParts(SDNode *N, SDValue &Base,
404 ISD::MemIndexedMode &AM,
405 SelectionDAG &DAG) const override;
407 /// SelectAddressRegReg - Given the specified addressed, check to see if it
408 /// can be represented as an indexed [r+r] operation. Returns false if it
409 /// can be more efficiently represented with [r+imm].
410 bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index,
411 SelectionDAG &DAG) const;
413 /// SelectAddressRegImm - Returns true if the address N can be represented
414 /// by a base register plus a signed 16-bit displacement [r+imm], and if it
415 /// is not better represented as reg+reg. If Aligned is true, only accept
416 /// displacements suitable for STD and friends, i.e. multiples of 4.
417 bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base,
418 SelectionDAG &DAG, bool Aligned) const;
420 /// SelectAddressRegRegOnly - Given the specified addressed, force it to be
421 /// represented as an indexed [r+r] operation.
422 bool SelectAddressRegRegOnly(SDValue N, SDValue &Base, SDValue &Index,
423 SelectionDAG &DAG) const;
425 Sched::Preference getSchedulingPreference(SDNode *N) const override;
427 /// LowerOperation - Provide custom lowering hooks for some operations.
429 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
431 /// ReplaceNodeResults - Replace the results of node with an illegal result
432 /// type with new values built out of custom code.
434 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
435 SelectionDAG &DAG) const override;
437 SDValue expandVSXLoadForLE(SDNode *N, DAGCombinerInfo &DCI) const;
438 SDValue expandVSXStoreForLE(SDNode *N, DAGCombinerInfo &DCI) const;
440 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
442 SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
443 std::vector<SDNode *> *Created) const override;
445 unsigned getRegisterByName(const char* RegName, EVT VT) const override;
447 void computeKnownBitsForTargetNode(const SDValue Op,
450 const SelectionDAG &DAG,
451 unsigned Depth = 0) const override;
453 unsigned getPrefLoopAlignment(MachineLoop *ML) const override;
455 Instruction* emitLeadingFence(IRBuilder<> &Builder, AtomicOrdering Ord,
456 bool IsStore, bool IsLoad) const override;
457 Instruction* emitTrailingFence(IRBuilder<> &Builder, AtomicOrdering Ord,
458 bool IsStore, bool IsLoad) const override;
461 EmitInstrWithCustomInserter(MachineInstr *MI,
462 MachineBasicBlock *MBB) const override;
463 MachineBasicBlock *EmitAtomicBinary(MachineInstr *MI,
464 MachineBasicBlock *MBB, bool is64Bit,
465 unsigned BinOpcode) const;
466 MachineBasicBlock *EmitPartwordAtomicBinary(MachineInstr *MI,
467 MachineBasicBlock *MBB,
468 bool is8bit, unsigned Opcode) const;
470 MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr *MI,
471 MachineBasicBlock *MBB) const;
473 MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr *MI,
474 MachineBasicBlock *MBB) const;
477 getConstraintType(const std::string &Constraint) const override;
479 /// Examine constraint string and operand type and determine a weight value.
480 /// The operand object must already have been set up with the operand type.
481 ConstraintWeight getSingleConstraintMatchWeight(
482 AsmOperandInfo &info, const char *constraint) const override;
484 std::pair<unsigned, const TargetRegisterClass*>
485 getRegForInlineAsmConstraint(const std::string &Constraint,
486 MVT VT) const override;
488 /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
489 /// function arguments in the caller parameter area. This is the actual
490 /// alignment, not its logarithm.
491 unsigned getByValTypeAlignment(Type *Ty) const override;
493 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
494 /// vector. If it is invalid, don't add anything to Ops.
495 void LowerAsmOperandForConstraint(SDValue Op,
496 std::string &Constraint,
497 std::vector<SDValue> &Ops,
498 SelectionDAG &DAG) const override;
500 /// isLegalAddressingMode - Return true if the addressing mode represented
501 /// by AM is legal for this target, for a load/store of the specified type.
502 bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const override;
504 /// isLegalICmpImmediate - Return true if the specified immediate is legal
505 /// icmp immediate, that is the target has icmp instructions which can
506 /// compare a register against the immediate without having to materialize
507 /// the immediate into a register.
508 bool isLegalICmpImmediate(int64_t Imm) const override;
510 /// isLegalAddImmediate - Return true if the specified immediate is legal
511 /// add immediate, that is the target has add instructions which can
512 /// add a register and the immediate without having to materialize
513 /// the immediate into a register.
514 bool isLegalAddImmediate(int64_t Imm) const override;
516 /// isTruncateFree - Return true if it's free to truncate a value of
517 /// type Ty1 to type Ty2. e.g. On PPC it's free to truncate a i64 value in
518 /// register X1 to i32 by referencing its sub-register R1.
519 bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
520 bool isTruncateFree(EVT VT1, EVT VT2) const override;
522 bool isZExtFree(SDValue Val, EVT VT2) const override;
524 bool isFPExtFree(EVT VT) const override;
526 /// \brief Returns true if it is beneficial to convert a load of a constant
527 /// to just the constant itself.
528 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
529 Type *Ty) const override;
531 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
533 bool getTgtMemIntrinsic(IntrinsicInfo &Info,
535 unsigned Intrinsic) const override;
537 /// getOptimalMemOpType - Returns the target specific optimal type for load
538 /// and store operations as a result of memset, memcpy, and memmove
539 /// lowering. If DstAlign is zero that means it's safe to destination
540 /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it
541 /// means there isn't a need to check it against alignment requirement,
542 /// probably because the source does not need to be loaded. If 'IsMemset' is
543 /// true, that means it's expanding a memset. If 'ZeroMemset' is true, that
544 /// means it's a memset of zero. 'MemcpyStrSrc' indicates whether the memcpy
545 /// source is constant so it does not need to be loaded.
546 /// It returns EVT::Other if the type should be determined using generic
547 /// target-independent logic.
549 getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign,
550 bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
551 MachineFunction &MF) const override;
553 /// Is unaligned memory access allowed for the given type, and is it fast
554 /// relative to software emulation.
555 bool allowsMisalignedMemoryAccesses(EVT VT,
558 bool *Fast = nullptr) const override;
560 /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster
561 /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be
562 /// expanded to FMAs when this method returns true, otherwise fmuladd is
563 /// expanded to fmul + fadd.
564 bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
566 const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;
568 // Should we expand the build vector with shuffles?
570 shouldExpandBuildVectorWithShuffles(EVT VT,
571 unsigned DefinedValues) const override;
573 /// createFastISel - This method returns a target-specific FastISel object,
574 /// or null if the target does not support "fast" instruction selection.
575 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
576 const TargetLibraryInfo *LibInfo) const override;
578 /// \brief Returns true if an argument of type Ty needs to be passed in a
579 /// contiguous block of registers in calling convention CallConv.
580 bool functionArgumentNeedsConsecutiveRegisters(
581 Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override {
582 // We support any array type as "consecutive" block in the parameter
583 // save area. The element type defines the alignment requirement and
584 // whether the argument should go in GPRs, FPRs, or VRs if available.
586 // Note that clang uses this capability both to implement the ELFv2
587 // homogeneous float/vector aggregate ABI, and to avoid having to use
588 // "byval" when passing aggregates that might fully fit in registers.
589 return Ty->isArrayTy();
594 struct ReuseLoadInfo {
598 MachinePointerInfo MPI;
602 const MDNode *Ranges;
604 ReuseLoadInfo() : IsInvariant(false), Alignment(0), Ranges(nullptr) {}
607 bool canReuseLoadAddress(SDValue Op, EVT MemVT, ReuseLoadInfo &RLI,
609 ISD::LoadExtType ET = ISD::NON_EXTLOAD) const;
610 void spliceIntoChain(SDValue ResChain, SDValue NewResChain,
611 SelectionDAG &DAG) const;
613 void LowerFP_TO_INTForReuse(SDValue Op, ReuseLoadInfo &RLI,
614 SelectionDAG &DAG, SDLoc dl) const;
616 SDValue getFramePointerFrameIndex(SelectionDAG & DAG) const;
617 SDValue getReturnAddrFrameIndex(SelectionDAG & DAG) const;
620 IsEligibleForTailCallOptimization(SDValue Callee,
621 CallingConv::ID CalleeCC,
623 const SmallVectorImpl<ISD::InputArg> &Ins,
624 SelectionDAG& DAG) const;
626 SDValue EmitTailCallLoadFPAndRetAddr(SelectionDAG & DAG,
634 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
635 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
636 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
637 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
638 std::pair<SDValue,SDValue> lowerTLSCall(SDValue Op, SDLoc dl,
639 SelectionDAG &DAG) const;
640 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
641 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
642 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
643 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
644 SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
645 SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
646 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG,
647 const PPCSubtarget &Subtarget) const;
648 SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG,
649 const PPCSubtarget &Subtarget) const;
650 SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG,
651 const PPCSubtarget &Subtarget) const;
652 SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG,
653 const PPCSubtarget &Subtarget) const;
654 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG,
655 const PPCSubtarget &Subtarget) const;
656 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
657 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
658 SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const;
659 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
660 SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG, SDLoc dl) const;
661 SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
662 SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
663 SDValue LowerSHL_PARTS(SDValue Op, SelectionDAG &DAG) const;
664 SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const;
665 SDValue LowerSRA_PARTS(SDValue Op, SelectionDAG &DAG) const;
666 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
667 SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
668 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
669 SDValue LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const;
670 SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;
671 SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const;
673 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
674 CallingConv::ID CallConv, bool isVarArg,
675 const SmallVectorImpl<ISD::InputArg> &Ins,
676 SDLoc dl, SelectionDAG &DAG,
677 SmallVectorImpl<SDValue> &InVals) const;
678 SDValue FinishCall(CallingConv::ID CallConv, SDLoc dl, bool isTailCall,
679 bool isVarArg, bool IsPatchPoint,
681 SmallVector<std::pair<unsigned, SDValue>, 8>
683 SDValue InFlag, SDValue Chain, SDValue CallSeqStart,
685 int SPDiff, unsigned NumBytes,
686 const SmallVectorImpl<ISD::InputArg> &Ins,
687 SmallVectorImpl<SDValue> &InVals,
688 ImmutableCallSite *CS) const;
691 LowerFormalArguments(SDValue Chain,
692 CallingConv::ID CallConv, bool isVarArg,
693 const SmallVectorImpl<ISD::InputArg> &Ins,
694 SDLoc dl, SelectionDAG &DAG,
695 SmallVectorImpl<SDValue> &InVals) const override;
698 LowerCall(TargetLowering::CallLoweringInfo &CLI,
699 SmallVectorImpl<SDValue> &InVals) const override;
702 CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
704 const SmallVectorImpl<ISD::OutputArg> &Outs,
705 LLVMContext &Context) const override;
708 LowerReturn(SDValue Chain,
709 CallingConv::ID CallConv, bool isVarArg,
710 const SmallVectorImpl<ISD::OutputArg> &Outs,
711 const SmallVectorImpl<SDValue> &OutVals,
712 SDLoc dl, SelectionDAG &DAG) const override;
715 extendArgForPPC64(ISD::ArgFlagsTy Flags, EVT ObjectVT, SelectionDAG &DAG,
716 SDValue ArgVal, SDLoc dl) const;
719 LowerFormalArguments_Darwin(SDValue Chain,
720 CallingConv::ID CallConv, bool isVarArg,
721 const SmallVectorImpl<ISD::InputArg> &Ins,
722 SDLoc dl, SelectionDAG &DAG,
723 SmallVectorImpl<SDValue> &InVals) const;
725 LowerFormalArguments_64SVR4(SDValue Chain,
726 CallingConv::ID CallConv, bool isVarArg,
727 const SmallVectorImpl<ISD::InputArg> &Ins,
728 SDLoc dl, SelectionDAG &DAG,
729 SmallVectorImpl<SDValue> &InVals) const;
731 LowerFormalArguments_32SVR4(SDValue Chain,
732 CallingConv::ID CallConv, bool isVarArg,
733 const SmallVectorImpl<ISD::InputArg> &Ins,
734 SDLoc dl, SelectionDAG &DAG,
735 SmallVectorImpl<SDValue> &InVals) const;
738 createMemcpyOutsideCallSeq(SDValue Arg, SDValue PtrOff,
739 SDValue CallSeqStart, ISD::ArgFlagsTy Flags,
740 SelectionDAG &DAG, SDLoc dl) const;
743 LowerCall_Darwin(SDValue Chain, SDValue Callee,
744 CallingConv::ID CallConv,
745 bool isVarArg, bool isTailCall, bool IsPatchPoint,
746 const SmallVectorImpl<ISD::OutputArg> &Outs,
747 const SmallVectorImpl<SDValue> &OutVals,
748 const SmallVectorImpl<ISD::InputArg> &Ins,
749 SDLoc dl, SelectionDAG &DAG,
750 SmallVectorImpl<SDValue> &InVals,
751 ImmutableCallSite *CS) const;
753 LowerCall_64SVR4(SDValue Chain, SDValue Callee,
754 CallingConv::ID CallConv,
755 bool isVarArg, bool isTailCall, bool IsPatchPoint,
756 const SmallVectorImpl<ISD::OutputArg> &Outs,
757 const SmallVectorImpl<SDValue> &OutVals,
758 const SmallVectorImpl<ISD::InputArg> &Ins,
759 SDLoc dl, SelectionDAG &DAG,
760 SmallVectorImpl<SDValue> &InVals,
761 ImmutableCallSite *CS) const;
763 LowerCall_32SVR4(SDValue Chain, SDValue Callee, CallingConv::ID CallConv,
764 bool isVarArg, bool isTailCall, bool IsPatchPoint,
765 const SmallVectorImpl<ISD::OutputArg> &Outs,
766 const SmallVectorImpl<SDValue> &OutVals,
767 const SmallVectorImpl<ISD::InputArg> &Ins,
768 SDLoc dl, SelectionDAG &DAG,
769 SmallVectorImpl<SDValue> &InVals,
770 ImmutableCallSite *CS) const;
772 SDValue lowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
773 SDValue lowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
775 SDValue DAGCombineExtBoolTrunc(SDNode *N, DAGCombinerInfo &DCI) const;
776 SDValue DAGCombineTruncBoolExt(SDNode *N, DAGCombinerInfo &DCI) const;
777 SDValue combineFPToIntToFP(SDNode *N, DAGCombinerInfo &DCI) const;
779 SDValue getRsqrtEstimate(SDValue Operand, DAGCombinerInfo &DCI,
780 unsigned &RefinementSteps,
781 bool &UseOneConstNR) const override;
782 SDValue getRecipEstimate(SDValue Operand, DAGCombinerInfo &DCI,
783 unsigned &RefinementSteps) const override;
784 bool combineRepeatedFPDivisors(unsigned NumUsers) const override;
786 CCAssignFn *useFastISelCCs(unsigned Flag) const;
790 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
791 const TargetLibraryInfo *LibInfo);
794 bool CC_PPC32_SVR4_Custom_Dummy(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
795 CCValAssign::LocInfo &LocInfo,
796 ISD::ArgFlagsTy &ArgFlags,
799 bool CC_PPC32_SVR4_Custom_AlignArgRegs(unsigned &ValNo, MVT &ValVT,
801 CCValAssign::LocInfo &LocInfo,
802 ISD::ArgFlagsTy &ArgFlags,
805 bool CC_PPC32_SVR4_Custom_AlignFPArgRegs(unsigned &ValNo, MVT &ValVT,
807 CCValAssign::LocInfo &LocInfo,
808 ISD::ArgFlagsTy &ArgFlags,
812 #endif // LLVM_TARGET_POWERPC_PPC32ISELLOWERING_H