23 #ifndef LLVM_CODEGEN_TARGETLOWERING_H 24 #define LLVM_CODEGEN_TARGETLOWERING_H 69 class BranchProbability;
74 class FunctionLoweringInfo;
79 class MachineBasicBlock;
80 class MachineFunction;
82 class MachineJumpTableInfo;
84 class MachineRegisterInfo;
88 class TargetRegisterClass;
89 class TargetLibraryInfo;
90 class TargetRegisterInfo;
143 ZeroOrNegativeOneBooleanContent
191 uint16_t Alignment = 0;
207 case UndefinedBooleanContent:
210 case ZeroOrOneBooleanContent:
213 case ZeroOrNegativeOneBooleanContent:
251 return getPointerTy(DL);
259 bool LegalTypes =
true)
const;
265 return getPointerTy(DL);
282 return HasMultipleConditionRegisters;
293 return TypeScalarizeVector;
295 return TypePromoteInteger;
309 unsigned DefinedValues)
const {
310 return DefinedValues < 3;
367 return BypassSlowDivWidths;
377 return PredictableSelectIsExpensive;
391 EVT BitcastVT)
const {
401 if (getOperationAction(
ISD::LOAD, LoadMVT) == Promote &&
412 return isLoadBitCastBeneficial(StoreVT, BitcastVT);
420 unsigned AddrSpace)
const {
518 return hasAndNotCompare(X);
539 unsigned KeptBits)
const {
553 unsigned &Cost)
const {
565 return HasFloatingPointExceptions;
600 return BooleanVectorContents;
601 return isFloat ? BooleanFloatContents : BooleanContents;
610 return SchedPreferenceInfo;
624 assert(RC &&
"This value type is not natively supported!");
643 return RepRegClassCostForVT[VT.
SimpleTy];
667 return ValueTypeActions[VT.
SimpleTy];
671 ValueTypeActions[VT.
SimpleTy] = Action;
676 return ValueTypeActions;
684 return getTypeConversion(Context, VT).first;
687 return ValueTypeActions.getTypeAction(VT);
697 return getTypeConversion(Context, VT).second;
707 switch (getTypeAction(Context, VT)) {
710 case TypeExpandInteger:
711 VT = getTypeToTransformTo(Context, VT);
729 unsigned &NumIntermediates,
730 MVT &RegisterVT)
const;
737 unsigned &NumIntermediates,
MVT &RegisterVT)
const {
738 return getVectorTypeBreakdown(Context, VT, IntermediateVT, NumIntermediates,
787 virtual bool canOpTrap(
unsigned Op,
EVT VT)
const;
812 unsigned Scale)
const {
821 unsigned Scale)
const {
822 auto Action = getOperationAction(Op, VT);
833 Supported = isSupportedFixedPointOperation(Op, VT, Scale);
837 return Supported ? Action : Expand;
870 auto Action = getOperationAction(EqOpc, VT);
884 return (VT ==
MVT::Other || isTypeLegal(VT)) &&
885 (getOperationAction(Op, VT) ==
Legal ||
886 getOperationAction(Op, VT) == Custom);
893 return (VT ==
MVT::Other || isTypeLegal(VT)) &&
894 (getOperationAction(Op, VT) ==
Legal ||
895 getOperationAction(Op, VT) == Promote);
902 return (VT ==
MVT::Other || isTypeLegal(VT)) &&
903 (getOperationAction(Op, VT) ==
Legal ||
904 getOperationAction(Op, VT) == Custom ||
905 getOperationAction(Op, VT) == Promote);
911 return getOperationAction(Op, VT) == Custom;
928 uint64_t Range = (High - Low).getLimitedValue(
UINT64_MAX - 1) + 1;
940 uint64_t Range)
const {
942 const unsigned MinDensity = getMinimumJumpTableDensity(OptForSize);
943 const unsigned MaxJumpTableSize =
944 OptForSize || getMaximumJumpTableSize() == 0
946 : getMaximumJumpTableSize();
948 if (Range <= MaxJumpTableSize &&
949 (NumCases * 100 >= Range * MinDensity)) {
970 if (!rangeFitsInWord(Low, High, DL))
978 return (NumDests == 1 && NumCmps >= 3) || (NumDests == 2 && NumCmps >= 5) ||
979 (NumDests == 3 && NumCmps >= 6);
986 return (!isTypeLegal(VT) || getOperationAction(Op, VT) == Expand);
991 return (VT ==
MVT::Other || isTypeLegal(VT)) &&
992 getOperationAction(Op, VT) ==
Legal;
1006 return (
LegalizeAction)((LoadExtActions[ValI][MemI] >> Shift) & 0xf);
1011 return getLoadExtAction(ExtType, ValVT, MemVT) ==
Legal;
1017 return getLoadExtAction(ExtType, ValVT, MemVT) ==
Legal ||
1018 getLoadExtAction(ExtType, ValVT, MemVT) == Custom;
1029 "Table isn't big enough!");
1030 return TruncStoreActions[ValI][MemI];
1036 return isTypeLegal(ValVT) && getTruncStoreAction(ValVT, MemVT) ==
Legal;
1042 return isTypeLegal(ValVT) &&
1043 (getTruncStoreAction(ValVT, MemVT) ==
Legal ||
1044 getTruncStoreAction(ValVT, MemVT) == Custom);
1053 "Table isn't big enough!");
1055 return (
LegalizeAction)((IndexedModeActions[Ty][IdxMode] & 0xf0) >> 4);
1062 getIndexedLoadAction(IdxMode, VT.
getSimpleVT()) == Custom);
1071 "Table isn't big enough!");
1080 getIndexedStoreAction(IdxMode, VT.
getSimpleVT()) == Custom);
1090 "Table isn't big enough!");
1095 assert(Action != Promote &&
"Can't promote condition code!");
1101 return getCondCodeAction(CC, VT) ==
Legal;
1107 return getCondCodeAction(CC, VT) ==
Legal ||
1108 getCondCodeAction(CC, VT) == Custom;
1114 assert(getOperationAction(Op, VT) == Promote &&
1115 "This operation isn't promoted!");
1118 std::map<std::pair<unsigned, MVT::SimpleValueType>,
1120 PromoteToType.find(std::make_pair(Op, VT.
SimpleTy));
1121 if (PTTI != PromoteToType.end())
return PTTI->second;
1124 "Cannot autopromote this type, add it with AddPromotedToType.");
1130 "Didn't find type to promote to!");
1131 }
while (!isTypeLegal(NVT) ||
1132 getOperationAction(Op, NVT) == Promote);
1141 bool AllowUnknown =
false)
const {
1144 return getPointerTy(DL, PTy->getAddressSpace());
1150 if (
PointerType *PT = dyn_cast<PointerType>(Elm)) {
1151 EVT PointerTy(getPointerTy(DL, PT->getAddressSpace()));
1163 bool AllowUnknown =
false)
const {
1164 return getValueType(DL, Ty, AllowUnknown).getSimpleVT();
1170 virtual unsigned getByValTypeAlignment(
Type *Ty,
const DataLayout &DL)
const;
1175 return RegisterTypeForVT[VT.
SimpleTy];
1188 unsigned NumIntermediates;
1189 (void)getVectorTypeBreakdown(Context, VT, VT1,
1190 NumIntermediates, RegisterVT);
1194 return getRegisterType(Context, getTypeToTransformTo(Context, VT));
1216 unsigned NumIntermediates;
1217 return getVectorTypeBreakdown(Context, VT, VT1, NumIntermediates, VT2);
1221 unsigned RegWidth = getRegisterType(Context, VT).getSizeInBits();
1222 return (BitWidth + RegWidth - 1) / RegWidth;
1232 return getRegisterType(Context, VT);
1241 return getNumRegisters(Context, VT);
1279 return TargetDAGCombineArray[NT >> 3] & (1 << (NT&7));
1283 return GatherAllAliasesMaxDepth;
1288 return getPointerTy(DL).getSizeInBits();
1298 return OptSize ? MaxStoresPerMemsetOptSize : MaxStoresPerMemset;
1308 return OptSize ? MaxStoresPerMemcpyOptSize : MaxStoresPerMemcpy;
1317 return MaxGluedStoresPerMemcpy;
1327 return OptSize ? MaxLoadsPerMemcmpOptSize : MaxLoadsPerMemcmp;
1349 return OptSize ? MaxStoresPerMemmoveOptSize : MaxStoresPerMemmove;
1362 unsigned AddrSpace = 0,
1364 bool * =
nullptr)
const {
1373 unsigned AddrSpace = 0,
unsigned Alignment = 1,
1374 bool *
Fast =
nullptr)
const;
1388 unsigned ,
unsigned ,
1407 return UseUnderscoreSetJmp;
1412 return UseUnderscoreLongJmp;
1416 virtual unsigned getMinimumJumpTableEntries()
const;
1419 unsigned getMinimumJumpTableDensity(
bool OptForSize)
const;
1423 unsigned getMaximumJumpTableSize()
const;
1432 return StackPointerRegisterToSaveRestore;
1464 return JumpBufAlignment;
1469 return MinStackArgumentAlignment;
1474 return MinFunctionAlignment;
1479 return PrefFunctionAlignment;
1484 return PrefLoopAlignment;
1501 virtual void insertSSPDeclarations(
Module &M)
const;
1506 virtual Value *getSDagStackGuard(
const Module &M)
const;
1518 virtual Value *getSSPStackGuardCheck(
const Module &M)
const;
1542 return isNoopAddrSpaceCast(SrcAS, DestAS);
1550 unsigned & )
const {
1559 int InstructionOpcodeToISD(
unsigned Opcode)
const;
1562 std::pair<int, MVT> getTypeLegalizationCost(
const DataLayout &DL,
1576 return MaxAtomicSizeInBitsSupported;
1622 llvm_unreachable(
"Masked atomicrmw expansion unimplemented on this target");
1756 if (hasMultipleConditionRegisters())
1761 return Action != TypeExpandInteger && Action != TypeExpandFloat &&
1762 Action != TypeSplitVector;
1787 bool IsSigned)
const {
1799 BooleanContents = Ty;
1800 BooleanFloatContents = Ty;
1806 BooleanContents = IntTy;
1807 BooleanFloatContents = FloatTy;
1813 BooleanVectorContents = Ty;
1818 SchedPreferenceInfo = Pref;
1824 UseUnderscoreSetJmp = Val;
1830 UseUnderscoreLongJmp = Val;
1834 void setMinimumJumpTableEntries(
unsigned Val);
1838 void setMaximumJumpTableSize(
unsigned);
1843 StackPointerRegisterToSaveRestore = R;
1852 HasMultipleConditionRegisters = hasManyRegs;
1860 HasExtractBitsInsn = hasExtractInsn;
1866 void setJumpIsExpensive(
bool isExpensive =
true);
1871 HasFloatingPointExceptions = FPExceptions;
1876 BypassSlowDivWidths[SlowBitWidth] = FastBitWidth;
1889 virtual std::pair<const TargetRegisterClass *, uint8_t>
1910 MemVT.
isValid() &&
"Table isn't big enough!");
1911 assert((
unsigned)Action < 0x10 &&
"too many bits for bitfield array");
1913 LoadExtActions[ValVT.
SimpleTy][MemVT.
SimpleTy] &= ~((uint16_t)0xF << Shift);
1914 LoadExtActions[ValVT.
SimpleTy][MemVT.
SimpleTy] |= (uint16_t)Action << Shift;
1933 (
unsigned)Action < 0xf &&
"Table isn't big enough!");
1936 IndexedModeActions[(
unsigned)VT.
SimpleTy][IdxMode] |= ((uint8_t)Action) <<4;
1947 (
unsigned)Action < 0xf &&
"Table isn't big enough!");
1950 IndexedModeActions[(
unsigned)VT.
SimpleTy][IdxMode] |= ((uint8_t)Action);
1958 "Table isn't big enough!");
1959 assert((
unsigned)Action < 0x10 &&
"too many bits for bitfield array");
1979 setOperationAction(Opc, OrigVT, Promote);
1980 AddPromotedToType(Opc, OrigVT, DestVT);
1988 TargetDAGCombineArray[NT >> 3] |= 1 << (NT&7);
1999 JumpBufAlignment =
Align;
2004 MinFunctionAlignment =
Align;
2011 PrefFunctionAlignment =
Align;
2019 PrefLoopAlignment =
Align;
2024 MinStackArgumentAlignment =
Align;
2032 MaxAtomicSizeInBitsSupported = SizeInBits;
2037 MinCmpXchgSizeInBits = SizeInBits;
2042 SupportsUnalignedAtomics = UnalignedSupported;
2070 int64_t BaseOffs = 0;
2071 bool HasBaseReg =
false;
2087 Type *Ty,
unsigned AddrSpace,
2098 Type *Ty,
unsigned AS = 0)
const {
2100 if (isLegalAddressingMode(DL, AM, Ty, AS))
2165 default:
return false;
2203 case Instruction::FPExt:
2208 case Instruction::ZExt:
2212 case Instruction::SExt:
2217 return isExtFreeImpl(I);
2229 EVT LoadVT = getValueType(DL, Load->
getType());
2233 if (!Load->
hasOneUse() && (isTypeLegal(LoadVT) || !isTypeLegal(VT)) &&
2239 if (isa<ZExtInst>(Ext))
2242 assert(isa<SExtInst>(Ext) &&
"Unexpected ext type!");
2246 return isLoadExtLegal(LType, VT, LoadVT);
2295 unsigned & )
const {
2316 unsigned Factor)
const {
2327 unsigned Factor)
const {
2343 "invalid fpext types");
2352 "invalid fpext types");
2353 return isFPExtFree(DestVT, SrcVT);
2408 unsigned Index)
const {
2446 CmpLibcallCCs[Call] = CC;
2452 return CmpLibcallCCs[Call];
2457 LibcallCallingConvs[Call] = CC;
2462 return LibcallCallingConvs[Call];
2479 bool HasMultipleConditionRegisters;
2485 bool HasExtractBitsInsn;
2496 bool JumpIsExpensive;
2500 bool HasFloatingPointExceptions;
2505 bool UseUnderscoreSetJmp;
2510 bool UseUnderscoreLongJmp;
2529 unsigned JumpBufSize;
2532 unsigned JumpBufAlignment;
2535 unsigned MinStackArgumentAlignment;
2539 unsigned MinFunctionAlignment;
2543 unsigned PrefFunctionAlignment;
2546 unsigned PrefLoopAlignment;
2550 unsigned MaxAtomicSizeInBitsSupported;
2554 unsigned MinCmpXchgSizeInBits;
2557 bool SupportsUnalignedAtomics;
2561 unsigned StackPointerRegisterToSaveRestore;
2654 void InitLibcalls(
const Triple &TT);
2703 unsigned MaxGluedStoresPerMemcpy = 0;
2770 bool isPositionIndependent()
const;
2805 virtual unsigned getJumpTableEncoding()
const;
2833 const SDLoc &DL)
const;
2839 bool isSigned,
const SDLoc &dl,
2840 bool doesNotReturn =
false,
2841 bool isReturnValueUsed =
true)
const;
2847 const uint32_t *CallerPreservedMask,
2867 DAG(InDAG), LegalTys(LT), LegalOps(LO) {}
2897 bool ShrinkDemandedOp(
SDValue Op,
unsigned BitWidth,
const APInt &Demanded,
2916 bool AssumeSingleUse =
false)
const;
2920 bool SimplifyDemandedBits(
SDValue Op,
const APInt &DemandedBits,
2923 bool AssumeSingleUse =
false)
const;
2927 bool SimplifyDemandedBits(
SDValue Op,
const APInt &DemandedMask,
2944 bool SimplifyDemandedVectorElts(
SDValue Op,
const APInt &DemandedEltMask,
2947 bool AssumeSingleUse =
false)
const;
2951 bool SimplifyDemandedVectorElts(
SDValue Op,
const APInt &DemandedElts,
2959 virtual void computeKnownBitsForTargetNode(
const SDValue Op,
2961 const APInt &DemandedElts,
2963 unsigned Depth = 0)
const;
2968 virtual void computeKnownBitsForFrameIndex(
const SDValue FIOp,
2970 const APInt &DemandedElts,
2972 unsigned Depth = 0)
const;
2978 virtual unsigned ComputeNumSignBitsForTargetNode(
SDValue Op,
2979 const APInt &DemandedElts,
2981 unsigned Depth = 0)
const;
2988 virtual bool SimplifyDemandedVectorEltsForTargetNode(
2997 virtual bool SimplifyDemandedBitsForTargetNode(
SDValue Op,
2998 const APInt &DemandedBits,
2999 const APInt &DemandedElts,
3002 unsigned Depth = 0)
const;
3007 virtual bool isKnownNeverNaNForTargetNode(
SDValue Op,
3010 unsigned Depth = 0)
const;
3020 : DC(dc), Level(level), CalledByLegalizer(cl), DAG(dag) {}
3030 void AddToWorklist(
SDNode *
N);
3040 bool isConstTrueVal(
const SDNode *
N)
const;
3044 bool isConstFalseVal(
const SDNode *N)
const;
3053 const SDLoc &dl)
const;
3120 return isTypeLegal(VT);
3201 bool IsTailCall =
false;
3204 bool IsPostTypeLegalization =
false;
3220 DoesNotReturn(
false), IsReturnValueUsed(
true), IsConvergent(
false),
3221 IsPatchPoint(
false), DAG(DAG) {}
3239 NumFixedArgs = ArgsList.size();
3240 Args = std::move(ArgsList);
3252 NumFixedArgs = ArgsList.size();
3253 Args = std::move(ArgsList);
3276 Args = std::move(ArgsList);
3289 DoesNotReturn =
Value;
3304 IsReturnValueUsed = !
Value;
3309 IsConvergent =
Value;
3324 IsPatchPoint =
Value;
3329 IsPostTypeLegalization =
Value;
3401 return "__clear_cache";
3421 return VT.
bitsLT(MinVT) ? MinVT : VT;
3429 bool isVarArg)
const {
3471 virtual void LowerOperationWrapper(
SDNode *N,
3498 virtual const char *getTargetNodeName(
unsigned Opcode)
const;
3507 bool verifyReturnAddressArgumentIsConstant(
SDValue Op,
3539 CW_SpecificReg = CW_Okay,
3540 CW_Register = CW_Good,
3541 CW_Memory = CW_Better,
3542 CW_Constant = CW_Best,
3543 CW_Default = CW_Okay
3571 bool isMatchingInputConstraint()
const;
3575 unsigned getMatchedOperand()
const;
3618 virtual std::pair<unsigned, const TargetRegisterClass *>
3623 if (ConstraintCode ==
"i")
3625 else if (ConstraintCode ==
"m")
3633 virtual const char *LowerXConstraint(
EVT ConstraintVT)
const;
3637 virtual void LowerAsmOperandForConstraint(
SDValue Op, std::string &Constraint,
3638 std::vector<SDValue> &Ops,
3684 int Enabled,
int &RefinementSteps,
3685 bool &UseOneConstNR,
bool Reciprocal)
const {
3700 int Enabled,
int &RefinementSteps)
const {
3812 std::pair<SDValue, SDValue> expandUnalignedLoad(
LoadSDNode *LD,
3828 bool IsCompressedMemory)
const;
3865 virtual void AdjustInstrPostInstrSelection(
MachineInstr &MI,
3875 const SDLoc &DL)
const {
3899 const SDLoc &DL)
const;
3904 const SDLoc &DL)
const;
3916 #endif // LLVM_CODEGEN_TARGETLOWERING_H virtual AtomicExpansionKind shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass...
LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return how this load with extension should be treated: either it is legal, needs to be promoted to a ...
virtual bool isJumpTableRelative() const
static MVT getIntegerVT(unsigned BitWidth)
BUILTIN_OP_END - This must be the last enum value in this list.
A parsed version of the target data layout string in and methods for querying it. ...
const_iterator end(StringRef path)
Get end iterator over path.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
virtual MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
EVT getValueType() const
Return the ValueType of the referenced return value.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
bool isInteger() const
Return true if this is an integer or a vector integer type.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
virtual bool canMergeStoresTo(unsigned AS, EVT MemVT, const SelectionDAG &DAG) const
Returns if it's reasonable to merge stores to MemVT size.
unsigned getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
C - The default llvm calling convention, compatible with C.
virtual bool isCheapAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast from SrcAS to DestAS is "cheap", such that e.g.
CombineLevel getDAGCombineLevel()
Constrained versions of libm-equivalent floating point intrinsics.
bool usesUnderscoreLongJmp() const
Determine if we should use _longjmp or longjmp to implement llvm.longjmp.
unsigned MaxLoadsPerMemcmpOptSize
virtual bool shouldInsertFencesForAtomic(const Instruction *I) const
Whether AtomicExpandPass should automatically insert fences and reduce ordering for this atomic...
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
Atomic ordering constants.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
virtual SDValue expandIndirectJTBranch(const SDLoc &dl, SDValue Value, SDValue Addr, SelectionDAG &DAG) const
Expands target specific indirect branch for the case of JumpTable expanasion.
virtual bool isFPImmLegal(const APFloat &, EVT) const
Returns true if the target can instruction select the specified FP immediate natively.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
bool isOperationCustom(unsigned Op, EVT VT) const
Return true if the operation uses custom lowering, regardless of whether the type is legal or not...
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0...
A Module instance is used to store all the information related to an LLVM module. ...
virtual const TargetRegisterClass * getRepRegClassFor(MVT VT) const
Return the 'representative' register class for the specified value type.
virtual bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const
Return if the target supports combining a chain like:
virtual bool reduceSelectOfFPConstantLoads(bool IsFPSetCC) const
Return true if it is profitable to convert a select of FP constants into a constant pool load whose a...
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
CallLoweringInfo & setIsPostTypeLegalization(bool Value=true)
Sched::Preference getSchedulingPreference() const
Return target scheduling preference.
void setJumpBufAlignment(unsigned Align)
Set the target's required jmp_buf buffer alignment (in bytes); default is 0.
bool usesUnderscoreSetJmp() const
Determine if we should use _setjmp or setjmp to implement llvm.setjmp.
virtual unsigned getRegisterByName(const char *RegName, EVT VT, SelectionDAG &DAG) const
Return the register ID of the name passed in.
Carry-setting nodes for multiple precision addition and subtraction.
virtual unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
virtual bool enableAggressiveFMAFusion(EVT VT) const
Return true if target always beneficiates from combining into FMA for a given value type...
virtual bool getPreIndexedAddressParts(SDNode *, SDValue &, SDValue &, ISD::MemIndexedMode &, SelectionDAG &) const
Returns true by value, base pointer and offset pointer and addressing mode by reference if the node's...
virtual SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps, bool &UseOneConstNR, bool Reciprocal) const
Hooks for building estimates in place of slower divisions and square roots.
This class represents a function call, abstracting a target machine's calling convention.
virtual bool isFNegFree(EVT VT) const
Return true if an fneg operation is free to the point where it is never worthwhile to replace it with...
void setHasFloatingPointExceptions(bool FPExceptions=true)
Tells the code generator that this target supports floating point exceptions and cares about preservi...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
virtual unsigned combineRepeatedFPDivisors() const
Indicate whether this target prefers to combine FDIVs with the same divisor.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
static ISD::NodeType getExtendForContent(BooleanContent Content)
unsigned getVectorNumElements() const
virtual bool isSelectSupported(SelectSupportKind) const
Function Alias Analysis Results
bool isSuitableForBitTests(unsigned NumDests, unsigned NumCmps, const APInt &Low, const APInt &High, const DataLayout &DL) const
Return true if lowering to a bit test is suitable for a set of case clusters which contains NumDests ...
bool LegalOperations() const
This instruction constructs a fixed permutation of two input vectors.
virtual bool isCommutativeBinOp(unsigned Opcode) const
Returns true if the opcode is a commutative binary operation.
virtual void markLibCallAttributes(MachineFunction *MF, unsigned CC, ArgListTy &Args) const
unsigned getMaxStoresPerMemset(bool OptSize) const
Get maximum # of store operations permitted for llvm.memset.
virtual void HandleByVal(CCState *, unsigned &, unsigned) const
Target-specific cleanup for formal ByVal parameters.
CallLoweringInfo & setNoReturn(bool Value=true)
virtual bool isSafeMemOpType(MVT) const
Returns true if it's safe to use load / store of the specified type to expand memcpy / memset inline...
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
Constrained versions of the binary floating point operators.
LegalizeAction getIndexedStoreAction(unsigned IdxMode, MVT VT) const
Return how the indexed store should be treated: either it is legal, needs to be promoted to a larger ...
bool isTruncStoreLegal(EVT ValVT, EVT MemVT) const
Return true if the specified store with truncation is legal on this target.
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
unsigned const TargetRegisterInfo * TRI
bool isInteger() const
Return true if this is an integer or a vector integer type.
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
bool hasMultipleConditionRegisters() const
Return true if multiple condition registers are available.
block Block Frequency true
An instruction for reading from memory.
virtual AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const
Returns how the given (atomic) load should be expanded by the IR-level AtomicExpand pass...
virtual bool mayBeEmittedAsTailCall(const CallInst *) const
Return true if the target may be able emit the call instruction as a tail call.
virtual bool isTypeDesirableForOp(unsigned, EVT VT) const
Return true if the target has native support for the specified value type and it is 'desirable' to us...
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
bool hasExtractBitsInsn() const
Return true if the target has BitExtract instructions.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
BooleanContent getBooleanContents(bool isVec, bool isFloat) const
For targets without i1 registers, this gives the nature of the high-bits of boolean values held in ty...
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isVectorTy() const
True if this is an instance of VectorType.
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
virtual bool storeOfVectorConstantIsCheap(EVT MemVT, unsigned NumElem, unsigned AddrSpace) const
Return true if it is expected to be cheaper to do a store of a non-zero vector constant with the give...
bool isOperationLegalOrCustom(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
LegalizeAction getFixedPointOperationAction(unsigned Op, EVT VT, unsigned Scale) const
Some fixed point operations may be natively supported by the target but only for specific scales...
unsigned getJumpBufAlignment() const
Returns the target's jmp_buf alignment in bytes (if never set, the default is 0)
std::pair< LegalizeTypeAction, EVT > LegalizeKind
LegalizeKind holds the legalization kind that needs to happen to EVT in order to type-legalize it...
CallLoweringInfo & setDiscardResult(bool Value=true)
virtual StringRef getStackProbeSymbolName(MachineFunction &MF) const
Returns the name of the symbol used to emit stack probes or the empty string if not applicable...
virtual bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, MachineFunction &, unsigned) const
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
bool isValid() const
Return true if this is a valid simple valuetype.
bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal on this target.
virtual Value * emitMaskedAtomicRMWIntrinsic(IRBuilder<> &Builder, AtomicRMWInst *AI, Value *AlignedAddr, Value *Incr, Value *Mask, Value *ShiftAmt, AtomicOrdering Ord) const
Perform a masked atomicrmw using a target-specific intrinsic.
CallLoweringInfo & setCallee(Type *ResultType, FunctionType *FTy, SDValue Target, ArgListTy &&ArgsList, ImmutableCallSite Call)
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
virtual bool isFPExtFree(EVT DestVT, EVT SrcVT) const
Return true if an fpext operation is free (for instance, because single-precision floating-point numb...
virtual bool isStoreBitCastBeneficial(EVT StoreVT, EVT BitcastVT) const
Return true if the following transform is beneficial: (store (y (conv x)), y*)) -> (store x...
virtual bool isCtlzFast() const
Return true if ctlz instruction is fast.
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
unsigned getAllocaAddrSpace() const
bool hasOneUse() const
Return true if there is exactly one use of this node.
bool isBeforeLegalize() const
bool doesNotReturn() const
Determine if the call cannot return.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
virtual bool decomposeMulByConstant(EVT VT, SDValue C) const
Return true if it is profitable to transform an integer multiplication-by-constant into simpler opera...
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
bool isAfterLegalizeDAG() const
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
virtual bool isSupportedFixedPointOperation(unsigned Op, EVT VT, unsigned Scale) const
Custom method defined by each target to indicate if an operation which may require a scale is support...
CallLoweringInfo & setVarArg(bool Value=true)
CallLoweringInfo & setChain(SDValue InChain)
RESULT = SMULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same wi...
virtual uint8_t getRepRegClassCostFor(MVT VT) const
Return the cost of the 'representative' register class for the specified value type.
Base class for the full range of assembler expressions which are needed for parsing.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
virtual bool useLoadStackGuardNode() const
If this function returns true, SelectionDAGBuilder emits a LOAD_STACK_GUARD node when it is lowering ...
void setCondCodeAction(ISD::CondCode CC, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
This file contains the simple types necessary to represent the attributes associated with functions a...
InstrTy * getInstruction() const
void addBypassSlowDiv(unsigned int SlowBitWidth, unsigned int FastBitWidth)
Tells the code generator which bitwidths to bypass.
virtual bool isVectorShiftByScalarCheap(Type *Ty) const
Return true if it's significantly cheaper to shift a vector by a uniform scalar than by an amount whi...
bool isLoadExtLegalOrCustom(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return true if the specified load with extension is legal or custom on this target.
bool hasBigEndianPartOrdering(EVT VT, const DataLayout &DL) const
When splitting a value of the specified type into parts, does the Lo or Hi part come first...
virtual bool shouldUseStrictFP_TO_INT(EVT FpVT, EVT IntVT, bool IsSigned) const
Return true if it is more correct/profitable to use strict FP_TO_INT conversion operations - canonica...
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
virtual bool convertSetCCLogicToBitwiseLogic(EVT VT) const
Use bitwise logic to make pairs of compares more efficient.
virtual bool isMultiStoresCheaperThanBitsMerge(EVT LTy, EVT HTy) const
Return true if it is cheaper to split the store of a merged int val from a pair of smaller values int...
uint64_t getNumElements() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
virtual bool aggressivelyPreferBuildVectorSources(EVT VecVT) const
This file implements a class to represent arbitrary precision integral constant values and operations...
virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const
Return true if it's free to truncate a value of type FromTy to type ToTy.
SmallVector< ISD::InputArg, 32 > Ins
AtomicOrdering
Atomic ordering for LLVM's memory model.
virtual bool ShouldShrinkFPConstant(EVT) const
If true, then instruction selection should seek to shrink the FP constant of the specified type to a ...
virtual SDValue prepareVolatileOrAtomicLoad(SDValue Chain, const SDLoc &DL, SelectionDAG &DAG) const
This callback is used to prepare for a volatile or atomic load.
Context object for machine code objects.
virtual void ReplaceNodeResults(SDNode *, SmallVectorImpl< SDValue > &, SelectionDAG &) const
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
Fast - This calling convention attempts to make calls as fast as possible (e.g.
virtual unsigned getABIAlignmentForCallingConv(Type *ArgTy, DataLayout DL) const
Certain targets have context senstive alignment requirements, where one type has the alignment requir...
virtual bool isLoadBitCastBeneficial(EVT LoadVT, EVT BitcastVT) const
Return true if the following transform is beneficial: fold (conv (load x)) -> (load (conv*)x) On arch...
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Class to represent function types.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
Type * getType() const
All values are typed, get the type of this value.
MachineFunction & getMachineFunction() const
unsigned MaxLoadsPerMemcmp
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
This contains information for each constraint that we are lowering.
Simple integer binary arithmetic operators.
SmallVector< ISD::OutputArg, 32 > Outs
virtual EVT getOptimalMemOpType(uint64_t, unsigned, unsigned, bool, bool, bool, MachineFunction &) const
Returns the target specific optimal type for load and store operations as a result of memset...
virtual bool isCheapToSpeculateCtlz() const
Return true if it is cheap to speculate a call to intrinsic ctlz.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
CallLoweringInfo & setZExtResult(bool Value=true)
BooleanContent getBooleanContents(EVT Type) const
An instruction for storing to memory.
unsigned getPrefFunctionAlignment() const
Return the preferred function alignment.
MVT getRegisterType(LLVMContext &Context, EVT VT) const
Return the type of registers that this ValueType will eventually require.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
virtual const MCExpr * LowerCustomJumpTableEntry(const MachineJumpTableInfo *, const MachineBasicBlock *, unsigned, MCContext &) const
virtual bool isCheapToSpeculateCttz() const
Return true if it is cheap to speculate a call to intrinsic cttz.
virtual bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI, unsigned Factor) const
Lower an interleaved store to target specific intrinsics.
virtual unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const
void setMinCmpXchgSizeInBits(unsigned SizeInBits)
Sets the minimum cmpxchg or ll/sc size supported by the backend.
Value * getOperand(unsigned i) const
Analysis containing CSE Info
Class to represent pointers.
This class is used to represent ISD::STORE nodes.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool isJumpExpensive() const
Return true if Flow Control is an expensive operation that should be avoided.
virtual bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx, unsigned &Cost) const
Return true if the target can combine store(extractelement VectorTy, Idx).
virtual bool alignLoopsWithOptSize() const
Should loops be aligned even when the function is marked OptSize (but not MinSize).
virtual Value * emitStoreConditional(IRBuilder<> &Builder, Value *Val, Value *Addr, AtomicOrdering Ord) const
Perform a store-conditional operation to Addr.
EVT getTypeToExpandTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
SmallVector< SDValue, 4 > InVals
std::vector< AsmOperandInfo > AsmOperandInfoVector
MVT getSimpleValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the MVT corresponding to this LLVM type. See getValueType.
virtual bool isSuitableForJumpTable(const SwitchInst *SI, uint64_t NumCases, uint64_t Range) const
Return true if lowering to a jump table is suitable for a set of case clusters which may contain NumC...
virtual bool getAddrModeArguments(IntrinsicInst *, SmallVectorImpl< Value *> &, Type *&) const
CodeGenPrepare sinks address calculations into the same BB as Load/Store instructions reading the add...
unsigned const MachineRegisterInfo * MRI
MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
virtual unsigned getExceptionPointerRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception address on entry to an ...
DAGCombinerInfo(SelectionDAG &dag, CombineLevel level, bool cl, void *dc)
CallLoweringInfo & setIsPatchPoint(bool Value=true)
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
void setJumpBufSize(unsigned Size)
Set the target's required jmp_buf buffer size (in bytes); default is 200.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type...
Simple binary floating point operators.
void setTargetDAGCombine(ISD::NodeType NT)
Targets should invoke this method for each target independent node that they want to provide a custom...
virtual Value * emitMaskedAtomicCmpXchgIntrinsic(IRBuilder<> &Builder, AtomicCmpXchgInst *CI, Value *AlignedAddr, Value *CmpVal, Value *NewVal, Value *Mask, AtomicOrdering Ord) const
Perform a masked cmpxchg using a target-specific intrinsic.
virtual bool isTruncateFree(EVT FromVT, EVT ToVT) const
virtual ISD::NodeType getExtendForAtomicOps() const
Returns how the platform's atomic operations are extended (ZERO_EXTEND, SIGN_EXTEND, or ANY_EXTEND).
This is an important base class in LLVM.
virtual bool shouldConvertConstantLoadToIntImm(const APInt &Imm, Type *Ty) const
Return true if it is beneficial to convert a load of a constant to just the constant itself...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Carry-using nodes for multiple precision addition and subtraction.
bool isSlowDivBypassed() const
Returns true if target has indicated at least one type should be bypassed.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
virtual Value * emitLoadLinked(IRBuilder<> &Builder, Value *Addr, AtomicOrdering Ord) const
Perform a load-linked operation on Addr, returning a "Value *" with the corresponding pointee type...
virtual unsigned getPrefLoopAlignment(MachineLoop *ML=nullptr) const
Return the preferred loop alignment.
virtual SDValue unwrapAddress(SDValue N) const
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
bool isAcquireOrStronger(AtomicOrdering ao)
virtual SDValue emitStackGuardXorFP(SelectionDAG &DAG, SDValue Val, const SDLoc &DL) const
virtual bool isFPExtFoldable(unsigned Opcode, EVT DestVT, EVT SrcVT) const
Return true if an fpext operation input to an Opcode operation is free (for instance, because half-precision floating-point numbers are implicitly extended to float-precision) for an FMA instruction.
virtual LoadInst * lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *RMWI) const
On some platforms, an AtomicRMW that never actually modifies the value (such as fetch_add of 0) can b...
virtual unsigned getExceptionSelectorRegister(const Constant *PersonalityFn) const
If a physical register, this returns the register that receives the exception typeid on entry to a la...
LegalizeAction getCondCodeAction(ISD::CondCode CC, MVT VT) const
Return how the condition code should be treated: either it is legal, needs to be expanded to some oth...
virtual bool areJTsAllowed(const Function *Fn) const
Return true if lowering to a jump table is allowed.
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
void setOperationPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT)
Convenience method to set an operation to Promote and specify the type in a single call...
bool CombineTo(SDValue O, SDValue N)
bool isOperationLegalOrCustomOrPromote(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
virtual bool targetShrinkDemandedConstant(SDValue Op, const APInt &Demanded, TargetLoweringOpt &TLO) const
virtual bool ExpandInlineAsm(CallInst *) const
This hook allows the target to expand an inline asm call to be explicit llvm code if it wants to...
void setPrefFunctionAlignment(unsigned Align)
Set the target's preferred function alignment.
virtual bool hasPairedLoad(EVT, unsigned &) const
Return true if the target supplies and combines to a paired load two loaded values of type LoadedType...
virtual MVT getFenceOperandTy(const DataLayout &DL) const
Return the type for operands of fence.
virtual bool isDesirableToCombineBuildVectorToShuffleTruncate(ArrayRef< int > ShuffleMask, EVT SrcVT, EVT TruncVT) const
bool isIndexedLoadLegal(unsigned IdxMode, EVT VT) const
Return true if the specified indexed load is legal on this target.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
virtual bool isDesirableToTransformToIntegerOp(unsigned, EVT) const
Return true if it is profitable for dag combiner to transform a floating point op of specified opcode...
virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all...
void AddPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT)
If Opc/OrigVT is specified as being promoted, the promotion code defaults to trying a larger integer/...
unsigned MaxStoresPerMemmove
Specify maximum bytes of store instructions per memmove call.
virtual bool isSExtCheaperThanZExt(EVT FromTy, EVT ToTy) const
Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension. ...
virtual bool isProfitableToHoist(Instruction *I) const
bool supportsUnalignedAtomics() const
Whether the target supports unaligned atomic operations.
virtual bool hasVectorBlend() const
Return true if the target has a vector blend instruction.
virtual EVT getTypeForExtReturn(LLVMContext &Context, EVT VT, ISD::NodeType) const
Return the type that should be used to zero or sign extend a zeroext/signext integer return value...
static unsigned NumFixedArgs
std::vector< ArgListEntry > ArgListTy
virtual bool functionArgumentNeedsConsecutiveRegisters(Type *Ty, CallingConv::ID CallConv, bool isVarArg) const
For some targets, an LLVM struct type must be broken down into multiple simple types, but the calling convention specifies that the entire struct must be passed in a block of consecutive registers.
virtual bool allowTruncateForTailCall(Type *FromTy, Type *ToTy) const
Return true if a truncation from FromTy to ToTy is permitted when deciding whether a call is in tail ...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual Sched::Preference getSchedulingPreference(SDNode *) const
Some scheduler, e.g.
This structure contains all information that is necessary for lowering calls.
virtual bool isUsedByReturnOnly(SDNode *, SDValue &) const
Return true if result of the specified node is used by a return node only.
bool isBeforeLegalizeOps() const
bool isExtFree(const Instruction *I) const
Return true if the extension represented by I is free.
const TargetMachine & getTargetMachine() const
virtual bool useStackGuardXorFP() const
If this function returns true, stack protection checks should XOR the frame pointer (or whichever poi...
void setUseUnderscoreLongJmp(bool Val)
Indicate whether this target prefers to use _longjmp to implement llvm.longjmp or the version without...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setLibcallCallingConv(RTLIB::Libcall Call, CallingConv::ID CC)
Set the CallingConv that should be used for the specified libcall.
AsmOperandInfo(InlineAsm::ConstraintInfo Info)
Copy constructor for copying from a ConstraintInfo.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
std::string ConstraintCode
This contains the actual string for the code, like "m".
virtual Instruction * emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst, AtomicOrdering Ord) const
Inserts in the IR a target-specific intrinsic specifying a fence.
unsigned getMaxAtomicSizeInBitsSupported() const
Returns the maximum atomic operation size (in bits) supported by the backend.
unsigned GatherAllAliasesMaxDepth
Depth that GatherAllAliases should should continue looking for chain dependencies when trying to find...
bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM)
Test if the given instruction is in a position to be optimized with a tail-call.
Triple - Helper class for working with autoconf configuration names.
unsigned getMaxStoresPerMemcpy(bool OptSize) const
Get maximum # of store operations permitted for llvm.memcpy.
bool isInvoke() const
Return true if a InvokeInst is enclosed.
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
virtual const MCPhysReg * getScratchRegisters(CallingConv::ID CC) const
Returns a 0 terminated array of registers that can be safely used as scratch registers.
void setCmpLibcallCC(RTLIB::Libcall Call, ISD::CondCode CC)
Override the default CondCode to be used to test the result of the comparison libcall against zero...
virtual bool shouldScalarizeBinop(SDValue VecOp) const
Try to convert an extract element of a vector binary operation into an extract element followed by a ...
virtual bool isExtFreeImpl(const Instruction *I) const
Return true if the extension represented by I is free.
void setHasExtractBitsInsn(bool hasExtractInsn=true)
Tells the code generator that the target has BitExtract instructions.
bool isReleaseOrStronger(AtomicOrdering ao)
void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags...
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
virtual MVT hasFastEqualityCompare(unsigned NumBits) const
Return the preferred operand type if the target has a quick way to compare integer values of the give...
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
virtual bool IsDesirableToPromoteOp(SDValue, EVT &) const
This method query the target whether it is beneficial for dag combiner to promote the specified node...
const TargetLowering & getTargetLoweringInfo() const
virtual bool supportSplitCSR(MachineFunction *MF) const
Return true if the target supports that a subset of CSRs for the given machine function is handled ex...
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
static const int LAST_LOADEXT_TYPE
CCState - This class holds information needed while lowering arguments and return values...
virtual void initializeSplitCSR(MachineBasicBlock *Entry) const
Perform necessary initialization to handle a subset of CSRs explicitly via copies.
ReciprocalEstimate
Reciprocal estimate status values used by the functions below.
virtual bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT) const
Return true if it is profitable to reduce a load to a smaller type.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
virtual bool shouldNormalizeToSelectSequence(LLVMContext &Context, EVT VT) const
Returns true if we should normalize select(N0&N1, X, Y) => select(N0, select(N1, X, Y), Y) and select(N0|N1, X, Y) => select(N0, select(N1, X, Y, Y)) if it is likely that it saves us from materializing N0 and N1 in an integer register.
virtual bool getPostIndexedAddressParts(SDNode *, SDNode *, SDValue &, SDValue &, ISD::MemIndexedMode &, SelectionDAG &) const
Returns true by value, base pointer and offset pointer and addressing mode by reference if this node ...
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, unsigned Align=1, bool *=nullptr) const
Determine if the target supports unaligned memory accesses.
virtual const char * getClearCacheBuiltinName() const
Return the builtin name for the __builtin___clear_cache intrinsic Default is to invoke the clear cach...
unsigned getJumpBufSize() const
Returns the target's jmp_buf size in bytes (if never set, the default is 200)
virtual bool lowerInterleavedLoad(LoadInst *LI, ArrayRef< ShuffleVectorInst *> Shuffles, ArrayRef< unsigned > Indices, unsigned Factor) const
Lower an interleaved load to target specific intrinsics.
bool hasFloatingPointExceptions() const
Return true if target supports floating point exceptions.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
virtual unsigned getMaxSupportedInterleaveFactor() const
Get the maximum supported factor for interleaved memory accesses.
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
virtual bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT, unsigned Index) const
Return true if EXTRACT_SUBVECTOR is cheap for extracting this result type from this source type with ...
Provides information about what library functions are available for the current target.
virtual bool shouldConsiderGEPOffsetSplit() const
TargetLoweringOpt(SelectionDAG &InDAG, bool LT, bool LO)
virtual bool isZExtFree(EVT FromTy, EVT ToTy) const
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
const DenseMap< unsigned int, unsigned int > & getBypassSlowDivWidths() const
Returns map of slow types for division or remainder with corresponding fast types.
virtual bool isVectorLoadExtDesirable(SDValue ExtVal) const
Return true if folding a vector load into ExtVal (a sign, zero, or any extend node) is profitable...
bool rangeFitsInWord(const APInt &Low, const APInt &High, const DataLayout &DL) const
Check whether the range [Low,High] fits in a machine word.
virtual bool isZExtFree(SDValue Val, EVT VT2) const
Return true if zero-extending the specific node Val to type VT2 is free (either because it's implicit...
bool isCalledByLegalizer() const
bool isTruncStoreLegalOrCustom(EVT ValVT, EVT MemVT) const
Return true if the specified store with truncation has solution on this target.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
void setHasMultipleConditionRegisters(bool hasManyRegs=true)
Tells the code generator that the target has multiple (allocatable) condition registers that can be u...
CallLoweringInfo & setSExtResult(bool Value=true)
Represents one node in the SelectionDAG.
LegalizeAction getTruncStoreAction(EVT ValVT, EVT MemVT) const
Return how this store with truncation should be treated: either it is legal, needs to be promoted to ...
bool enableExtLdPromotion() const
Return true if the target wants to use the optimization that turns ext(promotableInst1(...(promotableInstN(load)))) into promotedInst1(...(promotedInstN(ext(load)))).
Class to represent vector types.
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT...
void setIndexedLoadAction(unsigned IdxMode, MVT VT, LegalizeAction Action)
Indicate that the specified indexed load does or does not work with the specified type and indicate w...
Target - Wrapper for Target specific information.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Class for arbitrary precision integers.
virtual unsigned getVaListSizeInBits(const DataLayout &DL) const
Returns the size of the platform's va_list object.
virtual bool preferShiftsToClearExtremeBits(SDValue X) const
There are two ways to clear extreme bits (either low or high): Mask: x & (-1 << y) (the instcombine c...
virtual bool hasAndNot(SDValue X) const
Return true if the target has a bitwise and-not operation: X = ~A & B This can be used to simplify se...
LegalizeTypeAction getTypeAction(MVT VT) const
void setMinFunctionAlignment(unsigned Align)
Set the target's minimum function alignment (in log2(bytes))
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
unsigned getMaxExpandSizeMemcmp(bool OptSize) const
Get maximum # of load operations permitted for memcmp.
void setPrefLoopAlignment(unsigned Align)
Set the target's preferred loop alignment.
ZERO_EXTEND - Used for integer types, zeroing the new bits.
virtual SDValue LowerFormalArguments(SDValue, CallingConv::ID, bool, const SmallVectorImpl< ISD::InputArg > &, const SDLoc &, SelectionDAG &, SmallVectorImpl< SDValue > &) const
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array...
ANY_EXTEND - Used for integer types. The high bits are undefined.
ValueTypeActionImpl ValueTypeActions
MulExpansionKind
Enum that specifies when a multiplication should be expanded.
virtual bool needsFixedCatchObjects() const
virtual bool isFMAFasterThanFMulAndFAdd(EVT) const
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
Flags
Flags values. These may be or'd together.
MVT getTypeToPromoteTo(unsigned Op, MVT VT) const
If the action for this operation is to promote, this method returns the ValueType to promote to...
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
virtual bool hasAndNotCompare(SDValue Y) const
Return true if the target should transform: (X & Y) == Y —> (~X & Y) == 0 (X & Y) != Y —> (~X & Y) ...
virtual bool hasStandaloneRem(EVT VT) const
Return true if the target can handle a standalone remainder operation.
virtual bool useSoftFloat() const
CallLoweringInfo & setTailCall(bool Value=true)
virtual bool isLegalICmpImmediate(int64_t) const
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
BR_JT - Jumptable branch.
Representation of each machine instruction.
virtual bool isDesirableToCommuteWithShift(const SDNode *N, CombineLevel Level) const
Return true if it is profitable to move this shift by a constant amount though its operand...
CallLoweringInfo & setConvergent(bool Value=true)
SmallVector< SDValue, 32 > OutVals
bool isVector() const
Return true if this is a vector value type.
virtual bool convertSelectOfConstantsToMath(EVT VT) const
Return true if a select of constants (select Cond, C1, C2) should be transformed into simple math ops...
Bitwise operators - logical and, logical or, logical xor.
FenceInst * CreateFence(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
virtual bool isSDNodeSourceOfDivergence(const SDNode *N, FunctionLoweringInfo *FLI, LegacyDivergenceAnalysis *DA) const
SelectSupportKind
Enum that describes what type of support for selects the target has.
virtual SDValue LowerCall(CallLoweringInfo &, SmallVectorImpl< SDValue > &) const
This hook must be implemented to lower calls into the specified DAG.
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
const ValueTypeActionImpl & getValueTypeActions() const
StringRef getValueAsString() const
Return the attribute's value as a string.
void setTypeAction(MVT VT, LegalizeTypeAction Action)
bool isPositionIndependent() const
virtual void insertCopiesSplitCSR(MachineBasicBlock *Entry, const SmallVectorImpl< MachineBasicBlock *> &Exits) const
Insert explicit copies in entry and exit blocks.
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
PointerUnion< const Value *, const PseudoSourceValue * > ptrVal
Establish a view to a call site for examination.
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
const Function * getParent() const
Return the enclosing method, or null if none.
virtual SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps) const
Return a reciprocal estimate value for the input operand.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
unsigned MaxStoresPerMemmoveOptSize
Maximum number of store instructions that may be substituted for a call to memmove, used for functions with OptSize attribute.
unsigned MaxStoresPerMemcpyOptSize
Maximum number of store operations that may be substituted for a call to memcpy, used for functions w...
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
virtual bool shouldFoldShiftPairToMask(const SDNode *N, CombineLevel Level) const
Return true if it is profitable to fold a pair of shifts into a mask.
ISD::CondCode getCmpLibcallCC(RTLIB::Libcall Call) const
Get the CondCode that's to be used to test the result of the comparison libcall against zero...
virtual void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const
void setLibcallName(RTLIB::Libcall Call, const char *Name)
Rename the default libcall routine name for the specified libcall.
unsigned getMinCmpXchgSizeInBits() const
Returns the size of the smallest cmpxchg or ll/sc instruction the backend supports.
static const int LAST_INDEXED_MODE
virtual bool shouldExpandAtomicStoreInIR(StoreInst *SI) const
Returns true if the given (atomic) store should be expanded by the IR-level AtomicExpand pass into an...
unsigned MaxStoresPerMemcpy
Specify maximum bytes of store instructions per memcpy call.
virtual MachineMemOperand::Flags getMMOFlags(const Instruction &I) const
This callback is used to inspect load/store instructions and add target-specific MachineMemOperand fl...
virtual bool isIntDivCheap(EVT VT, AttributeList Attr) const
Return true if integer divide is usually cheaper than a sequence of several shifts, adds, and multiplies for this target.
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
void setSupportsUnalignedAtomics(bool UnalignedSupported)
Sets whether unaligned atomic operations are supported.
unsigned getMaxStoresPerMemmove(bool OptSize) const
Get maximum # of store operations permitted for llvm.memmove.
LegalizeAction getStrictFPOperationAction(unsigned Op, EVT VT) const
LegalizeAction getIndexedLoadAction(unsigned IdxMode, MVT VT) const
Return how the indexed load should be treated: either it is legal, needs to be promoted to a larger s...
bool EnableExtLdPromotion
bool hasAtomicStore() const
Return true if this atomic instruction stores to memory.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getMinFunctionAlignment() const
Return the minimum function alignment.
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
bool isFloat(MCInstrInfo const &MCII, MCInst const &MCI)
Return whether it is a floating-point insn.
virtual bool CanLowerReturn(CallingConv::ID, MachineFunction &, bool, const SmallVectorImpl< ISD::OutputArg > &, LLVMContext &) const
This hook should be implemented to check whether the return values described by the Outs array can fi...
void setMinStackArgumentAlignment(unsigned Align)
Set the minimum stack alignment of an argument (in log2(bytes)).
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
virtual unsigned getMemcmpEqZeroLoadsPerBlock() const
For memcmp expansion when the memcmp result is only compared equal or not-equal to 0...
CallLoweringInfo & setInRegister(bool Value=true)
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if this return value has the given attribute.
LLVM Value Representation.
FMA - Perform a * b + c with no intermediate rounding step.
void setUseUnderscoreSetJmp(bool Val)
Indicate whether this target prefers to use _setjmp to implement llvm.setjmp or the version without _...
virtual FastISel * createFastISel(FunctionLoweringInfo &, const TargetLibraryInfo *) const
This method returns a target specific FastISel object, or null if the target does not support "fast" ...
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
virtual bool isVectorClearMaskLegal(ArrayRef< int >, EVT) const
Similar to isShuffleMaskLegal.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, const APInt &Demanded)
Check to see if the specified operand of the specified instruction is a constant integer.
virtual bool isFsqrtCheap(SDValue X, SelectionDAG &DAG) const
Return true if SQRT(X) shouldn't be replaced with X*RSQRT(X).
bool isOperationLegalOrPromote(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal using promotion...
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
virtual bool shouldExpandBuildVectorWithShuffles(EVT, unsigned DefinedValues) const
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return true if the specified load with extension is legal on this target.
bool isCondCodeLegalOrCustom(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal or custom on this target.
CallLoweringInfo(SelectionDAG &DAG)
Primary interface to the complete machine description for the target machine.
virtual bool mergeStoresAfterLegalization() const
Allow store merging after legalization in addition to before legalization.
Type * getElementType() const
virtual int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS=0) const
Return the cost of the scaling factor used in the addressing mode represented by AM for this target...
bool hasOneUse() const
Return true if there is exactly one user of this value.
StringRef - Represent a constant reference to a string, i.e.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
unsigned MaxStoresPerMemsetOptSize
Maximum number of stores operations that may be substituted for the call to memset, used for functions with OptSize attribute.
virtual bool isShuffleMaskLegal(ArrayRef< int >, EVT) const
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations, those with specific masks.
BooleanContent
Enum that describes how the target represents true/false values.
unsigned getGatherAllAliasesMaxDepth() const
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
bool hasTargetDAGCombine(ISD::NodeType NT) const
If true, the target has custom DAG combine transformations that it can perform for the specified node...
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
unsigned getMinStackArgumentAlignment() const
Return the minimum stack alignment of an argument.
virtual bool hasBitPreservingFPLogic(EVT VT) const
Return true if it is safe to transform an integer-domain bitwise operation into the equivalent floati...
virtual unsigned getMaxGluedStoresPerMemcpy() const
Get maximum # of store operations to be glued together.
virtual SDValue LowerReturn(SDValue, CallingConv::ID, bool, const SmallVectorImpl< ISD::OutputArg > &, const SmallVectorImpl< SDValue > &, const SDLoc &, SelectionDAG &) const
This hook must be implemented to lower outgoing return values, described by the Outs array...
virtual bool shouldAlignPointerArgs(CallInst *, unsigned &, unsigned &) const
Return true if the pointer arguments to CI should be aligned by aligning the object whose address is ...
virtual bool shouldTransformSignedTruncationCheck(EVT XVT, unsigned KeptBits) const
Should we tranform the IR-optimal check for whether given truncation down into KeptBits would be trun...
virtual TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const
Return the preferred vector type legalization action.
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
virtual bool isLegalAddImmediate(int64_t) const
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
The operation is expected to be selectable directly by the target, and no transformation is necessary...
virtual bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const
Returns true if arguments should be sign-extended in lib calls.
bool isExtended() const
Test if the given EVT is extended (as opposed to being simple).
void setBooleanContents(BooleanContent IntTy, BooleanContent FloatTy)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
virtual bool isSDNodeAlwaysUniform(const SDNode *N) const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool isOperationExpand(unsigned Op, EVT VT) const
Return true if the specified operation is illegal on this target or unlikely to be made legal with cu...
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
bool PredictableSelectIsExpensive
Tells the code generator that select is more expensive than a branch if the branch is usually predict...
bool isIndexedStoreLegal(unsigned IdxMode, EVT VT) const
Return true if the specified indexed load is legal on this target.
LegalizeTypeAction getTypeAction(MVT VT) const
virtual bool isNarrowingProfitable(EVT, EVT) const
Return true if it's profitable to narrow operations of type VT1 to VT2.
A wrapper class for inspecting calls to intrinsic functions.
virtual bool isFAbsFree(EVT VT) const
Return true if an fabs operation is free to the point where it is never worthwhile to replace it with...
virtual bool isLegalStoreImmediate(int64_t Value) const
Return true if the specified immediate is legal for the value input of a store instruction.
const BasicBlock * getParent() const
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
virtual bool shouldSplatInsEltVarIndex(EVT) const
Return true if inserting a scalar into a variable element of an undef vector is more efficiently hand...
virtual Instruction * emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst, AtomicOrdering Ord) const
void setIndexedStoreAction(unsigned IdxMode, MVT VT, LegalizeAction Action)
Indicate that the specified indexed store does or does not work with the specified type and indicate ...
static const char * LibcallRoutineNames[]
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
This class is used to represent ISD::LOAD nodes.
bool isPredictableSelectExpensive() const
Return true if selects are only cheaper than branches if the branch is unlikely to be predicted right...
bool isExtLoad(const LoadInst *Load, const Instruction *Ext, const DataLayout &DL) const
Return true if Load and Ext can form an ExtLoad.