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