1*06f32e7eSjoerg //===-- PPCISelLowering.h - PPC32 DAG Lowering Interface --------*- C++ -*-===// 2*06f32e7eSjoerg // 3*06f32e7eSjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*06f32e7eSjoerg // See https://llvm.org/LICENSE.txt for license information. 5*06f32e7eSjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*06f32e7eSjoerg // 7*06f32e7eSjoerg //===----------------------------------------------------------------------===// 8*06f32e7eSjoerg // 9*06f32e7eSjoerg // This file defines the interfaces that PPC uses to lower LLVM code into a 10*06f32e7eSjoerg // selection DAG. 11*06f32e7eSjoerg // 12*06f32e7eSjoerg //===----------------------------------------------------------------------===// 13*06f32e7eSjoerg 14*06f32e7eSjoerg #ifndef LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H 15*06f32e7eSjoerg #define LLVM_LIB_TARGET_POWERPC_PPCISELLOWERING_H 16*06f32e7eSjoerg 17*06f32e7eSjoerg #include "PPCInstrInfo.h" 18*06f32e7eSjoerg #include "llvm/CodeGen/CallingConvLower.h" 19*06f32e7eSjoerg #include "llvm/CodeGen/MachineFunction.h" 20*06f32e7eSjoerg #include "llvm/CodeGen/MachineMemOperand.h" 21*06f32e7eSjoerg #include "llvm/CodeGen/SelectionDAG.h" 22*06f32e7eSjoerg #include "llvm/CodeGen/SelectionDAGNodes.h" 23*06f32e7eSjoerg #include "llvm/CodeGen/TargetLowering.h" 24*06f32e7eSjoerg #include "llvm/CodeGen/ValueTypes.h" 25*06f32e7eSjoerg #include "llvm/IR/Attributes.h" 26*06f32e7eSjoerg #include "llvm/IR/CallingConv.h" 27*06f32e7eSjoerg #include "llvm/IR/Function.h" 28*06f32e7eSjoerg #include "llvm/IR/InlineAsm.h" 29*06f32e7eSjoerg #include "llvm/IR/Metadata.h" 30*06f32e7eSjoerg #include "llvm/IR/Type.h" 31*06f32e7eSjoerg #include "llvm/Support/MachineValueType.h" 32*06f32e7eSjoerg #include <utility> 33*06f32e7eSjoerg 34*06f32e7eSjoerg namespace llvm { 35*06f32e7eSjoerg 36*06f32e7eSjoerg namespace PPCISD { 37*06f32e7eSjoerg 38*06f32e7eSjoerg // When adding a NEW PPCISD node please add it to the correct position in 39*06f32e7eSjoerg // the enum. The order of elements in this enum matters! 40*06f32e7eSjoerg // Values that are added after this entry: 41*06f32e7eSjoerg // STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE 42*06f32e7eSjoerg // are considered memory opcodes and are treated differently than entries 43*06f32e7eSjoerg // that come before it. For example, ADD or MUL should be placed before 44*06f32e7eSjoerg // the ISD::FIRST_TARGET_MEMORY_OPCODE while a LOAD or STORE should come 45*06f32e7eSjoerg // after it. 46*06f32e7eSjoerg enum NodeType : unsigned { 47*06f32e7eSjoerg // Start the numbering where the builtin ops and target ops leave off. 48*06f32e7eSjoerg FIRST_NUMBER = ISD::BUILTIN_OP_END, 49*06f32e7eSjoerg 50*06f32e7eSjoerg /// FSEL - Traditional three-operand fsel node. 51*06f32e7eSjoerg /// 52*06f32e7eSjoerg FSEL, 53*06f32e7eSjoerg 54*06f32e7eSjoerg /// FCFID - The FCFID instruction, taking an f64 operand and producing 55*06f32e7eSjoerg /// and f64 value containing the FP representation of the integer that 56*06f32e7eSjoerg /// was temporarily in the f64 operand. 57*06f32e7eSjoerg FCFID, 58*06f32e7eSjoerg 59*06f32e7eSjoerg /// Newer FCFID[US] integer-to-floating-point conversion instructions for 60*06f32e7eSjoerg /// unsigned integers and single-precision outputs. 61*06f32e7eSjoerg FCFIDU, FCFIDS, FCFIDUS, 62*06f32e7eSjoerg 63*06f32e7eSjoerg /// FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64 64*06f32e7eSjoerg /// operand, producing an f64 value containing the integer representation 65*06f32e7eSjoerg /// of that FP value. 66*06f32e7eSjoerg FCTIDZ, FCTIWZ, 67*06f32e7eSjoerg 68*06f32e7eSjoerg /// Newer FCTI[D,W]UZ floating-point-to-integer conversion instructions for 69*06f32e7eSjoerg /// unsigned integers with round toward zero. 70*06f32e7eSjoerg FCTIDUZ, FCTIWUZ, 71*06f32e7eSjoerg 72*06f32e7eSjoerg /// Floating-point-to-interger conversion instructions 73*06f32e7eSjoerg FP_TO_UINT_IN_VSR, FP_TO_SINT_IN_VSR, 74*06f32e7eSjoerg 75*06f32e7eSjoerg /// VEXTS, ByteWidth - takes an input in VSFRC and produces an output in 76*06f32e7eSjoerg /// VSFRC that is sign-extended from ByteWidth to a 64-byte integer. 77*06f32e7eSjoerg VEXTS, 78*06f32e7eSjoerg 79*06f32e7eSjoerg /// SExtVElems, takes an input vector of a smaller type and sign 80*06f32e7eSjoerg /// extends to an output vector of a larger type. 81*06f32e7eSjoerg SExtVElems, 82*06f32e7eSjoerg 83*06f32e7eSjoerg /// Reciprocal estimate instructions (unary FP ops). 84*06f32e7eSjoerg FRE, FRSQRTE, 85*06f32e7eSjoerg 86*06f32e7eSjoerg // VMADDFP, VNMSUBFP - The VMADDFP and VNMSUBFP instructions, taking 87*06f32e7eSjoerg // three v4f32 operands and producing a v4f32 result. 88*06f32e7eSjoerg VMADDFP, VNMSUBFP, 89*06f32e7eSjoerg 90*06f32e7eSjoerg /// VPERM - The PPC VPERM Instruction. 91*06f32e7eSjoerg /// 92*06f32e7eSjoerg VPERM, 93*06f32e7eSjoerg 94*06f32e7eSjoerg /// XXSPLT - The PPC VSX splat instructions 95*06f32e7eSjoerg /// 96*06f32e7eSjoerg XXSPLT, 97*06f32e7eSjoerg 98*06f32e7eSjoerg /// VECINSERT - The PPC vector insert instruction 99*06f32e7eSjoerg /// 100*06f32e7eSjoerg VECINSERT, 101*06f32e7eSjoerg 102*06f32e7eSjoerg /// XXREVERSE - The PPC VSX reverse instruction 103*06f32e7eSjoerg /// 104*06f32e7eSjoerg XXREVERSE, 105*06f32e7eSjoerg 106*06f32e7eSjoerg /// VECSHL - The PPC vector shift left instruction 107*06f32e7eSjoerg /// 108*06f32e7eSjoerg VECSHL, 109*06f32e7eSjoerg 110*06f32e7eSjoerg /// XXPERMDI - The PPC XXPERMDI instruction 111*06f32e7eSjoerg /// 112*06f32e7eSjoerg XXPERMDI, 113*06f32e7eSjoerg 114*06f32e7eSjoerg /// The CMPB instruction (takes two operands of i32 or i64). 115*06f32e7eSjoerg CMPB, 116*06f32e7eSjoerg 117*06f32e7eSjoerg /// Hi/Lo - These represent the high and low 16-bit parts of a global 118*06f32e7eSjoerg /// address respectively. These nodes have two operands, the first of 119*06f32e7eSjoerg /// which must be a TargetGlobalAddress, and the second of which must be a 120*06f32e7eSjoerg /// Constant. Selected naively, these turn into 'lis G+C' and 'li G+C', 121*06f32e7eSjoerg /// though these are usually folded into other nodes. 122*06f32e7eSjoerg Hi, Lo, 123*06f32e7eSjoerg 124*06f32e7eSjoerg /// The following two target-specific nodes are used for calls through 125*06f32e7eSjoerg /// function pointers in the 64-bit SVR4 ABI. 126*06f32e7eSjoerg 127*06f32e7eSjoerg /// OPRC, CHAIN = DYNALLOC(CHAIN, NEGSIZE, FRAME_INDEX) 128*06f32e7eSjoerg /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to 129*06f32e7eSjoerg /// compute an allocation on the stack. 130*06f32e7eSjoerg DYNALLOC, 131*06f32e7eSjoerg 132*06f32e7eSjoerg /// This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to 133*06f32e7eSjoerg /// compute an offset from native SP to the address of the most recent 134*06f32e7eSjoerg /// dynamic alloca. 135*06f32e7eSjoerg DYNAREAOFFSET, 136*06f32e7eSjoerg 137*06f32e7eSjoerg /// GlobalBaseReg - On Darwin, this node represents the result of the mflr 138*06f32e7eSjoerg /// at function entry, used for PIC code. 139*06f32e7eSjoerg GlobalBaseReg, 140*06f32e7eSjoerg 141*06f32e7eSjoerg /// These nodes represent PPC shifts. 142*06f32e7eSjoerg /// 143*06f32e7eSjoerg /// For scalar types, only the last `n + 1` bits of the shift amounts 144*06f32e7eSjoerg /// are used, where n is log2(sizeof(element) * 8). See sld/slw, etc. 145*06f32e7eSjoerg /// for exact behaviors. 146*06f32e7eSjoerg /// 147*06f32e7eSjoerg /// For vector types, only the last n bits are used. See vsld. 148*06f32e7eSjoerg SRL, SRA, SHL, 149*06f32e7eSjoerg 150*06f32e7eSjoerg /// EXTSWSLI = The PPC extswsli instruction, which does an extend-sign 151*06f32e7eSjoerg /// word and shift left immediate. 152*06f32e7eSjoerg EXTSWSLI, 153*06f32e7eSjoerg 154*06f32e7eSjoerg /// The combination of sra[wd]i and addze used to implemented signed 155*06f32e7eSjoerg /// integer division by a power of 2. The first operand is the dividend, 156*06f32e7eSjoerg /// and the second is the constant shift amount (representing the 157*06f32e7eSjoerg /// divisor). 158*06f32e7eSjoerg SRA_ADDZE, 159*06f32e7eSjoerg 160*06f32e7eSjoerg /// CALL - A direct function call. 161*06f32e7eSjoerg /// CALL_NOP is a call with the special NOP which follows 64-bit 162*06f32e7eSjoerg /// SVR4 calls and 32-bit/64-bit AIX calls. 163*06f32e7eSjoerg CALL, CALL_NOP, 164*06f32e7eSjoerg 165*06f32e7eSjoerg /// CHAIN,FLAG = MTCTR(VAL, CHAIN[, INFLAG]) - Directly corresponds to a 166*06f32e7eSjoerg /// MTCTR instruction. 167*06f32e7eSjoerg MTCTR, 168*06f32e7eSjoerg 169*06f32e7eSjoerg /// CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a 170*06f32e7eSjoerg /// BCTRL instruction. 171*06f32e7eSjoerg BCTRL, 172*06f32e7eSjoerg 173*06f32e7eSjoerg /// CHAIN,FLAG = BCTRL(CHAIN, ADDR, INFLAG) - The combination of a bctrl 174*06f32e7eSjoerg /// instruction and the TOC reload required on SVR4 PPC64. 175*06f32e7eSjoerg BCTRL_LOAD_TOC, 176*06f32e7eSjoerg 177*06f32e7eSjoerg /// Return with a flag operand, matched by 'blr' 178*06f32e7eSjoerg RET_FLAG, 179*06f32e7eSjoerg 180*06f32e7eSjoerg /// R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction. 181*06f32e7eSjoerg /// This copies the bits corresponding to the specified CRREG into the 182*06f32e7eSjoerg /// resultant GPR. Bits corresponding to other CR regs are undefined. 183*06f32e7eSjoerg MFOCRF, 184*06f32e7eSjoerg 185*06f32e7eSjoerg /// Direct move from a VSX register to a GPR 186*06f32e7eSjoerg MFVSR, 187*06f32e7eSjoerg 188*06f32e7eSjoerg /// Direct move from a GPR to a VSX register (algebraic) 189*06f32e7eSjoerg MTVSRA, 190*06f32e7eSjoerg 191*06f32e7eSjoerg /// Direct move from a GPR to a VSX register (zero) 192*06f32e7eSjoerg MTVSRZ, 193*06f32e7eSjoerg 194*06f32e7eSjoerg /// Direct move of 2 consecutive GPR to a VSX register. 195*06f32e7eSjoerg BUILD_FP128, 196*06f32e7eSjoerg 197*06f32e7eSjoerg /// BUILD_SPE64 and EXTRACT_SPE are analogous to BUILD_PAIR and 198*06f32e7eSjoerg /// EXTRACT_ELEMENT but take f64 arguments instead of i64, as i64 is 199*06f32e7eSjoerg /// unsupported for this target. 200*06f32e7eSjoerg /// Merge 2 GPRs to a single SPE register. 201*06f32e7eSjoerg BUILD_SPE64, 202*06f32e7eSjoerg 203*06f32e7eSjoerg /// Extract SPE register component, second argument is high or low. 204*06f32e7eSjoerg EXTRACT_SPE, 205*06f32e7eSjoerg 206*06f32e7eSjoerg /// Extract a subvector from signed integer vector and convert to FP. 207*06f32e7eSjoerg /// It is primarily used to convert a (widened) illegal integer vector 208*06f32e7eSjoerg /// type to a legal floating point vector type. 209*06f32e7eSjoerg /// For example v2i32 -> widened to v4i32 -> v2f64 210*06f32e7eSjoerg SINT_VEC_TO_FP, 211*06f32e7eSjoerg 212*06f32e7eSjoerg /// Extract a subvector from unsigned integer vector and convert to FP. 213*06f32e7eSjoerg /// As with SINT_VEC_TO_FP, used for converting illegal types. 214*06f32e7eSjoerg UINT_VEC_TO_FP, 215*06f32e7eSjoerg 216*06f32e7eSjoerg // FIXME: Remove these once the ANDI glue bug is fixed: 217*06f32e7eSjoerg /// i1 = ANDIo_1_[EQ|GT]_BIT(i32 or i64 x) - Represents the result of the 218*06f32e7eSjoerg /// eq or gt bit of CR0 after executing andi. x, 1. This is used to 219*06f32e7eSjoerg /// implement truncation of i32 or i64 to i1. 220*06f32e7eSjoerg ANDIo_1_EQ_BIT, ANDIo_1_GT_BIT, 221*06f32e7eSjoerg 222*06f32e7eSjoerg // READ_TIME_BASE - A read of the 64-bit time-base register on a 32-bit 223*06f32e7eSjoerg // target (returns (Lo, Hi)). It takes a chain operand. 224*06f32e7eSjoerg READ_TIME_BASE, 225*06f32e7eSjoerg 226*06f32e7eSjoerg // EH_SJLJ_SETJMP - SjLj exception handling setjmp. 227*06f32e7eSjoerg EH_SJLJ_SETJMP, 228*06f32e7eSjoerg 229*06f32e7eSjoerg // EH_SJLJ_LONGJMP - SjLj exception handling longjmp. 230*06f32e7eSjoerg EH_SJLJ_LONGJMP, 231*06f32e7eSjoerg 232*06f32e7eSjoerg /// RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP* 233*06f32e7eSjoerg /// instructions. For lack of better number, we use the opcode number 234*06f32e7eSjoerg /// encoding for the OPC field to identify the compare. For example, 838 235*06f32e7eSjoerg /// is VCMPGTSH. 236*06f32e7eSjoerg VCMP, 237*06f32e7eSjoerg 238*06f32e7eSjoerg /// RESVEC, OUTFLAG = VCMPo(LHS, RHS, OPC) - Represents one of the 239*06f32e7eSjoerg /// altivec VCMP*o instructions. For lack of better number, we use the 240*06f32e7eSjoerg /// opcode number encoding for the OPC field to identify the compare. For 241*06f32e7eSjoerg /// example, 838 is VCMPGTSH. 242*06f32e7eSjoerg VCMPo, 243*06f32e7eSjoerg 244*06f32e7eSjoerg /// CHAIN = COND_BRANCH CHAIN, CRRC, OPC, DESTBB [, INFLAG] - This 245*06f32e7eSjoerg /// corresponds to the COND_BRANCH pseudo instruction. CRRC is the 246*06f32e7eSjoerg /// condition register to branch on, OPC is the branch opcode to use (e.g. 247*06f32e7eSjoerg /// PPC::BLE), DESTBB is the destination block to branch to, and INFLAG is 248*06f32e7eSjoerg /// an optional input flag argument. 249*06f32e7eSjoerg COND_BRANCH, 250*06f32e7eSjoerg 251*06f32e7eSjoerg /// CHAIN = BDNZ CHAIN, DESTBB - These are used to create counter-based 252*06f32e7eSjoerg /// loops. 253*06f32e7eSjoerg BDNZ, BDZ, 254*06f32e7eSjoerg 255*06f32e7eSjoerg /// F8RC = FADDRTZ F8RC, F8RC - This is an FADD done with rounding 256*06f32e7eSjoerg /// towards zero. Used only as part of the long double-to-int 257*06f32e7eSjoerg /// conversion sequence. 258*06f32e7eSjoerg FADDRTZ, 259*06f32e7eSjoerg 260*06f32e7eSjoerg /// F8RC = MFFS - This moves the FPSCR (not modeled) into the register. 261*06f32e7eSjoerg MFFS, 262*06f32e7eSjoerg 263*06f32e7eSjoerg /// TC_RETURN - A tail call return. 264*06f32e7eSjoerg /// operand #0 chain 265*06f32e7eSjoerg /// operand #1 callee (register or absolute) 266*06f32e7eSjoerg /// operand #2 stack adjustment 267*06f32e7eSjoerg /// operand #3 optional in flag 268*06f32e7eSjoerg TC_RETURN, 269*06f32e7eSjoerg 270*06f32e7eSjoerg /// ch, gl = CR6[UN]SET ch, inglue - Toggle CR bit 6 for SVR4 vararg calls 271*06f32e7eSjoerg CR6SET, 272*06f32e7eSjoerg CR6UNSET, 273*06f32e7eSjoerg 274*06f32e7eSjoerg /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by initial-exec TLS 275*06f32e7eSjoerg /// for non-position independent code on PPC32. 276*06f32e7eSjoerg PPC32_GOT, 277*06f32e7eSjoerg 278*06f32e7eSjoerg /// GPRC = address of _GLOBAL_OFFSET_TABLE_. Used by general dynamic and 279*06f32e7eSjoerg /// local dynamic TLS and position indendepent code on PPC32. 280*06f32e7eSjoerg PPC32_PICGOT, 281*06f32e7eSjoerg 282*06f32e7eSjoerg /// G8RC = ADDIS_GOT_TPREL_HA %x2, Symbol - Used by the initial-exec 283*06f32e7eSjoerg /// TLS model, produces an ADDIS8 instruction that adds the GOT 284*06f32e7eSjoerg /// base to sym\@got\@tprel\@ha. 285*06f32e7eSjoerg ADDIS_GOT_TPREL_HA, 286*06f32e7eSjoerg 287*06f32e7eSjoerg /// G8RC = LD_GOT_TPREL_L Symbol, G8RReg - Used by the initial-exec 288*06f32e7eSjoerg /// TLS model, produces a LD instruction with base register G8RReg 289*06f32e7eSjoerg /// and offset sym\@got\@tprel\@l. This completes the addition that 290*06f32e7eSjoerg /// finds the offset of "sym" relative to the thread pointer. 291*06f32e7eSjoerg LD_GOT_TPREL_L, 292*06f32e7eSjoerg 293*06f32e7eSjoerg /// G8RC = ADD_TLS G8RReg, Symbol - Used by the initial-exec TLS 294*06f32e7eSjoerg /// model, produces an ADD instruction that adds the contents of 295*06f32e7eSjoerg /// G8RReg to the thread pointer. Symbol contains a relocation 296*06f32e7eSjoerg /// sym\@tls which is to be replaced by the thread pointer and 297*06f32e7eSjoerg /// identifies to the linker that the instruction is part of a 298*06f32e7eSjoerg /// TLS sequence. 299*06f32e7eSjoerg ADD_TLS, 300*06f32e7eSjoerg 301*06f32e7eSjoerg /// G8RC = ADDIS_TLSGD_HA %x2, Symbol - For the general-dynamic TLS 302*06f32e7eSjoerg /// model, produces an ADDIS8 instruction that adds the GOT base 303*06f32e7eSjoerg /// register to sym\@got\@tlsgd\@ha. 304*06f32e7eSjoerg ADDIS_TLSGD_HA, 305*06f32e7eSjoerg 306*06f32e7eSjoerg /// %x3 = ADDI_TLSGD_L G8RReg, Symbol - For the general-dynamic TLS 307*06f32e7eSjoerg /// model, produces an ADDI8 instruction that adds G8RReg to 308*06f32e7eSjoerg /// sym\@got\@tlsgd\@l and stores the result in X3. Hidden by 309*06f32e7eSjoerg /// ADDIS_TLSGD_L_ADDR until after register assignment. 310*06f32e7eSjoerg ADDI_TLSGD_L, 311*06f32e7eSjoerg 312*06f32e7eSjoerg /// %x3 = GET_TLS_ADDR %x3, Symbol - For the general-dynamic TLS 313*06f32e7eSjoerg /// model, produces a call to __tls_get_addr(sym\@tlsgd). Hidden by 314*06f32e7eSjoerg /// ADDIS_TLSGD_L_ADDR until after register assignment. 315*06f32e7eSjoerg GET_TLS_ADDR, 316*06f32e7eSjoerg 317*06f32e7eSjoerg /// G8RC = ADDI_TLSGD_L_ADDR G8RReg, Symbol, Symbol - Op that 318*06f32e7eSjoerg /// combines ADDI_TLSGD_L and GET_TLS_ADDR until expansion following 319*06f32e7eSjoerg /// register assignment. 320*06f32e7eSjoerg ADDI_TLSGD_L_ADDR, 321*06f32e7eSjoerg 322*06f32e7eSjoerg /// G8RC = ADDIS_TLSLD_HA %x2, Symbol - For the local-dynamic TLS 323*06f32e7eSjoerg /// model, produces an ADDIS8 instruction that adds the GOT base 324*06f32e7eSjoerg /// register to sym\@got\@tlsld\@ha. 325*06f32e7eSjoerg ADDIS_TLSLD_HA, 326*06f32e7eSjoerg 327*06f32e7eSjoerg /// %x3 = ADDI_TLSLD_L G8RReg, Symbol - For the local-dynamic TLS 328*06f32e7eSjoerg /// model, produces an ADDI8 instruction that adds G8RReg to 329*06f32e7eSjoerg /// sym\@got\@tlsld\@l and stores the result in X3. Hidden by 330*06f32e7eSjoerg /// ADDIS_TLSLD_L_ADDR until after register assignment. 331*06f32e7eSjoerg ADDI_TLSLD_L, 332*06f32e7eSjoerg 333*06f32e7eSjoerg /// %x3 = GET_TLSLD_ADDR %x3, Symbol - For the local-dynamic TLS 334*06f32e7eSjoerg /// model, produces a call to __tls_get_addr(sym\@tlsld). Hidden by 335*06f32e7eSjoerg /// ADDIS_TLSLD_L_ADDR until after register assignment. 336*06f32e7eSjoerg GET_TLSLD_ADDR, 337*06f32e7eSjoerg 338*06f32e7eSjoerg /// G8RC = ADDI_TLSLD_L_ADDR G8RReg, Symbol, Symbol - Op that 339*06f32e7eSjoerg /// combines ADDI_TLSLD_L and GET_TLSLD_ADDR until expansion 340*06f32e7eSjoerg /// following register assignment. 341*06f32e7eSjoerg ADDI_TLSLD_L_ADDR, 342*06f32e7eSjoerg 343*06f32e7eSjoerg /// G8RC = ADDIS_DTPREL_HA %x3, Symbol - For the local-dynamic TLS 344*06f32e7eSjoerg /// model, produces an ADDIS8 instruction that adds X3 to 345*06f32e7eSjoerg /// sym\@dtprel\@ha. 346*06f32e7eSjoerg ADDIS_DTPREL_HA, 347*06f32e7eSjoerg 348*06f32e7eSjoerg /// G8RC = ADDI_DTPREL_L G8RReg, Symbol - For the local-dynamic TLS 349*06f32e7eSjoerg /// model, produces an ADDI8 instruction that adds G8RReg to 350*06f32e7eSjoerg /// sym\@got\@dtprel\@l. 351*06f32e7eSjoerg ADDI_DTPREL_L, 352*06f32e7eSjoerg 353*06f32e7eSjoerg /// VRRC = VADD_SPLAT Elt, EltSize - Temporary node to be expanded 354*06f32e7eSjoerg /// during instruction selection to optimize a BUILD_VECTOR into 355*06f32e7eSjoerg /// operations on splats. This is necessary to avoid losing these 356*06f32e7eSjoerg /// optimizations due to constant folding. 357*06f32e7eSjoerg VADD_SPLAT, 358*06f32e7eSjoerg 359*06f32e7eSjoerg /// CHAIN = SC CHAIN, Imm128 - System call. The 7-bit unsigned 360*06f32e7eSjoerg /// operand identifies the operating system entry point. 361*06f32e7eSjoerg SC, 362*06f32e7eSjoerg 363*06f32e7eSjoerg /// CHAIN = CLRBHRB CHAIN - Clear branch history rolling buffer. 364*06f32e7eSjoerg CLRBHRB, 365*06f32e7eSjoerg 366*06f32e7eSjoerg /// GPRC, CHAIN = MFBHRBE CHAIN, Entry, Dummy - Move from branch 367*06f32e7eSjoerg /// history rolling buffer entry. 368*06f32e7eSjoerg MFBHRBE, 369*06f32e7eSjoerg 370*06f32e7eSjoerg /// CHAIN = RFEBB CHAIN, State - Return from event-based branch. 371*06f32e7eSjoerg RFEBB, 372*06f32e7eSjoerg 373*06f32e7eSjoerg /// VSRC, CHAIN = XXSWAPD CHAIN, VSRC - Occurs only for little 374*06f32e7eSjoerg /// endian. Maps to an xxswapd instruction that corrects an lxvd2x 375*06f32e7eSjoerg /// or stxvd2x instruction. The chain is necessary because the 376*06f32e7eSjoerg /// sequence replaces a load and needs to provide the same number 377*06f32e7eSjoerg /// of outputs. 378*06f32e7eSjoerg XXSWAPD, 379*06f32e7eSjoerg 380*06f32e7eSjoerg /// An SDNode for swaps that are not associated with any loads/stores 381*06f32e7eSjoerg /// and thereby have no chain. 382*06f32e7eSjoerg SWAP_NO_CHAIN, 383*06f32e7eSjoerg 384*06f32e7eSjoerg /// An SDNode for Power9 vector absolute value difference. 385*06f32e7eSjoerg /// operand #0 vector 386*06f32e7eSjoerg /// operand #1 vector 387*06f32e7eSjoerg /// operand #2 constant i32 0 or 1, to indicate whether needs to patch 388*06f32e7eSjoerg /// the most significant bit for signed i32 389*06f32e7eSjoerg /// 390*06f32e7eSjoerg /// Power9 VABSD* instructions are designed to support unsigned integer 391*06f32e7eSjoerg /// vectors (byte/halfword/word), if we want to make use of them for signed 392*06f32e7eSjoerg /// integer vectors, we have to flip their sign bits first. To flip sign bit 393*06f32e7eSjoerg /// for byte/halfword integer vector would become inefficient, but for word 394*06f32e7eSjoerg /// integer vector, we can leverage XVNEGSP to make it efficiently. eg: 395*06f32e7eSjoerg /// abs(sub(a,b)) => VABSDUW(a+0x80000000, b+0x80000000) 396*06f32e7eSjoerg /// => VABSDUW((XVNEGSP a), (XVNEGSP b)) 397*06f32e7eSjoerg VABSD, 398*06f32e7eSjoerg 399*06f32e7eSjoerg /// QVFPERM = This corresponds to the QPX qvfperm instruction. 400*06f32e7eSjoerg QVFPERM, 401*06f32e7eSjoerg 402*06f32e7eSjoerg /// QVGPCI = This corresponds to the QPX qvgpci instruction. 403*06f32e7eSjoerg QVGPCI, 404*06f32e7eSjoerg 405*06f32e7eSjoerg /// QVALIGNI = This corresponds to the QPX qvaligni instruction. 406*06f32e7eSjoerg QVALIGNI, 407*06f32e7eSjoerg 408*06f32e7eSjoerg /// QVESPLATI = This corresponds to the QPX qvesplati instruction. 409*06f32e7eSjoerg QVESPLATI, 410*06f32e7eSjoerg 411*06f32e7eSjoerg /// QBFLT = Access the underlying QPX floating-point boolean 412*06f32e7eSjoerg /// representation. 413*06f32e7eSjoerg QBFLT, 414*06f32e7eSjoerg 415*06f32e7eSjoerg /// FP_EXTEND_HALF(VECTOR, IDX) - Custom extend upper (IDX=0) half or 416*06f32e7eSjoerg /// lower (IDX=1) half of v4f32 to v2f64. 417*06f32e7eSjoerg FP_EXTEND_HALF, 418*06f32e7eSjoerg 419*06f32e7eSjoerg /// CHAIN = STBRX CHAIN, GPRC, Ptr, Type - This is a 420*06f32e7eSjoerg /// byte-swapping store instruction. It byte-swaps the low "Type" bits of 421*06f32e7eSjoerg /// the GPRC input, then stores it through Ptr. Type can be either i16 or 422*06f32e7eSjoerg /// i32. 423*06f32e7eSjoerg STBRX = ISD::FIRST_TARGET_MEMORY_OPCODE, 424*06f32e7eSjoerg 425*06f32e7eSjoerg /// GPRC, CHAIN = LBRX CHAIN, Ptr, Type - This is a 426*06f32e7eSjoerg /// byte-swapping load instruction. It loads "Type" bits, byte swaps it, 427*06f32e7eSjoerg /// then puts it in the bottom bits of the GPRC. TYPE can be either i16 428*06f32e7eSjoerg /// or i32. 429*06f32e7eSjoerg LBRX, 430*06f32e7eSjoerg 431*06f32e7eSjoerg /// STFIWX - The STFIWX instruction. The first operand is an input token 432*06f32e7eSjoerg /// chain, then an f64 value to store, then an address to store it to. 433*06f32e7eSjoerg STFIWX, 434*06f32e7eSjoerg 435*06f32e7eSjoerg /// GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point 436*06f32e7eSjoerg /// load which sign-extends from a 32-bit integer value into the 437*06f32e7eSjoerg /// destination 64-bit register. 438*06f32e7eSjoerg LFIWAX, 439*06f32e7eSjoerg 440*06f32e7eSjoerg /// GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point 441*06f32e7eSjoerg /// load which zero-extends from a 32-bit integer value into the 442*06f32e7eSjoerg /// destination 64-bit register. 443*06f32e7eSjoerg LFIWZX, 444*06f32e7eSjoerg 445*06f32e7eSjoerg /// GPRC, CHAIN = LXSIZX, CHAIN, Ptr, ByteWidth - This is a load of an 446*06f32e7eSjoerg /// integer smaller than 64 bits into a VSR. The integer is zero-extended. 447*06f32e7eSjoerg /// This can be used for converting loaded integers to floating point. 448*06f32e7eSjoerg LXSIZX, 449*06f32e7eSjoerg 450*06f32e7eSjoerg /// STXSIX - The STXSI[bh]X instruction. The first operand is an input 451*06f32e7eSjoerg /// chain, then an f64 value to store, then an address to store it to, 452*06f32e7eSjoerg /// followed by a byte-width for the store. 453*06f32e7eSjoerg STXSIX, 454*06f32e7eSjoerg 455*06f32e7eSjoerg /// VSRC, CHAIN = LXVD2X_LE CHAIN, Ptr - Occurs only for little endian. 456*06f32e7eSjoerg /// Maps directly to an lxvd2x instruction that will be followed by 457*06f32e7eSjoerg /// an xxswapd. 458*06f32e7eSjoerg LXVD2X, 459*06f32e7eSjoerg 460*06f32e7eSjoerg /// VSRC, CHAIN = LOAD_VEC_BE CHAIN, Ptr - Occurs only for little endian. 461*06f32e7eSjoerg /// Maps directly to one of lxvd2x/lxvw4x/lxvh8x/lxvb16x depending on 462*06f32e7eSjoerg /// the vector type to load vector in big-endian element order. 463*06f32e7eSjoerg LOAD_VEC_BE, 464*06f32e7eSjoerg 465*06f32e7eSjoerg /// VSRC, CHAIN = LD_VSX_LH CHAIN, Ptr - This is a floating-point load of a 466*06f32e7eSjoerg /// v2f32 value into the lower half of a VSR register. 467*06f32e7eSjoerg LD_VSX_LH, 468*06f32e7eSjoerg 469*06f32e7eSjoerg /// VSRC, CHAIN = LD_SPLAT, CHAIN, Ptr - a splatting load memory 470*06f32e7eSjoerg /// instructions such as LXVDSX, LXVWSX. 471*06f32e7eSjoerg LD_SPLAT, 472*06f32e7eSjoerg 473*06f32e7eSjoerg /// CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian. 474*06f32e7eSjoerg /// Maps directly to an stxvd2x instruction that will be preceded by 475*06f32e7eSjoerg /// an xxswapd. 476*06f32e7eSjoerg STXVD2X, 477*06f32e7eSjoerg 478*06f32e7eSjoerg /// CHAIN = STORE_VEC_BE CHAIN, VSRC, Ptr - Occurs only for little endian. 479*06f32e7eSjoerg /// Maps directly to one of stxvd2x/stxvw4x/stxvh8x/stxvb16x depending on 480*06f32e7eSjoerg /// the vector type to store vector in big-endian element order. 481*06f32e7eSjoerg STORE_VEC_BE, 482*06f32e7eSjoerg 483*06f32e7eSjoerg /// Store scalar integers from VSR. 484*06f32e7eSjoerg ST_VSR_SCAL_INT, 485*06f32e7eSjoerg 486*06f32e7eSjoerg /// QBRC, CHAIN = QVLFSb CHAIN, Ptr 487*06f32e7eSjoerg /// The 4xf32 load used for v4i1 constants. 488*06f32e7eSjoerg QVLFSb, 489*06f32e7eSjoerg 490*06f32e7eSjoerg /// ATOMIC_CMP_SWAP - the exact same as the target-independent nodes 491*06f32e7eSjoerg /// except they ensure that the compare input is zero-extended for 492*06f32e7eSjoerg /// sub-word versions because the atomic loads zero-extend. 493*06f32e7eSjoerg ATOMIC_CMP_SWAP_8, ATOMIC_CMP_SWAP_16, 494*06f32e7eSjoerg 495*06f32e7eSjoerg /// GPRC = TOC_ENTRY GA, TOC 496*06f32e7eSjoerg /// Loads the entry for GA from the TOC, where the TOC base is given by 497*06f32e7eSjoerg /// the last operand. 498*06f32e7eSjoerg TOC_ENTRY 499*06f32e7eSjoerg }; 500*06f32e7eSjoerg 501*06f32e7eSjoerg } // end namespace PPCISD 502*06f32e7eSjoerg 503*06f32e7eSjoerg /// Define some predicates that are used for node matching. 504*06f32e7eSjoerg namespace PPC { 505*06f32e7eSjoerg 506*06f32e7eSjoerg /// isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a 507*06f32e7eSjoerg /// VPKUHUM instruction. 508*06f32e7eSjoerg bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, 509*06f32e7eSjoerg SelectionDAG &DAG); 510*06f32e7eSjoerg 511*06f32e7eSjoerg /// isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a 512*06f32e7eSjoerg /// VPKUWUM instruction. 513*06f32e7eSjoerg bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, 514*06f32e7eSjoerg SelectionDAG &DAG); 515*06f32e7eSjoerg 516*06f32e7eSjoerg /// isVPKUDUMShuffleMask - Return true if this is the shuffle mask for a 517*06f32e7eSjoerg /// VPKUDUM instruction. 518*06f32e7eSjoerg bool isVPKUDUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, 519*06f32e7eSjoerg SelectionDAG &DAG); 520*06f32e7eSjoerg 521*06f32e7eSjoerg /// isVMRGLShuffleMask - Return true if this is a shuffle mask suitable for 522*06f32e7eSjoerg /// a VRGL* instruction with the specified unit size (1,2 or 4 bytes). 523*06f32e7eSjoerg bool isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize, 524*06f32e7eSjoerg unsigned ShuffleKind, SelectionDAG &DAG); 525*06f32e7eSjoerg 526*06f32e7eSjoerg /// isVMRGHShuffleMask - Return true if this is a shuffle mask suitable for 527*06f32e7eSjoerg /// a VRGH* instruction with the specified unit size (1,2 or 4 bytes). 528*06f32e7eSjoerg bool isVMRGHShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize, 529*06f32e7eSjoerg unsigned ShuffleKind, SelectionDAG &DAG); 530*06f32e7eSjoerg 531*06f32e7eSjoerg /// isVMRGEOShuffleMask - Return true if this is a shuffle mask suitable for 532*06f32e7eSjoerg /// a VMRGEW or VMRGOW instruction 533*06f32e7eSjoerg bool isVMRGEOShuffleMask(ShuffleVectorSDNode *N, bool CheckEven, 534*06f32e7eSjoerg unsigned ShuffleKind, SelectionDAG &DAG); 535*06f32e7eSjoerg /// isXXSLDWIShuffleMask - Return true if this is a shuffle mask suitable 536*06f32e7eSjoerg /// for a XXSLDWI instruction. 537*06f32e7eSjoerg bool isXXSLDWIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, 538*06f32e7eSjoerg bool &Swap, bool IsLE); 539*06f32e7eSjoerg 540*06f32e7eSjoerg /// isXXBRHShuffleMask - Return true if this is a shuffle mask suitable 541*06f32e7eSjoerg /// for a XXBRH instruction. 542*06f32e7eSjoerg bool isXXBRHShuffleMask(ShuffleVectorSDNode *N); 543*06f32e7eSjoerg 544*06f32e7eSjoerg /// isXXBRWShuffleMask - Return true if this is a shuffle mask suitable 545*06f32e7eSjoerg /// for a XXBRW instruction. 546*06f32e7eSjoerg bool isXXBRWShuffleMask(ShuffleVectorSDNode *N); 547*06f32e7eSjoerg 548*06f32e7eSjoerg /// isXXBRDShuffleMask - Return true if this is a shuffle mask suitable 549*06f32e7eSjoerg /// for a XXBRD instruction. 550*06f32e7eSjoerg bool isXXBRDShuffleMask(ShuffleVectorSDNode *N); 551*06f32e7eSjoerg 552*06f32e7eSjoerg /// isXXBRQShuffleMask - Return true if this is a shuffle mask suitable 553*06f32e7eSjoerg /// for a XXBRQ instruction. 554*06f32e7eSjoerg bool isXXBRQShuffleMask(ShuffleVectorSDNode *N); 555*06f32e7eSjoerg 556*06f32e7eSjoerg /// isXXPERMDIShuffleMask - Return true if this is a shuffle mask suitable 557*06f32e7eSjoerg /// for a XXPERMDI instruction. 558*06f32e7eSjoerg bool isXXPERMDIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, 559*06f32e7eSjoerg bool &Swap, bool IsLE); 560*06f32e7eSjoerg 561*06f32e7eSjoerg /// isVSLDOIShuffleMask - If this is a vsldoi shuffle mask, return the 562*06f32e7eSjoerg /// shift amount, otherwise return -1. 563*06f32e7eSjoerg int isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind, 564*06f32e7eSjoerg SelectionDAG &DAG); 565*06f32e7eSjoerg 566*06f32e7eSjoerg /// isSplatShuffleMask - Return true if the specified VECTOR_SHUFFLE operand 567*06f32e7eSjoerg /// specifies a splat of a single element that is suitable for input to 568*06f32e7eSjoerg /// VSPLTB/VSPLTH/VSPLTW. 569*06f32e7eSjoerg bool isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize); 570*06f32e7eSjoerg 571*06f32e7eSjoerg /// isXXINSERTWMask - Return true if this VECTOR_SHUFFLE can be handled by 572*06f32e7eSjoerg /// the XXINSERTW instruction introduced in ISA 3.0. This is essentially any 573*06f32e7eSjoerg /// shuffle of v4f32/v4i32 vectors that just inserts one element from one 574*06f32e7eSjoerg /// vector into the other. This function will also set a couple of 575*06f32e7eSjoerg /// output parameters for how much the source vector needs to be shifted and 576*06f32e7eSjoerg /// what byte number needs to be specified for the instruction to put the 577*06f32e7eSjoerg /// element in the desired location of the target vector. 578*06f32e7eSjoerg bool isXXINSERTWMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, 579*06f32e7eSjoerg unsigned &InsertAtByte, bool &Swap, bool IsLE); 580*06f32e7eSjoerg 581*06f32e7eSjoerg /// getSplatIdxForPPCMnemonics - Return the splat index as a value that is 582*06f32e7eSjoerg /// appropriate for PPC mnemonics (which have a big endian bias - namely 583*06f32e7eSjoerg /// elements are counted from the left of the vector register). 584*06f32e7eSjoerg unsigned getSplatIdxForPPCMnemonics(SDNode *N, unsigned EltSize, 585*06f32e7eSjoerg SelectionDAG &DAG); 586*06f32e7eSjoerg 587*06f32e7eSjoerg /// get_VSPLTI_elt - If this is a build_vector of constants which can be 588*06f32e7eSjoerg /// formed by using a vspltis[bhw] instruction of the specified element 589*06f32e7eSjoerg /// size, return the constant being splatted. The ByteSize field indicates 590*06f32e7eSjoerg /// the number of bytes of each element [124] -> [bhw]. 591*06f32e7eSjoerg SDValue get_VSPLTI_elt(SDNode *N, unsigned ByteSize, SelectionDAG &DAG); 592*06f32e7eSjoerg 593*06f32e7eSjoerg /// If this is a qvaligni shuffle mask, return the shift 594*06f32e7eSjoerg /// amount, otherwise return -1. 595*06f32e7eSjoerg int isQVALIGNIShuffleMask(SDNode *N); 596*06f32e7eSjoerg 597*06f32e7eSjoerg } // end namespace PPC 598*06f32e7eSjoerg 599*06f32e7eSjoerg class PPCTargetLowering : public TargetLowering { 600*06f32e7eSjoerg const PPCSubtarget &Subtarget; 601*06f32e7eSjoerg 602*06f32e7eSjoerg public: 603*06f32e7eSjoerg explicit PPCTargetLowering(const PPCTargetMachine &TM, 604*06f32e7eSjoerg const PPCSubtarget &STI); 605*06f32e7eSjoerg 606*06f32e7eSjoerg /// getTargetNodeName() - This method returns the name of a target specific 607*06f32e7eSjoerg /// DAG node. 608*06f32e7eSjoerg const char *getTargetNodeName(unsigned Opcode) const override; 609*06f32e7eSjoerg 610*06f32e7eSjoerg bool isSelectSupported(SelectSupportKind Kind) const override { 611*06f32e7eSjoerg // PowerPC does not support scalar condition selects on vectors. 612*06f32e7eSjoerg return (Kind != SelectSupportKind::ScalarCondVectorVal); 613*06f32e7eSjoerg } 614*06f32e7eSjoerg 615*06f32e7eSjoerg /// getPreferredVectorAction - The code we generate when vector types are 616*06f32e7eSjoerg /// legalized by promoting the integer element type is often much worse 617*06f32e7eSjoerg /// than code we generate if we widen the type for applicable vector types. 618*06f32e7eSjoerg /// The issue with promoting is that the vector is scalaraized, individual 619*06f32e7eSjoerg /// elements promoted and then the vector is rebuilt. So say we load a pair 620*06f32e7eSjoerg /// of v4i8's and shuffle them. This will turn into a mess of 8 extending 621*06f32e7eSjoerg /// loads, moves back into VSR's (or memory ops if we don't have moves) and 622*06f32e7eSjoerg /// then the VPERM for the shuffle. All in all a very slow sequence. 623*06f32e7eSjoerg TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) 624*06f32e7eSjoerg const override { 625*06f32e7eSjoerg if (VT.getScalarSizeInBits() % 8 == 0) 626*06f32e7eSjoerg return TypeWidenVector; 627*06f32e7eSjoerg return TargetLoweringBase::getPreferredVectorAction(VT); 628*06f32e7eSjoerg } 629*06f32e7eSjoerg 630*06f32e7eSjoerg bool useSoftFloat() const override; 631*06f32e7eSjoerg 632*06f32e7eSjoerg bool hasSPE() const; 633*06f32e7eSjoerg 634*06f32e7eSjoerg MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override { 635*06f32e7eSjoerg return MVT::i32; 636*06f32e7eSjoerg } 637*06f32e7eSjoerg 638*06f32e7eSjoerg bool isCheapToSpeculateCttz() const override { 639*06f32e7eSjoerg return true; 640*06f32e7eSjoerg } 641*06f32e7eSjoerg 642*06f32e7eSjoerg bool isCheapToSpeculateCtlz() const override { 643*06f32e7eSjoerg return true; 644*06f32e7eSjoerg } 645*06f32e7eSjoerg 646*06f32e7eSjoerg bool isCtlzFast() const override { 647*06f32e7eSjoerg return true; 648*06f32e7eSjoerg } 649*06f32e7eSjoerg 650*06f32e7eSjoerg bool hasAndNotCompare(SDValue) const override { 651*06f32e7eSjoerg return true; 652*06f32e7eSjoerg } 653*06f32e7eSjoerg 654*06f32e7eSjoerg bool preferIncOfAddToSubOfNot(EVT VT) const override; 655*06f32e7eSjoerg 656*06f32e7eSjoerg bool convertSetCCLogicToBitwiseLogic(EVT VT) const override { 657*06f32e7eSjoerg return VT.isScalarInteger(); 658*06f32e7eSjoerg } 659*06f32e7eSjoerg 660*06f32e7eSjoerg bool supportSplitCSR(MachineFunction *MF) const override { 661*06f32e7eSjoerg return 662*06f32e7eSjoerg MF->getFunction().getCallingConv() == CallingConv::CXX_FAST_TLS && 663*06f32e7eSjoerg MF->getFunction().hasFnAttribute(Attribute::NoUnwind); 664*06f32e7eSjoerg } 665*06f32e7eSjoerg 666*06f32e7eSjoerg void initializeSplitCSR(MachineBasicBlock *Entry) const override; 667*06f32e7eSjoerg 668*06f32e7eSjoerg void insertCopiesSplitCSR( 669*06f32e7eSjoerg MachineBasicBlock *Entry, 670*06f32e7eSjoerg const SmallVectorImpl<MachineBasicBlock *> &Exits) const override; 671*06f32e7eSjoerg 672*06f32e7eSjoerg /// getSetCCResultType - Return the ISD::SETCC ValueType 673*06f32e7eSjoerg EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, 674*06f32e7eSjoerg EVT VT) const override; 675*06f32e7eSjoerg 676*06f32e7eSjoerg /// Return true if target always beneficiates from combining into FMA for a 677*06f32e7eSjoerg /// given value type. This must typically return false on targets where FMA 678*06f32e7eSjoerg /// takes more cycles to execute than FADD. 679*06f32e7eSjoerg bool enableAggressiveFMAFusion(EVT VT) const override; 680*06f32e7eSjoerg 681*06f32e7eSjoerg /// getPreIndexedAddressParts - returns true by value, base pointer and 682*06f32e7eSjoerg /// offset pointer and addressing mode by reference if the node's address 683*06f32e7eSjoerg /// can be legally represented as pre-indexed load / store address. 684*06f32e7eSjoerg bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, 685*06f32e7eSjoerg SDValue &Offset, 686*06f32e7eSjoerg ISD::MemIndexedMode &AM, 687*06f32e7eSjoerg SelectionDAG &DAG) const override; 688*06f32e7eSjoerg 689*06f32e7eSjoerg /// SelectAddressEVXRegReg - Given the specified addressed, check to see if 690*06f32e7eSjoerg /// it can be more efficiently represented as [r+imm]. 691*06f32e7eSjoerg bool SelectAddressEVXRegReg(SDValue N, SDValue &Base, SDValue &Index, 692*06f32e7eSjoerg SelectionDAG &DAG) const; 693*06f32e7eSjoerg 694*06f32e7eSjoerg /// SelectAddressRegReg - Given the specified addressed, check to see if it 695*06f32e7eSjoerg /// can be more efficiently represented as [r+imm]. If \p EncodingAlignment 696*06f32e7eSjoerg /// is non-zero, only accept displacement which is not suitable for [r+imm]. 697*06f32e7eSjoerg /// Returns false if it can be represented by [r+imm], which are preferred. 698*06f32e7eSjoerg bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index, 699*06f32e7eSjoerg SelectionDAG &DAG, 700*06f32e7eSjoerg unsigned EncodingAlignment = 0) const; 701*06f32e7eSjoerg 702*06f32e7eSjoerg /// SelectAddressRegImm - Returns true if the address N can be represented 703*06f32e7eSjoerg /// by a base register plus a signed 16-bit displacement [r+imm], and if it 704*06f32e7eSjoerg /// is not better represented as reg+reg. If \p EncodingAlignment is 705*06f32e7eSjoerg /// non-zero, only accept displacements suitable for instruction encoding 706*06f32e7eSjoerg /// requirement, i.e. multiples of 4 for DS form. 707*06f32e7eSjoerg bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base, 708*06f32e7eSjoerg SelectionDAG &DAG, 709*06f32e7eSjoerg unsigned EncodingAlignment) const; 710*06f32e7eSjoerg 711*06f32e7eSjoerg /// SelectAddressRegRegOnly - Given the specified addressed, force it to be 712*06f32e7eSjoerg /// represented as an indexed [r+r] operation. 713*06f32e7eSjoerg bool SelectAddressRegRegOnly(SDValue N, SDValue &Base, SDValue &Index, 714*06f32e7eSjoerg SelectionDAG &DAG) const; 715*06f32e7eSjoerg 716*06f32e7eSjoerg Sched::Preference getSchedulingPreference(SDNode *N) const override; 717*06f32e7eSjoerg 718*06f32e7eSjoerg /// LowerOperation - Provide custom lowering hooks for some operations. 719*06f32e7eSjoerg /// 720*06f32e7eSjoerg SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 721*06f32e7eSjoerg 722*06f32e7eSjoerg /// ReplaceNodeResults - Replace the results of node with an illegal result 723*06f32e7eSjoerg /// type with new values built out of custom code. 724*06f32e7eSjoerg /// 725*06f32e7eSjoerg void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, 726*06f32e7eSjoerg SelectionDAG &DAG) const override; 727*06f32e7eSjoerg 728*06f32e7eSjoerg SDValue expandVSXLoadForLE(SDNode *N, DAGCombinerInfo &DCI) const; 729*06f32e7eSjoerg SDValue expandVSXStoreForLE(SDNode *N, DAGCombinerInfo &DCI) const; 730*06f32e7eSjoerg 731*06f32e7eSjoerg SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; 732*06f32e7eSjoerg 733*06f32e7eSjoerg SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, 734*06f32e7eSjoerg SmallVectorImpl<SDNode *> &Created) const override; 735*06f32e7eSjoerg 736*06f32e7eSjoerg Register getRegisterByName(const char* RegName, EVT VT, 737*06f32e7eSjoerg const MachineFunction &MF) const override; 738*06f32e7eSjoerg 739*06f32e7eSjoerg void computeKnownBitsForTargetNode(const SDValue Op, 740*06f32e7eSjoerg KnownBits &Known, 741*06f32e7eSjoerg const APInt &DemandedElts, 742*06f32e7eSjoerg const SelectionDAG &DAG, 743*06f32e7eSjoerg unsigned Depth = 0) const override; 744*06f32e7eSjoerg 745*06f32e7eSjoerg Align getPrefLoopAlignment(MachineLoop *ML) const override; 746*06f32e7eSjoerg 747*06f32e7eSjoerg bool shouldInsertFencesForAtomic(const Instruction *I) const override { 748*06f32e7eSjoerg return true; 749*06f32e7eSjoerg } 750*06f32e7eSjoerg 751*06f32e7eSjoerg Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst, 752*06f32e7eSjoerg AtomicOrdering Ord) const override; 753*06f32e7eSjoerg Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst, 754*06f32e7eSjoerg AtomicOrdering Ord) const override; 755*06f32e7eSjoerg 756*06f32e7eSjoerg MachineBasicBlock * 757*06f32e7eSjoerg EmitInstrWithCustomInserter(MachineInstr &MI, 758*06f32e7eSjoerg MachineBasicBlock *MBB) const override; 759*06f32e7eSjoerg MachineBasicBlock *EmitAtomicBinary(MachineInstr &MI, 760*06f32e7eSjoerg MachineBasicBlock *MBB, 761*06f32e7eSjoerg unsigned AtomicSize, 762*06f32e7eSjoerg unsigned BinOpcode, 763*06f32e7eSjoerg unsigned CmpOpcode = 0, 764*06f32e7eSjoerg unsigned CmpPred = 0) const; 765*06f32e7eSjoerg MachineBasicBlock *EmitPartwordAtomicBinary(MachineInstr &MI, 766*06f32e7eSjoerg MachineBasicBlock *MBB, 767*06f32e7eSjoerg bool is8bit, 768*06f32e7eSjoerg unsigned Opcode, 769*06f32e7eSjoerg unsigned CmpOpcode = 0, 770*06f32e7eSjoerg unsigned CmpPred = 0) const; 771*06f32e7eSjoerg 772*06f32e7eSjoerg MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr &MI, 773*06f32e7eSjoerg MachineBasicBlock *MBB) const; 774*06f32e7eSjoerg 775*06f32e7eSjoerg MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr &MI, 776*06f32e7eSjoerg MachineBasicBlock *MBB) const; 777*06f32e7eSjoerg 778*06f32e7eSjoerg ConstraintType getConstraintType(StringRef Constraint) const override; 779*06f32e7eSjoerg 780*06f32e7eSjoerg /// Examine constraint string and operand type and determine a weight value. 781*06f32e7eSjoerg /// The operand object must already have been set up with the operand type. 782*06f32e7eSjoerg ConstraintWeight getSingleConstraintMatchWeight( 783*06f32e7eSjoerg AsmOperandInfo &info, const char *constraint) const override; 784*06f32e7eSjoerg 785*06f32e7eSjoerg std::pair<unsigned, const TargetRegisterClass *> 786*06f32e7eSjoerg getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, 787*06f32e7eSjoerg StringRef Constraint, MVT VT) const override; 788*06f32e7eSjoerg 789*06f32e7eSjoerg /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate 790*06f32e7eSjoerg /// function arguments in the caller parameter area. This is the actual 791*06f32e7eSjoerg /// alignment, not its logarithm. 792*06f32e7eSjoerg unsigned getByValTypeAlignment(Type *Ty, 793*06f32e7eSjoerg const DataLayout &DL) const override; 794*06f32e7eSjoerg 795*06f32e7eSjoerg /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops 796*06f32e7eSjoerg /// vector. If it is invalid, don't add anything to Ops. 797*06f32e7eSjoerg void LowerAsmOperandForConstraint(SDValue Op, 798*06f32e7eSjoerg std::string &Constraint, 799*06f32e7eSjoerg std::vector<SDValue> &Ops, 800*06f32e7eSjoerg SelectionDAG &DAG) const override; 801*06f32e7eSjoerg 802*06f32e7eSjoerg unsigned 803*06f32e7eSjoerg getInlineAsmMemConstraint(StringRef ConstraintCode) const override { 804*06f32e7eSjoerg if (ConstraintCode == "es") 805*06f32e7eSjoerg return InlineAsm::Constraint_es; 806*06f32e7eSjoerg else if (ConstraintCode == "o") 807*06f32e7eSjoerg return InlineAsm::Constraint_o; 808*06f32e7eSjoerg else if (ConstraintCode == "Q") 809*06f32e7eSjoerg return InlineAsm::Constraint_Q; 810*06f32e7eSjoerg else if (ConstraintCode == "Z") 811*06f32e7eSjoerg return InlineAsm::Constraint_Z; 812*06f32e7eSjoerg else if (ConstraintCode == "Zy") 813*06f32e7eSjoerg return InlineAsm::Constraint_Zy; 814*06f32e7eSjoerg return TargetLowering::getInlineAsmMemConstraint(ConstraintCode); 815*06f32e7eSjoerg } 816*06f32e7eSjoerg 817*06f32e7eSjoerg /// isLegalAddressingMode - Return true if the addressing mode represented 818*06f32e7eSjoerg /// by AM is legal for this target, for a load/store of the specified type. 819*06f32e7eSjoerg bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, 820*06f32e7eSjoerg Type *Ty, unsigned AS, 821*06f32e7eSjoerg Instruction *I = nullptr) const override; 822*06f32e7eSjoerg 823*06f32e7eSjoerg /// isLegalICmpImmediate - Return true if the specified immediate is legal 824*06f32e7eSjoerg /// icmp immediate, that is the target has icmp instructions which can 825*06f32e7eSjoerg /// compare a register against the immediate without having to materialize 826*06f32e7eSjoerg /// the immediate into a register. 827*06f32e7eSjoerg bool isLegalICmpImmediate(int64_t Imm) const override; 828*06f32e7eSjoerg 829*06f32e7eSjoerg /// isLegalAddImmediate - Return true if the specified immediate is legal 830*06f32e7eSjoerg /// add immediate, that is the target has add instructions which can 831*06f32e7eSjoerg /// add a register and the immediate without having to materialize 832*06f32e7eSjoerg /// the immediate into a register. 833*06f32e7eSjoerg bool isLegalAddImmediate(int64_t Imm) const override; 834*06f32e7eSjoerg 835*06f32e7eSjoerg /// isTruncateFree - Return true if it's free to truncate a value of 836*06f32e7eSjoerg /// type Ty1 to type Ty2. e.g. On PPC it's free to truncate a i64 value in 837*06f32e7eSjoerg /// register X1 to i32 by referencing its sub-register R1. 838*06f32e7eSjoerg bool isTruncateFree(Type *Ty1, Type *Ty2) const override; 839*06f32e7eSjoerg bool isTruncateFree(EVT VT1, EVT VT2) const override; 840*06f32e7eSjoerg 841*06f32e7eSjoerg bool isZExtFree(SDValue Val, EVT VT2) const override; 842*06f32e7eSjoerg 843*06f32e7eSjoerg bool isFPExtFree(EVT DestVT, EVT SrcVT) const override; 844*06f32e7eSjoerg 845*06f32e7eSjoerg /// Returns true if it is beneficial to convert a load of a constant 846*06f32e7eSjoerg /// to just the constant itself. 847*06f32e7eSjoerg bool shouldConvertConstantLoadToIntImm(const APInt &Imm, 848*06f32e7eSjoerg Type *Ty) const override; 849*06f32e7eSjoerg 850*06f32e7eSjoerg bool convertSelectOfConstantsToMath(EVT VT) const override { 851*06f32e7eSjoerg return true; 852*06f32e7eSjoerg } 853*06f32e7eSjoerg 854*06f32e7eSjoerg bool isDesirableToTransformToIntegerOp(unsigned Opc, 855*06f32e7eSjoerg EVT VT) const override { 856*06f32e7eSjoerg // Only handle float load/store pair because float(fpr) load/store 857*06f32e7eSjoerg // instruction has more cycles than integer(gpr) load/store in PPC. 858*06f32e7eSjoerg if (Opc != ISD::LOAD && Opc != ISD::STORE) 859*06f32e7eSjoerg return false; 860*06f32e7eSjoerg if (VT != MVT::f32 && VT != MVT::f64) 861*06f32e7eSjoerg return false; 862*06f32e7eSjoerg 863*06f32e7eSjoerg return true; 864*06f32e7eSjoerg } 865*06f32e7eSjoerg 866*06f32e7eSjoerg // Returns true if the address of the global is stored in TOC entry. 867*06f32e7eSjoerg bool isAccessedAsGotIndirect(SDValue N) const; 868*06f32e7eSjoerg 869*06f32e7eSjoerg bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override; 870*06f32e7eSjoerg 871*06f32e7eSjoerg bool getTgtMemIntrinsic(IntrinsicInfo &Info, 872*06f32e7eSjoerg const CallInst &I, 873*06f32e7eSjoerg MachineFunction &MF, 874*06f32e7eSjoerg unsigned Intrinsic) const override; 875*06f32e7eSjoerg 876*06f32e7eSjoerg /// getOptimalMemOpType - Returns the target specific optimal type for load 877*06f32e7eSjoerg /// and store operations as a result of memset, memcpy, and memmove 878*06f32e7eSjoerg /// lowering. If DstAlign is zero that means it's safe to destination 879*06f32e7eSjoerg /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it 880*06f32e7eSjoerg /// means there isn't a need to check it against alignment requirement, 881*06f32e7eSjoerg /// probably because the source does not need to be loaded. If 'IsMemset' is 882*06f32e7eSjoerg /// true, that means it's expanding a memset. If 'ZeroMemset' is true, that 883*06f32e7eSjoerg /// means it's a memset of zero. 'MemcpyStrSrc' indicates whether the memcpy 884*06f32e7eSjoerg /// source is constant so it does not need to be loaded. 885*06f32e7eSjoerg /// It returns EVT::Other if the type should be determined using generic 886*06f32e7eSjoerg /// target-independent logic. 887*06f32e7eSjoerg EVT 888*06f32e7eSjoerg getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, 889*06f32e7eSjoerg bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc, 890*06f32e7eSjoerg const AttributeList &FuncAttributes) const override; 891*06f32e7eSjoerg 892*06f32e7eSjoerg /// Is unaligned memory access allowed for the given type, and is it fast 893*06f32e7eSjoerg /// relative to software emulation. 894*06f32e7eSjoerg bool allowsMisalignedMemoryAccesses( 895*06f32e7eSjoerg EVT VT, unsigned AddrSpace, unsigned Align = 1, 896*06f32e7eSjoerg MachineMemOperand::Flags Flags = MachineMemOperand::MONone, 897*06f32e7eSjoerg bool *Fast = nullptr) const override; 898*06f32e7eSjoerg 899*06f32e7eSjoerg /// isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster 900*06f32e7eSjoerg /// than a pair of fmul and fadd instructions. fmuladd intrinsics will be 901*06f32e7eSjoerg /// expanded to FMAs when this method returns true, otherwise fmuladd is 902*06f32e7eSjoerg /// expanded to fmul + fadd. 903*06f32e7eSjoerg bool isFMAFasterThanFMulAndFAdd(EVT VT) const override; 904*06f32e7eSjoerg 905*06f32e7eSjoerg const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override; 906*06f32e7eSjoerg 907*06f32e7eSjoerg // Should we expand the build vector with shuffles? 908*06f32e7eSjoerg bool 909*06f32e7eSjoerg shouldExpandBuildVectorWithShuffles(EVT VT, 910*06f32e7eSjoerg unsigned DefinedValues) const override; 911*06f32e7eSjoerg 912*06f32e7eSjoerg /// createFastISel - This method returns a target-specific FastISel object, 913*06f32e7eSjoerg /// or null if the target does not support "fast" instruction selection. 914*06f32e7eSjoerg FastISel *createFastISel(FunctionLoweringInfo &FuncInfo, 915*06f32e7eSjoerg const TargetLibraryInfo *LibInfo) const override; 916*06f32e7eSjoerg 917*06f32e7eSjoerg /// Returns true if an argument of type Ty needs to be passed in a 918*06f32e7eSjoerg /// contiguous block of registers in calling convention CallConv. 919*06f32e7eSjoerg bool functionArgumentNeedsConsecutiveRegisters( 920*06f32e7eSjoerg Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override { 921*06f32e7eSjoerg // We support any array type as "consecutive" block in the parameter 922*06f32e7eSjoerg // save area. The element type defines the alignment requirement and 923*06f32e7eSjoerg // whether the argument should go in GPRs, FPRs, or VRs if available. 924*06f32e7eSjoerg // 925*06f32e7eSjoerg // Note that clang uses this capability both to implement the ELFv2 926*06f32e7eSjoerg // homogeneous float/vector aggregate ABI, and to avoid having to use 927*06f32e7eSjoerg // "byval" when passing aggregates that might fully fit in registers. 928*06f32e7eSjoerg return Ty->isArrayTy(); 929*06f32e7eSjoerg } 930*06f32e7eSjoerg 931*06f32e7eSjoerg /// If a physical register, this returns the register that receives the 932*06f32e7eSjoerg /// exception address on entry to an EH pad. 933*06f32e7eSjoerg unsigned 934*06f32e7eSjoerg getExceptionPointerRegister(const Constant *PersonalityFn) const override; 935*06f32e7eSjoerg 936*06f32e7eSjoerg /// If a physical register, this returns the register that receives the 937*06f32e7eSjoerg /// exception typeid on entry to a landing pad. 938*06f32e7eSjoerg unsigned 939*06f32e7eSjoerg getExceptionSelectorRegister(const Constant *PersonalityFn) const override; 940*06f32e7eSjoerg 941*06f32e7eSjoerg /// Override to support customized stack guard loading. 942*06f32e7eSjoerg bool useLoadStackGuardNode() const override; 943*06f32e7eSjoerg void insertSSPDeclarations(Module &M) const override; 944*06f32e7eSjoerg 945*06f32e7eSjoerg bool isFPImmLegal(const APFloat &Imm, EVT VT, 946*06f32e7eSjoerg bool ForCodeSize) const override; 947*06f32e7eSjoerg 948*06f32e7eSjoerg unsigned getJumpTableEncoding() const override; 949*06f32e7eSjoerg bool isJumpTableRelative() const override; 950*06f32e7eSjoerg SDValue getPICJumpTableRelocBase(SDValue Table, 951*06f32e7eSjoerg SelectionDAG &DAG) const override; 952*06f32e7eSjoerg const MCExpr *getPICJumpTableRelocBaseExpr(const MachineFunction *MF, 953*06f32e7eSjoerg unsigned JTI, 954*06f32e7eSjoerg MCContext &Ctx) const override; 955*06f32e7eSjoerg 956*06f32e7eSjoerg private: 957*06f32e7eSjoerg struct ReuseLoadInfo { 958*06f32e7eSjoerg SDValue Ptr; 959*06f32e7eSjoerg SDValue Chain; 960*06f32e7eSjoerg SDValue ResChain; 961*06f32e7eSjoerg MachinePointerInfo MPI; 962*06f32e7eSjoerg bool IsDereferenceable = false; 963*06f32e7eSjoerg bool IsInvariant = false; 964*06f32e7eSjoerg unsigned Alignment = 0; 965*06f32e7eSjoerg AAMDNodes AAInfo; 966*06f32e7eSjoerg const MDNode *Ranges = nullptr; 967*06f32e7eSjoerg 968*06f32e7eSjoerg ReuseLoadInfo() = default; 969*06f32e7eSjoerg 970*06f32e7eSjoerg MachineMemOperand::Flags MMOFlags() const { 971*06f32e7eSjoerg MachineMemOperand::Flags F = MachineMemOperand::MONone; 972*06f32e7eSjoerg if (IsDereferenceable) 973*06f32e7eSjoerg F |= MachineMemOperand::MODereferenceable; 974*06f32e7eSjoerg if (IsInvariant) 975*06f32e7eSjoerg F |= MachineMemOperand::MOInvariant; 976*06f32e7eSjoerg return F; 977*06f32e7eSjoerg } 978*06f32e7eSjoerg }; 979*06f32e7eSjoerg 980*06f32e7eSjoerg bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override { 981*06f32e7eSjoerg // Addrspacecasts are always noops. 982*06f32e7eSjoerg return true; 983*06f32e7eSjoerg } 984*06f32e7eSjoerg 985*06f32e7eSjoerg bool canReuseLoadAddress(SDValue Op, EVT MemVT, ReuseLoadInfo &RLI, 986*06f32e7eSjoerg SelectionDAG &DAG, 987*06f32e7eSjoerg ISD::LoadExtType ET = ISD::NON_EXTLOAD) const; 988*06f32e7eSjoerg void spliceIntoChain(SDValue ResChain, SDValue NewResChain, 989*06f32e7eSjoerg SelectionDAG &DAG) const; 990*06f32e7eSjoerg 991*06f32e7eSjoerg void LowerFP_TO_INTForReuse(SDValue Op, ReuseLoadInfo &RLI, 992*06f32e7eSjoerg SelectionDAG &DAG, const SDLoc &dl) const; 993*06f32e7eSjoerg SDValue LowerFP_TO_INTDirectMove(SDValue Op, SelectionDAG &DAG, 994*06f32e7eSjoerg const SDLoc &dl) const; 995*06f32e7eSjoerg 996*06f32e7eSjoerg bool directMoveIsProfitable(const SDValue &Op) const; 997*06f32e7eSjoerg SDValue LowerINT_TO_FPDirectMove(SDValue Op, SelectionDAG &DAG, 998*06f32e7eSjoerg const SDLoc &dl) const; 999*06f32e7eSjoerg 1000*06f32e7eSjoerg SDValue LowerINT_TO_FPVector(SDValue Op, SelectionDAG &DAG, 1001*06f32e7eSjoerg const SDLoc &dl) const; 1002*06f32e7eSjoerg 1003*06f32e7eSjoerg SDValue LowerTRUNCATEVector(SDValue Op, SelectionDAG &DAG) const; 1004*06f32e7eSjoerg 1005*06f32e7eSjoerg SDValue getFramePointerFrameIndex(SelectionDAG & DAG) const; 1006*06f32e7eSjoerg SDValue getReturnAddrFrameIndex(SelectionDAG & DAG) const; 1007*06f32e7eSjoerg 1008*06f32e7eSjoerg bool 1009*06f32e7eSjoerg IsEligibleForTailCallOptimization(SDValue Callee, 1010*06f32e7eSjoerg CallingConv::ID CalleeCC, 1011*06f32e7eSjoerg bool isVarArg, 1012*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1013*06f32e7eSjoerg SelectionDAG& DAG) const; 1014*06f32e7eSjoerg 1015*06f32e7eSjoerg bool 1016*06f32e7eSjoerg IsEligibleForTailCallOptimization_64SVR4( 1017*06f32e7eSjoerg SDValue Callee, 1018*06f32e7eSjoerg CallingConv::ID CalleeCC, 1019*06f32e7eSjoerg ImmutableCallSite CS, 1020*06f32e7eSjoerg bool isVarArg, 1021*06f32e7eSjoerg const SmallVectorImpl<ISD::OutputArg> &Outs, 1022*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1023*06f32e7eSjoerg SelectionDAG& DAG) const; 1024*06f32e7eSjoerg 1025*06f32e7eSjoerg SDValue EmitTailCallLoadFPAndRetAddr(SelectionDAG &DAG, int SPDiff, 1026*06f32e7eSjoerg SDValue Chain, SDValue &LROpOut, 1027*06f32e7eSjoerg SDValue &FPOpOut, 1028*06f32e7eSjoerg const SDLoc &dl) const; 1029*06f32e7eSjoerg 1030*06f32e7eSjoerg SDValue getTOCEntry(SelectionDAG &DAG, const SDLoc &dl, SDValue GA) const; 1031*06f32e7eSjoerg 1032*06f32e7eSjoerg SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; 1033*06f32e7eSjoerg SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const; 1034*06f32e7eSjoerg SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; 1035*06f32e7eSjoerg SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; 1036*06f32e7eSjoerg SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; 1037*06f32e7eSjoerg SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; 1038*06f32e7eSjoerg SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const; 1039*06f32e7eSjoerg SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const; 1040*06f32e7eSjoerg SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const; 1041*06f32e7eSjoerg SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const; 1042*06f32e7eSjoerg SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const; 1043*06f32e7eSjoerg SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const; 1044*06f32e7eSjoerg SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const; 1045*06f32e7eSjoerg SDValue LowerSTACKRESTORE(SDValue Op, SelectionDAG &DAG) const; 1046*06f32e7eSjoerg SDValue LowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const; 1047*06f32e7eSjoerg SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; 1048*06f32e7eSjoerg SDValue LowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const; 1049*06f32e7eSjoerg SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const; 1050*06f32e7eSjoerg SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const; 1051*06f32e7eSjoerg SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const; 1052*06f32e7eSjoerg SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; 1053*06f32e7eSjoerg SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG, 1054*06f32e7eSjoerg const SDLoc &dl) const; 1055*06f32e7eSjoerg SDValue LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const; 1056*06f32e7eSjoerg SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const; 1057*06f32e7eSjoerg SDValue LowerSHL_PARTS(SDValue Op, SelectionDAG &DAG) const; 1058*06f32e7eSjoerg SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const; 1059*06f32e7eSjoerg SDValue LowerSRA_PARTS(SDValue Op, SelectionDAG &DAG) const; 1060*06f32e7eSjoerg SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const; 1061*06f32e7eSjoerg SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const; 1062*06f32e7eSjoerg SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 1063*06f32e7eSjoerg SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 1064*06f32e7eSjoerg SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const; 1065*06f32e7eSjoerg SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const; 1066*06f32e7eSjoerg SDValue LowerREM(SDValue Op, SelectionDAG &DAG) const; 1067*06f32e7eSjoerg SDValue LowerBSWAP(SDValue Op, SelectionDAG &DAG) const; 1068*06f32e7eSjoerg SDValue LowerATOMIC_CMP_SWAP(SDValue Op, SelectionDAG &DAG) const; 1069*06f32e7eSjoerg SDValue LowerSCALAR_TO_VECTOR(SDValue Op, SelectionDAG &DAG) const; 1070*06f32e7eSjoerg SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const; 1071*06f32e7eSjoerg SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const; 1072*06f32e7eSjoerg SDValue LowerABS(SDValue Op, SelectionDAG &DAG) const; 1073*06f32e7eSjoerg SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const; 1074*06f32e7eSjoerg 1075*06f32e7eSjoerg SDValue LowerVectorLoad(SDValue Op, SelectionDAG &DAG) const; 1076*06f32e7eSjoerg SDValue LowerVectorStore(SDValue Op, SelectionDAG &DAG) const; 1077*06f32e7eSjoerg 1078*06f32e7eSjoerg SDValue LowerCallResult(SDValue Chain, SDValue InFlag, 1079*06f32e7eSjoerg CallingConv::ID CallConv, bool isVarArg, 1080*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1081*06f32e7eSjoerg const SDLoc &dl, SelectionDAG &DAG, 1082*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals) const; 1083*06f32e7eSjoerg SDValue FinishCall(CallingConv::ID CallConv, const SDLoc &dl, 1084*06f32e7eSjoerg bool isTailCall, bool isVarArg, bool isPatchPoint, 1085*06f32e7eSjoerg bool hasNest, SelectionDAG &DAG, 1086*06f32e7eSjoerg SmallVector<std::pair<unsigned, SDValue>, 8> &RegsToPass, 1087*06f32e7eSjoerg SDValue InFlag, SDValue Chain, SDValue CallSeqStart, 1088*06f32e7eSjoerg SDValue &Callee, int SPDiff, unsigned NumBytes, 1089*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1090*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals, 1091*06f32e7eSjoerg ImmutableCallSite CS) const; 1092*06f32e7eSjoerg 1093*06f32e7eSjoerg SDValue 1094*06f32e7eSjoerg LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 1095*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1096*06f32e7eSjoerg const SDLoc &dl, SelectionDAG &DAG, 1097*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals) const override; 1098*06f32e7eSjoerg 1099*06f32e7eSjoerg SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, 1100*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals) const override; 1101*06f32e7eSjoerg 1102*06f32e7eSjoerg bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, 1103*06f32e7eSjoerg bool isVarArg, 1104*06f32e7eSjoerg const SmallVectorImpl<ISD::OutputArg> &Outs, 1105*06f32e7eSjoerg LLVMContext &Context) const override; 1106*06f32e7eSjoerg 1107*06f32e7eSjoerg SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 1108*06f32e7eSjoerg const SmallVectorImpl<ISD::OutputArg> &Outs, 1109*06f32e7eSjoerg const SmallVectorImpl<SDValue> &OutVals, 1110*06f32e7eSjoerg const SDLoc &dl, SelectionDAG &DAG) const override; 1111*06f32e7eSjoerg 1112*06f32e7eSjoerg SDValue extendArgForPPC64(ISD::ArgFlagsTy Flags, EVT ObjectVT, 1113*06f32e7eSjoerg SelectionDAG &DAG, SDValue ArgVal, 1114*06f32e7eSjoerg const SDLoc &dl) const; 1115*06f32e7eSjoerg 1116*06f32e7eSjoerg SDValue LowerFormalArguments_Darwin( 1117*06f32e7eSjoerg SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 1118*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl, 1119*06f32e7eSjoerg SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const; 1120*06f32e7eSjoerg SDValue LowerFormalArguments_64SVR4( 1121*06f32e7eSjoerg SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 1122*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl, 1123*06f32e7eSjoerg SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const; 1124*06f32e7eSjoerg SDValue LowerFormalArguments_32SVR4( 1125*06f32e7eSjoerg SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 1126*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl, 1127*06f32e7eSjoerg SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const; 1128*06f32e7eSjoerg 1129*06f32e7eSjoerg SDValue createMemcpyOutsideCallSeq(SDValue Arg, SDValue PtrOff, 1130*06f32e7eSjoerg SDValue CallSeqStart, 1131*06f32e7eSjoerg ISD::ArgFlagsTy Flags, SelectionDAG &DAG, 1132*06f32e7eSjoerg const SDLoc &dl) const; 1133*06f32e7eSjoerg 1134*06f32e7eSjoerg SDValue LowerCall_Darwin(SDValue Chain, SDValue Callee, 1135*06f32e7eSjoerg CallingConv::ID CallConv, bool isVarArg, 1136*06f32e7eSjoerg bool isTailCall, bool isPatchPoint, 1137*06f32e7eSjoerg const SmallVectorImpl<ISD::OutputArg> &Outs, 1138*06f32e7eSjoerg const SmallVectorImpl<SDValue> &OutVals, 1139*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1140*06f32e7eSjoerg const SDLoc &dl, SelectionDAG &DAG, 1141*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals, 1142*06f32e7eSjoerg ImmutableCallSite CS) const; 1143*06f32e7eSjoerg SDValue LowerCall_64SVR4(SDValue Chain, SDValue Callee, 1144*06f32e7eSjoerg CallingConv::ID CallConv, bool isVarArg, 1145*06f32e7eSjoerg bool isTailCall, bool isPatchPoint, 1146*06f32e7eSjoerg const SmallVectorImpl<ISD::OutputArg> &Outs, 1147*06f32e7eSjoerg const SmallVectorImpl<SDValue> &OutVals, 1148*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1149*06f32e7eSjoerg const SDLoc &dl, SelectionDAG &DAG, 1150*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals, 1151*06f32e7eSjoerg ImmutableCallSite CS) const; 1152*06f32e7eSjoerg SDValue LowerCall_32SVR4(SDValue Chain, SDValue Callee, 1153*06f32e7eSjoerg CallingConv::ID CallConv, bool isVarArg, 1154*06f32e7eSjoerg bool isTailCall, bool isPatchPoint, 1155*06f32e7eSjoerg const SmallVectorImpl<ISD::OutputArg> &Outs, 1156*06f32e7eSjoerg const SmallVectorImpl<SDValue> &OutVals, 1157*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1158*06f32e7eSjoerg const SDLoc &dl, SelectionDAG &DAG, 1159*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals, 1160*06f32e7eSjoerg ImmutableCallSite CS) const; 1161*06f32e7eSjoerg SDValue LowerCall_AIX(SDValue Chain, SDValue Callee, 1162*06f32e7eSjoerg CallingConv::ID CallConv, bool isVarArg, 1163*06f32e7eSjoerg bool isTailCall, bool isPatchPoint, 1164*06f32e7eSjoerg const SmallVectorImpl<ISD::OutputArg> &Outs, 1165*06f32e7eSjoerg const SmallVectorImpl<SDValue> &OutVals, 1166*06f32e7eSjoerg const SmallVectorImpl<ISD::InputArg> &Ins, 1167*06f32e7eSjoerg const SDLoc &dl, SelectionDAG &DAG, 1168*06f32e7eSjoerg SmallVectorImpl<SDValue> &InVals, 1169*06f32e7eSjoerg ImmutableCallSite CS) const; 1170*06f32e7eSjoerg 1171*06f32e7eSjoerg SDValue lowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const; 1172*06f32e7eSjoerg SDValue lowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const; 1173*06f32e7eSjoerg SDValue LowerBITCAST(SDValue Op, SelectionDAG &DAG) const; 1174*06f32e7eSjoerg 1175*06f32e7eSjoerg SDValue DAGCombineExtBoolTrunc(SDNode *N, DAGCombinerInfo &DCI) const; 1176*06f32e7eSjoerg SDValue DAGCombineBuildVector(SDNode *N, DAGCombinerInfo &DCI) const; 1177*06f32e7eSjoerg SDValue DAGCombineTruncBoolExt(SDNode *N, DAGCombinerInfo &DCI) const; 1178*06f32e7eSjoerg SDValue combineStoreFPToInt(SDNode *N, DAGCombinerInfo &DCI) const; 1179*06f32e7eSjoerg SDValue combineFPToIntToFP(SDNode *N, DAGCombinerInfo &DCI) const; 1180*06f32e7eSjoerg SDValue combineSHL(SDNode *N, DAGCombinerInfo &DCI) const; 1181*06f32e7eSjoerg SDValue combineSRA(SDNode *N, DAGCombinerInfo &DCI) const; 1182*06f32e7eSjoerg SDValue combineSRL(SDNode *N, DAGCombinerInfo &DCI) const; 1183*06f32e7eSjoerg SDValue combineMUL(SDNode *N, DAGCombinerInfo &DCI) const; 1184*06f32e7eSjoerg SDValue combineADD(SDNode *N, DAGCombinerInfo &DCI) const; 1185*06f32e7eSjoerg SDValue combineTRUNCATE(SDNode *N, DAGCombinerInfo &DCI) const; 1186*06f32e7eSjoerg SDValue combineSetCC(SDNode *N, DAGCombinerInfo &DCI) const; 1187*06f32e7eSjoerg SDValue combineABS(SDNode *N, DAGCombinerInfo &DCI) const; 1188*06f32e7eSjoerg SDValue combineVSelect(SDNode *N, DAGCombinerInfo &DCI) const; 1189*06f32e7eSjoerg SDValue combineVReverseMemOP(ShuffleVectorSDNode *SVN, LSBaseSDNode *LSBase, 1190*06f32e7eSjoerg DAGCombinerInfo &DCI) const; 1191*06f32e7eSjoerg 1192*06f32e7eSjoerg /// ConvertSETCCToSubtract - looks at SETCC that compares ints. It replaces 1193*06f32e7eSjoerg /// SETCC with integer subtraction when (1) there is a legal way of doing it 1194*06f32e7eSjoerg /// (2) keeping the result of comparison in GPR has performance benefit. 1195*06f32e7eSjoerg SDValue ConvertSETCCToSubtract(SDNode *N, DAGCombinerInfo &DCI) const; 1196*06f32e7eSjoerg 1197*06f32e7eSjoerg SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, 1198*06f32e7eSjoerg int &RefinementSteps, bool &UseOneConstNR, 1199*06f32e7eSjoerg bool Reciprocal) const override; 1200*06f32e7eSjoerg SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, 1201*06f32e7eSjoerg int &RefinementSteps) const override; 1202*06f32e7eSjoerg unsigned combineRepeatedFPDivisors() const override; 1203*06f32e7eSjoerg 1204*06f32e7eSjoerg SDValue 1205*06f32e7eSjoerg combineElementTruncationToVectorTruncation(SDNode *N, 1206*06f32e7eSjoerg DAGCombinerInfo &DCI) const; 1207*06f32e7eSjoerg 1208*06f32e7eSjoerg /// lowerToVINSERTH - Return the SDValue if this VECTOR_SHUFFLE can be 1209*06f32e7eSjoerg /// handled by the VINSERTH instruction introduced in ISA 3.0. This is 1210*06f32e7eSjoerg /// essentially any shuffle of v8i16 vectors that just inserts one element 1211*06f32e7eSjoerg /// from one vector into the other. 1212*06f32e7eSjoerg SDValue lowerToVINSERTH(ShuffleVectorSDNode *N, SelectionDAG &DAG) const; 1213*06f32e7eSjoerg 1214*06f32e7eSjoerg /// lowerToVINSERTB - Return the SDValue if this VECTOR_SHUFFLE can be 1215*06f32e7eSjoerg /// handled by the VINSERTB instruction introduced in ISA 3.0. This is 1216*06f32e7eSjoerg /// essentially v16i8 vector version of VINSERTH. 1217*06f32e7eSjoerg SDValue lowerToVINSERTB(ShuffleVectorSDNode *N, SelectionDAG &DAG) const; 1218*06f32e7eSjoerg 1219*06f32e7eSjoerg // Return whether the call instruction can potentially be optimized to a 1220*06f32e7eSjoerg // tail call. This will cause the optimizers to attempt to move, or 1221*06f32e7eSjoerg // duplicate return instructions to help enable tail call optimizations. 1222*06f32e7eSjoerg bool mayBeEmittedAsTailCall(const CallInst *CI) const override; 1223*06f32e7eSjoerg bool hasBitPreservingFPLogic(EVT VT) const override; 1224*06f32e7eSjoerg bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override; 1225*06f32e7eSjoerg }; // end class PPCTargetLowering 1226*06f32e7eSjoerg 1227*06f32e7eSjoerg namespace PPC { 1228*06f32e7eSjoerg 1229*06f32e7eSjoerg FastISel *createFastISel(FunctionLoweringInfo &FuncInfo, 1230*06f32e7eSjoerg const TargetLibraryInfo *LibInfo); 1231*06f32e7eSjoerg 1232*06f32e7eSjoerg } // end namespace PPC 1233*06f32e7eSjoerg 1234*06f32e7eSjoerg bool isIntS16Immediate(SDNode *N, int16_t &Imm); 1235*06f32e7eSjoerg bool isIntS16Immediate(SDValue Op, int16_t &Imm); 1236*06f32e7eSjoerg 1237*06f32e7eSjoerg } // end namespace llvm 1238*06f32e7eSjoerg 1239*06f32e7eSjoerg #endif // LLVM_TARGET_POWERPC_PPC32ISELLOWERING_H 1240