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