xref: /aosp_15_r20/external/llvm/lib/Target/X86/X86ISelLowering.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- X86ISelLowering.h - X86 DAG Lowering Interface ----------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file defines the interfaces that X86 uses to lower LLVM code into a
11*9880d681SAndroid Build Coastguard Worker // selection DAG.
12*9880d681SAndroid Build Coastguard Worker //
13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
14*9880d681SAndroid Build Coastguard Worker 
15*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_X86_X86ISELLOWERING_H
16*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_X86_X86ISELLOWERING_H
17*9880d681SAndroid Build Coastguard Worker 
18*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/CallingConvLower.h"
19*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/SelectionDAG.h"
20*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h"
21*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetOptions.h"
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker namespace llvm {
24*9880d681SAndroid Build Coastguard Worker   class X86Subtarget;
25*9880d681SAndroid Build Coastguard Worker   class X86TargetMachine;
26*9880d681SAndroid Build Coastguard Worker 
27*9880d681SAndroid Build Coastguard Worker   namespace X86ISD {
28*9880d681SAndroid Build Coastguard Worker     // X86 Specific DAG Nodes
29*9880d681SAndroid Build Coastguard Worker     enum NodeType : unsigned {
30*9880d681SAndroid Build Coastguard Worker       // Start the numbering where the builtin ops leave off.
31*9880d681SAndroid Build Coastguard Worker       FIRST_NUMBER = ISD::BUILTIN_OP_END,
32*9880d681SAndroid Build Coastguard Worker 
33*9880d681SAndroid Build Coastguard Worker       /// Bit scan forward.
34*9880d681SAndroid Build Coastguard Worker       BSF,
35*9880d681SAndroid Build Coastguard Worker       /// Bit scan reverse.
36*9880d681SAndroid Build Coastguard Worker       BSR,
37*9880d681SAndroid Build Coastguard Worker 
38*9880d681SAndroid Build Coastguard Worker       /// Double shift instructions. These correspond to
39*9880d681SAndroid Build Coastguard Worker       /// X86::SHLDxx and X86::SHRDxx instructions.
40*9880d681SAndroid Build Coastguard Worker       SHLD,
41*9880d681SAndroid Build Coastguard Worker       SHRD,
42*9880d681SAndroid Build Coastguard Worker 
43*9880d681SAndroid Build Coastguard Worker       /// Bitwise logical AND of floating point values. This corresponds
44*9880d681SAndroid Build Coastguard Worker       /// to X86::ANDPS or X86::ANDPD.
45*9880d681SAndroid Build Coastguard Worker       FAND,
46*9880d681SAndroid Build Coastguard Worker 
47*9880d681SAndroid Build Coastguard Worker       /// Bitwise logical OR of floating point values. This corresponds
48*9880d681SAndroid Build Coastguard Worker       /// to X86::ORPS or X86::ORPD.
49*9880d681SAndroid Build Coastguard Worker       FOR,
50*9880d681SAndroid Build Coastguard Worker 
51*9880d681SAndroid Build Coastguard Worker       /// Bitwise logical XOR of floating point values. This corresponds
52*9880d681SAndroid Build Coastguard Worker       /// to X86::XORPS or X86::XORPD.
53*9880d681SAndroid Build Coastguard Worker       FXOR,
54*9880d681SAndroid Build Coastguard Worker 
55*9880d681SAndroid Build Coastguard Worker       ///  Bitwise logical ANDNOT of floating point values. This
56*9880d681SAndroid Build Coastguard Worker       /// corresponds to X86::ANDNPS or X86::ANDNPD.
57*9880d681SAndroid Build Coastguard Worker       FANDN,
58*9880d681SAndroid Build Coastguard Worker 
59*9880d681SAndroid Build Coastguard Worker       /// These operations represent an abstract X86 call
60*9880d681SAndroid Build Coastguard Worker       /// instruction, which includes a bunch of information.  In particular the
61*9880d681SAndroid Build Coastguard Worker       /// operands of these node are:
62*9880d681SAndroid Build Coastguard Worker       ///
63*9880d681SAndroid Build Coastguard Worker       ///     #0 - The incoming token chain
64*9880d681SAndroid Build Coastguard Worker       ///     #1 - The callee
65*9880d681SAndroid Build Coastguard Worker       ///     #2 - The number of arg bytes the caller pushes on the stack.
66*9880d681SAndroid Build Coastguard Worker       ///     #3 - The number of arg bytes the callee pops off the stack.
67*9880d681SAndroid Build Coastguard Worker       ///     #4 - The value to pass in AL/AX/EAX (optional)
68*9880d681SAndroid Build Coastguard Worker       ///     #5 - The value to pass in DL/DX/EDX (optional)
69*9880d681SAndroid Build Coastguard Worker       ///
70*9880d681SAndroid Build Coastguard Worker       /// The result values of these nodes are:
71*9880d681SAndroid Build Coastguard Worker       ///
72*9880d681SAndroid Build Coastguard Worker       ///     #0 - The outgoing token chain
73*9880d681SAndroid Build Coastguard Worker       ///     #1 - The first register result value (optional)
74*9880d681SAndroid Build Coastguard Worker       ///     #2 - The second register result value (optional)
75*9880d681SAndroid Build Coastguard Worker       ///
76*9880d681SAndroid Build Coastguard Worker       CALL,
77*9880d681SAndroid Build Coastguard Worker 
78*9880d681SAndroid Build Coastguard Worker       /// This operation implements the lowering for readcyclecounter.
79*9880d681SAndroid Build Coastguard Worker       RDTSC_DAG,
80*9880d681SAndroid Build Coastguard Worker 
81*9880d681SAndroid Build Coastguard Worker       /// X86 Read Time-Stamp Counter and Processor ID.
82*9880d681SAndroid Build Coastguard Worker       RDTSCP_DAG,
83*9880d681SAndroid Build Coastguard Worker 
84*9880d681SAndroid Build Coastguard Worker       /// X86 Read Performance Monitoring Counters.
85*9880d681SAndroid Build Coastguard Worker       RDPMC_DAG,
86*9880d681SAndroid Build Coastguard Worker 
87*9880d681SAndroid Build Coastguard Worker       /// X86 compare and logical compare instructions.
88*9880d681SAndroid Build Coastguard Worker       CMP, COMI, UCOMI,
89*9880d681SAndroid Build Coastguard Worker 
90*9880d681SAndroid Build Coastguard Worker       /// X86 bit-test instructions.
91*9880d681SAndroid Build Coastguard Worker       BT,
92*9880d681SAndroid Build Coastguard Worker 
93*9880d681SAndroid Build Coastguard Worker       /// X86 SetCC. Operand 0 is condition code, and operand 1 is the EFLAGS
94*9880d681SAndroid Build Coastguard Worker       /// operand, usually produced by a CMP instruction.
95*9880d681SAndroid Build Coastguard Worker       SETCC,
96*9880d681SAndroid Build Coastguard Worker 
97*9880d681SAndroid Build Coastguard Worker       /// X86 Select
98*9880d681SAndroid Build Coastguard Worker       SELECT,
99*9880d681SAndroid Build Coastguard Worker 
100*9880d681SAndroid Build Coastguard Worker       // Same as SETCC except it's materialized with a sbb and the value is all
101*9880d681SAndroid Build Coastguard Worker       // one's or all zero's.
102*9880d681SAndroid Build Coastguard Worker       SETCC_CARRY,  // R = carry_bit ? ~0 : 0
103*9880d681SAndroid Build Coastguard Worker 
104*9880d681SAndroid Build Coastguard Worker       /// X86 FP SETCC, implemented with CMP{cc}SS/CMP{cc}SD.
105*9880d681SAndroid Build Coastguard Worker       /// Operands are two FP values to compare; result is a mask of
106*9880d681SAndroid Build Coastguard Worker       /// 0s or 1s.  Generally DTRT for C/C++ with NaNs.
107*9880d681SAndroid Build Coastguard Worker       FSETCC,
108*9880d681SAndroid Build Coastguard Worker 
109*9880d681SAndroid Build Coastguard Worker       /// X86 conditional moves. Operand 0 and operand 1 are the two values
110*9880d681SAndroid Build Coastguard Worker       /// to select from. Operand 2 is the condition code, and operand 3 is the
111*9880d681SAndroid Build Coastguard Worker       /// flag operand produced by a CMP or TEST instruction. It also writes a
112*9880d681SAndroid Build Coastguard Worker       /// flag result.
113*9880d681SAndroid Build Coastguard Worker       CMOV,
114*9880d681SAndroid Build Coastguard Worker 
115*9880d681SAndroid Build Coastguard Worker       /// X86 conditional branches. Operand 0 is the chain operand, operand 1
116*9880d681SAndroid Build Coastguard Worker       /// is the block to branch if condition is true, operand 2 is the
117*9880d681SAndroid Build Coastguard Worker       /// condition code, and operand 3 is the flag operand produced by a CMP
118*9880d681SAndroid Build Coastguard Worker       /// or TEST instruction.
119*9880d681SAndroid Build Coastguard Worker       BRCOND,
120*9880d681SAndroid Build Coastguard Worker 
121*9880d681SAndroid Build Coastguard Worker       /// Return with a flag operand. Operand 0 is the chain operand, operand
122*9880d681SAndroid Build Coastguard Worker       /// 1 is the number of bytes of stack to pop.
123*9880d681SAndroid Build Coastguard Worker       RET_FLAG,
124*9880d681SAndroid Build Coastguard Worker 
125*9880d681SAndroid Build Coastguard Worker       /// Return from interrupt. Operand 0 is the number of bytes to pop.
126*9880d681SAndroid Build Coastguard Worker       IRET,
127*9880d681SAndroid Build Coastguard Worker 
128*9880d681SAndroid Build Coastguard Worker       /// Repeat fill, corresponds to X86::REP_STOSx.
129*9880d681SAndroid Build Coastguard Worker       REP_STOS,
130*9880d681SAndroid Build Coastguard Worker 
131*9880d681SAndroid Build Coastguard Worker       /// Repeat move, corresponds to X86::REP_MOVSx.
132*9880d681SAndroid Build Coastguard Worker       REP_MOVS,
133*9880d681SAndroid Build Coastguard Worker 
134*9880d681SAndroid Build Coastguard Worker       /// On Darwin, this node represents the result of the popl
135*9880d681SAndroid Build Coastguard Worker       /// at function entry, used for PIC code.
136*9880d681SAndroid Build Coastguard Worker       GlobalBaseReg,
137*9880d681SAndroid Build Coastguard Worker 
138*9880d681SAndroid Build Coastguard Worker       /// A wrapper node for TargetConstantPool,
139*9880d681SAndroid Build Coastguard Worker       /// TargetExternalSymbol, and TargetGlobalAddress.
140*9880d681SAndroid Build Coastguard Worker       Wrapper,
141*9880d681SAndroid Build Coastguard Worker 
142*9880d681SAndroid Build Coastguard Worker       /// Special wrapper used under X86-64 PIC mode for RIP
143*9880d681SAndroid Build Coastguard Worker       /// relative displacements.
144*9880d681SAndroid Build Coastguard Worker       WrapperRIP,
145*9880d681SAndroid Build Coastguard Worker 
146*9880d681SAndroid Build Coastguard Worker       /// Copies a 64-bit value from the low word of an XMM vector
147*9880d681SAndroid Build Coastguard Worker       /// to an MMX vector.  If you think this is too close to the previous
148*9880d681SAndroid Build Coastguard Worker       /// mnemonic, so do I; blame Intel.
149*9880d681SAndroid Build Coastguard Worker       MOVDQ2Q,
150*9880d681SAndroid Build Coastguard Worker 
151*9880d681SAndroid Build Coastguard Worker       /// Copies a 32-bit value from the low word of a MMX
152*9880d681SAndroid Build Coastguard Worker       /// vector to a GPR.
153*9880d681SAndroid Build Coastguard Worker       MMX_MOVD2W,
154*9880d681SAndroid Build Coastguard Worker 
155*9880d681SAndroid Build Coastguard Worker       /// Copies a GPR into the low 32-bit word of a MMX vector
156*9880d681SAndroid Build Coastguard Worker       /// and zero out the high word.
157*9880d681SAndroid Build Coastguard Worker       MMX_MOVW2D,
158*9880d681SAndroid Build Coastguard Worker 
159*9880d681SAndroid Build Coastguard Worker       /// Extract an 8-bit value from a vector and zero extend it to
160*9880d681SAndroid Build Coastguard Worker       /// i32, corresponds to X86::PEXTRB.
161*9880d681SAndroid Build Coastguard Worker       PEXTRB,
162*9880d681SAndroid Build Coastguard Worker 
163*9880d681SAndroid Build Coastguard Worker       /// Extract a 16-bit value from a vector and zero extend it to
164*9880d681SAndroid Build Coastguard Worker       /// i32, corresponds to X86::PEXTRW.
165*9880d681SAndroid Build Coastguard Worker       PEXTRW,
166*9880d681SAndroid Build Coastguard Worker 
167*9880d681SAndroid Build Coastguard Worker       /// Insert any element of a 4 x float vector into any element
168*9880d681SAndroid Build Coastguard Worker       /// of a destination 4 x floatvector.
169*9880d681SAndroid Build Coastguard Worker       INSERTPS,
170*9880d681SAndroid Build Coastguard Worker 
171*9880d681SAndroid Build Coastguard Worker       /// Insert the lower 8-bits of a 32-bit value to a vector,
172*9880d681SAndroid Build Coastguard Worker       /// corresponds to X86::PINSRB.
173*9880d681SAndroid Build Coastguard Worker       PINSRB,
174*9880d681SAndroid Build Coastguard Worker 
175*9880d681SAndroid Build Coastguard Worker       /// Insert the lower 16-bits of a 32-bit value to a vector,
176*9880d681SAndroid Build Coastguard Worker       /// corresponds to X86::PINSRW.
177*9880d681SAndroid Build Coastguard Worker       PINSRW, MMX_PINSRW,
178*9880d681SAndroid Build Coastguard Worker 
179*9880d681SAndroid Build Coastguard Worker       /// Shuffle 16 8-bit values within a vector.
180*9880d681SAndroid Build Coastguard Worker       PSHUFB,
181*9880d681SAndroid Build Coastguard Worker 
182*9880d681SAndroid Build Coastguard Worker       /// Compute Sum of Absolute Differences.
183*9880d681SAndroid Build Coastguard Worker       PSADBW,
184*9880d681SAndroid Build Coastguard Worker       /// Compute Double Block Packed Sum-Absolute-Differences
185*9880d681SAndroid Build Coastguard Worker       DBPSADBW,
186*9880d681SAndroid Build Coastguard Worker 
187*9880d681SAndroid Build Coastguard Worker       /// Bitwise Logical AND NOT of Packed FP values.
188*9880d681SAndroid Build Coastguard Worker       ANDNP,
189*9880d681SAndroid Build Coastguard Worker 
190*9880d681SAndroid Build Coastguard Worker       /// Blend where the selector is an immediate.
191*9880d681SAndroid Build Coastguard Worker       BLENDI,
192*9880d681SAndroid Build Coastguard Worker 
193*9880d681SAndroid Build Coastguard Worker       /// Blend where the condition has been shrunk.
194*9880d681SAndroid Build Coastguard Worker       /// This is used to emphasize that the condition mask is
195*9880d681SAndroid Build Coastguard Worker       /// no more valid for generic VSELECT optimizations.
196*9880d681SAndroid Build Coastguard Worker       SHRUNKBLEND,
197*9880d681SAndroid Build Coastguard Worker 
198*9880d681SAndroid Build Coastguard Worker       /// Combined add and sub on an FP vector.
199*9880d681SAndroid Build Coastguard Worker       ADDSUB,
200*9880d681SAndroid Build Coastguard Worker 
201*9880d681SAndroid Build Coastguard Worker       //  FP vector ops with rounding mode.
202*9880d681SAndroid Build Coastguard Worker       FADD_RND,
203*9880d681SAndroid Build Coastguard Worker       FSUB_RND,
204*9880d681SAndroid Build Coastguard Worker       FMUL_RND,
205*9880d681SAndroid Build Coastguard Worker       FDIV_RND,
206*9880d681SAndroid Build Coastguard Worker       FMAX_RND,
207*9880d681SAndroid Build Coastguard Worker       FMIN_RND,
208*9880d681SAndroid Build Coastguard Worker       FSQRT_RND,
209*9880d681SAndroid Build Coastguard Worker 
210*9880d681SAndroid Build Coastguard Worker       // FP vector get exponent.
211*9880d681SAndroid Build Coastguard Worker       FGETEXP_RND,
212*9880d681SAndroid Build Coastguard Worker       // Extract Normalized Mantissas.
213*9880d681SAndroid Build Coastguard Worker       VGETMANT,
214*9880d681SAndroid Build Coastguard Worker       // FP Scale.
215*9880d681SAndroid Build Coastguard Worker       SCALEF,
216*9880d681SAndroid Build Coastguard Worker       SCALEFS,
217*9880d681SAndroid Build Coastguard Worker 
218*9880d681SAndroid Build Coastguard Worker       // Integer add/sub with unsigned saturation.
219*9880d681SAndroid Build Coastguard Worker       ADDUS,
220*9880d681SAndroid Build Coastguard Worker       SUBUS,
221*9880d681SAndroid Build Coastguard Worker 
222*9880d681SAndroid Build Coastguard Worker       // Integer add/sub with signed saturation.
223*9880d681SAndroid Build Coastguard Worker       ADDS,
224*9880d681SAndroid Build Coastguard Worker       SUBS,
225*9880d681SAndroid Build Coastguard Worker 
226*9880d681SAndroid Build Coastguard Worker       // Unsigned Integer average.
227*9880d681SAndroid Build Coastguard Worker       AVG,
228*9880d681SAndroid Build Coastguard Worker 
229*9880d681SAndroid Build Coastguard Worker       /// Integer horizontal add/sub.
230*9880d681SAndroid Build Coastguard Worker       HADD,
231*9880d681SAndroid Build Coastguard Worker       HSUB,
232*9880d681SAndroid Build Coastguard Worker 
233*9880d681SAndroid Build Coastguard Worker       /// Floating point horizontal add/sub.
234*9880d681SAndroid Build Coastguard Worker       FHADD,
235*9880d681SAndroid Build Coastguard Worker       FHSUB,
236*9880d681SAndroid Build Coastguard Worker 
237*9880d681SAndroid Build Coastguard Worker       // Integer absolute value
238*9880d681SAndroid Build Coastguard Worker       ABS,
239*9880d681SAndroid Build Coastguard Worker 
240*9880d681SAndroid Build Coastguard Worker       // Detect Conflicts Within a Vector
241*9880d681SAndroid Build Coastguard Worker       CONFLICT,
242*9880d681SAndroid Build Coastguard Worker 
243*9880d681SAndroid Build Coastguard Worker       /// Floating point max and min.
244*9880d681SAndroid Build Coastguard Worker       FMAX, FMIN,
245*9880d681SAndroid Build Coastguard Worker 
246*9880d681SAndroid Build Coastguard Worker       /// Commutative FMIN and FMAX.
247*9880d681SAndroid Build Coastguard Worker       FMAXC, FMINC,
248*9880d681SAndroid Build Coastguard Worker 
249*9880d681SAndroid Build Coastguard Worker       /// Floating point reciprocal-sqrt and reciprocal approximation.
250*9880d681SAndroid Build Coastguard Worker       /// Note that these typically require refinement
251*9880d681SAndroid Build Coastguard Worker       /// in order to obtain suitable precision.
252*9880d681SAndroid Build Coastguard Worker       FRSQRT, FRCP,
253*9880d681SAndroid Build Coastguard Worker       FRSQRTS, FRCPS,
254*9880d681SAndroid Build Coastguard Worker 
255*9880d681SAndroid Build Coastguard Worker       // Thread Local Storage.
256*9880d681SAndroid Build Coastguard Worker       TLSADDR,
257*9880d681SAndroid Build Coastguard Worker 
258*9880d681SAndroid Build Coastguard Worker       // Thread Local Storage. A call to get the start address
259*9880d681SAndroid Build Coastguard Worker       // of the TLS block for the current module.
260*9880d681SAndroid Build Coastguard Worker       TLSBASEADDR,
261*9880d681SAndroid Build Coastguard Worker 
262*9880d681SAndroid Build Coastguard Worker       // Thread Local Storage.  When calling to an OS provided
263*9880d681SAndroid Build Coastguard Worker       // thunk at the address from an earlier relocation.
264*9880d681SAndroid Build Coastguard Worker       TLSCALL,
265*9880d681SAndroid Build Coastguard Worker 
266*9880d681SAndroid Build Coastguard Worker       // Exception Handling helpers.
267*9880d681SAndroid Build Coastguard Worker       EH_RETURN,
268*9880d681SAndroid Build Coastguard Worker 
269*9880d681SAndroid Build Coastguard Worker       // SjLj exception handling setjmp.
270*9880d681SAndroid Build Coastguard Worker       EH_SJLJ_SETJMP,
271*9880d681SAndroid Build Coastguard Worker 
272*9880d681SAndroid Build Coastguard Worker       // SjLj exception handling longjmp.
273*9880d681SAndroid Build Coastguard Worker       EH_SJLJ_LONGJMP,
274*9880d681SAndroid Build Coastguard Worker 
275*9880d681SAndroid Build Coastguard Worker       // SjLj exception handling dispatch.
276*9880d681SAndroid Build Coastguard Worker       EH_SJLJ_SETUP_DISPATCH,
277*9880d681SAndroid Build Coastguard Worker 
278*9880d681SAndroid Build Coastguard Worker       /// Tail call return. See X86TargetLowering::LowerCall for
279*9880d681SAndroid Build Coastguard Worker       /// the list of operands.
280*9880d681SAndroid Build Coastguard Worker       TC_RETURN,
281*9880d681SAndroid Build Coastguard Worker 
282*9880d681SAndroid Build Coastguard Worker       // Vector move to low scalar and zero higher vector elements.
283*9880d681SAndroid Build Coastguard Worker       VZEXT_MOVL,
284*9880d681SAndroid Build Coastguard Worker 
285*9880d681SAndroid Build Coastguard Worker       // Vector integer zero-extend.
286*9880d681SAndroid Build Coastguard Worker       VZEXT,
287*9880d681SAndroid Build Coastguard Worker       // Vector integer signed-extend.
288*9880d681SAndroid Build Coastguard Worker       VSEXT,
289*9880d681SAndroid Build Coastguard Worker 
290*9880d681SAndroid Build Coastguard Worker       // Vector integer truncate.
291*9880d681SAndroid Build Coastguard Worker       VTRUNC,
292*9880d681SAndroid Build Coastguard Worker       // Vector integer truncate with unsigned/signed saturation.
293*9880d681SAndroid Build Coastguard Worker       VTRUNCUS, VTRUNCS,
294*9880d681SAndroid Build Coastguard Worker 
295*9880d681SAndroid Build Coastguard Worker       // Vector FP extend.
296*9880d681SAndroid Build Coastguard Worker       VFPEXT,
297*9880d681SAndroid Build Coastguard Worker 
298*9880d681SAndroid Build Coastguard Worker       // Vector FP round.
299*9880d681SAndroid Build Coastguard Worker       VFPROUND,
300*9880d681SAndroid Build Coastguard Worker 
301*9880d681SAndroid Build Coastguard Worker       // Vector signed/unsigned integer to double.
302*9880d681SAndroid Build Coastguard Worker       CVTDQ2PD, CVTUDQ2PD,
303*9880d681SAndroid Build Coastguard Worker 
304*9880d681SAndroid Build Coastguard Worker       // Convert a vector to mask, set bits base on MSB.
305*9880d681SAndroid Build Coastguard Worker       CVT2MASK,
306*9880d681SAndroid Build Coastguard Worker 
307*9880d681SAndroid Build Coastguard Worker       // 128-bit vector logical left / right shift
308*9880d681SAndroid Build Coastguard Worker       VSHLDQ, VSRLDQ,
309*9880d681SAndroid Build Coastguard Worker 
310*9880d681SAndroid Build Coastguard Worker       // Vector shift elements
311*9880d681SAndroid Build Coastguard Worker       VSHL, VSRL, VSRA,
312*9880d681SAndroid Build Coastguard Worker 
313*9880d681SAndroid Build Coastguard Worker       // Vector variable shift right arithmetic.
314*9880d681SAndroid Build Coastguard Worker       // Unlike ISD::SRA, in case shift count greater then element size
315*9880d681SAndroid Build Coastguard Worker       // use sign bit to fill destination data element.
316*9880d681SAndroid Build Coastguard Worker       VSRAV,
317*9880d681SAndroid Build Coastguard Worker 
318*9880d681SAndroid Build Coastguard Worker       // Vector shift elements by immediate
319*9880d681SAndroid Build Coastguard Worker       VSHLI, VSRLI, VSRAI,
320*9880d681SAndroid Build Coastguard Worker 
321*9880d681SAndroid Build Coastguard Worker       // Bit rotate by immediate
322*9880d681SAndroid Build Coastguard Worker       VROTLI, VROTRI,
323*9880d681SAndroid Build Coastguard Worker 
324*9880d681SAndroid Build Coastguard Worker       // Vector packed double/float comparison.
325*9880d681SAndroid Build Coastguard Worker       CMPP,
326*9880d681SAndroid Build Coastguard Worker 
327*9880d681SAndroid Build Coastguard Worker       // Vector integer comparisons.
328*9880d681SAndroid Build Coastguard Worker       PCMPEQ, PCMPGT,
329*9880d681SAndroid Build Coastguard Worker       // Vector integer comparisons, the result is in a mask vector.
330*9880d681SAndroid Build Coastguard Worker       PCMPEQM, PCMPGTM,
331*9880d681SAndroid Build Coastguard Worker 
332*9880d681SAndroid Build Coastguard Worker       MULTISHIFT,
333*9880d681SAndroid Build Coastguard Worker 
334*9880d681SAndroid Build Coastguard Worker       /// Vector comparison generating mask bits for fp and
335*9880d681SAndroid Build Coastguard Worker       /// integer signed and unsigned data types.
336*9880d681SAndroid Build Coastguard Worker       CMPM,
337*9880d681SAndroid Build Coastguard Worker       CMPMU,
338*9880d681SAndroid Build Coastguard Worker       // Vector comparison with rounding mode for FP values
339*9880d681SAndroid Build Coastguard Worker       CMPM_RND,
340*9880d681SAndroid Build Coastguard Worker 
341*9880d681SAndroid Build Coastguard Worker       // Arithmetic operations with FLAGS results.
342*9880d681SAndroid Build Coastguard Worker       ADD, SUB, ADC, SBB, SMUL,
343*9880d681SAndroid Build Coastguard Worker       INC, DEC, OR, XOR, AND,
344*9880d681SAndroid Build Coastguard Worker 
345*9880d681SAndroid Build Coastguard Worker       // Bit field extract.
346*9880d681SAndroid Build Coastguard Worker       BEXTR,
347*9880d681SAndroid Build Coastguard Worker 
348*9880d681SAndroid Build Coastguard Worker       // LOW, HI, FLAGS = umul LHS, RHS.
349*9880d681SAndroid Build Coastguard Worker       UMUL,
350*9880d681SAndroid Build Coastguard Worker 
351*9880d681SAndroid Build Coastguard Worker       // 8-bit SMUL/UMUL - AX, FLAGS = smul8/umul8 AL, RHS.
352*9880d681SAndroid Build Coastguard Worker       SMUL8, UMUL8,
353*9880d681SAndroid Build Coastguard Worker 
354*9880d681SAndroid Build Coastguard Worker       // 8-bit divrem that zero-extend the high result (AH).
355*9880d681SAndroid Build Coastguard Worker       UDIVREM8_ZEXT_HREG,
356*9880d681SAndroid Build Coastguard Worker       SDIVREM8_SEXT_HREG,
357*9880d681SAndroid Build Coastguard Worker 
358*9880d681SAndroid Build Coastguard Worker       // X86-specific multiply by immediate.
359*9880d681SAndroid Build Coastguard Worker       MUL_IMM,
360*9880d681SAndroid Build Coastguard Worker 
361*9880d681SAndroid Build Coastguard Worker       // Vector sign bit extraction.
362*9880d681SAndroid Build Coastguard Worker       MOVMSK,
363*9880d681SAndroid Build Coastguard Worker 
364*9880d681SAndroid Build Coastguard Worker       // Vector bitwise comparisons.
365*9880d681SAndroid Build Coastguard Worker       PTEST,
366*9880d681SAndroid Build Coastguard Worker 
367*9880d681SAndroid Build Coastguard Worker       // Vector packed fp sign bitwise comparisons.
368*9880d681SAndroid Build Coastguard Worker       TESTP,
369*9880d681SAndroid Build Coastguard Worker 
370*9880d681SAndroid Build Coastguard Worker       // Vector "test" in AVX-512, the result is in a mask vector.
371*9880d681SAndroid Build Coastguard Worker       TESTM,
372*9880d681SAndroid Build Coastguard Worker       TESTNM,
373*9880d681SAndroid Build Coastguard Worker 
374*9880d681SAndroid Build Coastguard Worker       // OR/AND test for masks.
375*9880d681SAndroid Build Coastguard Worker       KORTEST,
376*9880d681SAndroid Build Coastguard Worker       KTEST,
377*9880d681SAndroid Build Coastguard Worker 
378*9880d681SAndroid Build Coastguard Worker       // Several flavors of instructions with vector shuffle behaviors.
379*9880d681SAndroid Build Coastguard Worker       // Saturated signed/unnsigned packing.
380*9880d681SAndroid Build Coastguard Worker       PACKSS,
381*9880d681SAndroid Build Coastguard Worker       PACKUS,
382*9880d681SAndroid Build Coastguard Worker       // Intra-lane alignr.
383*9880d681SAndroid Build Coastguard Worker       PALIGNR,
384*9880d681SAndroid Build Coastguard Worker       // AVX512 inter-lane alignr.
385*9880d681SAndroid Build Coastguard Worker       VALIGN,
386*9880d681SAndroid Build Coastguard Worker       PSHUFD,
387*9880d681SAndroid Build Coastguard Worker       PSHUFHW,
388*9880d681SAndroid Build Coastguard Worker       PSHUFLW,
389*9880d681SAndroid Build Coastguard Worker       SHUFP,
390*9880d681SAndroid Build Coastguard Worker       //Shuffle Packed Values at 128-bit granularity.
391*9880d681SAndroid Build Coastguard Worker       SHUF128,
392*9880d681SAndroid Build Coastguard Worker       MOVDDUP,
393*9880d681SAndroid Build Coastguard Worker       MOVSHDUP,
394*9880d681SAndroid Build Coastguard Worker       MOVSLDUP,
395*9880d681SAndroid Build Coastguard Worker       MOVLHPS,
396*9880d681SAndroid Build Coastguard Worker       MOVLHPD,
397*9880d681SAndroid Build Coastguard Worker       MOVHLPS,
398*9880d681SAndroid Build Coastguard Worker       MOVLPS,
399*9880d681SAndroid Build Coastguard Worker       MOVLPD,
400*9880d681SAndroid Build Coastguard Worker       MOVSD,
401*9880d681SAndroid Build Coastguard Worker       MOVSS,
402*9880d681SAndroid Build Coastguard Worker       UNPCKL,
403*9880d681SAndroid Build Coastguard Worker       UNPCKH,
404*9880d681SAndroid Build Coastguard Worker       VPERMILPV,
405*9880d681SAndroid Build Coastguard Worker       VPERMILPI,
406*9880d681SAndroid Build Coastguard Worker       VPERMI,
407*9880d681SAndroid Build Coastguard Worker       VPERM2X128,
408*9880d681SAndroid Build Coastguard Worker 
409*9880d681SAndroid Build Coastguard Worker       // Variable Permute (VPERM).
410*9880d681SAndroid Build Coastguard Worker       // Res = VPERMV MaskV, V0
411*9880d681SAndroid Build Coastguard Worker       VPERMV,
412*9880d681SAndroid Build Coastguard Worker 
413*9880d681SAndroid Build Coastguard Worker       // 3-op Variable Permute (VPERMT2).
414*9880d681SAndroid Build Coastguard Worker       // Res = VPERMV3 V0, MaskV, V1
415*9880d681SAndroid Build Coastguard Worker       VPERMV3,
416*9880d681SAndroid Build Coastguard Worker 
417*9880d681SAndroid Build Coastguard Worker       // 3-op Variable Permute overwriting the index (VPERMI2).
418*9880d681SAndroid Build Coastguard Worker       // Res = VPERMIV3 V0, MaskV, V1
419*9880d681SAndroid Build Coastguard Worker       VPERMIV3,
420*9880d681SAndroid Build Coastguard Worker 
421*9880d681SAndroid Build Coastguard Worker       // Bitwise ternary logic.
422*9880d681SAndroid Build Coastguard Worker       VPTERNLOG,
423*9880d681SAndroid Build Coastguard Worker       // Fix Up Special Packed Float32/64 values.
424*9880d681SAndroid Build Coastguard Worker       VFIXUPIMM,
425*9880d681SAndroid Build Coastguard Worker       VFIXUPIMMS,
426*9880d681SAndroid Build Coastguard Worker       // Range Restriction Calculation For Packed Pairs of Float32/64 values.
427*9880d681SAndroid Build Coastguard Worker       VRANGE,
428*9880d681SAndroid Build Coastguard Worker       // Reduce - Perform Reduction Transformation on scalar\packed FP.
429*9880d681SAndroid Build Coastguard Worker       VREDUCE,
430*9880d681SAndroid Build Coastguard Worker       // RndScale - Round FP Values To Include A Given Number Of Fraction Bits.
431*9880d681SAndroid Build Coastguard Worker       VRNDSCALE,
432*9880d681SAndroid Build Coastguard Worker       // Tests Types Of a FP Values for packed types.
433*9880d681SAndroid Build Coastguard Worker       VFPCLASS,
434*9880d681SAndroid Build Coastguard Worker       // Tests Types Of a FP Values for scalar types.
435*9880d681SAndroid Build Coastguard Worker       VFPCLASSS,
436*9880d681SAndroid Build Coastguard Worker 
437*9880d681SAndroid Build Coastguard Worker       // Broadcast scalar to vector.
438*9880d681SAndroid Build Coastguard Worker       VBROADCAST,
439*9880d681SAndroid Build Coastguard Worker       // Broadcast mask to vector.
440*9880d681SAndroid Build Coastguard Worker       VBROADCASTM,
441*9880d681SAndroid Build Coastguard Worker       // Broadcast subvector to vector.
442*9880d681SAndroid Build Coastguard Worker       SUBV_BROADCAST,
443*9880d681SAndroid Build Coastguard Worker 
444*9880d681SAndroid Build Coastguard Worker       // Insert/Extract vector element.
445*9880d681SAndroid Build Coastguard Worker       VINSERT,
446*9880d681SAndroid Build Coastguard Worker       VEXTRACT,
447*9880d681SAndroid Build Coastguard Worker 
448*9880d681SAndroid Build Coastguard Worker       /// SSE4A Extraction and Insertion.
449*9880d681SAndroid Build Coastguard Worker       EXTRQI, INSERTQI,
450*9880d681SAndroid Build Coastguard Worker 
451*9880d681SAndroid Build Coastguard Worker       // XOP variable/immediate rotations.
452*9880d681SAndroid Build Coastguard Worker       VPROT, VPROTI,
453*9880d681SAndroid Build Coastguard Worker       // XOP arithmetic/logical shifts.
454*9880d681SAndroid Build Coastguard Worker       VPSHA, VPSHL,
455*9880d681SAndroid Build Coastguard Worker       // XOP signed/unsigned integer comparisons.
456*9880d681SAndroid Build Coastguard Worker       VPCOM, VPCOMU,
457*9880d681SAndroid Build Coastguard Worker       // XOP packed permute bytes.
458*9880d681SAndroid Build Coastguard Worker       VPPERM,
459*9880d681SAndroid Build Coastguard Worker       // XOP two source permutation.
460*9880d681SAndroid Build Coastguard Worker       VPERMIL2,
461*9880d681SAndroid Build Coastguard Worker 
462*9880d681SAndroid Build Coastguard Worker       // Vector multiply packed unsigned doubleword integers.
463*9880d681SAndroid Build Coastguard Worker       PMULUDQ,
464*9880d681SAndroid Build Coastguard Worker       // Vector multiply packed signed doubleword integers.
465*9880d681SAndroid Build Coastguard Worker       PMULDQ,
466*9880d681SAndroid Build Coastguard Worker       // Vector Multiply Packed UnsignedIntegers with Round and Scale.
467*9880d681SAndroid Build Coastguard Worker       MULHRS,
468*9880d681SAndroid Build Coastguard Worker 
469*9880d681SAndroid Build Coastguard Worker       // Multiply and Add Packed Integers.
470*9880d681SAndroid Build Coastguard Worker       VPMADDUBSW, VPMADDWD,
471*9880d681SAndroid Build Coastguard Worker       VPMADD52L, VPMADD52H,
472*9880d681SAndroid Build Coastguard Worker 
473*9880d681SAndroid Build Coastguard Worker       // FMA nodes.
474*9880d681SAndroid Build Coastguard Worker       FMADD,
475*9880d681SAndroid Build Coastguard Worker       FNMADD,
476*9880d681SAndroid Build Coastguard Worker       FMSUB,
477*9880d681SAndroid Build Coastguard Worker       FNMSUB,
478*9880d681SAndroid Build Coastguard Worker       FMADDSUB,
479*9880d681SAndroid Build Coastguard Worker       FMSUBADD,
480*9880d681SAndroid Build Coastguard Worker 
481*9880d681SAndroid Build Coastguard Worker       // FMA with rounding mode.
482*9880d681SAndroid Build Coastguard Worker       FMADD_RND,
483*9880d681SAndroid Build Coastguard Worker       FNMADD_RND,
484*9880d681SAndroid Build Coastguard Worker       FMSUB_RND,
485*9880d681SAndroid Build Coastguard Worker       FNMSUB_RND,
486*9880d681SAndroid Build Coastguard Worker       FMADDSUB_RND,
487*9880d681SAndroid Build Coastguard Worker       FMSUBADD_RND,
488*9880d681SAndroid Build Coastguard Worker 
489*9880d681SAndroid Build Coastguard Worker       // Compress and expand.
490*9880d681SAndroid Build Coastguard Worker       COMPRESS,
491*9880d681SAndroid Build Coastguard Worker       EXPAND,
492*9880d681SAndroid Build Coastguard Worker 
493*9880d681SAndroid Build Coastguard Worker       // Convert Unsigned/Integer to Scalar Floating-Point Value
494*9880d681SAndroid Build Coastguard Worker       // with rounding mode.
495*9880d681SAndroid Build Coastguard Worker       SINT_TO_FP_RND,
496*9880d681SAndroid Build Coastguard Worker       UINT_TO_FP_RND,
497*9880d681SAndroid Build Coastguard Worker 
498*9880d681SAndroid Build Coastguard Worker       // Vector float/double to signed/unsigned integer.
499*9880d681SAndroid Build Coastguard Worker       FP_TO_SINT_RND, FP_TO_UINT_RND,
500*9880d681SAndroid Build Coastguard Worker       // Scalar float/double to signed/unsigned integer.
501*9880d681SAndroid Build Coastguard Worker       SCALAR_FP_TO_SINT_RND, SCALAR_FP_TO_UINT_RND,
502*9880d681SAndroid Build Coastguard Worker 
503*9880d681SAndroid Build Coastguard Worker       // Save xmm argument registers to the stack, according to %al. An operator
504*9880d681SAndroid Build Coastguard Worker       // is needed so that this can be expanded with control flow.
505*9880d681SAndroid Build Coastguard Worker       VASTART_SAVE_XMM_REGS,
506*9880d681SAndroid Build Coastguard Worker 
507*9880d681SAndroid Build Coastguard Worker       // Windows's _chkstk call to do stack probing.
508*9880d681SAndroid Build Coastguard Worker       WIN_ALLOCA,
509*9880d681SAndroid Build Coastguard Worker 
510*9880d681SAndroid Build Coastguard Worker       // For allocating variable amounts of stack space when using
511*9880d681SAndroid Build Coastguard Worker       // segmented stacks. Check if the current stacklet has enough space, and
512*9880d681SAndroid Build Coastguard Worker       // falls back to heap allocation if not.
513*9880d681SAndroid Build Coastguard Worker       SEG_ALLOCA,
514*9880d681SAndroid Build Coastguard Worker 
515*9880d681SAndroid Build Coastguard Worker       // Memory barriers.
516*9880d681SAndroid Build Coastguard Worker       MEMBARRIER,
517*9880d681SAndroid Build Coastguard Worker       MFENCE,
518*9880d681SAndroid Build Coastguard Worker 
519*9880d681SAndroid Build Coastguard Worker       // Store FP status word into i16 register.
520*9880d681SAndroid Build Coastguard Worker       FNSTSW16r,
521*9880d681SAndroid Build Coastguard Worker 
522*9880d681SAndroid Build Coastguard Worker       // Store contents of %ah into %eflags.
523*9880d681SAndroid Build Coastguard Worker       SAHF,
524*9880d681SAndroid Build Coastguard Worker 
525*9880d681SAndroid Build Coastguard Worker       // Get a random integer and indicate whether it is valid in CF.
526*9880d681SAndroid Build Coastguard Worker       RDRAND,
527*9880d681SAndroid Build Coastguard Worker 
528*9880d681SAndroid Build Coastguard Worker       // Get a NIST SP800-90B & C compliant random integer and
529*9880d681SAndroid Build Coastguard Worker       // indicate whether it is valid in CF.
530*9880d681SAndroid Build Coastguard Worker       RDSEED,
531*9880d681SAndroid Build Coastguard Worker 
532*9880d681SAndroid Build Coastguard Worker       // SSE42 string comparisons.
533*9880d681SAndroid Build Coastguard Worker       PCMPISTRI,
534*9880d681SAndroid Build Coastguard Worker       PCMPESTRI,
535*9880d681SAndroid Build Coastguard Worker 
536*9880d681SAndroid Build Coastguard Worker       // Test if in transactional execution.
537*9880d681SAndroid Build Coastguard Worker       XTEST,
538*9880d681SAndroid Build Coastguard Worker 
539*9880d681SAndroid Build Coastguard Worker       // ERI instructions.
540*9880d681SAndroid Build Coastguard Worker       RSQRT28, RCP28, EXP2,
541*9880d681SAndroid Build Coastguard Worker 
542*9880d681SAndroid Build Coastguard Worker       // Compare and swap.
543*9880d681SAndroid Build Coastguard Worker       LCMPXCHG_DAG = ISD::FIRST_TARGET_MEMORY_OPCODE,
544*9880d681SAndroid Build Coastguard Worker       LCMPXCHG8_DAG,
545*9880d681SAndroid Build Coastguard Worker       LCMPXCHG16_DAG,
546*9880d681SAndroid Build Coastguard Worker       LCMPXCHG8_SAVE_EBX_DAG,
547*9880d681SAndroid Build Coastguard Worker       LCMPXCHG16_SAVE_RBX_DAG,
548*9880d681SAndroid Build Coastguard Worker 
549*9880d681SAndroid Build Coastguard Worker       /// LOCK-prefixed arithmetic read-modify-write instructions.
550*9880d681SAndroid Build Coastguard Worker       /// EFLAGS, OUTCHAIN = LADD(INCHAIN, PTR, RHS)
551*9880d681SAndroid Build Coastguard Worker       LADD, LSUB, LOR, LXOR, LAND,
552*9880d681SAndroid Build Coastguard Worker 
553*9880d681SAndroid Build Coastguard Worker       // Load, scalar_to_vector, and zero extend.
554*9880d681SAndroid Build Coastguard Worker       VZEXT_LOAD,
555*9880d681SAndroid Build Coastguard Worker 
556*9880d681SAndroid Build Coastguard Worker       // Store FP control world into i16 memory.
557*9880d681SAndroid Build Coastguard Worker       FNSTCW16m,
558*9880d681SAndroid Build Coastguard Worker 
559*9880d681SAndroid Build Coastguard Worker       /// This instruction implements FP_TO_SINT with the
560*9880d681SAndroid Build Coastguard Worker       /// integer destination in memory and a FP reg source.  This corresponds
561*9880d681SAndroid Build Coastguard Worker       /// to the X86::FIST*m instructions and the rounding mode change stuff. It
562*9880d681SAndroid Build Coastguard Worker       /// has two inputs (token chain and address) and two outputs (int value
563*9880d681SAndroid Build Coastguard Worker       /// and token chain).
564*9880d681SAndroid Build Coastguard Worker       FP_TO_INT16_IN_MEM,
565*9880d681SAndroid Build Coastguard Worker       FP_TO_INT32_IN_MEM,
566*9880d681SAndroid Build Coastguard Worker       FP_TO_INT64_IN_MEM,
567*9880d681SAndroid Build Coastguard Worker 
568*9880d681SAndroid Build Coastguard Worker       /// This instruction implements SINT_TO_FP with the
569*9880d681SAndroid Build Coastguard Worker       /// integer source in memory and FP reg result.  This corresponds to the
570*9880d681SAndroid Build Coastguard Worker       /// X86::FILD*m instructions. It has three inputs (token chain, address,
571*9880d681SAndroid Build Coastguard Worker       /// and source type) and two outputs (FP value and token chain). FILD_FLAG
572*9880d681SAndroid Build Coastguard Worker       /// also produces a flag).
573*9880d681SAndroid Build Coastguard Worker       FILD,
574*9880d681SAndroid Build Coastguard Worker       FILD_FLAG,
575*9880d681SAndroid Build Coastguard Worker 
576*9880d681SAndroid Build Coastguard Worker       /// This instruction implements an extending load to FP stack slots.
577*9880d681SAndroid Build Coastguard Worker       /// This corresponds to the X86::FLD32m / X86::FLD64m. It takes a chain
578*9880d681SAndroid Build Coastguard Worker       /// operand, ptr to load from, and a ValueType node indicating the type
579*9880d681SAndroid Build Coastguard Worker       /// to load to.
580*9880d681SAndroid Build Coastguard Worker       FLD,
581*9880d681SAndroid Build Coastguard Worker 
582*9880d681SAndroid Build Coastguard Worker       /// This instruction implements a truncating store to FP stack
583*9880d681SAndroid Build Coastguard Worker       /// slots. This corresponds to the X86::FST32m / X86::FST64m. It takes a
584*9880d681SAndroid Build Coastguard Worker       /// chain operand, value to store, address, and a ValueType to store it
585*9880d681SAndroid Build Coastguard Worker       /// as.
586*9880d681SAndroid Build Coastguard Worker       FST,
587*9880d681SAndroid Build Coastguard Worker 
588*9880d681SAndroid Build Coastguard Worker       /// This instruction grabs the address of the next argument
589*9880d681SAndroid Build Coastguard Worker       /// from a va_list. (reads and modifies the va_list in memory)
590*9880d681SAndroid Build Coastguard Worker       VAARG_64
591*9880d681SAndroid Build Coastguard Worker 
592*9880d681SAndroid Build Coastguard Worker       // WARNING: Do not add anything in the end unless you want the node to
593*9880d681SAndroid Build Coastguard Worker       // have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all
594*9880d681SAndroid Build Coastguard Worker       // opcodes will be thought as target memory ops!
595*9880d681SAndroid Build Coastguard Worker     };
596*9880d681SAndroid Build Coastguard Worker   } // end namespace X86ISD
597*9880d681SAndroid Build Coastguard Worker 
598*9880d681SAndroid Build Coastguard Worker   /// Define some predicates that are used for node matching.
599*9880d681SAndroid Build Coastguard Worker   namespace X86 {
600*9880d681SAndroid Build Coastguard Worker     /// Return true if the specified
601*9880d681SAndroid Build Coastguard Worker     /// EXTRACT_SUBVECTOR operand specifies a vector extract that is
602*9880d681SAndroid Build Coastguard Worker     /// suitable for input to VEXTRACTF128, VEXTRACTI128 instructions.
603*9880d681SAndroid Build Coastguard Worker     bool isVEXTRACT128Index(SDNode *N);
604*9880d681SAndroid Build Coastguard Worker 
605*9880d681SAndroid Build Coastguard Worker     /// Return true if the specified
606*9880d681SAndroid Build Coastguard Worker     /// INSERT_SUBVECTOR operand specifies a subvector insert that is
607*9880d681SAndroid Build Coastguard Worker     /// suitable for input to VINSERTF128, VINSERTI128 instructions.
608*9880d681SAndroid Build Coastguard Worker     bool isVINSERT128Index(SDNode *N);
609*9880d681SAndroid Build Coastguard Worker 
610*9880d681SAndroid Build Coastguard Worker     /// Return true if the specified
611*9880d681SAndroid Build Coastguard Worker     /// EXTRACT_SUBVECTOR operand specifies a vector extract that is
612*9880d681SAndroid Build Coastguard Worker     /// suitable for input to VEXTRACTF64X4, VEXTRACTI64X4 instructions.
613*9880d681SAndroid Build Coastguard Worker     bool isVEXTRACT256Index(SDNode *N);
614*9880d681SAndroid Build Coastguard Worker 
615*9880d681SAndroid Build Coastguard Worker     /// Return true if the specified
616*9880d681SAndroid Build Coastguard Worker     /// INSERT_SUBVECTOR operand specifies a subvector insert that is
617*9880d681SAndroid Build Coastguard Worker     /// suitable for input to VINSERTF64X4, VINSERTI64X4 instructions.
618*9880d681SAndroid Build Coastguard Worker     bool isVINSERT256Index(SDNode *N);
619*9880d681SAndroid Build Coastguard Worker 
620*9880d681SAndroid Build Coastguard Worker     /// Return the appropriate
621*9880d681SAndroid Build Coastguard Worker     /// immediate to extract the specified EXTRACT_SUBVECTOR index
622*9880d681SAndroid Build Coastguard Worker     /// with VEXTRACTF128, VEXTRACTI128 instructions.
623*9880d681SAndroid Build Coastguard Worker     unsigned getExtractVEXTRACT128Immediate(SDNode *N);
624*9880d681SAndroid Build Coastguard Worker 
625*9880d681SAndroid Build Coastguard Worker     /// Return the appropriate
626*9880d681SAndroid Build Coastguard Worker     /// immediate to insert at the specified INSERT_SUBVECTOR index
627*9880d681SAndroid Build Coastguard Worker     /// with VINSERTF128, VINSERT128 instructions.
628*9880d681SAndroid Build Coastguard Worker     unsigned getInsertVINSERT128Immediate(SDNode *N);
629*9880d681SAndroid Build Coastguard Worker 
630*9880d681SAndroid Build Coastguard Worker     /// Return the appropriate
631*9880d681SAndroid Build Coastguard Worker     /// immediate to extract the specified EXTRACT_SUBVECTOR index
632*9880d681SAndroid Build Coastguard Worker     /// with VEXTRACTF64X4, VEXTRACTI64x4 instructions.
633*9880d681SAndroid Build Coastguard Worker     unsigned getExtractVEXTRACT256Immediate(SDNode *N);
634*9880d681SAndroid Build Coastguard Worker 
635*9880d681SAndroid Build Coastguard Worker     /// Return the appropriate
636*9880d681SAndroid Build Coastguard Worker     /// immediate to insert at the specified INSERT_SUBVECTOR index
637*9880d681SAndroid Build Coastguard Worker     /// with VINSERTF64x4, VINSERTI64x4 instructions.
638*9880d681SAndroid Build Coastguard Worker     unsigned getInsertVINSERT256Immediate(SDNode *N);
639*9880d681SAndroid Build Coastguard Worker 
640*9880d681SAndroid Build Coastguard Worker     /// Returns true if Elt is a constant zero or floating point constant +0.0.
641*9880d681SAndroid Build Coastguard Worker     bool isZeroNode(SDValue Elt);
642*9880d681SAndroid Build Coastguard Worker 
643*9880d681SAndroid Build Coastguard Worker     /// Returns true of the given offset can be
644*9880d681SAndroid Build Coastguard Worker     /// fit into displacement field of the instruction.
645*9880d681SAndroid Build Coastguard Worker     bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M,
646*9880d681SAndroid Build Coastguard Worker                                       bool hasSymbolicDisplacement = true);
647*9880d681SAndroid Build Coastguard Worker 
648*9880d681SAndroid Build Coastguard Worker     /// Determines whether the callee is required to pop its
649*9880d681SAndroid Build Coastguard Worker     /// own arguments. Callee pop is necessary to support tail calls.
650*9880d681SAndroid Build Coastguard Worker     bool isCalleePop(CallingConv::ID CallingConv,
651*9880d681SAndroid Build Coastguard Worker                      bool is64Bit, bool IsVarArg, bool GuaranteeTCO);
652*9880d681SAndroid Build Coastguard Worker 
653*9880d681SAndroid Build Coastguard Worker   } // end namespace X86
654*9880d681SAndroid Build Coastguard Worker 
655*9880d681SAndroid Build Coastguard Worker   //===--------------------------------------------------------------------===//
656*9880d681SAndroid Build Coastguard Worker   //  X86 Implementation of the TargetLowering interface
657*9880d681SAndroid Build Coastguard Worker   class X86TargetLowering final : public TargetLowering {
658*9880d681SAndroid Build Coastguard Worker   public:
659*9880d681SAndroid Build Coastguard Worker     explicit X86TargetLowering(const X86TargetMachine &TM,
660*9880d681SAndroid Build Coastguard Worker                                const X86Subtarget &STI);
661*9880d681SAndroid Build Coastguard Worker 
662*9880d681SAndroid Build Coastguard Worker     unsigned getJumpTableEncoding() const override;
663*9880d681SAndroid Build Coastguard Worker     bool useSoftFloat() const override;
664*9880d681SAndroid Build Coastguard Worker 
getScalarShiftAmountTy(const DataLayout &,EVT)665*9880d681SAndroid Build Coastguard Worker     MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
666*9880d681SAndroid Build Coastguard Worker       return MVT::i8;
667*9880d681SAndroid Build Coastguard Worker     }
668*9880d681SAndroid Build Coastguard Worker 
669*9880d681SAndroid Build Coastguard Worker     const MCExpr *
670*9880d681SAndroid Build Coastguard Worker     LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI,
671*9880d681SAndroid Build Coastguard Worker                               const MachineBasicBlock *MBB, unsigned uid,
672*9880d681SAndroid Build Coastguard Worker                               MCContext &Ctx) const override;
673*9880d681SAndroid Build Coastguard Worker 
674*9880d681SAndroid Build Coastguard Worker     /// Returns relocation base for the given PIC jumptable.
675*9880d681SAndroid Build Coastguard Worker     SDValue getPICJumpTableRelocBase(SDValue Table,
676*9880d681SAndroid Build Coastguard Worker                                      SelectionDAG &DAG) const override;
677*9880d681SAndroid Build Coastguard Worker     const MCExpr *
678*9880d681SAndroid Build Coastguard Worker     getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
679*9880d681SAndroid Build Coastguard Worker                                  unsigned JTI, MCContext &Ctx) const override;
680*9880d681SAndroid Build Coastguard Worker 
681*9880d681SAndroid Build Coastguard Worker     /// Return the desired alignment for ByVal aggregate
682*9880d681SAndroid Build Coastguard Worker     /// function arguments in the caller parameter area. For X86, aggregates
683*9880d681SAndroid Build Coastguard Worker     /// that contains are placed at 16-byte boundaries while the rest are at
684*9880d681SAndroid Build Coastguard Worker     /// 4-byte boundaries.
685*9880d681SAndroid Build Coastguard Worker     unsigned getByValTypeAlignment(Type *Ty,
686*9880d681SAndroid Build Coastguard Worker                                    const DataLayout &DL) const override;
687*9880d681SAndroid Build Coastguard Worker 
688*9880d681SAndroid Build Coastguard Worker     /// Returns the target specific optimal type for load
689*9880d681SAndroid Build Coastguard Worker     /// and store operations as a result of memset, memcpy, and memmove
690*9880d681SAndroid Build Coastguard Worker     /// lowering. If DstAlign is zero that means it's safe to destination
691*9880d681SAndroid Build Coastguard Worker     /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it
692*9880d681SAndroid Build Coastguard Worker     /// means there isn't a need to check it against alignment requirement,
693*9880d681SAndroid Build Coastguard Worker     /// probably because the source does not need to be loaded. If 'IsMemset' is
694*9880d681SAndroid Build Coastguard Worker     /// true, that means it's expanding a memset. If 'ZeroMemset' is true, that
695*9880d681SAndroid Build Coastguard Worker     /// means it's a memset of zero. 'MemcpyStrSrc' indicates whether the memcpy
696*9880d681SAndroid Build Coastguard Worker     /// source is constant so it does not need to be loaded.
697*9880d681SAndroid Build Coastguard Worker     /// It returns EVT::Other if the type should be determined using generic
698*9880d681SAndroid Build Coastguard Worker     /// target-independent logic.
699*9880d681SAndroid Build Coastguard Worker     EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign,
700*9880d681SAndroid Build Coastguard Worker                             bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
701*9880d681SAndroid Build Coastguard Worker                             MachineFunction &MF) const override;
702*9880d681SAndroid Build Coastguard Worker 
703*9880d681SAndroid Build Coastguard Worker     /// Returns true if it's safe to use load / store of the
704*9880d681SAndroid Build Coastguard Worker     /// specified type to expand memcpy / memset inline. This is mostly true
705*9880d681SAndroid Build Coastguard Worker     /// for all types except for some special cases. For example, on X86
706*9880d681SAndroid Build Coastguard Worker     /// targets without SSE2 f64 load / store are done with fldl / fstpl which
707*9880d681SAndroid Build Coastguard Worker     /// also does type conversion. Note the specified type doesn't have to be
708*9880d681SAndroid Build Coastguard Worker     /// legal as the hook is used before type legalization.
709*9880d681SAndroid Build Coastguard Worker     bool isSafeMemOpType(MVT VT) const override;
710*9880d681SAndroid Build Coastguard Worker 
711*9880d681SAndroid Build Coastguard Worker     /// Returns true if the target allows unaligned memory accesses of the
712*9880d681SAndroid Build Coastguard Worker     /// specified type. Returns whether it is "fast" in the last argument.
713*9880d681SAndroid Build Coastguard Worker     bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, unsigned Align,
714*9880d681SAndroid Build Coastguard Worker                                        bool *Fast) const override;
715*9880d681SAndroid Build Coastguard Worker 
716*9880d681SAndroid Build Coastguard Worker     /// Provide custom lowering hooks for some operations.
717*9880d681SAndroid Build Coastguard Worker     ///
718*9880d681SAndroid Build Coastguard Worker     SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
719*9880d681SAndroid Build Coastguard Worker 
720*9880d681SAndroid Build Coastguard Worker     /// Places new result values for the node in Results (their number
721*9880d681SAndroid Build Coastguard Worker     /// and types must exactly match those of the original return values of
722*9880d681SAndroid Build Coastguard Worker     /// the node), or leaves Results empty, which indicates that the node is not
723*9880d681SAndroid Build Coastguard Worker     /// to be custom lowered after all.
724*9880d681SAndroid Build Coastguard Worker     void LowerOperationWrapper(SDNode *N,
725*9880d681SAndroid Build Coastguard Worker                                SmallVectorImpl<SDValue> &Results,
726*9880d681SAndroid Build Coastguard Worker                                SelectionDAG &DAG) const override;
727*9880d681SAndroid Build Coastguard Worker 
728*9880d681SAndroid Build Coastguard Worker     /// Replace the results of node with an illegal result
729*9880d681SAndroid Build Coastguard Worker     /// type with new values built out of custom code.
730*9880d681SAndroid Build Coastguard Worker     ///
731*9880d681SAndroid Build Coastguard Worker     void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
732*9880d681SAndroid Build Coastguard Worker                             SelectionDAG &DAG) const override;
733*9880d681SAndroid Build Coastguard Worker 
734*9880d681SAndroid Build Coastguard Worker     SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
735*9880d681SAndroid Build Coastguard Worker 
736*9880d681SAndroid Build Coastguard Worker     /// Return true if the target has native support for
737*9880d681SAndroid Build Coastguard Worker     /// the specified value type and it is 'desirable' to use the type for the
738*9880d681SAndroid Build Coastguard Worker     /// given node type. e.g. On x86 i16 is legal, but undesirable since i16
739*9880d681SAndroid Build Coastguard Worker     /// instruction encodings are longer and some i16 instructions are slow.
740*9880d681SAndroid Build Coastguard Worker     bool isTypeDesirableForOp(unsigned Opc, EVT VT) const override;
741*9880d681SAndroid Build Coastguard Worker 
742*9880d681SAndroid Build Coastguard Worker     /// Return true if the target has native support for the
743*9880d681SAndroid Build Coastguard Worker     /// specified value type and it is 'desirable' to use the type. e.g. On x86
744*9880d681SAndroid Build Coastguard Worker     /// i16 is legal, but undesirable since i16 instruction encodings are longer
745*9880d681SAndroid Build Coastguard Worker     /// and some i16 instructions are slow.
746*9880d681SAndroid Build Coastguard Worker     bool IsDesirableToPromoteOp(SDValue Op, EVT &PVT) const override;
747*9880d681SAndroid Build Coastguard Worker 
748*9880d681SAndroid Build Coastguard Worker     /// Return true if the MachineFunction contains a COPY which would imply
749*9880d681SAndroid Build Coastguard Worker     /// HasOpaqueSPAdjustment.
750*9880d681SAndroid Build Coastguard Worker     bool hasCopyImplyingStackAdjustment(MachineFunction *MF) const override;
751*9880d681SAndroid Build Coastguard Worker 
752*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *
753*9880d681SAndroid Build Coastguard Worker     EmitInstrWithCustomInserter(MachineInstr &MI,
754*9880d681SAndroid Build Coastguard Worker                                 MachineBasicBlock *MBB) const override;
755*9880d681SAndroid Build Coastguard Worker 
756*9880d681SAndroid Build Coastguard Worker     /// This method returns the name of a target specific DAG node.
757*9880d681SAndroid Build Coastguard Worker     const char *getTargetNodeName(unsigned Opcode) const override;
758*9880d681SAndroid Build Coastguard Worker 
759*9880d681SAndroid Build Coastguard Worker     bool isCheapToSpeculateCttz() const override;
760*9880d681SAndroid Build Coastguard Worker 
761*9880d681SAndroid Build Coastguard Worker     bool isCheapToSpeculateCtlz() const override;
762*9880d681SAndroid Build Coastguard Worker 
hasBitPreservingFPLogic(EVT VT)763*9880d681SAndroid Build Coastguard Worker     bool hasBitPreservingFPLogic(EVT VT) const override {
764*9880d681SAndroid Build Coastguard Worker       return VT == MVT::f32 || VT == MVT::f64 || VT.isVector();
765*9880d681SAndroid Build Coastguard Worker     }
766*9880d681SAndroid Build Coastguard Worker 
767*9880d681SAndroid Build Coastguard Worker     bool hasAndNotCompare(SDValue Y) const override;
768*9880d681SAndroid Build Coastguard Worker 
769*9880d681SAndroid Build Coastguard Worker     /// Return the value type to use for ISD::SETCC.
770*9880d681SAndroid Build Coastguard Worker     EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
771*9880d681SAndroid Build Coastguard Worker                            EVT VT) const override;
772*9880d681SAndroid Build Coastguard Worker 
773*9880d681SAndroid Build Coastguard Worker     /// Determine which of the bits specified in Mask are known to be either
774*9880d681SAndroid Build Coastguard Worker     /// zero or one and return them in the KnownZero/KnownOne bitsets.
775*9880d681SAndroid Build Coastguard Worker     void computeKnownBitsForTargetNode(const SDValue Op,
776*9880d681SAndroid Build Coastguard Worker                                        APInt &KnownZero,
777*9880d681SAndroid Build Coastguard Worker                                        APInt &KnownOne,
778*9880d681SAndroid Build Coastguard Worker                                        const SelectionDAG &DAG,
779*9880d681SAndroid Build Coastguard Worker                                        unsigned Depth = 0) const override;
780*9880d681SAndroid Build Coastguard Worker 
781*9880d681SAndroid Build Coastguard Worker     /// Determine the number of bits in the operation that are sign bits.
782*9880d681SAndroid Build Coastguard Worker     unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
783*9880d681SAndroid Build Coastguard Worker                                              const SelectionDAG &DAG,
784*9880d681SAndroid Build Coastguard Worker                                              unsigned Depth) const override;
785*9880d681SAndroid Build Coastguard Worker 
786*9880d681SAndroid Build Coastguard Worker     bool isGAPlusOffset(SDNode *N, const GlobalValue* &GA,
787*9880d681SAndroid Build Coastguard Worker                         int64_t &Offset) const override;
788*9880d681SAndroid Build Coastguard Worker 
789*9880d681SAndroid Build Coastguard Worker     SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const;
790*9880d681SAndroid Build Coastguard Worker 
791*9880d681SAndroid Build Coastguard Worker     bool ExpandInlineAsm(CallInst *CI) const override;
792*9880d681SAndroid Build Coastguard Worker 
793*9880d681SAndroid Build Coastguard Worker     ConstraintType getConstraintType(StringRef Constraint) const override;
794*9880d681SAndroid Build Coastguard Worker 
795*9880d681SAndroid Build Coastguard Worker     /// Examine constraint string and operand type and determine a weight value.
796*9880d681SAndroid Build Coastguard Worker     /// The operand object must already have been set up with the operand type.
797*9880d681SAndroid Build Coastguard Worker     ConstraintWeight
798*9880d681SAndroid Build Coastguard Worker       getSingleConstraintMatchWeight(AsmOperandInfo &info,
799*9880d681SAndroid Build Coastguard Worker                                      const char *constraint) const override;
800*9880d681SAndroid Build Coastguard Worker 
801*9880d681SAndroid Build Coastguard Worker     const char *LowerXConstraint(EVT ConstraintVT) const override;
802*9880d681SAndroid Build Coastguard Worker 
803*9880d681SAndroid Build Coastguard Worker     /// Lower the specified operand into the Ops vector. If it is invalid, don't
804*9880d681SAndroid Build Coastguard Worker     /// add anything to Ops. If hasMemory is true it means one of the asm
805*9880d681SAndroid Build Coastguard Worker     /// constraint of the inline asm instruction being processed is 'm'.
806*9880d681SAndroid Build Coastguard Worker     void LowerAsmOperandForConstraint(SDValue Op,
807*9880d681SAndroid Build Coastguard Worker                                       std::string &Constraint,
808*9880d681SAndroid Build Coastguard Worker                                       std::vector<SDValue> &Ops,
809*9880d681SAndroid Build Coastguard Worker                                       SelectionDAG &DAG) const override;
810*9880d681SAndroid Build Coastguard Worker 
811*9880d681SAndroid Build Coastguard Worker     unsigned
getInlineAsmMemConstraint(StringRef ConstraintCode)812*9880d681SAndroid Build Coastguard Worker     getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
813*9880d681SAndroid Build Coastguard Worker       if (ConstraintCode == "i")
814*9880d681SAndroid Build Coastguard Worker         return InlineAsm::Constraint_i;
815*9880d681SAndroid Build Coastguard Worker       else if (ConstraintCode == "o")
816*9880d681SAndroid Build Coastguard Worker         return InlineAsm::Constraint_o;
817*9880d681SAndroid Build Coastguard Worker       else if (ConstraintCode == "v")
818*9880d681SAndroid Build Coastguard Worker         return InlineAsm::Constraint_v;
819*9880d681SAndroid Build Coastguard Worker       else if (ConstraintCode == "X")
820*9880d681SAndroid Build Coastguard Worker         return InlineAsm::Constraint_X;
821*9880d681SAndroid Build Coastguard Worker       return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
822*9880d681SAndroid Build Coastguard Worker     }
823*9880d681SAndroid Build Coastguard Worker 
824*9880d681SAndroid Build Coastguard Worker     /// Given a physical register constraint
825*9880d681SAndroid Build Coastguard Worker     /// (e.g. {edx}), return the register number and the register class for the
826*9880d681SAndroid Build Coastguard Worker     /// register.  This should only be used for C_Register constraints.  On
827*9880d681SAndroid Build Coastguard Worker     /// error, this returns a register number of 0.
828*9880d681SAndroid Build Coastguard Worker     std::pair<unsigned, const TargetRegisterClass *>
829*9880d681SAndroid Build Coastguard Worker     getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
830*9880d681SAndroid Build Coastguard Worker                                  StringRef Constraint, MVT VT) const override;
831*9880d681SAndroid Build Coastguard Worker 
832*9880d681SAndroid Build Coastguard Worker     /// Return true if the addressing mode represented
833*9880d681SAndroid Build Coastguard Worker     /// by AM is legal for this target, for a load/store of the specified type.
834*9880d681SAndroid Build Coastguard Worker     bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
835*9880d681SAndroid Build Coastguard Worker                                Type *Ty, unsigned AS) const override;
836*9880d681SAndroid Build Coastguard Worker 
837*9880d681SAndroid Build Coastguard Worker     /// Return true if the specified immediate is legal
838*9880d681SAndroid Build Coastguard Worker     /// icmp immediate, that is the target has icmp instructions which can
839*9880d681SAndroid Build Coastguard Worker     /// compare a register against the immediate without having to materialize
840*9880d681SAndroid Build Coastguard Worker     /// the immediate into a register.
841*9880d681SAndroid Build Coastguard Worker     bool isLegalICmpImmediate(int64_t Imm) const override;
842*9880d681SAndroid Build Coastguard Worker 
843*9880d681SAndroid Build Coastguard Worker     /// Return true if the specified immediate is legal
844*9880d681SAndroid Build Coastguard Worker     /// add immediate, that is the target has add instructions which can
845*9880d681SAndroid Build Coastguard Worker     /// add a register and the immediate without having to materialize
846*9880d681SAndroid Build Coastguard Worker     /// the immediate into a register.
847*9880d681SAndroid Build Coastguard Worker     bool isLegalAddImmediate(int64_t Imm) const override;
848*9880d681SAndroid Build Coastguard Worker 
849*9880d681SAndroid Build Coastguard Worker     /// \brief Return the cost of the scaling factor used in the addressing
850*9880d681SAndroid Build Coastguard Worker     /// mode represented by AM for this target, for a load/store
851*9880d681SAndroid Build Coastguard Worker     /// of the specified type.
852*9880d681SAndroid Build Coastguard Worker     /// If the AM is supported, the return value must be >= 0.
853*9880d681SAndroid Build Coastguard Worker     /// If the AM is not supported, it returns a negative value.
854*9880d681SAndroid Build Coastguard Worker     int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty,
855*9880d681SAndroid Build Coastguard Worker                              unsigned AS) const override;
856*9880d681SAndroid Build Coastguard Worker 
857*9880d681SAndroid Build Coastguard Worker     bool isVectorShiftByScalarCheap(Type *Ty) const override;
858*9880d681SAndroid Build Coastguard Worker 
859*9880d681SAndroid Build Coastguard Worker     /// Return true if it's free to truncate a value of
860*9880d681SAndroid Build Coastguard Worker     /// type Ty1 to type Ty2. e.g. On x86 it's free to truncate a i32 value in
861*9880d681SAndroid Build Coastguard Worker     /// register EAX to i16 by referencing its sub-register AX.
862*9880d681SAndroid Build Coastguard Worker     bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
863*9880d681SAndroid Build Coastguard Worker     bool isTruncateFree(EVT VT1, EVT VT2) const override;
864*9880d681SAndroid Build Coastguard Worker 
865*9880d681SAndroid Build Coastguard Worker     bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
866*9880d681SAndroid Build Coastguard Worker 
867*9880d681SAndroid Build Coastguard Worker     /// Return true if any actual instruction that defines a
868*9880d681SAndroid Build Coastguard Worker     /// value of type Ty1 implicit zero-extends the value to Ty2 in the result
869*9880d681SAndroid Build Coastguard Worker     /// register. This does not necessarily include registers defined in
870*9880d681SAndroid Build Coastguard Worker     /// unknown ways, such as incoming arguments, or copies from unknown
871*9880d681SAndroid Build Coastguard Worker     /// virtual registers. Also, if isTruncateFree(Ty2, Ty1) is true, this
872*9880d681SAndroid Build Coastguard Worker     /// does not necessarily apply to truncate instructions. e.g. on x86-64,
873*9880d681SAndroid Build Coastguard Worker     /// all instructions that define 32-bit values implicit zero-extend the
874*9880d681SAndroid Build Coastguard Worker     /// result out to 64 bits.
875*9880d681SAndroid Build Coastguard Worker     bool isZExtFree(Type *Ty1, Type *Ty2) const override;
876*9880d681SAndroid Build Coastguard Worker     bool isZExtFree(EVT VT1, EVT VT2) const override;
877*9880d681SAndroid Build Coastguard Worker     bool isZExtFree(SDValue Val, EVT VT2) const override;
878*9880d681SAndroid Build Coastguard Worker 
879*9880d681SAndroid Build Coastguard Worker     /// Return true if folding a vector load into ExtVal (a sign, zero, or any
880*9880d681SAndroid Build Coastguard Worker     /// extend node) is profitable.
881*9880d681SAndroid Build Coastguard Worker     bool isVectorLoadExtDesirable(SDValue) const override;
882*9880d681SAndroid Build Coastguard Worker 
883*9880d681SAndroid Build Coastguard Worker     /// Return true if an FMA operation is faster than a pair of fmul and fadd
884*9880d681SAndroid Build Coastguard Worker     /// instructions. fmuladd intrinsics will be expanded to FMAs when this
885*9880d681SAndroid Build Coastguard Worker     /// method returns true, otherwise fmuladd is expanded to fmul + fadd.
886*9880d681SAndroid Build Coastguard Worker     bool isFMAFasterThanFMulAndFAdd(EVT VT) const override;
887*9880d681SAndroid Build Coastguard Worker 
888*9880d681SAndroid Build Coastguard Worker     /// Return true if it's profitable to narrow
889*9880d681SAndroid Build Coastguard Worker     /// operations of type VT1 to VT2. e.g. on x86, it's profitable to narrow
890*9880d681SAndroid Build Coastguard Worker     /// from i32 to i8 but not from i32 to i16.
891*9880d681SAndroid Build Coastguard Worker     bool isNarrowingProfitable(EVT VT1, EVT VT2) const override;
892*9880d681SAndroid Build Coastguard Worker 
893*9880d681SAndroid Build Coastguard Worker     /// Given an intrinsic, checks if on the target the intrinsic will need to map
894*9880d681SAndroid Build Coastguard Worker     /// to a MemIntrinsicNode (touches memory). If this is the case, it returns
895*9880d681SAndroid Build Coastguard Worker     /// true and stores the intrinsic information into the IntrinsicInfo that was
896*9880d681SAndroid Build Coastguard Worker     /// passed to the function.
897*9880d681SAndroid Build Coastguard Worker     bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
898*9880d681SAndroid Build Coastguard Worker                             unsigned Intrinsic) const override;
899*9880d681SAndroid Build Coastguard Worker 
900*9880d681SAndroid Build Coastguard Worker     /// Returns true if the target can instruction select the
901*9880d681SAndroid Build Coastguard Worker     /// specified FP immediate natively. If false, the legalizer will
902*9880d681SAndroid Build Coastguard Worker     /// materialize the FP immediate as a load from a constant pool.
903*9880d681SAndroid Build Coastguard Worker     bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
904*9880d681SAndroid Build Coastguard Worker 
905*9880d681SAndroid Build Coastguard Worker     /// Targets can use this to indicate that they only support *some*
906*9880d681SAndroid Build Coastguard Worker     /// VECTOR_SHUFFLE operations, those with specific masks. By default, if a
907*9880d681SAndroid Build Coastguard Worker     /// target supports the VECTOR_SHUFFLE node, all mask values are assumed to
908*9880d681SAndroid Build Coastguard Worker     /// be legal.
909*9880d681SAndroid Build Coastguard Worker     bool isShuffleMaskLegal(const SmallVectorImpl<int> &Mask,
910*9880d681SAndroid Build Coastguard Worker                             EVT VT) const override;
911*9880d681SAndroid Build Coastguard Worker 
912*9880d681SAndroid Build Coastguard Worker     /// Similar to isShuffleMaskLegal. This is used by Targets can use this to
913*9880d681SAndroid Build Coastguard Worker     /// indicate if there is a suitable VECTOR_SHUFFLE that can be used to
914*9880d681SAndroid Build Coastguard Worker     /// replace a VAND with a constant pool entry.
915*9880d681SAndroid Build Coastguard Worker     bool isVectorClearMaskLegal(const SmallVectorImpl<int> &Mask,
916*9880d681SAndroid Build Coastguard Worker                                 EVT VT) const override;
917*9880d681SAndroid Build Coastguard Worker 
918*9880d681SAndroid Build Coastguard Worker     /// If true, then instruction selection should
919*9880d681SAndroid Build Coastguard Worker     /// seek to shrink the FP constant of the specified type to a smaller type
920*9880d681SAndroid Build Coastguard Worker     /// in order to save space and / or reduce runtime.
ShouldShrinkFPConstant(EVT VT)921*9880d681SAndroid Build Coastguard Worker     bool ShouldShrinkFPConstant(EVT VT) const override {
922*9880d681SAndroid Build Coastguard Worker       // Don't shrink FP constpool if SSE2 is available since cvtss2sd is more
923*9880d681SAndroid Build Coastguard Worker       // expensive than a straight movsd. On the other hand, it's important to
924*9880d681SAndroid Build Coastguard Worker       // shrink long double fp constant since fldt is very slow.
925*9880d681SAndroid Build Coastguard Worker       return !X86ScalarSSEf64 || VT == MVT::f80;
926*9880d681SAndroid Build Coastguard Worker     }
927*9880d681SAndroid Build Coastguard Worker 
928*9880d681SAndroid Build Coastguard Worker     /// Return true if we believe it is correct and profitable to reduce the
929*9880d681SAndroid Build Coastguard Worker     /// load node to a smaller type.
930*9880d681SAndroid Build Coastguard Worker     bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy,
931*9880d681SAndroid Build Coastguard Worker                                EVT NewVT) const override;
932*9880d681SAndroid Build Coastguard Worker 
933*9880d681SAndroid Build Coastguard Worker     /// Return true if the specified scalar FP type is computed in an SSE
934*9880d681SAndroid Build Coastguard Worker     /// register, not on the X87 floating point stack.
isScalarFPTypeInSSEReg(EVT VT)935*9880d681SAndroid Build Coastguard Worker     bool isScalarFPTypeInSSEReg(EVT VT) const {
936*9880d681SAndroid Build Coastguard Worker       return (VT == MVT::f64 && X86ScalarSSEf64) || // f64 is when SSE2
937*9880d681SAndroid Build Coastguard Worker              (VT == MVT::f32 && X86ScalarSSEf32);   // f32 is when SSE1
938*9880d681SAndroid Build Coastguard Worker     }
939*9880d681SAndroid Build Coastguard Worker 
940*9880d681SAndroid Build Coastguard Worker     /// \brief Returns true if it is beneficial to convert a load of a constant
941*9880d681SAndroid Build Coastguard Worker     /// to just the constant itself.
942*9880d681SAndroid Build Coastguard Worker     bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
943*9880d681SAndroid Build Coastguard Worker                                            Type *Ty) const override;
944*9880d681SAndroid Build Coastguard Worker 
945*9880d681SAndroid Build Coastguard Worker     /// Return true if EXTRACT_SUBVECTOR is cheap for this result type
946*9880d681SAndroid Build Coastguard Worker     /// with this index.
947*9880d681SAndroid Build Coastguard Worker     bool isExtractSubvectorCheap(EVT ResVT, unsigned Index) const override;
948*9880d681SAndroid Build Coastguard Worker 
949*9880d681SAndroid Build Coastguard Worker     /// Intel processors have a unified instruction and data cache
getClearCacheBuiltinName()950*9880d681SAndroid Build Coastguard Worker     const char * getClearCacheBuiltinName() const override {
951*9880d681SAndroid Build Coastguard Worker       return nullptr; // nothing to do, move along.
952*9880d681SAndroid Build Coastguard Worker     }
953*9880d681SAndroid Build Coastguard Worker 
954*9880d681SAndroid Build Coastguard Worker     unsigned getRegisterByName(const char* RegName, EVT VT,
955*9880d681SAndroid Build Coastguard Worker                                SelectionDAG &DAG) const override;
956*9880d681SAndroid Build Coastguard Worker 
957*9880d681SAndroid Build Coastguard Worker     /// If a physical register, this returns the register that receives the
958*9880d681SAndroid Build Coastguard Worker     /// exception address on entry to an EH pad.
959*9880d681SAndroid Build Coastguard Worker     unsigned
960*9880d681SAndroid Build Coastguard Worker     getExceptionPointerRegister(const Constant *PersonalityFn) const override;
961*9880d681SAndroid Build Coastguard Worker 
962*9880d681SAndroid Build Coastguard Worker     /// If a physical register, this returns the register that receives the
963*9880d681SAndroid Build Coastguard Worker     /// exception typeid on entry to a landing pad.
964*9880d681SAndroid Build Coastguard Worker     unsigned
965*9880d681SAndroid Build Coastguard Worker     getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
966*9880d681SAndroid Build Coastguard Worker 
967*9880d681SAndroid Build Coastguard Worker     virtual bool needsFixedCatchObjects() const override;
968*9880d681SAndroid Build Coastguard Worker 
969*9880d681SAndroid Build Coastguard Worker     /// This method returns a target specific FastISel object,
970*9880d681SAndroid Build Coastguard Worker     /// or null if the target does not support "fast" ISel.
971*9880d681SAndroid Build Coastguard Worker     FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
972*9880d681SAndroid Build Coastguard Worker                              const TargetLibraryInfo *libInfo) const override;
973*9880d681SAndroid Build Coastguard Worker 
974*9880d681SAndroid Build Coastguard Worker     /// If the target has a standard location for the stack protector cookie,
975*9880d681SAndroid Build Coastguard Worker     /// returns the address of that location. Otherwise, returns nullptr.
976*9880d681SAndroid Build Coastguard Worker     Value *getIRStackGuard(IRBuilder<> &IRB) const override;
977*9880d681SAndroid Build Coastguard Worker 
978*9880d681SAndroid Build Coastguard Worker     bool useLoadStackGuardNode() const override;
979*9880d681SAndroid Build Coastguard Worker     void insertSSPDeclarations(Module &M) const override;
980*9880d681SAndroid Build Coastguard Worker     Value *getSDagStackGuard(const Module &M) const override;
981*9880d681SAndroid Build Coastguard Worker     Value *getSSPStackGuardCheck(const Module &M) const override;
982*9880d681SAndroid Build Coastguard Worker 
983*9880d681SAndroid Build Coastguard Worker     /// Return true if the target stores SafeStack pointer at a fixed offset in
984*9880d681SAndroid Build Coastguard Worker     /// some non-standard address space, and populates the address space and
985*9880d681SAndroid Build Coastguard Worker     /// offset as appropriate.
986*9880d681SAndroid Build Coastguard Worker     Value *getSafeStackPointerLocation(IRBuilder<> &IRB) const override;
987*9880d681SAndroid Build Coastguard Worker 
988*9880d681SAndroid Build Coastguard Worker     SDValue BuildFILD(SDValue Op, EVT SrcVT, SDValue Chain, SDValue StackSlot,
989*9880d681SAndroid Build Coastguard Worker                       SelectionDAG &DAG) const;
990*9880d681SAndroid Build Coastguard Worker 
991*9880d681SAndroid Build Coastguard Worker     bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
992*9880d681SAndroid Build Coastguard Worker 
993*9880d681SAndroid Build Coastguard Worker     /// \brief Customize the preferred legalization strategy for certain types.
994*9880d681SAndroid Build Coastguard Worker     LegalizeTypeAction getPreferredVectorAction(EVT VT) const override;
995*9880d681SAndroid Build Coastguard Worker 
996*9880d681SAndroid Build Coastguard Worker     bool isIntDivCheap(EVT VT, AttributeSet Attr) const override;
997*9880d681SAndroid Build Coastguard Worker 
supportSwiftError()998*9880d681SAndroid Build Coastguard Worker     bool supportSwiftError() const override {
999*9880d681SAndroid Build Coastguard Worker       return true;
1000*9880d681SAndroid Build Coastguard Worker     }
1001*9880d681SAndroid Build Coastguard Worker 
1002*9880d681SAndroid Build Coastguard Worker   protected:
1003*9880d681SAndroid Build Coastguard Worker     std::pair<const TargetRegisterClass *, uint8_t>
1004*9880d681SAndroid Build Coastguard Worker     findRepresentativeClass(const TargetRegisterInfo *TRI,
1005*9880d681SAndroid Build Coastguard Worker                             MVT VT) const override;
1006*9880d681SAndroid Build Coastguard Worker 
1007*9880d681SAndroid Build Coastguard Worker   private:
1008*9880d681SAndroid Build Coastguard Worker     /// Keep a reference to the X86Subtarget around so that we can
1009*9880d681SAndroid Build Coastguard Worker     /// make the right decision when generating code for different targets.
1010*9880d681SAndroid Build Coastguard Worker     const X86Subtarget &Subtarget;
1011*9880d681SAndroid Build Coastguard Worker 
1012*9880d681SAndroid Build Coastguard Worker     /// Select between SSE or x87 floating point ops.
1013*9880d681SAndroid Build Coastguard Worker     /// When SSE is available, use it for f32 operations.
1014*9880d681SAndroid Build Coastguard Worker     /// When SSE2 is available, use it for f64 operations.
1015*9880d681SAndroid Build Coastguard Worker     bool X86ScalarSSEf32;
1016*9880d681SAndroid Build Coastguard Worker     bool X86ScalarSSEf64;
1017*9880d681SAndroid Build Coastguard Worker 
1018*9880d681SAndroid Build Coastguard Worker     /// A list of legal FP immediates.
1019*9880d681SAndroid Build Coastguard Worker     std::vector<APFloat> LegalFPImmediates;
1020*9880d681SAndroid Build Coastguard Worker 
1021*9880d681SAndroid Build Coastguard Worker     /// Indicate that this x86 target can instruction
1022*9880d681SAndroid Build Coastguard Worker     /// select the specified FP immediate natively.
addLegalFPImmediate(const APFloat & Imm)1023*9880d681SAndroid Build Coastguard Worker     void addLegalFPImmediate(const APFloat& Imm) {
1024*9880d681SAndroid Build Coastguard Worker       LegalFPImmediates.push_back(Imm);
1025*9880d681SAndroid Build Coastguard Worker     }
1026*9880d681SAndroid Build Coastguard Worker 
1027*9880d681SAndroid Build Coastguard Worker     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
1028*9880d681SAndroid Build Coastguard Worker                             CallingConv::ID CallConv, bool isVarArg,
1029*9880d681SAndroid Build Coastguard Worker                             const SmallVectorImpl<ISD::InputArg> &Ins,
1030*9880d681SAndroid Build Coastguard Worker                             const SDLoc &dl, SelectionDAG &DAG,
1031*9880d681SAndroid Build Coastguard Worker                             SmallVectorImpl<SDValue> &InVals) const;
1032*9880d681SAndroid Build Coastguard Worker     SDValue LowerMemArgument(SDValue Chain, CallingConv::ID CallConv,
1033*9880d681SAndroid Build Coastguard Worker                              const SmallVectorImpl<ISD::InputArg> &ArgInfo,
1034*9880d681SAndroid Build Coastguard Worker                              const SDLoc &dl, SelectionDAG &DAG,
1035*9880d681SAndroid Build Coastguard Worker                              const CCValAssign &VA, MachineFrameInfo *MFI,
1036*9880d681SAndroid Build Coastguard Worker                              unsigned i) const;
1037*9880d681SAndroid Build Coastguard Worker     SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
1038*9880d681SAndroid Build Coastguard Worker                              const SDLoc &dl, SelectionDAG &DAG,
1039*9880d681SAndroid Build Coastguard Worker                              const CCValAssign &VA,
1040*9880d681SAndroid Build Coastguard Worker                              ISD::ArgFlagsTy Flags) const;
1041*9880d681SAndroid Build Coastguard Worker 
1042*9880d681SAndroid Build Coastguard Worker     // Call lowering helpers.
1043*9880d681SAndroid Build Coastguard Worker 
1044*9880d681SAndroid Build Coastguard Worker     /// Check whether the call is eligible for tail call optimization. Targets
1045*9880d681SAndroid Build Coastguard Worker     /// that want to do tail call optimization should implement this function.
1046*9880d681SAndroid Build Coastguard Worker     bool IsEligibleForTailCallOptimization(SDValue Callee,
1047*9880d681SAndroid Build Coastguard Worker                                            CallingConv::ID CalleeCC,
1048*9880d681SAndroid Build Coastguard Worker                                            bool isVarArg,
1049*9880d681SAndroid Build Coastguard Worker                                            bool isCalleeStructRet,
1050*9880d681SAndroid Build Coastguard Worker                                            bool isCallerStructRet,
1051*9880d681SAndroid Build Coastguard Worker                                            Type *RetTy,
1052*9880d681SAndroid Build Coastguard Worker                                     const SmallVectorImpl<ISD::OutputArg> &Outs,
1053*9880d681SAndroid Build Coastguard Worker                                     const SmallVectorImpl<SDValue> &OutVals,
1054*9880d681SAndroid Build Coastguard Worker                                     const SmallVectorImpl<ISD::InputArg> &Ins,
1055*9880d681SAndroid Build Coastguard Worker                                            SelectionDAG& DAG) const;
1056*9880d681SAndroid Build Coastguard Worker     SDValue EmitTailCallLoadRetAddr(SelectionDAG &DAG, SDValue &OutRetAddr,
1057*9880d681SAndroid Build Coastguard Worker                                     SDValue Chain, bool IsTailCall,
1058*9880d681SAndroid Build Coastguard Worker                                     bool Is64Bit, int FPDiff,
1059*9880d681SAndroid Build Coastguard Worker                                     const SDLoc &dl) const;
1060*9880d681SAndroid Build Coastguard Worker 
1061*9880d681SAndroid Build Coastguard Worker     unsigned GetAlignedArgumentStackSize(unsigned StackSize,
1062*9880d681SAndroid Build Coastguard Worker                                          SelectionDAG &DAG) const;
1063*9880d681SAndroid Build Coastguard Worker 
1064*9880d681SAndroid Build Coastguard Worker     unsigned getAddressSpace(void) const;
1065*9880d681SAndroid Build Coastguard Worker 
1066*9880d681SAndroid Build Coastguard Worker     std::pair<SDValue,SDValue> FP_TO_INTHelper(SDValue Op, SelectionDAG &DAG,
1067*9880d681SAndroid Build Coastguard Worker                                                bool isSigned,
1068*9880d681SAndroid Build Coastguard Worker                                                bool isReplace) const;
1069*9880d681SAndroid Build Coastguard Worker 
1070*9880d681SAndroid Build Coastguard Worker     SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
1071*9880d681SAndroid Build Coastguard Worker     SDValue LowerBUILD_VECTORvXi1(SDValue Op, SelectionDAG &DAG) const;
1072*9880d681SAndroid Build Coastguard Worker     SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const;
1073*9880d681SAndroid Build Coastguard Worker     SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1074*9880d681SAndroid Build Coastguard Worker     SDValue ExtractBitFromMaskVector(SDValue Op, SelectionDAG &DAG) const;
1075*9880d681SAndroid Build Coastguard Worker     SDValue InsertBitToMaskVector(SDValue Op, SelectionDAG &DAG) const;
1076*9880d681SAndroid Build Coastguard Worker 
1077*9880d681SAndroid Build Coastguard Worker     SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
1078*9880d681SAndroid Build Coastguard Worker     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
1079*9880d681SAndroid Build Coastguard Worker     SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
1080*9880d681SAndroid Build Coastguard Worker     SDValue LowerGlobalAddress(const GlobalValue *GV, const SDLoc &dl,
1081*9880d681SAndroid Build Coastguard Worker                                int64_t Offset, SelectionDAG &DAG) const;
1082*9880d681SAndroid Build Coastguard Worker     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
1083*9880d681SAndroid Build Coastguard Worker     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
1084*9880d681SAndroid Build Coastguard Worker     SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
1085*9880d681SAndroid Build Coastguard Worker     SDValue LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
1086*9880d681SAndroid Build Coastguard Worker     SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG) const;
1087*9880d681SAndroid Build Coastguard Worker     SDValue LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG) const;
1088*9880d681SAndroid Build Coastguard Worker     SDValue LowerUINT_TO_FP_i32(SDValue Op, SelectionDAG &DAG) const;
1089*9880d681SAndroid Build Coastguard Worker     SDValue lowerUINT_TO_FP_vec(SDValue Op, SelectionDAG &DAG) const;
1090*9880d681SAndroid Build Coastguard Worker     SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const;
1091*9880d681SAndroid Build Coastguard Worker     SDValue LowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG) const;
1092*9880d681SAndroid Build Coastguard Worker     SDValue LowerFP_TO_UINT(SDValue Op, SelectionDAG &DAG) const;
1093*9880d681SAndroid Build Coastguard Worker     SDValue LowerToBT(SDValue And, ISD::CondCode CC, const SDLoc &dl,
1094*9880d681SAndroid Build Coastguard Worker                       SelectionDAG &DAG) const;
1095*9880d681SAndroid Build Coastguard Worker     SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
1096*9880d681SAndroid Build Coastguard Worker     SDValue LowerSETCCE(SDValue Op, SelectionDAG &DAG) const;
1097*9880d681SAndroid Build Coastguard Worker     SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
1098*9880d681SAndroid Build Coastguard Worker     SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
1099*9880d681SAndroid Build Coastguard Worker     SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
1100*9880d681SAndroid Build Coastguard Worker     SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
1101*9880d681SAndroid Build Coastguard Worker     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
1102*9880d681SAndroid Build Coastguard Worker     SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
1103*9880d681SAndroid Build Coastguard Worker     SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
1104*9880d681SAndroid Build Coastguard Worker     SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
1105*9880d681SAndroid Build Coastguard Worker     SDValue LowerFRAME_TO_ARGS_OFFSET(SDValue Op, SelectionDAG &DAG) const;
1106*9880d681SAndroid Build Coastguard Worker     SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
1107*9880d681SAndroid Build Coastguard Worker     SDValue lowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const;
1108*9880d681SAndroid Build Coastguard Worker     SDValue lowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const;
1109*9880d681SAndroid Build Coastguard Worker     SDValue lowerEH_SJLJ_SETUP_DISPATCH(SDValue Op, SelectionDAG &DAG) const;
1110*9880d681SAndroid Build Coastguard Worker     SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
1111*9880d681SAndroid Build Coastguard Worker     SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const;
1112*9880d681SAndroid Build Coastguard Worker     SDValue LowerWin64_i128OP(SDValue Op, SelectionDAG &DAG) const;
1113*9880d681SAndroid Build Coastguard Worker     SDValue LowerGC_TRANSITION_START(SDValue Op, SelectionDAG &DAG) const;
1114*9880d681SAndroid Build Coastguard Worker     SDValue LowerGC_TRANSITION_END(SDValue Op, SelectionDAG &DAG) const;
1115*9880d681SAndroid Build Coastguard Worker 
1116*9880d681SAndroid Build Coastguard Worker     SDValue
1117*9880d681SAndroid Build Coastguard Worker     LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1118*9880d681SAndroid Build Coastguard Worker                          const SmallVectorImpl<ISD::InputArg> &Ins,
1119*9880d681SAndroid Build Coastguard Worker                          const SDLoc &dl, SelectionDAG &DAG,
1120*9880d681SAndroid Build Coastguard Worker                          SmallVectorImpl<SDValue> &InVals) const override;
1121*9880d681SAndroid Build Coastguard Worker     SDValue LowerCall(CallLoweringInfo &CLI,
1122*9880d681SAndroid Build Coastguard Worker                       SmallVectorImpl<SDValue> &InVals) const override;
1123*9880d681SAndroid Build Coastguard Worker 
1124*9880d681SAndroid Build Coastguard Worker     SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
1125*9880d681SAndroid Build Coastguard Worker                         const SmallVectorImpl<ISD::OutputArg> &Outs,
1126*9880d681SAndroid Build Coastguard Worker                         const SmallVectorImpl<SDValue> &OutVals,
1127*9880d681SAndroid Build Coastguard Worker                         const SDLoc &dl, SelectionDAG &DAG) const override;
1128*9880d681SAndroid Build Coastguard Worker 
supportSplitCSR(MachineFunction * MF)1129*9880d681SAndroid Build Coastguard Worker     bool supportSplitCSR(MachineFunction *MF) const override {
1130*9880d681SAndroid Build Coastguard Worker       return MF->getFunction()->getCallingConv() == CallingConv::CXX_FAST_TLS &&
1131*9880d681SAndroid Build Coastguard Worker           MF->getFunction()->hasFnAttribute(Attribute::NoUnwind);
1132*9880d681SAndroid Build Coastguard Worker     }
1133*9880d681SAndroid Build Coastguard Worker     void initializeSplitCSR(MachineBasicBlock *Entry) const override;
1134*9880d681SAndroid Build Coastguard Worker     void insertCopiesSplitCSR(
1135*9880d681SAndroid Build Coastguard Worker       MachineBasicBlock *Entry,
1136*9880d681SAndroid Build Coastguard Worker       const SmallVectorImpl<MachineBasicBlock *> &Exits) const override;
1137*9880d681SAndroid Build Coastguard Worker 
1138*9880d681SAndroid Build Coastguard Worker     bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
1139*9880d681SAndroid Build Coastguard Worker 
1140*9880d681SAndroid Build Coastguard Worker     bool mayBeEmittedAsTailCall(CallInst *CI) const override;
1141*9880d681SAndroid Build Coastguard Worker 
1142*9880d681SAndroid Build Coastguard Worker     EVT getTypeForExtReturn(LLVMContext &Context, EVT VT,
1143*9880d681SAndroid Build Coastguard Worker                             ISD::NodeType ExtendKind) const override;
1144*9880d681SAndroid Build Coastguard Worker 
1145*9880d681SAndroid Build Coastguard Worker     bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
1146*9880d681SAndroid Build Coastguard Worker                         bool isVarArg,
1147*9880d681SAndroid Build Coastguard Worker                         const SmallVectorImpl<ISD::OutputArg> &Outs,
1148*9880d681SAndroid Build Coastguard Worker                         LLVMContext &Context) const override;
1149*9880d681SAndroid Build Coastguard Worker 
1150*9880d681SAndroid Build Coastguard Worker     const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override;
1151*9880d681SAndroid Build Coastguard Worker 
1152*9880d681SAndroid Build Coastguard Worker     TargetLoweringBase::AtomicExpansionKind
1153*9880d681SAndroid Build Coastguard Worker     shouldExpandAtomicLoadInIR(LoadInst *SI) const override;
1154*9880d681SAndroid Build Coastguard Worker     bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
1155*9880d681SAndroid Build Coastguard Worker     TargetLoweringBase::AtomicExpansionKind
1156*9880d681SAndroid Build Coastguard Worker     shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
1157*9880d681SAndroid Build Coastguard Worker 
1158*9880d681SAndroid Build Coastguard Worker     LoadInst *
1159*9880d681SAndroid Build Coastguard Worker     lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const override;
1160*9880d681SAndroid Build Coastguard Worker 
1161*9880d681SAndroid Build Coastguard Worker     bool needsCmpXchgNb(Type *MemType) const;
1162*9880d681SAndroid Build Coastguard Worker 
1163*9880d681SAndroid Build Coastguard Worker     void SetupEntryBlockForSjLj(MachineInstr &MI, MachineBasicBlock *MBB,
1164*9880d681SAndroid Build Coastguard Worker                                 MachineBasicBlock *DispatchBB, int FI) const;
1165*9880d681SAndroid Build Coastguard Worker 
1166*9880d681SAndroid Build Coastguard Worker     // Utility function to emit the low-level va_arg code for X86-64.
1167*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *
1168*9880d681SAndroid Build Coastguard Worker     EmitVAARG64WithCustomInserter(MachineInstr &MI,
1169*9880d681SAndroid Build Coastguard Worker                                   MachineBasicBlock *MBB) const;
1170*9880d681SAndroid Build Coastguard Worker 
1171*9880d681SAndroid Build Coastguard Worker     /// Utility function to emit the xmm reg save portion of va_start.
1172*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *
1173*9880d681SAndroid Build Coastguard Worker     EmitVAStartSaveXMMRegsWithCustomInserter(MachineInstr &BInstr,
1174*9880d681SAndroid Build Coastguard Worker                                              MachineBasicBlock *BB) const;
1175*9880d681SAndroid Build Coastguard Worker 
1176*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitLoweredSelect(MachineInstr &I,
1177*9880d681SAndroid Build Coastguard Worker                                          MachineBasicBlock *BB) const;
1178*9880d681SAndroid Build Coastguard Worker 
1179*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitLoweredAtomicFP(MachineInstr &I,
1180*9880d681SAndroid Build Coastguard Worker                                            MachineBasicBlock *BB) const;
1181*9880d681SAndroid Build Coastguard Worker 
1182*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitLoweredCatchRet(MachineInstr &MI,
1183*9880d681SAndroid Build Coastguard Worker                                            MachineBasicBlock *BB) const;
1184*9880d681SAndroid Build Coastguard Worker 
1185*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitLoweredCatchPad(MachineInstr &MI,
1186*9880d681SAndroid Build Coastguard Worker                                            MachineBasicBlock *BB) const;
1187*9880d681SAndroid Build Coastguard Worker 
1188*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitLoweredSegAlloca(MachineInstr &MI,
1189*9880d681SAndroid Build Coastguard Worker                                             MachineBasicBlock *BB) const;
1190*9880d681SAndroid Build Coastguard Worker 
1191*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitLoweredTLSAddr(MachineInstr &MI,
1192*9880d681SAndroid Build Coastguard Worker                                           MachineBasicBlock *BB) const;
1193*9880d681SAndroid Build Coastguard Worker 
1194*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitLoweredTLSCall(MachineInstr &MI,
1195*9880d681SAndroid Build Coastguard Worker                                           MachineBasicBlock *BB) const;
1196*9880d681SAndroid Build Coastguard Worker 
1197*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr &MI,
1198*9880d681SAndroid Build Coastguard Worker                                         MachineBasicBlock *MBB) const;
1199*9880d681SAndroid Build Coastguard Worker 
1200*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr &MI,
1201*9880d681SAndroid Build Coastguard Worker                                          MachineBasicBlock *MBB) const;
1202*9880d681SAndroid Build Coastguard Worker 
1203*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *emitFMA3Instr(MachineInstr &MI,
1204*9880d681SAndroid Build Coastguard Worker                                      MachineBasicBlock *MBB) const;
1205*9880d681SAndroid Build Coastguard Worker 
1206*9880d681SAndroid Build Coastguard Worker     MachineBasicBlock *EmitSjLjDispatchBlock(MachineInstr &MI,
1207*9880d681SAndroid Build Coastguard Worker                                              MachineBasicBlock *MBB) const;
1208*9880d681SAndroid Build Coastguard Worker 
1209*9880d681SAndroid Build Coastguard Worker     /// Emit nodes that will be selected as "test Op0,Op0", or something
1210*9880d681SAndroid Build Coastguard Worker     /// equivalent, for use with the given x86 condition code.
1211*9880d681SAndroid Build Coastguard Worker     SDValue EmitTest(SDValue Op0, unsigned X86CC, const SDLoc &dl,
1212*9880d681SAndroid Build Coastguard Worker                      SelectionDAG &DAG) const;
1213*9880d681SAndroid Build Coastguard Worker 
1214*9880d681SAndroid Build Coastguard Worker     /// Emit nodes that will be selected as "cmp Op0,Op1", or something
1215*9880d681SAndroid Build Coastguard Worker     /// equivalent, for use with the given x86 condition code.
1216*9880d681SAndroid Build Coastguard Worker     SDValue EmitCmp(SDValue Op0, SDValue Op1, unsigned X86CC, const SDLoc &dl,
1217*9880d681SAndroid Build Coastguard Worker                     SelectionDAG &DAG) const;
1218*9880d681SAndroid Build Coastguard Worker 
1219*9880d681SAndroid Build Coastguard Worker     /// Convert a comparison if required by the subtarget.
1220*9880d681SAndroid Build Coastguard Worker     SDValue ConvertCmpIfNecessary(SDValue Cmp, SelectionDAG &DAG) const;
1221*9880d681SAndroid Build Coastguard Worker 
1222*9880d681SAndroid Build Coastguard Worker     /// Use rsqrt* to speed up sqrt calculations.
1223*9880d681SAndroid Build Coastguard Worker     SDValue getRsqrtEstimate(SDValue Operand, DAGCombinerInfo &DCI,
1224*9880d681SAndroid Build Coastguard Worker                              unsigned &RefinementSteps,
1225*9880d681SAndroid Build Coastguard Worker                              bool &UseOneConstNR) const override;
1226*9880d681SAndroid Build Coastguard Worker 
1227*9880d681SAndroid Build Coastguard Worker     /// Use rcp* to speed up fdiv calculations.
1228*9880d681SAndroid Build Coastguard Worker     SDValue getRecipEstimate(SDValue Operand, DAGCombinerInfo &DCI,
1229*9880d681SAndroid Build Coastguard Worker                              unsigned &RefinementSteps) const override;
1230*9880d681SAndroid Build Coastguard Worker 
1231*9880d681SAndroid Build Coastguard Worker     /// Reassociate floating point divisions into multiply by reciprocal.
1232*9880d681SAndroid Build Coastguard Worker     unsigned combineRepeatedFPDivisors() const override;
1233*9880d681SAndroid Build Coastguard Worker   };
1234*9880d681SAndroid Build Coastguard Worker 
1235*9880d681SAndroid Build Coastguard Worker   namespace X86 {
1236*9880d681SAndroid Build Coastguard Worker     FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
1237*9880d681SAndroid Build Coastguard Worker                              const TargetLibraryInfo *libInfo);
1238*9880d681SAndroid Build Coastguard Worker   } // end namespace X86
1239*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
1240*9880d681SAndroid Build Coastguard Worker 
1241*9880d681SAndroid Build Coastguard Worker #endif // LLVM_LIB_TARGET_X86_X86ISELLOWERING_H
1242