10b57cec5SDimitry Andric //===-- X86ISelLowering.h - X86 DAG Lowering Interface ----------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file defines the interfaces that X86 uses to lower LLVM code into a 100b57cec5SDimitry Andric // selection DAG. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_X86_X86ISELLOWERING_H 150b57cec5SDimitry Andric #define LLVM_LIB_TARGET_X86_X86ISELLOWERING_H 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric #include "llvm/CodeGen/CallingConvLower.h" 180b57cec5SDimitry Andric #include "llvm/CodeGen/SelectionDAG.h" 190b57cec5SDimitry Andric #include "llvm/CodeGen/TargetLowering.h" 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric namespace llvm { 220b57cec5SDimitry Andric class X86Subtarget; 230b57cec5SDimitry Andric class X86TargetMachine; 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric namespace X86ISD { 260b57cec5SDimitry Andric // X86 Specific DAG Nodes 270b57cec5SDimitry Andric enum NodeType : unsigned { 280b57cec5SDimitry Andric // Start the numbering where the builtin ops leave off. 290b57cec5SDimitry Andric FIRST_NUMBER = ISD::BUILTIN_OP_END, 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric /// Bit scan forward. 320b57cec5SDimitry Andric BSF, 330b57cec5SDimitry Andric /// Bit scan reverse. 340b57cec5SDimitry Andric BSR, 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric /// Double shift instructions. These correspond to 370b57cec5SDimitry Andric /// X86::SHLDxx and X86::SHRDxx instructions. 380b57cec5SDimitry Andric SHLD, 390b57cec5SDimitry Andric SHRD, 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric /// Bitwise logical AND of floating point values. This corresponds 420b57cec5SDimitry Andric /// to X86::ANDPS or X86::ANDPD. 430b57cec5SDimitry Andric FAND, 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric /// Bitwise logical OR of floating point values. This corresponds 460b57cec5SDimitry Andric /// to X86::ORPS or X86::ORPD. 470b57cec5SDimitry Andric FOR, 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric /// Bitwise logical XOR of floating point values. This corresponds 500b57cec5SDimitry Andric /// to X86::XORPS or X86::XORPD. 510b57cec5SDimitry Andric FXOR, 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric /// Bitwise logical ANDNOT of floating point values. This 540b57cec5SDimitry Andric /// corresponds to X86::ANDNPS or X86::ANDNPD. 550b57cec5SDimitry Andric FANDN, 560b57cec5SDimitry Andric 570b57cec5SDimitry Andric /// These operations represent an abstract X86 call 580b57cec5SDimitry Andric /// instruction, which includes a bunch of information. In particular the 590b57cec5SDimitry Andric /// operands of these node are: 600b57cec5SDimitry Andric /// 610b57cec5SDimitry Andric /// #0 - The incoming token chain 620b57cec5SDimitry Andric /// #1 - The callee 630b57cec5SDimitry Andric /// #2 - The number of arg bytes the caller pushes on the stack. 640b57cec5SDimitry Andric /// #3 - The number of arg bytes the callee pops off the stack. 650b57cec5SDimitry Andric /// #4 - The value to pass in AL/AX/EAX (optional) 660b57cec5SDimitry Andric /// #5 - The value to pass in DL/DX/EDX (optional) 670b57cec5SDimitry Andric /// 680b57cec5SDimitry Andric /// The result values of these nodes are: 690b57cec5SDimitry Andric /// 700b57cec5SDimitry Andric /// #0 - The outgoing token chain 710b57cec5SDimitry Andric /// #1 - The first register result value (optional) 720b57cec5SDimitry Andric /// #2 - The second register result value (optional) 730b57cec5SDimitry Andric /// 740b57cec5SDimitry Andric CALL, 750b57cec5SDimitry Andric 760b57cec5SDimitry Andric /// Same as call except it adds the NoTrack prefix. 770b57cec5SDimitry Andric NT_CALL, 780b57cec5SDimitry Andric 790b57cec5SDimitry Andric /// X86 compare and logical compare instructions. 800b57cec5SDimitry Andric CMP, COMI, UCOMI, 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric /// X86 bit-test instructions. 830b57cec5SDimitry Andric BT, 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric /// X86 SetCC. Operand 0 is condition code, and operand 1 is the EFLAGS 860b57cec5SDimitry Andric /// operand, usually produced by a CMP instruction. 870b57cec5SDimitry Andric SETCC, 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric /// X86 Select 900b57cec5SDimitry Andric SELECTS, 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric // Same as SETCC except it's materialized with a sbb and the value is all 930b57cec5SDimitry Andric // one's or all zero's. 940b57cec5SDimitry Andric SETCC_CARRY, // R = carry_bit ? ~0 : 0 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric /// X86 FP SETCC, implemented with CMP{cc}SS/CMP{cc}SD. 970b57cec5SDimitry Andric /// Operands are two FP values to compare; result is a mask of 980b57cec5SDimitry Andric /// 0s or 1s. Generally DTRT for C/C++ with NaNs. 990b57cec5SDimitry Andric FSETCC, 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric /// X86 FP SETCC, similar to above, but with output as an i1 mask and 1020b57cec5SDimitry Andric /// and a version with SAE. 1030b57cec5SDimitry Andric FSETCCM, FSETCCM_SAE, 1040b57cec5SDimitry Andric 1050b57cec5SDimitry Andric /// X86 conditional moves. Operand 0 and operand 1 are the two values 1060b57cec5SDimitry Andric /// to select from. Operand 2 is the condition code, and operand 3 is the 1070b57cec5SDimitry Andric /// flag operand produced by a CMP or TEST instruction. 1080b57cec5SDimitry Andric CMOV, 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric /// X86 conditional branches. Operand 0 is the chain operand, operand 1 1110b57cec5SDimitry Andric /// is the block to branch if condition is true, operand 2 is the 1120b57cec5SDimitry Andric /// condition code, and operand 3 is the flag operand produced by a CMP 1130b57cec5SDimitry Andric /// or TEST instruction. 1140b57cec5SDimitry Andric BRCOND, 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric /// BRIND node with NoTrack prefix. Operand 0 is the chain operand and 1170b57cec5SDimitry Andric /// operand 1 is the target address. 1180b57cec5SDimitry Andric NT_BRIND, 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric /// Return with a flag operand. Operand 0 is the chain operand, operand 1210b57cec5SDimitry Andric /// 1 is the number of bytes of stack to pop. 1220b57cec5SDimitry Andric RET_FLAG, 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andric /// Return from interrupt. Operand 0 is the number of bytes to pop. 1250b57cec5SDimitry Andric IRET, 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric /// Repeat fill, corresponds to X86::REP_STOSx. 1280b57cec5SDimitry Andric REP_STOS, 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andric /// Repeat move, corresponds to X86::REP_MOVSx. 1310b57cec5SDimitry Andric REP_MOVS, 1320b57cec5SDimitry Andric 1330b57cec5SDimitry Andric /// On Darwin, this node represents the result of the popl 1340b57cec5SDimitry Andric /// at function entry, used for PIC code. 1350b57cec5SDimitry Andric GlobalBaseReg, 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric /// A wrapper node for TargetConstantPool, TargetJumpTable, 1380b57cec5SDimitry Andric /// TargetExternalSymbol, TargetGlobalAddress, TargetGlobalTLSAddress, 1390b57cec5SDimitry Andric /// MCSymbol and TargetBlockAddress. 1400b57cec5SDimitry Andric Wrapper, 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andric /// Special wrapper used under X86-64 PIC mode for RIP 1430b57cec5SDimitry Andric /// relative displacements. 1440b57cec5SDimitry Andric WrapperRIP, 1450b57cec5SDimitry Andric 146*8bcb0991SDimitry Andric /// Copies a 64-bit value from an MMX vector to the low word 147*8bcb0991SDimitry Andric /// of an XMM vector, with the high word zero filled. 148*8bcb0991SDimitry Andric MOVQ2DQ, 149*8bcb0991SDimitry Andric 1500b57cec5SDimitry Andric /// Copies a 64-bit value from the low word of an XMM vector 1510b57cec5SDimitry Andric /// to an MMX vector. 1520b57cec5SDimitry Andric MOVDQ2Q, 1530b57cec5SDimitry Andric 1540b57cec5SDimitry Andric /// Copies a 32-bit value from the low word of a MMX 1550b57cec5SDimitry Andric /// vector to a GPR. 1560b57cec5SDimitry Andric MMX_MOVD2W, 1570b57cec5SDimitry Andric 1580b57cec5SDimitry Andric /// Copies a GPR into the low 32-bit word of a MMX vector 1590b57cec5SDimitry Andric /// and zero out the high word. 1600b57cec5SDimitry Andric MMX_MOVW2D, 1610b57cec5SDimitry Andric 1620b57cec5SDimitry Andric /// Extract an 8-bit value from a vector and zero extend it to 1630b57cec5SDimitry Andric /// i32, corresponds to X86::PEXTRB. 1640b57cec5SDimitry Andric PEXTRB, 1650b57cec5SDimitry Andric 1660b57cec5SDimitry Andric /// Extract a 16-bit value from a vector and zero extend it to 1670b57cec5SDimitry Andric /// i32, corresponds to X86::PEXTRW. 1680b57cec5SDimitry Andric PEXTRW, 1690b57cec5SDimitry Andric 1700b57cec5SDimitry Andric /// Insert any element of a 4 x float vector into any element 1710b57cec5SDimitry Andric /// of a destination 4 x floatvector. 1720b57cec5SDimitry Andric INSERTPS, 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andric /// Insert the lower 8-bits of a 32-bit value to a vector, 1750b57cec5SDimitry Andric /// corresponds to X86::PINSRB. 1760b57cec5SDimitry Andric PINSRB, 1770b57cec5SDimitry Andric 1780b57cec5SDimitry Andric /// Insert the lower 16-bits of a 32-bit value to a vector, 1790b57cec5SDimitry Andric /// corresponds to X86::PINSRW. 1800b57cec5SDimitry Andric PINSRW, 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andric /// Shuffle 16 8-bit values within a vector. 1830b57cec5SDimitry Andric PSHUFB, 1840b57cec5SDimitry Andric 1850b57cec5SDimitry Andric /// Compute Sum of Absolute Differences. 1860b57cec5SDimitry Andric PSADBW, 1870b57cec5SDimitry Andric /// Compute Double Block Packed Sum-Absolute-Differences 1880b57cec5SDimitry Andric DBPSADBW, 1890b57cec5SDimitry Andric 1900b57cec5SDimitry Andric /// Bitwise Logical AND NOT of Packed FP values. 1910b57cec5SDimitry Andric ANDNP, 1920b57cec5SDimitry Andric 1930b57cec5SDimitry Andric /// Blend where the selector is an immediate. 1940b57cec5SDimitry Andric BLENDI, 1950b57cec5SDimitry Andric 1960b57cec5SDimitry Andric /// Dynamic (non-constant condition) vector blend where only the sign bits 1970b57cec5SDimitry Andric /// of the condition elements are used. This is used to enforce that the 1980b57cec5SDimitry Andric /// condition mask is not valid for generic VSELECT optimizations. This 1990b57cec5SDimitry Andric /// is also used to implement the intrinsics. 2000b57cec5SDimitry Andric /// Operands are in VSELECT order: MASK, TRUE, FALSE 2010b57cec5SDimitry Andric BLENDV, 2020b57cec5SDimitry Andric 2030b57cec5SDimitry Andric /// Combined add and sub on an FP vector. 2040b57cec5SDimitry Andric ADDSUB, 2050b57cec5SDimitry Andric 2060b57cec5SDimitry Andric // FP vector ops with rounding mode. 2070b57cec5SDimitry Andric FADD_RND, FADDS, FADDS_RND, 2080b57cec5SDimitry Andric FSUB_RND, FSUBS, FSUBS_RND, 2090b57cec5SDimitry Andric FMUL_RND, FMULS, FMULS_RND, 2100b57cec5SDimitry Andric FDIV_RND, FDIVS, FDIVS_RND, 2110b57cec5SDimitry Andric FMAX_SAE, FMAXS_SAE, 2120b57cec5SDimitry Andric FMIN_SAE, FMINS_SAE, 2130b57cec5SDimitry Andric FSQRT_RND, FSQRTS, FSQRTS_RND, 2140b57cec5SDimitry Andric 2150b57cec5SDimitry Andric // FP vector get exponent. 2160b57cec5SDimitry Andric FGETEXP, FGETEXP_SAE, FGETEXPS, FGETEXPS_SAE, 2170b57cec5SDimitry Andric // Extract Normalized Mantissas. 2180b57cec5SDimitry Andric VGETMANT, VGETMANT_SAE, VGETMANTS, VGETMANTS_SAE, 2190b57cec5SDimitry Andric // FP Scale. 2200b57cec5SDimitry Andric SCALEF, SCALEF_RND, 2210b57cec5SDimitry Andric SCALEFS, SCALEFS_RND, 2220b57cec5SDimitry Andric 2230b57cec5SDimitry Andric // Unsigned Integer average. 2240b57cec5SDimitry Andric AVG, 2250b57cec5SDimitry Andric 2260b57cec5SDimitry Andric /// Integer horizontal add/sub. 2270b57cec5SDimitry Andric HADD, 2280b57cec5SDimitry Andric HSUB, 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric /// Floating point horizontal add/sub. 2310b57cec5SDimitry Andric FHADD, 2320b57cec5SDimitry Andric FHSUB, 2330b57cec5SDimitry Andric 2340b57cec5SDimitry Andric // Detect Conflicts Within a Vector 2350b57cec5SDimitry Andric CONFLICT, 2360b57cec5SDimitry Andric 2370b57cec5SDimitry Andric /// Floating point max and min. 2380b57cec5SDimitry Andric FMAX, FMIN, 2390b57cec5SDimitry Andric 2400b57cec5SDimitry Andric /// Commutative FMIN and FMAX. 2410b57cec5SDimitry Andric FMAXC, FMINC, 2420b57cec5SDimitry Andric 2430b57cec5SDimitry Andric /// Scalar intrinsic floating point max and min. 2440b57cec5SDimitry Andric FMAXS, FMINS, 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andric /// Floating point reciprocal-sqrt and reciprocal approximation. 2470b57cec5SDimitry Andric /// Note that these typically require refinement 2480b57cec5SDimitry Andric /// in order to obtain suitable precision. 2490b57cec5SDimitry Andric FRSQRT, FRCP, 2500b57cec5SDimitry Andric 2510b57cec5SDimitry Andric // AVX-512 reciprocal approximations with a little more precision. 2520b57cec5SDimitry Andric RSQRT14, RSQRT14S, RCP14, RCP14S, 2530b57cec5SDimitry Andric 2540b57cec5SDimitry Andric // Thread Local Storage. 2550b57cec5SDimitry Andric TLSADDR, 2560b57cec5SDimitry Andric 2570b57cec5SDimitry Andric // Thread Local Storage. A call to get the start address 2580b57cec5SDimitry Andric // of the TLS block for the current module. 2590b57cec5SDimitry Andric TLSBASEADDR, 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andric // Thread Local Storage. When calling to an OS provided 2620b57cec5SDimitry Andric // thunk at the address from an earlier relocation. 2630b57cec5SDimitry Andric TLSCALL, 2640b57cec5SDimitry Andric 2650b57cec5SDimitry Andric // Exception Handling helpers. 2660b57cec5SDimitry Andric EH_RETURN, 2670b57cec5SDimitry Andric 2680b57cec5SDimitry Andric // SjLj exception handling setjmp. 2690b57cec5SDimitry Andric EH_SJLJ_SETJMP, 2700b57cec5SDimitry Andric 2710b57cec5SDimitry Andric // SjLj exception handling longjmp. 2720b57cec5SDimitry Andric EH_SJLJ_LONGJMP, 2730b57cec5SDimitry Andric 2740b57cec5SDimitry Andric // SjLj exception handling dispatch. 2750b57cec5SDimitry Andric EH_SJLJ_SETUP_DISPATCH, 2760b57cec5SDimitry Andric 2770b57cec5SDimitry Andric /// Tail call return. See X86TargetLowering::LowerCall for 2780b57cec5SDimitry Andric /// the list of operands. 2790b57cec5SDimitry Andric TC_RETURN, 2800b57cec5SDimitry Andric 2810b57cec5SDimitry Andric // Vector move to low scalar and zero higher vector elements. 2820b57cec5SDimitry Andric VZEXT_MOVL, 2830b57cec5SDimitry Andric 2840b57cec5SDimitry Andric // Vector integer truncate. 2850b57cec5SDimitry Andric VTRUNC, 2860b57cec5SDimitry Andric // Vector integer truncate with unsigned/signed saturation. 2870b57cec5SDimitry Andric VTRUNCUS, VTRUNCS, 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andric // Masked version of the above. Used when less than a 128-bit result is 2900b57cec5SDimitry Andric // produced since the mask only applies to the lower elements and can't 2910b57cec5SDimitry Andric // be represented by a select. 2920b57cec5SDimitry Andric // SRC, PASSTHRU, MASK 2930b57cec5SDimitry Andric VMTRUNC, VMTRUNCUS, VMTRUNCS, 2940b57cec5SDimitry Andric 2950b57cec5SDimitry Andric // Vector FP extend. 2960b57cec5SDimitry Andric VFPEXT, VFPEXT_SAE, VFPEXTS, VFPEXTS_SAE, 2970b57cec5SDimitry Andric 2980b57cec5SDimitry Andric // Vector FP round. 2990b57cec5SDimitry Andric VFPROUND, VFPROUND_RND, VFPROUNDS, VFPROUNDS_RND, 3000b57cec5SDimitry Andric 3010b57cec5SDimitry Andric // Masked version of above. Used for v2f64->v4f32. 3020b57cec5SDimitry Andric // SRC, PASSTHRU, MASK 3030b57cec5SDimitry Andric VMFPROUND, 3040b57cec5SDimitry Andric 3050b57cec5SDimitry Andric // 128-bit vector logical left / right shift 3060b57cec5SDimitry Andric VSHLDQ, VSRLDQ, 3070b57cec5SDimitry Andric 3080b57cec5SDimitry Andric // Vector shift elements 3090b57cec5SDimitry Andric VSHL, VSRL, VSRA, 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andric // Vector variable shift 3120b57cec5SDimitry Andric VSHLV, VSRLV, VSRAV, 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andric // Vector shift elements by immediate 3150b57cec5SDimitry Andric VSHLI, VSRLI, VSRAI, 3160b57cec5SDimitry Andric 3170b57cec5SDimitry Andric // Shifts of mask registers. 3180b57cec5SDimitry Andric KSHIFTL, KSHIFTR, 3190b57cec5SDimitry Andric 3200b57cec5SDimitry Andric // Bit rotate by immediate 3210b57cec5SDimitry Andric VROTLI, VROTRI, 3220b57cec5SDimitry Andric 3230b57cec5SDimitry Andric // Vector packed double/float comparison. 3240b57cec5SDimitry Andric CMPP, 3250b57cec5SDimitry Andric 3260b57cec5SDimitry Andric // Vector integer comparisons. 3270b57cec5SDimitry Andric PCMPEQ, PCMPGT, 3280b57cec5SDimitry Andric 3290b57cec5SDimitry Andric // v8i16 Horizontal minimum and position. 3300b57cec5SDimitry Andric PHMINPOS, 3310b57cec5SDimitry Andric 3320b57cec5SDimitry Andric MULTISHIFT, 3330b57cec5SDimitry Andric 3340b57cec5SDimitry Andric /// Vector comparison generating mask bits for fp and 3350b57cec5SDimitry Andric /// integer signed and unsigned data types. 3360b57cec5SDimitry Andric CMPM, 3370b57cec5SDimitry Andric // Vector comparison with SAE for FP values 3380b57cec5SDimitry Andric CMPM_SAE, 3390b57cec5SDimitry Andric 3400b57cec5SDimitry Andric // Arithmetic operations with FLAGS results. 3410b57cec5SDimitry Andric ADD, SUB, ADC, SBB, SMUL, UMUL, 3420b57cec5SDimitry Andric OR, XOR, AND, 3430b57cec5SDimitry Andric 3440b57cec5SDimitry Andric // Bit field extract. 3450b57cec5SDimitry Andric BEXTR, 3460b57cec5SDimitry Andric 3470b57cec5SDimitry Andric // Zero High Bits Starting with Specified Bit Position. 3480b57cec5SDimitry Andric BZHI, 3490b57cec5SDimitry Andric 3500b57cec5SDimitry Andric // X86-specific multiply by immediate. 3510b57cec5SDimitry Andric MUL_IMM, 3520b57cec5SDimitry Andric 3530b57cec5SDimitry Andric // Vector sign bit extraction. 3540b57cec5SDimitry Andric MOVMSK, 3550b57cec5SDimitry Andric 3560b57cec5SDimitry Andric // Vector bitwise comparisons. 3570b57cec5SDimitry Andric PTEST, 3580b57cec5SDimitry Andric 3590b57cec5SDimitry Andric // Vector packed fp sign bitwise comparisons. 3600b57cec5SDimitry Andric TESTP, 3610b57cec5SDimitry Andric 3620b57cec5SDimitry Andric // OR/AND test for masks. 3630b57cec5SDimitry Andric KORTEST, 3640b57cec5SDimitry Andric KTEST, 3650b57cec5SDimitry Andric 3660b57cec5SDimitry Andric // ADD for masks. 3670b57cec5SDimitry Andric KADD, 3680b57cec5SDimitry Andric 3690b57cec5SDimitry Andric // Several flavors of instructions with vector shuffle behaviors. 3700b57cec5SDimitry Andric // Saturated signed/unnsigned packing. 3710b57cec5SDimitry Andric PACKSS, 3720b57cec5SDimitry Andric PACKUS, 3730b57cec5SDimitry Andric // Intra-lane alignr. 3740b57cec5SDimitry Andric PALIGNR, 3750b57cec5SDimitry Andric // AVX512 inter-lane alignr. 3760b57cec5SDimitry Andric VALIGN, 3770b57cec5SDimitry Andric PSHUFD, 3780b57cec5SDimitry Andric PSHUFHW, 3790b57cec5SDimitry Andric PSHUFLW, 3800b57cec5SDimitry Andric SHUFP, 3810b57cec5SDimitry Andric // VBMI2 Concat & Shift. 3820b57cec5SDimitry Andric VSHLD, 3830b57cec5SDimitry Andric VSHRD, 3840b57cec5SDimitry Andric VSHLDV, 3850b57cec5SDimitry Andric VSHRDV, 3860b57cec5SDimitry Andric //Shuffle Packed Values at 128-bit granularity. 3870b57cec5SDimitry Andric SHUF128, 3880b57cec5SDimitry Andric MOVDDUP, 3890b57cec5SDimitry Andric MOVSHDUP, 3900b57cec5SDimitry Andric MOVSLDUP, 3910b57cec5SDimitry Andric MOVLHPS, 3920b57cec5SDimitry Andric MOVHLPS, 3930b57cec5SDimitry Andric MOVSD, 3940b57cec5SDimitry Andric MOVSS, 3950b57cec5SDimitry Andric UNPCKL, 3960b57cec5SDimitry Andric UNPCKH, 3970b57cec5SDimitry Andric VPERMILPV, 3980b57cec5SDimitry Andric VPERMILPI, 3990b57cec5SDimitry Andric VPERMI, 4000b57cec5SDimitry Andric VPERM2X128, 4010b57cec5SDimitry Andric 4020b57cec5SDimitry Andric // Variable Permute (VPERM). 4030b57cec5SDimitry Andric // Res = VPERMV MaskV, V0 4040b57cec5SDimitry Andric VPERMV, 4050b57cec5SDimitry Andric 4060b57cec5SDimitry Andric // 3-op Variable Permute (VPERMT2). 4070b57cec5SDimitry Andric // Res = VPERMV3 V0, MaskV, V1 4080b57cec5SDimitry Andric VPERMV3, 4090b57cec5SDimitry Andric 4100b57cec5SDimitry Andric // Bitwise ternary logic. 4110b57cec5SDimitry Andric VPTERNLOG, 4120b57cec5SDimitry Andric // Fix Up Special Packed Float32/64 values. 4130b57cec5SDimitry Andric VFIXUPIMM, VFIXUPIMM_SAE, 4140b57cec5SDimitry Andric VFIXUPIMMS, VFIXUPIMMS_SAE, 4150b57cec5SDimitry Andric // Range Restriction Calculation For Packed Pairs of Float32/64 values. 4160b57cec5SDimitry Andric VRANGE, VRANGE_SAE, VRANGES, VRANGES_SAE, 4170b57cec5SDimitry Andric // Reduce - Perform Reduction Transformation on scalar\packed FP. 4180b57cec5SDimitry Andric VREDUCE, VREDUCE_SAE, VREDUCES, VREDUCES_SAE, 4190b57cec5SDimitry Andric // RndScale - Round FP Values To Include A Given Number Of Fraction Bits. 4200b57cec5SDimitry Andric // Also used by the legacy (V)ROUND intrinsics where we mask out the 4210b57cec5SDimitry Andric // scaling part of the immediate. 4220b57cec5SDimitry Andric VRNDSCALE, VRNDSCALE_SAE, VRNDSCALES, VRNDSCALES_SAE, 4230b57cec5SDimitry Andric // Tests Types Of a FP Values for packed types. 4240b57cec5SDimitry Andric VFPCLASS, 4250b57cec5SDimitry Andric // Tests Types Of a FP Values for scalar types. 4260b57cec5SDimitry Andric VFPCLASSS, 4270b57cec5SDimitry Andric 4280b57cec5SDimitry Andric // Broadcast (splat) scalar or element 0 of a vector. If the operand is 4290b57cec5SDimitry Andric // a vector, this node may change the vector length as part of the splat. 4300b57cec5SDimitry Andric VBROADCAST, 4310b57cec5SDimitry Andric // Broadcast mask to vector. 4320b57cec5SDimitry Andric VBROADCASTM, 4330b57cec5SDimitry Andric // Broadcast subvector to vector. 4340b57cec5SDimitry Andric SUBV_BROADCAST, 4350b57cec5SDimitry Andric 4360b57cec5SDimitry Andric /// SSE4A Extraction and Insertion. 4370b57cec5SDimitry Andric EXTRQI, INSERTQI, 4380b57cec5SDimitry Andric 4390b57cec5SDimitry Andric // XOP arithmetic/logical shifts. 4400b57cec5SDimitry Andric VPSHA, VPSHL, 4410b57cec5SDimitry Andric // XOP signed/unsigned integer comparisons. 4420b57cec5SDimitry Andric VPCOM, VPCOMU, 4430b57cec5SDimitry Andric // XOP packed permute bytes. 4440b57cec5SDimitry Andric VPPERM, 4450b57cec5SDimitry Andric // XOP two source permutation. 4460b57cec5SDimitry Andric VPERMIL2, 4470b57cec5SDimitry Andric 4480b57cec5SDimitry Andric // Vector multiply packed unsigned doubleword integers. 4490b57cec5SDimitry Andric PMULUDQ, 4500b57cec5SDimitry Andric // Vector multiply packed signed doubleword integers. 4510b57cec5SDimitry Andric PMULDQ, 4520b57cec5SDimitry Andric // Vector Multiply Packed UnsignedIntegers with Round and Scale. 4530b57cec5SDimitry Andric MULHRS, 4540b57cec5SDimitry Andric 4550b57cec5SDimitry Andric // Multiply and Add Packed Integers. 4560b57cec5SDimitry Andric VPMADDUBSW, VPMADDWD, 4570b57cec5SDimitry Andric 4580b57cec5SDimitry Andric // AVX512IFMA multiply and add. 4590b57cec5SDimitry Andric // NOTE: These are different than the instruction and perform 4600b57cec5SDimitry Andric // op0 x op1 + op2. 4610b57cec5SDimitry Andric VPMADD52L, VPMADD52H, 4620b57cec5SDimitry Andric 4630b57cec5SDimitry Andric // VNNI 4640b57cec5SDimitry Andric VPDPBUSD, 4650b57cec5SDimitry Andric VPDPBUSDS, 4660b57cec5SDimitry Andric VPDPWSSD, 4670b57cec5SDimitry Andric VPDPWSSDS, 4680b57cec5SDimitry Andric 4690b57cec5SDimitry Andric // FMA nodes. 4700b57cec5SDimitry Andric // We use the target independent ISD::FMA for the non-inverted case. 4710b57cec5SDimitry Andric FNMADD, 4720b57cec5SDimitry Andric FMSUB, 4730b57cec5SDimitry Andric FNMSUB, 4740b57cec5SDimitry Andric FMADDSUB, 4750b57cec5SDimitry Andric FMSUBADD, 4760b57cec5SDimitry Andric 4770b57cec5SDimitry Andric // FMA with rounding mode. 4780b57cec5SDimitry Andric FMADD_RND, 4790b57cec5SDimitry Andric FNMADD_RND, 4800b57cec5SDimitry Andric FMSUB_RND, 4810b57cec5SDimitry Andric FNMSUB_RND, 4820b57cec5SDimitry Andric FMADDSUB_RND, 4830b57cec5SDimitry Andric FMSUBADD_RND, 4840b57cec5SDimitry Andric 4850b57cec5SDimitry Andric // Compress and expand. 4860b57cec5SDimitry Andric COMPRESS, 4870b57cec5SDimitry Andric EXPAND, 4880b57cec5SDimitry Andric 4890b57cec5SDimitry Andric // Bits shuffle 4900b57cec5SDimitry Andric VPSHUFBITQMB, 4910b57cec5SDimitry Andric 4920b57cec5SDimitry Andric // Convert Unsigned/Integer to Floating-Point Value with rounding mode. 4930b57cec5SDimitry Andric SINT_TO_FP_RND, UINT_TO_FP_RND, 4940b57cec5SDimitry Andric SCALAR_SINT_TO_FP, SCALAR_UINT_TO_FP, 4950b57cec5SDimitry Andric SCALAR_SINT_TO_FP_RND, SCALAR_UINT_TO_FP_RND, 4960b57cec5SDimitry Andric 4970b57cec5SDimitry Andric // Vector float/double to signed/unsigned integer. 4980b57cec5SDimitry Andric CVTP2SI, CVTP2UI, CVTP2SI_RND, CVTP2UI_RND, 4990b57cec5SDimitry Andric // Scalar float/double to signed/unsigned integer. 5000b57cec5SDimitry Andric CVTS2SI, CVTS2UI, CVTS2SI_RND, CVTS2UI_RND, 5010b57cec5SDimitry Andric 5020b57cec5SDimitry Andric // Vector float/double to signed/unsigned integer with truncation. 5030b57cec5SDimitry Andric CVTTP2SI, CVTTP2UI, CVTTP2SI_SAE, CVTTP2UI_SAE, 5040b57cec5SDimitry Andric // Scalar float/double to signed/unsigned integer with truncation. 5050b57cec5SDimitry Andric CVTTS2SI, CVTTS2UI, CVTTS2SI_SAE, CVTTS2UI_SAE, 5060b57cec5SDimitry Andric 5070b57cec5SDimitry Andric // Vector signed/unsigned integer to float/double. 5080b57cec5SDimitry Andric CVTSI2P, CVTUI2P, 5090b57cec5SDimitry Andric 5100b57cec5SDimitry Andric // Masked versions of above. Used for v2f64->v4f32. 5110b57cec5SDimitry Andric // SRC, PASSTHRU, MASK 5120b57cec5SDimitry Andric MCVTP2SI, MCVTP2UI, MCVTTP2SI, MCVTTP2UI, 5130b57cec5SDimitry Andric MCVTSI2P, MCVTUI2P, 5140b57cec5SDimitry Andric 5150b57cec5SDimitry Andric // Vector float to bfloat16. 5160b57cec5SDimitry Andric // Convert TWO packed single data to one packed BF16 data 5170b57cec5SDimitry Andric CVTNE2PS2BF16, 5180b57cec5SDimitry Andric // Convert packed single data to packed BF16 data 5190b57cec5SDimitry Andric CVTNEPS2BF16, 5200b57cec5SDimitry Andric // Masked version of above. 5210b57cec5SDimitry Andric // SRC, PASSTHRU, MASK 5220b57cec5SDimitry Andric MCVTNEPS2BF16, 5230b57cec5SDimitry Andric 5240b57cec5SDimitry Andric // Dot product of BF16 pairs to accumulated into 5250b57cec5SDimitry Andric // packed single precision. 5260b57cec5SDimitry Andric DPBF16PS, 5270b57cec5SDimitry Andric 5280b57cec5SDimitry Andric // Save xmm argument registers to the stack, according to %al. An operator 5290b57cec5SDimitry Andric // is needed so that this can be expanded with control flow. 5300b57cec5SDimitry Andric VASTART_SAVE_XMM_REGS, 5310b57cec5SDimitry Andric 5320b57cec5SDimitry Andric // Windows's _chkstk call to do stack probing. 5330b57cec5SDimitry Andric WIN_ALLOCA, 5340b57cec5SDimitry Andric 5350b57cec5SDimitry Andric // For allocating variable amounts of stack space when using 5360b57cec5SDimitry Andric // segmented stacks. Check if the current stacklet has enough space, and 5370b57cec5SDimitry Andric // falls back to heap allocation if not. 5380b57cec5SDimitry Andric SEG_ALLOCA, 5390b57cec5SDimitry Andric 5400b57cec5SDimitry Andric // Memory barriers. 5410b57cec5SDimitry Andric MEMBARRIER, 5420b57cec5SDimitry Andric MFENCE, 5430b57cec5SDimitry Andric 5440b57cec5SDimitry Andric // Store FP status word into i16 register. 5450b57cec5SDimitry Andric FNSTSW16r, 5460b57cec5SDimitry Andric 5470b57cec5SDimitry Andric // Store contents of %ah into %eflags. 5480b57cec5SDimitry Andric SAHF, 5490b57cec5SDimitry Andric 5500b57cec5SDimitry Andric // Get a random integer and indicate whether it is valid in CF. 5510b57cec5SDimitry Andric RDRAND, 5520b57cec5SDimitry Andric 5530b57cec5SDimitry Andric // Get a NIST SP800-90B & C compliant random integer and 5540b57cec5SDimitry Andric // indicate whether it is valid in CF. 5550b57cec5SDimitry Andric RDSEED, 5560b57cec5SDimitry Andric 5570b57cec5SDimitry Andric // Protection keys 5580b57cec5SDimitry Andric // RDPKRU - Operand 0 is chain. Operand 1 is value for ECX. 5590b57cec5SDimitry Andric // WRPKRU - Operand 0 is chain. Operand 1 is value for EDX. Operand 2 is 5600b57cec5SDimitry Andric // value for ECX. 5610b57cec5SDimitry Andric RDPKRU, WRPKRU, 5620b57cec5SDimitry Andric 5630b57cec5SDimitry Andric // SSE42 string comparisons. 5640b57cec5SDimitry Andric // These nodes produce 3 results, index, mask, and flags. X86ISelDAGToDAG 5650b57cec5SDimitry Andric // will emit one or two instructions based on which results are used. If 5660b57cec5SDimitry Andric // flags and index/mask this allows us to use a single instruction since 5670b57cec5SDimitry Andric // we won't have to pick and opcode for flags. Instead we can rely on the 5680b57cec5SDimitry Andric // DAG to CSE everything and decide at isel. 5690b57cec5SDimitry Andric PCMPISTR, 5700b57cec5SDimitry Andric PCMPESTR, 5710b57cec5SDimitry Andric 5720b57cec5SDimitry Andric // Test if in transactional execution. 5730b57cec5SDimitry Andric XTEST, 5740b57cec5SDimitry Andric 5750b57cec5SDimitry Andric // ERI instructions. 5760b57cec5SDimitry Andric RSQRT28, RSQRT28_SAE, RSQRT28S, RSQRT28S_SAE, 5770b57cec5SDimitry Andric RCP28, RCP28_SAE, RCP28S, RCP28S_SAE, EXP2, EXP2_SAE, 5780b57cec5SDimitry Andric 5790b57cec5SDimitry Andric // Conversions between float and half-float. 5800b57cec5SDimitry Andric CVTPS2PH, CVTPH2PS, CVTPH2PS_SAE, 5810b57cec5SDimitry Andric 5820b57cec5SDimitry Andric // Masked version of above. 5830b57cec5SDimitry Andric // SRC, RND, PASSTHRU, MASK 5840b57cec5SDimitry Andric MCVTPS2PH, 5850b57cec5SDimitry Andric 5860b57cec5SDimitry Andric // Galois Field Arithmetic Instructions 5870b57cec5SDimitry Andric GF2P8AFFINEINVQB, GF2P8AFFINEQB, GF2P8MULB, 5880b57cec5SDimitry Andric 5890b57cec5SDimitry Andric // LWP insert record. 5900b57cec5SDimitry Andric LWPINS, 5910b57cec5SDimitry Andric 5920b57cec5SDimitry Andric // User level wait 5930b57cec5SDimitry Andric UMWAIT, TPAUSE, 5940b57cec5SDimitry Andric 5950b57cec5SDimitry Andric // Enqueue Stores Instructions 5960b57cec5SDimitry Andric ENQCMD, ENQCMDS, 5970b57cec5SDimitry Andric 5980b57cec5SDimitry Andric // For avx512-vp2intersect 5990b57cec5SDimitry Andric VP2INTERSECT, 6000b57cec5SDimitry Andric 6010b57cec5SDimitry Andric // Compare and swap. 6020b57cec5SDimitry Andric LCMPXCHG_DAG = ISD::FIRST_TARGET_MEMORY_OPCODE, 6030b57cec5SDimitry Andric LCMPXCHG8_DAG, 6040b57cec5SDimitry Andric LCMPXCHG16_DAG, 6050b57cec5SDimitry Andric LCMPXCHG8_SAVE_EBX_DAG, 6060b57cec5SDimitry Andric LCMPXCHG16_SAVE_RBX_DAG, 6070b57cec5SDimitry Andric 6080b57cec5SDimitry Andric /// LOCK-prefixed arithmetic read-modify-write instructions. 6090b57cec5SDimitry Andric /// EFLAGS, OUTCHAIN = LADD(INCHAIN, PTR, RHS) 6100b57cec5SDimitry Andric LADD, LSUB, LOR, LXOR, LAND, 6110b57cec5SDimitry Andric 6120b57cec5SDimitry Andric // Load, scalar_to_vector, and zero extend. 6130b57cec5SDimitry Andric VZEXT_LOAD, 6140b57cec5SDimitry Andric 6150b57cec5SDimitry Andric // extract_vector_elt, store. 6160b57cec5SDimitry Andric VEXTRACT_STORE, 6170b57cec5SDimitry Andric 618*8bcb0991SDimitry Andric // scalar broadcast from memory 619*8bcb0991SDimitry Andric VBROADCAST_LOAD, 620*8bcb0991SDimitry Andric 6210b57cec5SDimitry Andric // Store FP control world into i16 memory. 6220b57cec5SDimitry Andric FNSTCW16m, 6230b57cec5SDimitry Andric 6240b57cec5SDimitry Andric /// This instruction implements FP_TO_SINT with the 6250b57cec5SDimitry Andric /// integer destination in memory and a FP reg source. This corresponds 6260b57cec5SDimitry Andric /// to the X86::FIST*m instructions and the rounding mode change stuff. It 6270b57cec5SDimitry Andric /// has two inputs (token chain and address) and two outputs (int value 6280b57cec5SDimitry Andric /// and token chain). Memory VT specifies the type to store to. 6290b57cec5SDimitry Andric FP_TO_INT_IN_MEM, 6300b57cec5SDimitry Andric 6310b57cec5SDimitry Andric /// This instruction implements SINT_TO_FP with the 6320b57cec5SDimitry Andric /// integer source in memory and FP reg result. This corresponds to the 6330b57cec5SDimitry Andric /// X86::FILD*m instructions. It has two inputs (token chain and address) 6340b57cec5SDimitry Andric /// and two outputs (FP value and token chain). FILD_FLAG also produces a 6350b57cec5SDimitry Andric /// flag). The integer source type is specified by the memory VT. 6360b57cec5SDimitry Andric FILD, 6370b57cec5SDimitry Andric FILD_FLAG, 6380b57cec5SDimitry Andric 6390b57cec5SDimitry Andric /// This instruction implements a fp->int store from FP stack 6400b57cec5SDimitry Andric /// slots. This corresponds to the fist instruction. It takes a 6410b57cec5SDimitry Andric /// chain operand, value to store, address, and glue. The memory VT 6420b57cec5SDimitry Andric /// specifies the type to store as. 6430b57cec5SDimitry Andric FIST, 6440b57cec5SDimitry Andric 6450b57cec5SDimitry Andric /// This instruction implements an extending load to FP stack slots. 6460b57cec5SDimitry Andric /// This corresponds to the X86::FLD32m / X86::FLD64m. It takes a chain 6470b57cec5SDimitry Andric /// operand, and ptr to load from. The memory VT specifies the type to 6480b57cec5SDimitry Andric /// load from. 6490b57cec5SDimitry Andric FLD, 6500b57cec5SDimitry Andric 6510b57cec5SDimitry Andric /// This instruction implements a truncating store from FP stack 6520b57cec5SDimitry Andric /// slots. This corresponds to the X86::FST32m / X86::FST64m. It takes a 6530b57cec5SDimitry Andric /// chain operand, value to store, address, and glue. The memory VT 6540b57cec5SDimitry Andric /// specifies the type to store as. 6550b57cec5SDimitry Andric FST, 6560b57cec5SDimitry Andric 6570b57cec5SDimitry Andric /// This instruction grabs the address of the next argument 6580b57cec5SDimitry Andric /// from a va_list. (reads and modifies the va_list in memory) 6590b57cec5SDimitry Andric VAARG_64, 6600b57cec5SDimitry Andric 6610b57cec5SDimitry Andric // Vector truncating store with unsigned/signed saturation 6620b57cec5SDimitry Andric VTRUNCSTOREUS, VTRUNCSTORES, 6630b57cec5SDimitry Andric // Vector truncating masked store with unsigned/signed saturation 6640b57cec5SDimitry Andric VMTRUNCSTOREUS, VMTRUNCSTORES, 6650b57cec5SDimitry Andric 6660b57cec5SDimitry Andric // X86 specific gather and scatter 6670b57cec5SDimitry Andric MGATHER, MSCATTER, 6680b57cec5SDimitry Andric 6690b57cec5SDimitry Andric // WARNING: Do not add anything in the end unless you want the node to 6700b57cec5SDimitry Andric // have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all 6710b57cec5SDimitry Andric // opcodes will be thought as target memory ops! 6720b57cec5SDimitry Andric }; 6730b57cec5SDimitry Andric } // end namespace X86ISD 6740b57cec5SDimitry Andric 6750b57cec5SDimitry Andric /// Define some predicates that are used for node matching. 6760b57cec5SDimitry Andric namespace X86 { 6770b57cec5SDimitry Andric /// Returns true if Elt is a constant zero or floating point constant +0.0. 6780b57cec5SDimitry Andric bool isZeroNode(SDValue Elt); 6790b57cec5SDimitry Andric 6800b57cec5SDimitry Andric /// Returns true of the given offset can be 6810b57cec5SDimitry Andric /// fit into displacement field of the instruction. 6820b57cec5SDimitry Andric bool isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M, 6830b57cec5SDimitry Andric bool hasSymbolicDisplacement = true); 6840b57cec5SDimitry Andric 6850b57cec5SDimitry Andric /// Determines whether the callee is required to pop its 6860b57cec5SDimitry Andric /// own arguments. Callee pop is necessary to support tail calls. 6870b57cec5SDimitry Andric bool isCalleePop(CallingConv::ID CallingConv, 6880b57cec5SDimitry Andric bool is64Bit, bool IsVarArg, bool GuaranteeTCO); 6890b57cec5SDimitry Andric 690*8bcb0991SDimitry Andric /// If Op is a constant whose elements are all the same constant or 691*8bcb0991SDimitry Andric /// undefined, return true and return the constant value in \p SplatVal. 692*8bcb0991SDimitry Andric bool isConstantSplat(SDValue Op, APInt &SplatVal); 6930b57cec5SDimitry Andric } // end namespace X86 6940b57cec5SDimitry Andric 6950b57cec5SDimitry Andric //===--------------------------------------------------------------------===// 6960b57cec5SDimitry Andric // X86 Implementation of the TargetLowering interface 6970b57cec5SDimitry Andric class X86TargetLowering final : public TargetLowering { 6980b57cec5SDimitry Andric public: 6990b57cec5SDimitry Andric explicit X86TargetLowering(const X86TargetMachine &TM, 7000b57cec5SDimitry Andric const X86Subtarget &STI); 7010b57cec5SDimitry Andric 7020b57cec5SDimitry Andric unsigned getJumpTableEncoding() const override; 7030b57cec5SDimitry Andric bool useSoftFloat() const override; 7040b57cec5SDimitry Andric 7050b57cec5SDimitry Andric void markLibCallAttributes(MachineFunction *MF, unsigned CC, 7060b57cec5SDimitry Andric ArgListTy &Args) const override; 7070b57cec5SDimitry Andric 7080b57cec5SDimitry Andric MVT getScalarShiftAmountTy(const DataLayout &, EVT VT) const override { 7090b57cec5SDimitry Andric return MVT::i8; 7100b57cec5SDimitry Andric } 7110b57cec5SDimitry Andric 7120b57cec5SDimitry Andric const MCExpr * 7130b57cec5SDimitry Andric LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI, 7140b57cec5SDimitry Andric const MachineBasicBlock *MBB, unsigned uid, 7150b57cec5SDimitry Andric MCContext &Ctx) const override; 7160b57cec5SDimitry Andric 7170b57cec5SDimitry Andric /// Returns relocation base for the given PIC jumptable. 7180b57cec5SDimitry Andric SDValue getPICJumpTableRelocBase(SDValue Table, 7190b57cec5SDimitry Andric SelectionDAG &DAG) const override; 7200b57cec5SDimitry Andric const MCExpr * 7210b57cec5SDimitry Andric getPICJumpTableRelocBaseExpr(const MachineFunction *MF, 7220b57cec5SDimitry Andric unsigned JTI, MCContext &Ctx) const override; 7230b57cec5SDimitry Andric 7240b57cec5SDimitry Andric /// Return the desired alignment for ByVal aggregate 7250b57cec5SDimitry Andric /// function arguments in the caller parameter area. For X86, aggregates 7260b57cec5SDimitry Andric /// that contains are placed at 16-byte boundaries while the rest are at 7270b57cec5SDimitry Andric /// 4-byte boundaries. 7280b57cec5SDimitry Andric unsigned getByValTypeAlignment(Type *Ty, 7290b57cec5SDimitry Andric const DataLayout &DL) const override; 7300b57cec5SDimitry Andric 7310b57cec5SDimitry Andric /// Returns the target specific optimal type for load 7320b57cec5SDimitry Andric /// and store operations as a result of memset, memcpy, and memmove 7330b57cec5SDimitry Andric /// lowering. If DstAlign is zero that means it's safe to destination 7340b57cec5SDimitry Andric /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it 7350b57cec5SDimitry Andric /// means there isn't a need to check it against alignment requirement, 7360b57cec5SDimitry Andric /// probably because the source does not need to be loaded. If 'IsMemset' is 7370b57cec5SDimitry Andric /// true, that means it's expanding a memset. If 'ZeroMemset' is true, that 7380b57cec5SDimitry Andric /// means it's a memset of zero. 'MemcpyStrSrc' indicates whether the memcpy 7390b57cec5SDimitry Andric /// source is constant so it does not need to be loaded. 7400b57cec5SDimitry Andric /// It returns EVT::Other if the type should be determined using generic 7410b57cec5SDimitry Andric /// target-independent logic. 7420b57cec5SDimitry Andric EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, 7430b57cec5SDimitry Andric bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc, 7440b57cec5SDimitry Andric const AttributeList &FuncAttributes) const override; 7450b57cec5SDimitry Andric 7460b57cec5SDimitry Andric /// Returns true if it's safe to use load / store of the 7470b57cec5SDimitry Andric /// specified type to expand memcpy / memset inline. This is mostly true 7480b57cec5SDimitry Andric /// for all types except for some special cases. For example, on X86 7490b57cec5SDimitry Andric /// targets without SSE2 f64 load / store are done with fldl / fstpl which 7500b57cec5SDimitry Andric /// also does type conversion. Note the specified type doesn't have to be 7510b57cec5SDimitry Andric /// legal as the hook is used before type legalization. 7520b57cec5SDimitry Andric bool isSafeMemOpType(MVT VT) const override; 7530b57cec5SDimitry Andric 7540b57cec5SDimitry Andric /// Returns true if the target allows unaligned memory accesses of the 7550b57cec5SDimitry Andric /// specified type. Returns whether it is "fast" in the last argument. 7560b57cec5SDimitry Andric bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, unsigned Align, 7570b57cec5SDimitry Andric MachineMemOperand::Flags Flags, 7580b57cec5SDimitry Andric bool *Fast) const override; 7590b57cec5SDimitry Andric 7600b57cec5SDimitry Andric /// Provide custom lowering hooks for some operations. 7610b57cec5SDimitry Andric /// 7620b57cec5SDimitry Andric SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 7630b57cec5SDimitry Andric 7640b57cec5SDimitry Andric /// Places new result values for the node in Results (their number 7650b57cec5SDimitry Andric /// and types must exactly match those of the original return values of 7660b57cec5SDimitry Andric /// the node), or leaves Results empty, which indicates that the node is not 7670b57cec5SDimitry Andric /// to be custom lowered after all. 7680b57cec5SDimitry Andric void LowerOperationWrapper(SDNode *N, 7690b57cec5SDimitry Andric SmallVectorImpl<SDValue> &Results, 7700b57cec5SDimitry Andric SelectionDAG &DAG) const override; 7710b57cec5SDimitry Andric 7720b57cec5SDimitry Andric /// Replace the results of node with an illegal result 7730b57cec5SDimitry Andric /// type with new values built out of custom code. 7740b57cec5SDimitry Andric /// 7750b57cec5SDimitry Andric void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, 7760b57cec5SDimitry Andric SelectionDAG &DAG) const override; 7770b57cec5SDimitry Andric 7780b57cec5SDimitry Andric SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; 7790b57cec5SDimitry Andric 7800b57cec5SDimitry Andric // Return true if it is profitable to combine a BUILD_VECTOR with a 7810b57cec5SDimitry Andric // stride-pattern to a shuffle and a truncate. 7820b57cec5SDimitry Andric // Example of such a combine: 7830b57cec5SDimitry Andric // v4i32 build_vector((extract_elt V, 1), 7840b57cec5SDimitry Andric // (extract_elt V, 3), 7850b57cec5SDimitry Andric // (extract_elt V, 5), 7860b57cec5SDimitry Andric // (extract_elt V, 7)) 7870b57cec5SDimitry Andric // --> 7880b57cec5SDimitry Andric // v4i32 truncate (bitcast (shuffle<1,u,3,u,4,u,5,u,6,u,7,u> V, u) to 7890b57cec5SDimitry Andric // v4i64) 7900b57cec5SDimitry Andric bool isDesirableToCombineBuildVectorToShuffleTruncate( 7910b57cec5SDimitry Andric ArrayRef<int> ShuffleMask, EVT SrcVT, EVT TruncVT) const override; 7920b57cec5SDimitry Andric 7930b57cec5SDimitry Andric /// Return true if the target has native support for 7940b57cec5SDimitry Andric /// the specified value type and it is 'desirable' to use the type for the 7950b57cec5SDimitry Andric /// given node type. e.g. On x86 i16 is legal, but undesirable since i16 7960b57cec5SDimitry Andric /// instruction encodings are longer and some i16 instructions are slow. 7970b57cec5SDimitry Andric bool isTypeDesirableForOp(unsigned Opc, EVT VT) const override; 7980b57cec5SDimitry Andric 7990b57cec5SDimitry Andric /// Return true if the target has native support for the 8000b57cec5SDimitry Andric /// specified value type and it is 'desirable' to use the type. e.g. On x86 8010b57cec5SDimitry Andric /// i16 is legal, but undesirable since i16 instruction encodings are longer 8020b57cec5SDimitry Andric /// and some i16 instructions are slow. 8030b57cec5SDimitry Andric bool IsDesirableToPromoteOp(SDValue Op, EVT &PVT) const override; 8040b57cec5SDimitry Andric 805*8bcb0991SDimitry Andric /// Return 1 if we can compute the negated form of the specified expression 806*8bcb0991SDimitry Andric /// for the same cost as the expression itself, or 2 if we can compute the 807*8bcb0991SDimitry Andric /// negated form more cheaply than the expression itself. Else return 0. 808*8bcb0991SDimitry Andric char isNegatibleForFree(SDValue Op, SelectionDAG &DAG, bool LegalOperations, 809*8bcb0991SDimitry Andric bool ForCodeSize, unsigned Depth) const override; 810*8bcb0991SDimitry Andric 811*8bcb0991SDimitry Andric /// If isNegatibleForFree returns true, return the newly negated expression. 812*8bcb0991SDimitry Andric SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, 813*8bcb0991SDimitry Andric bool LegalOperations, bool ForCodeSize, 814*8bcb0991SDimitry Andric unsigned Depth) const override; 815*8bcb0991SDimitry Andric 8160b57cec5SDimitry Andric MachineBasicBlock * 8170b57cec5SDimitry Andric EmitInstrWithCustomInserter(MachineInstr &MI, 8180b57cec5SDimitry Andric MachineBasicBlock *MBB) const override; 8190b57cec5SDimitry Andric 8200b57cec5SDimitry Andric /// This method returns the name of a target specific DAG node. 8210b57cec5SDimitry Andric const char *getTargetNodeName(unsigned Opcode) const override; 8220b57cec5SDimitry Andric 8230b57cec5SDimitry Andric /// Do not merge vector stores after legalization because that may conflict 8240b57cec5SDimitry Andric /// with x86-specific store splitting optimizations. 8250b57cec5SDimitry Andric bool mergeStoresAfterLegalization(EVT MemVT) const override { 8260b57cec5SDimitry Andric return !MemVT.isVector(); 8270b57cec5SDimitry Andric } 8280b57cec5SDimitry Andric 8290b57cec5SDimitry Andric bool canMergeStoresTo(unsigned AddressSpace, EVT MemVT, 8300b57cec5SDimitry Andric const SelectionDAG &DAG) const override; 8310b57cec5SDimitry Andric 8320b57cec5SDimitry Andric bool isCheapToSpeculateCttz() const override; 8330b57cec5SDimitry Andric 8340b57cec5SDimitry Andric bool isCheapToSpeculateCtlz() const override; 8350b57cec5SDimitry Andric 8360b57cec5SDimitry Andric bool isCtlzFast() const override; 8370b57cec5SDimitry Andric 8380b57cec5SDimitry Andric bool hasBitPreservingFPLogic(EVT VT) const override { 8390b57cec5SDimitry Andric return VT == MVT::f32 || VT == MVT::f64 || VT.isVector(); 8400b57cec5SDimitry Andric } 8410b57cec5SDimitry Andric 8420b57cec5SDimitry Andric bool isMultiStoresCheaperThanBitsMerge(EVT LTy, EVT HTy) const override { 8430b57cec5SDimitry Andric // If the pair to store is a mixture of float and int values, we will 8440b57cec5SDimitry Andric // save two bitwise instructions and one float-to-int instruction and 8450b57cec5SDimitry Andric // increase one store instruction. There is potentially a more 8460b57cec5SDimitry Andric // significant benefit because it avoids the float->int domain switch 8470b57cec5SDimitry Andric // for input value. So It is more likely a win. 8480b57cec5SDimitry Andric if ((LTy.isFloatingPoint() && HTy.isInteger()) || 8490b57cec5SDimitry Andric (LTy.isInteger() && HTy.isFloatingPoint())) 8500b57cec5SDimitry Andric return true; 8510b57cec5SDimitry Andric // If the pair only contains int values, we will save two bitwise 8520b57cec5SDimitry Andric // instructions and increase one store instruction (costing one more 8530b57cec5SDimitry Andric // store buffer). Since the benefit is more blurred so we leave 8540b57cec5SDimitry Andric // such pair out until we get testcase to prove it is a win. 8550b57cec5SDimitry Andric return false; 8560b57cec5SDimitry Andric } 8570b57cec5SDimitry Andric 8580b57cec5SDimitry Andric bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override; 8590b57cec5SDimitry Andric 8600b57cec5SDimitry Andric bool hasAndNotCompare(SDValue Y) const override; 8610b57cec5SDimitry Andric 8620b57cec5SDimitry Andric bool hasAndNot(SDValue Y) const override; 8630b57cec5SDimitry Andric 864*8bcb0991SDimitry Andric bool hasBitTest(SDValue X, SDValue Y) const override; 865*8bcb0991SDimitry Andric 866*8bcb0991SDimitry Andric bool shouldProduceAndByConstByHoistingConstFromShiftsLHSOfAnd( 867*8bcb0991SDimitry Andric SDValue X, ConstantSDNode *XC, ConstantSDNode *CC, SDValue Y, 868*8bcb0991SDimitry Andric unsigned OldShiftOpcode, unsigned NewShiftOpcode, 869*8bcb0991SDimitry Andric SelectionDAG &DAG) const override; 870*8bcb0991SDimitry Andric 8710b57cec5SDimitry Andric bool shouldFoldConstantShiftPairToMask(const SDNode *N, 8720b57cec5SDimitry Andric CombineLevel Level) const override; 8730b57cec5SDimitry Andric 8740b57cec5SDimitry Andric bool shouldFoldMaskToVariableShiftPair(SDValue Y) const override; 8750b57cec5SDimitry Andric 8760b57cec5SDimitry Andric bool 8770b57cec5SDimitry Andric shouldTransformSignedTruncationCheck(EVT XVT, 8780b57cec5SDimitry Andric unsigned KeptBits) const override { 8790b57cec5SDimitry Andric // For vectors, we don't have a preference.. 8800b57cec5SDimitry Andric if (XVT.isVector()) 8810b57cec5SDimitry Andric return false; 8820b57cec5SDimitry Andric 8830b57cec5SDimitry Andric auto VTIsOk = [](EVT VT) -> bool { 8840b57cec5SDimitry Andric return VT == MVT::i8 || VT == MVT::i16 || VT == MVT::i32 || 8850b57cec5SDimitry Andric VT == MVT::i64; 8860b57cec5SDimitry Andric }; 8870b57cec5SDimitry Andric 8880b57cec5SDimitry Andric // We are ok with KeptBitsVT being byte/word/dword, what MOVS supports. 8890b57cec5SDimitry Andric // XVT will be larger than KeptBitsVT. 8900b57cec5SDimitry Andric MVT KeptBitsVT = MVT::getIntegerVT(KeptBits); 8910b57cec5SDimitry Andric return VTIsOk(XVT) && VTIsOk(KeptBitsVT); 8920b57cec5SDimitry Andric } 8930b57cec5SDimitry Andric 8940b57cec5SDimitry Andric bool shouldExpandShift(SelectionDAG &DAG, SDNode *N) const override; 8950b57cec5SDimitry Andric 8960b57cec5SDimitry Andric bool shouldSplatInsEltVarIndex(EVT VT) const override; 8970b57cec5SDimitry Andric 8980b57cec5SDimitry Andric bool convertSetCCLogicToBitwiseLogic(EVT VT) const override { 8990b57cec5SDimitry Andric return VT.isScalarInteger(); 9000b57cec5SDimitry Andric } 9010b57cec5SDimitry Andric 9020b57cec5SDimitry Andric /// Vector-sized comparisons are fast using PCMPEQ + PMOVMSK or PTEST. 9030b57cec5SDimitry Andric MVT hasFastEqualityCompare(unsigned NumBits) const override; 9040b57cec5SDimitry Andric 9050b57cec5SDimitry Andric /// Return the value type to use for ISD::SETCC. 9060b57cec5SDimitry Andric EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, 9070b57cec5SDimitry Andric EVT VT) const override; 9080b57cec5SDimitry Andric 9090b57cec5SDimitry Andric bool targetShrinkDemandedConstant(SDValue Op, const APInt &Demanded, 9100b57cec5SDimitry Andric TargetLoweringOpt &TLO) const override; 9110b57cec5SDimitry Andric 9120b57cec5SDimitry Andric /// Determine which of the bits specified in Mask are known to be either 9130b57cec5SDimitry Andric /// zero or one and return them in the KnownZero/KnownOne bitsets. 9140b57cec5SDimitry Andric void computeKnownBitsForTargetNode(const SDValue Op, 9150b57cec5SDimitry Andric KnownBits &Known, 9160b57cec5SDimitry Andric const APInt &DemandedElts, 9170b57cec5SDimitry Andric const SelectionDAG &DAG, 9180b57cec5SDimitry Andric unsigned Depth = 0) const override; 9190b57cec5SDimitry Andric 9200b57cec5SDimitry Andric /// Determine the number of bits in the operation that are sign bits. 9210b57cec5SDimitry Andric unsigned ComputeNumSignBitsForTargetNode(SDValue Op, 9220b57cec5SDimitry Andric const APInt &DemandedElts, 9230b57cec5SDimitry Andric const SelectionDAG &DAG, 9240b57cec5SDimitry Andric unsigned Depth) const override; 9250b57cec5SDimitry Andric 9260b57cec5SDimitry Andric bool SimplifyDemandedVectorEltsForTargetNode(SDValue Op, 9270b57cec5SDimitry Andric const APInt &DemandedElts, 9280b57cec5SDimitry Andric APInt &KnownUndef, 9290b57cec5SDimitry Andric APInt &KnownZero, 9300b57cec5SDimitry Andric TargetLoweringOpt &TLO, 9310b57cec5SDimitry Andric unsigned Depth) const override; 9320b57cec5SDimitry Andric 9330b57cec5SDimitry Andric bool SimplifyDemandedBitsForTargetNode(SDValue Op, 9340b57cec5SDimitry Andric const APInt &DemandedBits, 9350b57cec5SDimitry Andric const APInt &DemandedElts, 9360b57cec5SDimitry Andric KnownBits &Known, 9370b57cec5SDimitry Andric TargetLoweringOpt &TLO, 9380b57cec5SDimitry Andric unsigned Depth) const override; 9390b57cec5SDimitry Andric 940*8bcb0991SDimitry Andric SDValue SimplifyMultipleUseDemandedBitsForTargetNode( 941*8bcb0991SDimitry Andric SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, 942*8bcb0991SDimitry Andric SelectionDAG &DAG, unsigned Depth) const override; 943*8bcb0991SDimitry Andric 9440b57cec5SDimitry Andric const Constant *getTargetConstantFromLoad(LoadSDNode *LD) const override; 9450b57cec5SDimitry Andric 9460b57cec5SDimitry Andric SDValue unwrapAddress(SDValue N) const override; 9470b57cec5SDimitry Andric 9480b57cec5SDimitry Andric SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const; 9490b57cec5SDimitry Andric 9500b57cec5SDimitry Andric bool ExpandInlineAsm(CallInst *CI) const override; 9510b57cec5SDimitry Andric 9520b57cec5SDimitry Andric ConstraintType getConstraintType(StringRef Constraint) const override; 9530b57cec5SDimitry Andric 9540b57cec5SDimitry Andric /// Examine constraint string and operand type and determine a weight value. 9550b57cec5SDimitry Andric /// The operand object must already have been set up with the operand type. 9560b57cec5SDimitry Andric ConstraintWeight 9570b57cec5SDimitry Andric getSingleConstraintMatchWeight(AsmOperandInfo &info, 9580b57cec5SDimitry Andric const char *constraint) const override; 9590b57cec5SDimitry Andric 9600b57cec5SDimitry Andric const char *LowerXConstraint(EVT ConstraintVT) const override; 9610b57cec5SDimitry Andric 9620b57cec5SDimitry Andric /// Lower the specified operand into the Ops vector. If it is invalid, don't 9630b57cec5SDimitry Andric /// add anything to Ops. If hasMemory is true it means one of the asm 9640b57cec5SDimitry Andric /// constraint of the inline asm instruction being processed is 'm'. 9650b57cec5SDimitry Andric void LowerAsmOperandForConstraint(SDValue Op, 9660b57cec5SDimitry Andric std::string &Constraint, 9670b57cec5SDimitry Andric std::vector<SDValue> &Ops, 9680b57cec5SDimitry Andric SelectionDAG &DAG) const override; 9690b57cec5SDimitry Andric 9700b57cec5SDimitry Andric unsigned 9710b57cec5SDimitry Andric getInlineAsmMemConstraint(StringRef ConstraintCode) const override { 9720b57cec5SDimitry Andric if (ConstraintCode == "i") 9730b57cec5SDimitry Andric return InlineAsm::Constraint_i; 9740b57cec5SDimitry Andric else if (ConstraintCode == "o") 9750b57cec5SDimitry Andric return InlineAsm::Constraint_o; 9760b57cec5SDimitry Andric else if (ConstraintCode == "v") 9770b57cec5SDimitry Andric return InlineAsm::Constraint_v; 9780b57cec5SDimitry Andric else if (ConstraintCode == "X") 9790b57cec5SDimitry Andric return InlineAsm::Constraint_X; 9800b57cec5SDimitry Andric return TargetLowering::getInlineAsmMemConstraint(ConstraintCode); 9810b57cec5SDimitry Andric } 9820b57cec5SDimitry Andric 9830b57cec5SDimitry Andric /// Handle Lowering flag assembly outputs. 9840b57cec5SDimitry Andric SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Flag, SDLoc DL, 9850b57cec5SDimitry Andric const AsmOperandInfo &Constraint, 9860b57cec5SDimitry Andric SelectionDAG &DAG) const override; 9870b57cec5SDimitry Andric 9880b57cec5SDimitry Andric /// Given a physical register constraint 9890b57cec5SDimitry Andric /// (e.g. {edx}), return the register number and the register class for the 9900b57cec5SDimitry Andric /// register. This should only be used for C_Register constraints. On 9910b57cec5SDimitry Andric /// error, this returns a register number of 0. 9920b57cec5SDimitry Andric std::pair<unsigned, const TargetRegisterClass *> 9930b57cec5SDimitry Andric getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, 9940b57cec5SDimitry Andric StringRef Constraint, MVT VT) const override; 9950b57cec5SDimitry Andric 9960b57cec5SDimitry Andric /// Return true if the addressing mode represented 9970b57cec5SDimitry Andric /// by AM is legal for this target, for a load/store of the specified type. 9980b57cec5SDimitry Andric bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, 9990b57cec5SDimitry Andric Type *Ty, unsigned AS, 10000b57cec5SDimitry Andric Instruction *I = nullptr) const override; 10010b57cec5SDimitry Andric 10020b57cec5SDimitry Andric /// Return true if the specified immediate is legal 10030b57cec5SDimitry Andric /// icmp immediate, that is the target has icmp instructions which can 10040b57cec5SDimitry Andric /// compare a register against the immediate without having to materialize 10050b57cec5SDimitry Andric /// the immediate into a register. 10060b57cec5SDimitry Andric bool isLegalICmpImmediate(int64_t Imm) const override; 10070b57cec5SDimitry Andric 10080b57cec5SDimitry Andric /// Return true if the specified immediate is legal 10090b57cec5SDimitry Andric /// add immediate, that is the target has add instructions which can 10100b57cec5SDimitry Andric /// add a register and the immediate without having to materialize 10110b57cec5SDimitry Andric /// the immediate into a register. 10120b57cec5SDimitry Andric bool isLegalAddImmediate(int64_t Imm) const override; 10130b57cec5SDimitry Andric 10140b57cec5SDimitry Andric bool isLegalStoreImmediate(int64_t Imm) const override; 10150b57cec5SDimitry Andric 10160b57cec5SDimitry Andric /// Return the cost of the scaling factor used in the addressing 10170b57cec5SDimitry Andric /// mode represented by AM for this target, for a load/store 10180b57cec5SDimitry Andric /// of the specified type. 10190b57cec5SDimitry Andric /// If the AM is supported, the return value must be >= 0. 10200b57cec5SDimitry Andric /// If the AM is not supported, it returns a negative value. 10210b57cec5SDimitry Andric int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty, 10220b57cec5SDimitry Andric unsigned AS) const override; 10230b57cec5SDimitry Andric 10240b57cec5SDimitry Andric bool isVectorShiftByScalarCheap(Type *Ty) const override; 10250b57cec5SDimitry Andric 10260b57cec5SDimitry Andric /// Add x86-specific opcodes to the default list. 10270b57cec5SDimitry Andric bool isBinOp(unsigned Opcode) const override; 10280b57cec5SDimitry Andric 10290b57cec5SDimitry Andric /// Returns true if the opcode is a commutative binary operation. 10300b57cec5SDimitry Andric bool isCommutativeBinOp(unsigned Opcode) const override; 10310b57cec5SDimitry Andric 10320b57cec5SDimitry Andric /// Return true if it's free to truncate a value of 10330b57cec5SDimitry Andric /// type Ty1 to type Ty2. e.g. On x86 it's free to truncate a i32 value in 10340b57cec5SDimitry Andric /// register EAX to i16 by referencing its sub-register AX. 10350b57cec5SDimitry Andric bool isTruncateFree(Type *Ty1, Type *Ty2) const override; 10360b57cec5SDimitry Andric bool isTruncateFree(EVT VT1, EVT VT2) const override; 10370b57cec5SDimitry Andric 10380b57cec5SDimitry Andric bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override; 10390b57cec5SDimitry Andric 10400b57cec5SDimitry Andric /// Return true if any actual instruction that defines a 10410b57cec5SDimitry Andric /// value of type Ty1 implicit zero-extends the value to Ty2 in the result 10420b57cec5SDimitry Andric /// register. This does not necessarily include registers defined in 10430b57cec5SDimitry Andric /// unknown ways, such as incoming arguments, or copies from unknown 10440b57cec5SDimitry Andric /// virtual registers. Also, if isTruncateFree(Ty2, Ty1) is true, this 10450b57cec5SDimitry Andric /// does not necessarily apply to truncate instructions. e.g. on x86-64, 10460b57cec5SDimitry Andric /// all instructions that define 32-bit values implicit zero-extend the 10470b57cec5SDimitry Andric /// result out to 64 bits. 10480b57cec5SDimitry Andric bool isZExtFree(Type *Ty1, Type *Ty2) const override; 10490b57cec5SDimitry Andric bool isZExtFree(EVT VT1, EVT VT2) const override; 10500b57cec5SDimitry Andric bool isZExtFree(SDValue Val, EVT VT2) const override; 10510b57cec5SDimitry Andric 10520b57cec5SDimitry Andric /// Return true if folding a vector load into ExtVal (a sign, zero, or any 10530b57cec5SDimitry Andric /// extend node) is profitable. 10540b57cec5SDimitry Andric bool isVectorLoadExtDesirable(SDValue) const override; 10550b57cec5SDimitry Andric 10560b57cec5SDimitry Andric /// Return true if an FMA operation is faster than a pair of fmul and fadd 10570b57cec5SDimitry Andric /// instructions. fmuladd intrinsics will be expanded to FMAs when this 10580b57cec5SDimitry Andric /// method returns true, otherwise fmuladd is expanded to fmul + fadd. 10590b57cec5SDimitry Andric bool isFMAFasterThanFMulAndFAdd(EVT VT) const override; 10600b57cec5SDimitry Andric 10610b57cec5SDimitry Andric /// Return true if it's profitable to narrow 10620b57cec5SDimitry Andric /// operations of type VT1 to VT2. e.g. on x86, it's profitable to narrow 10630b57cec5SDimitry Andric /// from i32 to i8 but not from i32 to i16. 10640b57cec5SDimitry Andric bool isNarrowingProfitable(EVT VT1, EVT VT2) const override; 10650b57cec5SDimitry Andric 10660b57cec5SDimitry Andric /// Given an intrinsic, checks if on the target the intrinsic will need to map 10670b57cec5SDimitry Andric /// to a MemIntrinsicNode (touches memory). If this is the case, it returns 10680b57cec5SDimitry Andric /// true and stores the intrinsic information into the IntrinsicInfo that was 10690b57cec5SDimitry Andric /// passed to the function. 10700b57cec5SDimitry Andric bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, 10710b57cec5SDimitry Andric MachineFunction &MF, 10720b57cec5SDimitry Andric unsigned Intrinsic) const override; 10730b57cec5SDimitry Andric 10740b57cec5SDimitry Andric /// Returns true if the target can instruction select the 10750b57cec5SDimitry Andric /// specified FP immediate natively. If false, the legalizer will 10760b57cec5SDimitry Andric /// materialize the FP immediate as a load from a constant pool. 10770b57cec5SDimitry Andric bool isFPImmLegal(const APFloat &Imm, EVT VT, 10780b57cec5SDimitry Andric bool ForCodeSize) const override; 10790b57cec5SDimitry Andric 10800b57cec5SDimitry Andric /// Targets can use this to indicate that they only support *some* 10810b57cec5SDimitry Andric /// VECTOR_SHUFFLE operations, those with specific masks. By default, if a 10820b57cec5SDimitry Andric /// target supports the VECTOR_SHUFFLE node, all mask values are assumed to 10830b57cec5SDimitry Andric /// be legal. 10840b57cec5SDimitry Andric bool isShuffleMaskLegal(ArrayRef<int> Mask, EVT VT) const override; 10850b57cec5SDimitry Andric 10860b57cec5SDimitry Andric /// Similar to isShuffleMaskLegal. Targets can use this to indicate if there 10870b57cec5SDimitry Andric /// is a suitable VECTOR_SHUFFLE that can be used to replace a VAND with a 10880b57cec5SDimitry Andric /// constant pool entry. 10890b57cec5SDimitry Andric bool isVectorClearMaskLegal(ArrayRef<int> Mask, EVT VT) const override; 10900b57cec5SDimitry Andric 10910b57cec5SDimitry Andric /// Returns true if lowering to a jump table is allowed. 10920b57cec5SDimitry Andric bool areJTsAllowed(const Function *Fn) const override; 10930b57cec5SDimitry Andric 10940b57cec5SDimitry Andric /// If true, then instruction selection should 10950b57cec5SDimitry Andric /// seek to shrink the FP constant of the specified type to a smaller type 10960b57cec5SDimitry Andric /// in order to save space and / or reduce runtime. 10970b57cec5SDimitry Andric bool ShouldShrinkFPConstant(EVT VT) const override { 10980b57cec5SDimitry Andric // Don't shrink FP constpool if SSE2 is available since cvtss2sd is more 10990b57cec5SDimitry Andric // expensive than a straight movsd. On the other hand, it's important to 11000b57cec5SDimitry Andric // shrink long double fp constant since fldt is very slow. 11010b57cec5SDimitry Andric return !X86ScalarSSEf64 || VT == MVT::f80; 11020b57cec5SDimitry Andric } 11030b57cec5SDimitry Andric 11040b57cec5SDimitry Andric /// Return true if we believe it is correct and profitable to reduce the 11050b57cec5SDimitry Andric /// load node to a smaller type. 11060b57cec5SDimitry Andric bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, 11070b57cec5SDimitry Andric EVT NewVT) const override; 11080b57cec5SDimitry Andric 11090b57cec5SDimitry Andric /// Return true if the specified scalar FP type is computed in an SSE 11100b57cec5SDimitry Andric /// register, not on the X87 floating point stack. 11110b57cec5SDimitry Andric bool isScalarFPTypeInSSEReg(EVT VT) const { 11120b57cec5SDimitry Andric return (VT == MVT::f64 && X86ScalarSSEf64) || // f64 is when SSE2 11130b57cec5SDimitry Andric (VT == MVT::f32 && X86ScalarSSEf32); // f32 is when SSE1 11140b57cec5SDimitry Andric } 11150b57cec5SDimitry Andric 11160b57cec5SDimitry Andric /// Returns true if it is beneficial to convert a load of a constant 11170b57cec5SDimitry Andric /// to just the constant itself. 11180b57cec5SDimitry Andric bool shouldConvertConstantLoadToIntImm(const APInt &Imm, 11190b57cec5SDimitry Andric Type *Ty) const override; 11200b57cec5SDimitry Andric 1121*8bcb0991SDimitry Andric bool reduceSelectOfFPConstantLoads(EVT CmpOpVT) const override; 11220b57cec5SDimitry Andric 11230b57cec5SDimitry Andric bool convertSelectOfConstantsToMath(EVT VT) const override; 11240b57cec5SDimitry Andric 1125*8bcb0991SDimitry Andric bool decomposeMulByConstant(LLVMContext &Context, EVT VT, 1126*8bcb0991SDimitry Andric SDValue C) const override; 11270b57cec5SDimitry Andric 11280b57cec5SDimitry Andric bool shouldUseStrictFP_TO_INT(EVT FpVT, EVT IntVT, 11290b57cec5SDimitry Andric bool IsSigned) const override; 11300b57cec5SDimitry Andric 11310b57cec5SDimitry Andric /// Return true if EXTRACT_SUBVECTOR is cheap for this result type 11320b57cec5SDimitry Andric /// with this index. 11330b57cec5SDimitry Andric bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT, 11340b57cec5SDimitry Andric unsigned Index) const override; 11350b57cec5SDimitry Andric 11360b57cec5SDimitry Andric /// Scalar ops always have equal or better analysis/performance/power than 11370b57cec5SDimitry Andric /// the vector equivalent, so this always makes sense if the scalar op is 11380b57cec5SDimitry Andric /// supported. 11390b57cec5SDimitry Andric bool shouldScalarizeBinop(SDValue) const override; 11400b57cec5SDimitry Andric 11410b57cec5SDimitry Andric /// Extract of a scalar FP value from index 0 of a vector is free. 11420b57cec5SDimitry Andric bool isExtractVecEltCheap(EVT VT, unsigned Index) const override { 11430b57cec5SDimitry Andric EVT EltVT = VT.getScalarType(); 11440b57cec5SDimitry Andric return (EltVT == MVT::f32 || EltVT == MVT::f64) && Index == 0; 11450b57cec5SDimitry Andric } 11460b57cec5SDimitry Andric 11470b57cec5SDimitry Andric /// Overflow nodes should get combined/lowered to optimal instructions 11480b57cec5SDimitry Andric /// (they should allow eliminating explicit compares by getting flags from 11490b57cec5SDimitry Andric /// math ops). 11500b57cec5SDimitry Andric bool shouldFormOverflowOp(unsigned Opcode, EVT VT) const override; 11510b57cec5SDimitry Andric 11520b57cec5SDimitry Andric bool storeOfVectorConstantIsCheap(EVT MemVT, unsigned NumElem, 11530b57cec5SDimitry Andric unsigned AddrSpace) const override { 11540b57cec5SDimitry Andric // If we can replace more than 2 scalar stores, there will be a reduction 11550b57cec5SDimitry Andric // in instructions even after we add a vector constant load. 11560b57cec5SDimitry Andric return NumElem > 2; 11570b57cec5SDimitry Andric } 11580b57cec5SDimitry Andric 11590b57cec5SDimitry Andric bool isLoadBitCastBeneficial(EVT LoadVT, EVT BitcastVT, 11600b57cec5SDimitry Andric const SelectionDAG &DAG, 11610b57cec5SDimitry Andric const MachineMemOperand &MMO) const override; 11620b57cec5SDimitry Andric 11630b57cec5SDimitry Andric /// Intel processors have a unified instruction and data cache 11640b57cec5SDimitry Andric const char * getClearCacheBuiltinName() const override { 11650b57cec5SDimitry Andric return nullptr; // nothing to do, move along. 11660b57cec5SDimitry Andric } 11670b57cec5SDimitry Andric 1168*8bcb0991SDimitry Andric Register getRegisterByName(const char* RegName, EVT VT, 1169*8bcb0991SDimitry Andric const MachineFunction &MF) const override; 11700b57cec5SDimitry Andric 11710b57cec5SDimitry Andric /// If a physical register, this returns the register that receives the 11720b57cec5SDimitry Andric /// exception address on entry to an EH pad. 11730b57cec5SDimitry Andric unsigned 11740b57cec5SDimitry Andric getExceptionPointerRegister(const Constant *PersonalityFn) const override; 11750b57cec5SDimitry Andric 11760b57cec5SDimitry Andric /// If a physical register, this returns the register that receives the 11770b57cec5SDimitry Andric /// exception typeid on entry to a landing pad. 11780b57cec5SDimitry Andric unsigned 11790b57cec5SDimitry Andric getExceptionSelectorRegister(const Constant *PersonalityFn) const override; 11800b57cec5SDimitry Andric 11810b57cec5SDimitry Andric virtual bool needsFixedCatchObjects() const override; 11820b57cec5SDimitry Andric 11830b57cec5SDimitry Andric /// This method returns a target specific FastISel object, 11840b57cec5SDimitry Andric /// or null if the target does not support "fast" ISel. 11850b57cec5SDimitry Andric FastISel *createFastISel(FunctionLoweringInfo &funcInfo, 11860b57cec5SDimitry Andric const TargetLibraryInfo *libInfo) const override; 11870b57cec5SDimitry Andric 11880b57cec5SDimitry Andric /// If the target has a standard location for the stack protector cookie, 11890b57cec5SDimitry Andric /// returns the address of that location. Otherwise, returns nullptr. 11900b57cec5SDimitry Andric Value *getIRStackGuard(IRBuilder<> &IRB) const override; 11910b57cec5SDimitry Andric 11920b57cec5SDimitry Andric bool useLoadStackGuardNode() const override; 11930b57cec5SDimitry Andric bool useStackGuardXorFP() const override; 11940b57cec5SDimitry Andric void insertSSPDeclarations(Module &M) const override; 11950b57cec5SDimitry Andric Value *getSDagStackGuard(const Module &M) const override; 11960b57cec5SDimitry Andric Function *getSSPStackGuardCheck(const Module &M) const override; 11970b57cec5SDimitry Andric SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val, 11980b57cec5SDimitry Andric const SDLoc &DL) const override; 11990b57cec5SDimitry Andric 12000b57cec5SDimitry Andric 12010b57cec5SDimitry Andric /// Return true if the target stores SafeStack pointer at a fixed offset in 12020b57cec5SDimitry Andric /// some non-standard address space, and populates the address space and 12030b57cec5SDimitry Andric /// offset as appropriate. 12040b57cec5SDimitry Andric Value *getSafeStackPointerLocation(IRBuilder<> &IRB) const override; 12050b57cec5SDimitry Andric 12060b57cec5SDimitry Andric SDValue BuildFILD(SDValue Op, EVT SrcVT, SDValue Chain, SDValue StackSlot, 12070b57cec5SDimitry Andric SelectionDAG &DAG) const; 12080b57cec5SDimitry Andric 12090b57cec5SDimitry Andric bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override; 12100b57cec5SDimitry Andric 12110b57cec5SDimitry Andric /// Customize the preferred legalization strategy for certain types. 12120b57cec5SDimitry Andric LegalizeTypeAction getPreferredVectorAction(MVT VT) const override; 12130b57cec5SDimitry Andric 12140b57cec5SDimitry Andric MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, 12150b57cec5SDimitry Andric EVT VT) const override; 12160b57cec5SDimitry Andric 12170b57cec5SDimitry Andric unsigned getNumRegistersForCallingConv(LLVMContext &Context, 12180b57cec5SDimitry Andric CallingConv::ID CC, 12190b57cec5SDimitry Andric EVT VT) const override; 12200b57cec5SDimitry Andric 1221*8bcb0991SDimitry Andric unsigned getVectorTypeBreakdownForCallingConv( 1222*8bcb0991SDimitry Andric LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, 1223*8bcb0991SDimitry Andric unsigned &NumIntermediates, MVT &RegisterVT) const override; 1224*8bcb0991SDimitry Andric 12250b57cec5SDimitry Andric bool isIntDivCheap(EVT VT, AttributeList Attr) const override; 12260b57cec5SDimitry Andric 12270b57cec5SDimitry Andric bool supportSwiftError() const override; 12280b57cec5SDimitry Andric 12290b57cec5SDimitry Andric StringRef getStackProbeSymbolName(MachineFunction &MF) const override; 12300b57cec5SDimitry Andric 1231*8bcb0991SDimitry Andric unsigned getStackProbeSize(MachineFunction &MF) const; 1232*8bcb0991SDimitry Andric 12330b57cec5SDimitry Andric bool hasVectorBlend() const override { return true; } 12340b57cec5SDimitry Andric 12350b57cec5SDimitry Andric unsigned getMaxSupportedInterleaveFactor() const override { return 4; } 12360b57cec5SDimitry Andric 12370b57cec5SDimitry Andric /// Lower interleaved load(s) into target specific 12380b57cec5SDimitry Andric /// instructions/intrinsics. 12390b57cec5SDimitry Andric bool lowerInterleavedLoad(LoadInst *LI, 12400b57cec5SDimitry Andric ArrayRef<ShuffleVectorInst *> Shuffles, 12410b57cec5SDimitry Andric ArrayRef<unsigned> Indices, 12420b57cec5SDimitry Andric unsigned Factor) const override; 12430b57cec5SDimitry Andric 12440b57cec5SDimitry Andric /// Lower interleaved store(s) into target specific 12450b57cec5SDimitry Andric /// instructions/intrinsics. 12460b57cec5SDimitry Andric bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI, 12470b57cec5SDimitry Andric unsigned Factor) const override; 12480b57cec5SDimitry Andric 12490b57cec5SDimitry Andric SDValue expandIndirectJTBranch(const SDLoc& dl, SDValue Value, 12500b57cec5SDimitry Andric SDValue Addr, SelectionDAG &DAG) 12510b57cec5SDimitry Andric const override; 12520b57cec5SDimitry Andric 12530b57cec5SDimitry Andric protected: 12540b57cec5SDimitry Andric std::pair<const TargetRegisterClass *, uint8_t> 12550b57cec5SDimitry Andric findRepresentativeClass(const TargetRegisterInfo *TRI, 12560b57cec5SDimitry Andric MVT VT) const override; 12570b57cec5SDimitry Andric 12580b57cec5SDimitry Andric private: 12590b57cec5SDimitry Andric /// Keep a reference to the X86Subtarget around so that we can 12600b57cec5SDimitry Andric /// make the right decision when generating code for different targets. 12610b57cec5SDimitry Andric const X86Subtarget &Subtarget; 12620b57cec5SDimitry Andric 12630b57cec5SDimitry Andric /// Select between SSE or x87 floating point ops. 12640b57cec5SDimitry Andric /// When SSE is available, use it for f32 operations. 12650b57cec5SDimitry Andric /// When SSE2 is available, use it for f64 operations. 12660b57cec5SDimitry Andric bool X86ScalarSSEf32; 12670b57cec5SDimitry Andric bool X86ScalarSSEf64; 12680b57cec5SDimitry Andric 12690b57cec5SDimitry Andric /// A list of legal FP immediates. 12700b57cec5SDimitry Andric std::vector<APFloat> LegalFPImmediates; 12710b57cec5SDimitry Andric 12720b57cec5SDimitry Andric /// Indicate that this x86 target can instruction 12730b57cec5SDimitry Andric /// select the specified FP immediate natively. 12740b57cec5SDimitry Andric void addLegalFPImmediate(const APFloat& Imm) { 12750b57cec5SDimitry Andric LegalFPImmediates.push_back(Imm); 12760b57cec5SDimitry Andric } 12770b57cec5SDimitry Andric 12780b57cec5SDimitry Andric SDValue LowerCallResult(SDValue Chain, SDValue InFlag, 12790b57cec5SDimitry Andric CallingConv::ID CallConv, bool isVarArg, 12800b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &Ins, 12810b57cec5SDimitry Andric const SDLoc &dl, SelectionDAG &DAG, 12820b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals, 12830b57cec5SDimitry Andric uint32_t *RegMask) const; 12840b57cec5SDimitry Andric SDValue LowerMemArgument(SDValue Chain, CallingConv::ID CallConv, 12850b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &ArgInfo, 12860b57cec5SDimitry Andric const SDLoc &dl, SelectionDAG &DAG, 12870b57cec5SDimitry Andric const CCValAssign &VA, MachineFrameInfo &MFI, 12880b57cec5SDimitry Andric unsigned i) const; 12890b57cec5SDimitry Andric SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg, 12900b57cec5SDimitry Andric const SDLoc &dl, SelectionDAG &DAG, 12910b57cec5SDimitry Andric const CCValAssign &VA, 12920b57cec5SDimitry Andric ISD::ArgFlagsTy Flags) const; 12930b57cec5SDimitry Andric 12940b57cec5SDimitry Andric // Call lowering helpers. 12950b57cec5SDimitry Andric 12960b57cec5SDimitry Andric /// Check whether the call is eligible for tail call optimization. Targets 12970b57cec5SDimitry Andric /// that want to do tail call optimization should implement this function. 12980b57cec5SDimitry Andric bool IsEligibleForTailCallOptimization(SDValue Callee, 12990b57cec5SDimitry Andric CallingConv::ID CalleeCC, 13000b57cec5SDimitry Andric bool isVarArg, 13010b57cec5SDimitry Andric bool isCalleeStructRet, 13020b57cec5SDimitry Andric bool isCallerStructRet, 13030b57cec5SDimitry Andric Type *RetTy, 13040b57cec5SDimitry Andric const SmallVectorImpl<ISD::OutputArg> &Outs, 13050b57cec5SDimitry Andric const SmallVectorImpl<SDValue> &OutVals, 13060b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &Ins, 13070b57cec5SDimitry Andric SelectionDAG& DAG) const; 13080b57cec5SDimitry Andric SDValue EmitTailCallLoadRetAddr(SelectionDAG &DAG, SDValue &OutRetAddr, 13090b57cec5SDimitry Andric SDValue Chain, bool IsTailCall, 13100b57cec5SDimitry Andric bool Is64Bit, int FPDiff, 13110b57cec5SDimitry Andric const SDLoc &dl) const; 13120b57cec5SDimitry Andric 13130b57cec5SDimitry Andric unsigned GetAlignedArgumentStackSize(unsigned StackSize, 13140b57cec5SDimitry Andric SelectionDAG &DAG) const; 13150b57cec5SDimitry Andric 13160b57cec5SDimitry Andric unsigned getAddressSpace(void) const; 13170b57cec5SDimitry Andric 13180b57cec5SDimitry Andric SDValue FP_TO_INTHelper(SDValue Op, SelectionDAG &DAG, bool isSigned) const; 13190b57cec5SDimitry Andric 13200b57cec5SDimitry Andric SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const; 13210b57cec5SDimitry Andric SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const; 13220b57cec5SDimitry Andric SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 13230b57cec5SDimitry Andric SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const; 13240b57cec5SDimitry Andric 13250b57cec5SDimitry Andric unsigned getGlobalWrapperKind(const GlobalValue *GV = nullptr, 13260b57cec5SDimitry Andric const unsigned char OpFlags = 0) const; 13270b57cec5SDimitry Andric SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; 13280b57cec5SDimitry Andric SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; 13290b57cec5SDimitry Andric SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; 13300b57cec5SDimitry Andric SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; 13310b57cec5SDimitry Andric SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const; 13320b57cec5SDimitry Andric 13330b57cec5SDimitry Andric /// Creates target global address or external symbol nodes for calls or 13340b57cec5SDimitry Andric /// other uses. 13350b57cec5SDimitry Andric SDValue LowerGlobalOrExternal(SDValue Op, SelectionDAG &DAG, 13360b57cec5SDimitry Andric bool ForCall) const; 13370b57cec5SDimitry Andric 13380b57cec5SDimitry Andric SDValue LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG) const; 13390b57cec5SDimitry Andric SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG) const; 13400b57cec5SDimitry Andric SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const; 13410b57cec5SDimitry Andric SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const; 13420b57cec5SDimitry Andric SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const; 13430b57cec5SDimitry Andric SDValue LowerSETCCCARRY(SDValue Op, SelectionDAG &DAG) const; 13440b57cec5SDimitry Andric SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const; 13450b57cec5SDimitry Andric SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const; 13460b57cec5SDimitry Andric SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const; 13470b57cec5SDimitry Andric SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; 13480b57cec5SDimitry Andric SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const; 13490b57cec5SDimitry Andric SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const; 13500b57cec5SDimitry Andric SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; 13510b57cec5SDimitry Andric SDValue LowerADDROFRETURNADDR(SDValue Op, SelectionDAG &DAG) const; 13520b57cec5SDimitry Andric SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const; 13530b57cec5SDimitry Andric SDValue LowerFRAME_TO_ARGS_OFFSET(SDValue Op, SelectionDAG &DAG) const; 13540b57cec5SDimitry Andric SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const; 13550b57cec5SDimitry Andric SDValue lowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const; 13560b57cec5SDimitry Andric SDValue lowerEH_SJLJ_LONGJMP(SDValue Op, SelectionDAG &DAG) const; 13570b57cec5SDimitry Andric SDValue lowerEH_SJLJ_SETUP_DISPATCH(SDValue Op, SelectionDAG &DAG) const; 13580b57cec5SDimitry Andric SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const; 13590b57cec5SDimitry Andric SDValue LowerFLT_ROUNDS_(SDValue Op, SelectionDAG &DAG) const; 13600b57cec5SDimitry Andric SDValue LowerWin64_i128OP(SDValue Op, SelectionDAG &DAG) const; 13610b57cec5SDimitry Andric SDValue LowerGC_TRANSITION_START(SDValue Op, SelectionDAG &DAG) const; 13620b57cec5SDimitry Andric SDValue LowerGC_TRANSITION_END(SDValue Op, SelectionDAG &DAG) const; 13630b57cec5SDimitry Andric SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const; 1364*8bcb0991SDimitry Andric SDValue lowerFaddFsub(SDValue Op, SelectionDAG &DAG) const; 1365*8bcb0991SDimitry Andric SDValue LowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const; 1366*8bcb0991SDimitry Andric SDValue LowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const; 1367*8bcb0991SDimitry Andric 1368*8bcb0991SDimitry Andric SDValue LowerF128Call(SDValue Op, SelectionDAG &DAG, 1369*8bcb0991SDimitry Andric RTLIB::Libcall Call) const; 13700b57cec5SDimitry Andric 13710b57cec5SDimitry Andric SDValue 13720b57cec5SDimitry Andric LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 13730b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &Ins, 13740b57cec5SDimitry Andric const SDLoc &dl, SelectionDAG &DAG, 13750b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals) const override; 13760b57cec5SDimitry Andric SDValue LowerCall(CallLoweringInfo &CLI, 13770b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals) const override; 13780b57cec5SDimitry Andric 13790b57cec5SDimitry Andric SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 13800b57cec5SDimitry Andric const SmallVectorImpl<ISD::OutputArg> &Outs, 13810b57cec5SDimitry Andric const SmallVectorImpl<SDValue> &OutVals, 13820b57cec5SDimitry Andric const SDLoc &dl, SelectionDAG &DAG) const override; 13830b57cec5SDimitry Andric 13840b57cec5SDimitry Andric bool supportSplitCSR(MachineFunction *MF) const override { 13850b57cec5SDimitry Andric return MF->getFunction().getCallingConv() == CallingConv::CXX_FAST_TLS && 13860b57cec5SDimitry Andric MF->getFunction().hasFnAttribute(Attribute::NoUnwind); 13870b57cec5SDimitry Andric } 13880b57cec5SDimitry Andric void initializeSplitCSR(MachineBasicBlock *Entry) const override; 13890b57cec5SDimitry Andric void insertCopiesSplitCSR( 13900b57cec5SDimitry Andric MachineBasicBlock *Entry, 13910b57cec5SDimitry Andric const SmallVectorImpl<MachineBasicBlock *> &Exits) const override; 13920b57cec5SDimitry Andric 13930b57cec5SDimitry Andric bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override; 13940b57cec5SDimitry Andric 13950b57cec5SDimitry Andric bool mayBeEmittedAsTailCall(const CallInst *CI) const override; 13960b57cec5SDimitry Andric 13970b57cec5SDimitry Andric EVT getTypeForExtReturn(LLVMContext &Context, EVT VT, 13980b57cec5SDimitry Andric ISD::NodeType ExtendKind) const override; 13990b57cec5SDimitry Andric 14000b57cec5SDimitry Andric bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, 14010b57cec5SDimitry Andric bool isVarArg, 14020b57cec5SDimitry Andric const SmallVectorImpl<ISD::OutputArg> &Outs, 14030b57cec5SDimitry Andric LLVMContext &Context) const override; 14040b57cec5SDimitry Andric 14050b57cec5SDimitry Andric const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override; 14060b57cec5SDimitry Andric 14070b57cec5SDimitry Andric TargetLoweringBase::AtomicExpansionKind 14080b57cec5SDimitry Andric shouldExpandAtomicLoadInIR(LoadInst *SI) const override; 14090b57cec5SDimitry Andric bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override; 14100b57cec5SDimitry Andric TargetLoweringBase::AtomicExpansionKind 14110b57cec5SDimitry Andric shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override; 14120b57cec5SDimitry Andric 14130b57cec5SDimitry Andric LoadInst * 14140b57cec5SDimitry Andric lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const override; 14150b57cec5SDimitry Andric 1416*8bcb0991SDimitry Andric bool lowerAtomicStoreAsStoreSDNode(const StoreInst &SI) const override; 1417*8bcb0991SDimitry Andric bool lowerAtomicLoadAsLoadSDNode(const LoadInst &LI) const override; 1418*8bcb0991SDimitry Andric 14190b57cec5SDimitry Andric bool needsCmpXchgNb(Type *MemType) const; 14200b57cec5SDimitry Andric 14210b57cec5SDimitry Andric void SetupEntryBlockForSjLj(MachineInstr &MI, MachineBasicBlock *MBB, 14220b57cec5SDimitry Andric MachineBasicBlock *DispatchBB, int FI) const; 14230b57cec5SDimitry Andric 14240b57cec5SDimitry Andric // Utility function to emit the low-level va_arg code for X86-64. 14250b57cec5SDimitry Andric MachineBasicBlock * 14260b57cec5SDimitry Andric EmitVAARG64WithCustomInserter(MachineInstr &MI, 14270b57cec5SDimitry Andric MachineBasicBlock *MBB) const; 14280b57cec5SDimitry Andric 14290b57cec5SDimitry Andric /// Utility function to emit the xmm reg save portion of va_start. 14300b57cec5SDimitry Andric MachineBasicBlock * 14310b57cec5SDimitry Andric EmitVAStartSaveXMMRegsWithCustomInserter(MachineInstr &BInstr, 14320b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14330b57cec5SDimitry Andric 14340b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredCascadedSelect(MachineInstr &MI1, 14350b57cec5SDimitry Andric MachineInstr &MI2, 14360b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14370b57cec5SDimitry Andric 14380b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredSelect(MachineInstr &I, 14390b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14400b57cec5SDimitry Andric 14410b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredAtomicFP(MachineInstr &I, 14420b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14430b57cec5SDimitry Andric 14440b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredCatchRet(MachineInstr &MI, 14450b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14460b57cec5SDimitry Andric 14470b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredCatchPad(MachineInstr &MI, 14480b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14490b57cec5SDimitry Andric 14500b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredSegAlloca(MachineInstr &MI, 14510b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14520b57cec5SDimitry Andric 14530b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredTLSAddr(MachineInstr &MI, 14540b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14550b57cec5SDimitry Andric 14560b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredTLSCall(MachineInstr &MI, 14570b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14580b57cec5SDimitry Andric 14590b57cec5SDimitry Andric MachineBasicBlock *EmitLoweredRetpoline(MachineInstr &MI, 14600b57cec5SDimitry Andric MachineBasicBlock *BB) const; 14610b57cec5SDimitry Andric 14620b57cec5SDimitry Andric MachineBasicBlock *emitEHSjLjSetJmp(MachineInstr &MI, 14630b57cec5SDimitry Andric MachineBasicBlock *MBB) const; 14640b57cec5SDimitry Andric 14650b57cec5SDimitry Andric void emitSetJmpShadowStackFix(MachineInstr &MI, 14660b57cec5SDimitry Andric MachineBasicBlock *MBB) const; 14670b57cec5SDimitry Andric 14680b57cec5SDimitry Andric MachineBasicBlock *emitEHSjLjLongJmp(MachineInstr &MI, 14690b57cec5SDimitry Andric MachineBasicBlock *MBB) const; 14700b57cec5SDimitry Andric 14710b57cec5SDimitry Andric MachineBasicBlock *emitLongJmpShadowStackFix(MachineInstr &MI, 14720b57cec5SDimitry Andric MachineBasicBlock *MBB) const; 14730b57cec5SDimitry Andric 14740b57cec5SDimitry Andric MachineBasicBlock *emitFMA3Instr(MachineInstr &MI, 14750b57cec5SDimitry Andric MachineBasicBlock *MBB) const; 14760b57cec5SDimitry Andric 14770b57cec5SDimitry Andric MachineBasicBlock *EmitSjLjDispatchBlock(MachineInstr &MI, 14780b57cec5SDimitry Andric MachineBasicBlock *MBB) const; 14790b57cec5SDimitry Andric 14800b57cec5SDimitry Andric /// Emit nodes that will be selected as "cmp Op0,Op1", or something 14810b57cec5SDimitry Andric /// equivalent, for use with the given x86 condition code. 14820b57cec5SDimitry Andric SDValue EmitCmp(SDValue Op0, SDValue Op1, unsigned X86CC, const SDLoc &dl, 14830b57cec5SDimitry Andric SelectionDAG &DAG) const; 14840b57cec5SDimitry Andric 14850b57cec5SDimitry Andric /// Convert a comparison if required by the subtarget. 14860b57cec5SDimitry Andric SDValue ConvertCmpIfNecessary(SDValue Cmp, SelectionDAG &DAG) const; 14870b57cec5SDimitry Andric 14880b57cec5SDimitry Andric /// Emit flags for the given setcc condition and operands. Also returns the 14890b57cec5SDimitry Andric /// corresponding X86 condition code constant in X86CC. 14900b57cec5SDimitry Andric SDValue emitFlagsForSetcc(SDValue Op0, SDValue Op1, 14910b57cec5SDimitry Andric ISD::CondCode CC, const SDLoc &dl, 14920b57cec5SDimitry Andric SelectionDAG &DAG, 14930b57cec5SDimitry Andric SDValue &X86CC) const; 14940b57cec5SDimitry Andric 14950b57cec5SDimitry Andric /// Check if replacement of SQRT with RSQRT should be disabled. 14960b57cec5SDimitry Andric bool isFsqrtCheap(SDValue Operand, SelectionDAG &DAG) const override; 14970b57cec5SDimitry Andric 14980b57cec5SDimitry Andric /// Use rsqrt* to speed up sqrt calculations. 14990b57cec5SDimitry Andric SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, 15000b57cec5SDimitry Andric int &RefinementSteps, bool &UseOneConstNR, 15010b57cec5SDimitry Andric bool Reciprocal) const override; 15020b57cec5SDimitry Andric 15030b57cec5SDimitry Andric /// Use rcp* to speed up fdiv calculations. 15040b57cec5SDimitry Andric SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, 15050b57cec5SDimitry Andric int &RefinementSteps) const override; 15060b57cec5SDimitry Andric 15070b57cec5SDimitry Andric /// Reassociate floating point divisions into multiply by reciprocal. 15080b57cec5SDimitry Andric unsigned combineRepeatedFPDivisors() const override; 1509*8bcb0991SDimitry Andric 1510*8bcb0991SDimitry Andric SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, 1511*8bcb0991SDimitry Andric SmallVectorImpl<SDNode *> &Created) const override; 15120b57cec5SDimitry Andric }; 15130b57cec5SDimitry Andric 15140b57cec5SDimitry Andric namespace X86 { 15150b57cec5SDimitry Andric FastISel *createFastISel(FunctionLoweringInfo &funcInfo, 15160b57cec5SDimitry Andric const TargetLibraryInfo *libInfo); 15170b57cec5SDimitry Andric } // end namespace X86 15180b57cec5SDimitry Andric 15190b57cec5SDimitry Andric // Base class for all X86 non-masked store operations. 15200b57cec5SDimitry Andric class X86StoreSDNode : public MemSDNode { 15210b57cec5SDimitry Andric public: 15220b57cec5SDimitry Andric X86StoreSDNode(unsigned Opcode, unsigned Order, const DebugLoc &dl, 15230b57cec5SDimitry Andric SDVTList VTs, EVT MemVT, 15240b57cec5SDimitry Andric MachineMemOperand *MMO) 15250b57cec5SDimitry Andric :MemSDNode(Opcode, Order, dl, VTs, MemVT, MMO) {} 15260b57cec5SDimitry Andric const SDValue &getValue() const { return getOperand(1); } 15270b57cec5SDimitry Andric const SDValue &getBasePtr() const { return getOperand(2); } 15280b57cec5SDimitry Andric 15290b57cec5SDimitry Andric static bool classof(const SDNode *N) { 15300b57cec5SDimitry Andric return N->getOpcode() == X86ISD::VTRUNCSTORES || 15310b57cec5SDimitry Andric N->getOpcode() == X86ISD::VTRUNCSTOREUS; 15320b57cec5SDimitry Andric } 15330b57cec5SDimitry Andric }; 15340b57cec5SDimitry Andric 15350b57cec5SDimitry Andric // Base class for all X86 masked store operations. 15360b57cec5SDimitry Andric // The class has the same order of operands as MaskedStoreSDNode for 15370b57cec5SDimitry Andric // convenience. 15380b57cec5SDimitry Andric class X86MaskedStoreSDNode : public MemSDNode { 15390b57cec5SDimitry Andric public: 15400b57cec5SDimitry Andric X86MaskedStoreSDNode(unsigned Opcode, unsigned Order, 15410b57cec5SDimitry Andric const DebugLoc &dl, SDVTList VTs, EVT MemVT, 15420b57cec5SDimitry Andric MachineMemOperand *MMO) 15430b57cec5SDimitry Andric : MemSDNode(Opcode, Order, dl, VTs, MemVT, MMO) {} 15440b57cec5SDimitry Andric 15450b57cec5SDimitry Andric const SDValue &getValue() const { return getOperand(1); } 15460b57cec5SDimitry Andric const SDValue &getBasePtr() const { return getOperand(2); } 15470b57cec5SDimitry Andric const SDValue &getMask() const { return getOperand(3); } 15480b57cec5SDimitry Andric 15490b57cec5SDimitry Andric static bool classof(const SDNode *N) { 15500b57cec5SDimitry Andric return N->getOpcode() == X86ISD::VMTRUNCSTORES || 15510b57cec5SDimitry Andric N->getOpcode() == X86ISD::VMTRUNCSTOREUS; 15520b57cec5SDimitry Andric } 15530b57cec5SDimitry Andric }; 15540b57cec5SDimitry Andric 15550b57cec5SDimitry Andric // X86 Truncating Store with Signed saturation. 15560b57cec5SDimitry Andric class TruncSStoreSDNode : public X86StoreSDNode { 15570b57cec5SDimitry Andric public: 15580b57cec5SDimitry Andric TruncSStoreSDNode(unsigned Order, const DebugLoc &dl, 15590b57cec5SDimitry Andric SDVTList VTs, EVT MemVT, MachineMemOperand *MMO) 15600b57cec5SDimitry Andric : X86StoreSDNode(X86ISD::VTRUNCSTORES, Order, dl, VTs, MemVT, MMO) {} 15610b57cec5SDimitry Andric 15620b57cec5SDimitry Andric static bool classof(const SDNode *N) { 15630b57cec5SDimitry Andric return N->getOpcode() == X86ISD::VTRUNCSTORES; 15640b57cec5SDimitry Andric } 15650b57cec5SDimitry Andric }; 15660b57cec5SDimitry Andric 15670b57cec5SDimitry Andric // X86 Truncating Store with Unsigned saturation. 15680b57cec5SDimitry Andric class TruncUSStoreSDNode : public X86StoreSDNode { 15690b57cec5SDimitry Andric public: 15700b57cec5SDimitry Andric TruncUSStoreSDNode(unsigned Order, const DebugLoc &dl, 15710b57cec5SDimitry Andric SDVTList VTs, EVT MemVT, MachineMemOperand *MMO) 15720b57cec5SDimitry Andric : X86StoreSDNode(X86ISD::VTRUNCSTOREUS, Order, dl, VTs, MemVT, MMO) {} 15730b57cec5SDimitry Andric 15740b57cec5SDimitry Andric static bool classof(const SDNode *N) { 15750b57cec5SDimitry Andric return N->getOpcode() == X86ISD::VTRUNCSTOREUS; 15760b57cec5SDimitry Andric } 15770b57cec5SDimitry Andric }; 15780b57cec5SDimitry Andric 15790b57cec5SDimitry Andric // X86 Truncating Masked Store with Signed saturation. 15800b57cec5SDimitry Andric class MaskedTruncSStoreSDNode : public X86MaskedStoreSDNode { 15810b57cec5SDimitry Andric public: 15820b57cec5SDimitry Andric MaskedTruncSStoreSDNode(unsigned Order, 15830b57cec5SDimitry Andric const DebugLoc &dl, SDVTList VTs, EVT MemVT, 15840b57cec5SDimitry Andric MachineMemOperand *MMO) 15850b57cec5SDimitry Andric : X86MaskedStoreSDNode(X86ISD::VMTRUNCSTORES, Order, dl, VTs, MemVT, MMO) {} 15860b57cec5SDimitry Andric 15870b57cec5SDimitry Andric static bool classof(const SDNode *N) { 15880b57cec5SDimitry Andric return N->getOpcode() == X86ISD::VMTRUNCSTORES; 15890b57cec5SDimitry Andric } 15900b57cec5SDimitry Andric }; 15910b57cec5SDimitry Andric 15920b57cec5SDimitry Andric // X86 Truncating Masked Store with Unsigned saturation. 15930b57cec5SDimitry Andric class MaskedTruncUSStoreSDNode : public X86MaskedStoreSDNode { 15940b57cec5SDimitry Andric public: 15950b57cec5SDimitry Andric MaskedTruncUSStoreSDNode(unsigned Order, 15960b57cec5SDimitry Andric const DebugLoc &dl, SDVTList VTs, EVT MemVT, 15970b57cec5SDimitry Andric MachineMemOperand *MMO) 15980b57cec5SDimitry Andric : X86MaskedStoreSDNode(X86ISD::VMTRUNCSTOREUS, Order, dl, VTs, MemVT, MMO) {} 15990b57cec5SDimitry Andric 16000b57cec5SDimitry Andric static bool classof(const SDNode *N) { 16010b57cec5SDimitry Andric return N->getOpcode() == X86ISD::VMTRUNCSTOREUS; 16020b57cec5SDimitry Andric } 16030b57cec5SDimitry Andric }; 16040b57cec5SDimitry Andric 16050b57cec5SDimitry Andric // X86 specific Gather/Scatter nodes. 16060b57cec5SDimitry Andric // The class has the same order of operands as MaskedGatherScatterSDNode for 16070b57cec5SDimitry Andric // convenience. 16080b57cec5SDimitry Andric class X86MaskedGatherScatterSDNode : public MemSDNode { 16090b57cec5SDimitry Andric public: 16100b57cec5SDimitry Andric X86MaskedGatherScatterSDNode(unsigned Opc, unsigned Order, 16110b57cec5SDimitry Andric const DebugLoc &dl, SDVTList VTs, EVT MemVT, 16120b57cec5SDimitry Andric MachineMemOperand *MMO) 16130b57cec5SDimitry Andric : MemSDNode(Opc, Order, dl, VTs, MemVT, MMO) {} 16140b57cec5SDimitry Andric 16150b57cec5SDimitry Andric const SDValue &getBasePtr() const { return getOperand(3); } 16160b57cec5SDimitry Andric const SDValue &getIndex() const { return getOperand(4); } 16170b57cec5SDimitry Andric const SDValue &getMask() const { return getOperand(2); } 16180b57cec5SDimitry Andric const SDValue &getScale() const { return getOperand(5); } 16190b57cec5SDimitry Andric 16200b57cec5SDimitry Andric static bool classof(const SDNode *N) { 16210b57cec5SDimitry Andric return N->getOpcode() == X86ISD::MGATHER || 16220b57cec5SDimitry Andric N->getOpcode() == X86ISD::MSCATTER; 16230b57cec5SDimitry Andric } 16240b57cec5SDimitry Andric }; 16250b57cec5SDimitry Andric 16260b57cec5SDimitry Andric class X86MaskedGatherSDNode : public X86MaskedGatherScatterSDNode { 16270b57cec5SDimitry Andric public: 16280b57cec5SDimitry Andric X86MaskedGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, 16290b57cec5SDimitry Andric EVT MemVT, MachineMemOperand *MMO) 16300b57cec5SDimitry Andric : X86MaskedGatherScatterSDNode(X86ISD::MGATHER, Order, dl, VTs, MemVT, 16310b57cec5SDimitry Andric MMO) {} 16320b57cec5SDimitry Andric 16330b57cec5SDimitry Andric const SDValue &getPassThru() const { return getOperand(1); } 16340b57cec5SDimitry Andric 16350b57cec5SDimitry Andric static bool classof(const SDNode *N) { 16360b57cec5SDimitry Andric return N->getOpcode() == X86ISD::MGATHER; 16370b57cec5SDimitry Andric } 16380b57cec5SDimitry Andric }; 16390b57cec5SDimitry Andric 16400b57cec5SDimitry Andric class X86MaskedScatterSDNode : public X86MaskedGatherScatterSDNode { 16410b57cec5SDimitry Andric public: 16420b57cec5SDimitry Andric X86MaskedScatterSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, 16430b57cec5SDimitry Andric EVT MemVT, MachineMemOperand *MMO) 16440b57cec5SDimitry Andric : X86MaskedGatherScatterSDNode(X86ISD::MSCATTER, Order, dl, VTs, MemVT, 16450b57cec5SDimitry Andric MMO) {} 16460b57cec5SDimitry Andric 16470b57cec5SDimitry Andric const SDValue &getValue() const { return getOperand(1); } 16480b57cec5SDimitry Andric 16490b57cec5SDimitry Andric static bool classof(const SDNode *N) { 16500b57cec5SDimitry Andric return N->getOpcode() == X86ISD::MSCATTER; 16510b57cec5SDimitry Andric } 16520b57cec5SDimitry Andric }; 16530b57cec5SDimitry Andric 16540b57cec5SDimitry Andric /// Generate unpacklo/unpackhi shuffle mask. 16550b57cec5SDimitry Andric template <typename T = int> 16560b57cec5SDimitry Andric void createUnpackShuffleMask(MVT VT, SmallVectorImpl<T> &Mask, bool Lo, 16570b57cec5SDimitry Andric bool Unary) { 16580b57cec5SDimitry Andric assert(Mask.empty() && "Expected an empty shuffle mask vector"); 16590b57cec5SDimitry Andric int NumElts = VT.getVectorNumElements(); 16600b57cec5SDimitry Andric int NumEltsInLane = 128 / VT.getScalarSizeInBits(); 16610b57cec5SDimitry Andric for (int i = 0; i < NumElts; ++i) { 16620b57cec5SDimitry Andric unsigned LaneStart = (i / NumEltsInLane) * NumEltsInLane; 16630b57cec5SDimitry Andric int Pos = (i % NumEltsInLane) / 2 + LaneStart; 16640b57cec5SDimitry Andric Pos += (Unary ? 0 : NumElts * (i % 2)); 16650b57cec5SDimitry Andric Pos += (Lo ? 0 : NumEltsInLane / 2); 16660b57cec5SDimitry Andric Mask.push_back(Pos); 16670b57cec5SDimitry Andric } 16680b57cec5SDimitry Andric } 16690b57cec5SDimitry Andric 16700b57cec5SDimitry Andric /// Helper function to scale a shuffle or target shuffle mask, replacing each 16710b57cec5SDimitry Andric /// mask index with the scaled sequential indices for an equivalent narrowed 16720b57cec5SDimitry Andric /// mask. This is the reverse process to canWidenShuffleElements, but can 16730b57cec5SDimitry Andric /// always succeed. 16740b57cec5SDimitry Andric template <typename T> 1675*8bcb0991SDimitry Andric void scaleShuffleMask(size_t Scale, ArrayRef<T> Mask, 16760b57cec5SDimitry Andric SmallVectorImpl<T> &ScaledMask) { 16770b57cec5SDimitry Andric assert(0 < Scale && "Unexpected scaling factor"); 16780b57cec5SDimitry Andric size_t NumElts = Mask.size(); 16790b57cec5SDimitry Andric ScaledMask.assign(NumElts * Scale, -1); 16800b57cec5SDimitry Andric 1681*8bcb0991SDimitry Andric for (size_t i = 0; i != NumElts; ++i) { 16820b57cec5SDimitry Andric int M = Mask[i]; 16830b57cec5SDimitry Andric 16840b57cec5SDimitry Andric // Repeat sentinel values in every mask element. 16850b57cec5SDimitry Andric if (M < 0) { 1686*8bcb0991SDimitry Andric for (size_t s = 0; s != Scale; ++s) 16870b57cec5SDimitry Andric ScaledMask[(Scale * i) + s] = M; 16880b57cec5SDimitry Andric continue; 16890b57cec5SDimitry Andric } 16900b57cec5SDimitry Andric 16910b57cec5SDimitry Andric // Scale mask element and increment across each mask element. 1692*8bcb0991SDimitry Andric for (size_t s = 0; s != Scale; ++s) 16930b57cec5SDimitry Andric ScaledMask[(Scale * i) + s] = (Scale * M) + s; 16940b57cec5SDimitry Andric } 16950b57cec5SDimitry Andric } 16960b57cec5SDimitry Andric } // end namespace llvm 16970b57cec5SDimitry Andric 16980b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_X86_X86ISELLOWERING_H 1699