LLVM 24.0.0git
AMDGPUISelLowering.h
Go to the documentation of this file.
1//===-- AMDGPUISelLowering.h - AMDGPU Lowering Interface --------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// Interface definition of the TargetLowering class that is common
11/// to all AMD GPUs.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUISELLOWERING_H
16#define LLVM_LIB_TARGET_AMDGPU_AMDGPUISELLOWERING_H
17
20
21namespace llvm {
22
24class AMDGPUSubtarget;
25struct ArgDescriptor;
26
28private:
29 const AMDGPUSubtarget *Subtarget;
30
31 /// \returns AMDGPUISD::FFBH_U32 node if the incoming \p Op may have been
32 /// legalized from a smaller type VT. Need to match pre-legalized type because
33 /// the generic legalization inserts the add/sub between the select and
34 /// compare.
35 SDValue getFFBX_U32(SelectionDAG &DAG, SDValue Op, const SDLoc &DL, unsigned Opc) const;
36
37public:
38 /// \returns The minimum number of bits needed to store the value of \Op as an
39 /// unsigned integer. Truncating to this size and then zero-extending to the
40 /// original size will not change the value.
41 static unsigned numBitsUnsigned(SDValue Op, SelectionDAG &DAG);
42
43 /// \returns The minimum number of bits needed to store the value of \Op as a
44 /// signed integer. Truncating to this size and then sign-extending to the
45 /// original size will not change the value.
46 static unsigned numBitsSigned(SDValue Op, SelectionDAG &DAG);
47
48 /// \returns The known bits of a 24-bit multiply (MUL_U24/MUL_I24) with a
49 /// \p BitWidth wide result, given the known bits of its operands. Only the
50 /// low 24 bits of each operand are used, zero- or sign-extended depending on
51 /// \p IsSigned.
52 static KnownBits computeKnownBitsForMul24(const KnownBits &LHSKnown,
53 const KnownBits &RHSKnown,
54 unsigned BitWidth, bool IsSigned,
55 bool SelfMultiply);
56
57protected:
60 /// Split a vector store into multiple scalar stores.
61 /// \returns The resulting chain.
62
68
72
73 static bool allowApproxFunc(const SelectionDAG &DAG, SDNodeFlags Flags);
74 static bool needsDenormHandlingF32(const SelectionDAG &DAG, SDValue Src,
75 SDNodeFlags Flags);
77 std::pair<SDValue, SDValue> getScaledLogInput(SelectionDAG &DAG,
78 const SDLoc SL, SDValue Op,
79 SDNodeFlags Flags) const;
80
84 bool IsLog10, SDNodeFlags Flags) const;
86
88 SDNodeFlags Flags, bool IsExp10) const;
89
91 SDNodeFlags Flags) const;
93 SDNodeFlags Flags) const;
97
99
101
102 SDValue LowerINT_TO_FP16(SDValue Op, SelectionDAG &DAG, EVT FP16Ty) const;
108
113
115 SelectionDAG &DAG) const;
116
118
119protected:
120 /// Check whether value Val can be supported by v_mov_b64, for the current
121 /// target.
122 bool isInt64ImmLegal(SDNode *Val, SelectionDAG &DAG) const;
127
129 unsigned Opc, SDValue LHS,
130 uint32_t ValLo, uint32_t ValHi) const;
140 SDValue RHS, DAGCombinerInfo &DCI) const;
141
143 SDValue N) const;
145
148
153
154 static EVT getEquivalentMemType(LLVMContext &Context, EVT VT);
155
157 SelectionDAG &DAG) const;
158
160
161 /// Return 64-bit value Op as two 32-bit integers.
162 std::pair<SDValue, SDValue> split64BitValue(SDValue Op,
163 SelectionDAG &DAG) const;
165
166 /// Split a vector type into two parts. The first part is a power of two
167 /// vector. The second part is whatever is left over, and is a scalar if it
168 /// would otherwise be a 1-vector.
169 std::pair<EVT, EVT> getSplitDestVTs(const EVT &VT, SelectionDAG &DAG) const;
170
171 /// Split a vector value into two parts of types LoVT and HiVT. HiVT could be
172 /// scalar.
173 std::pair<SDValue, SDValue> splitVector(const SDValue &N, const SDLoc &DL,
174 const EVT &LoVT, const EVT &HighVT,
175 SelectionDAG &DAG) const;
176
177 /// Split a vector load into 2 loads of half the vector.
179
180 /// Widen a suitably aligned v3 load. For all other cases, split the input
181 /// vector load.
183
184 /// Split a vector store into 2 stores of half the vector.
186
189 SDValue LowerDIVREMToFloat(SDValue Op, SelectionDAG &DAG, bool sign) const;
192
194 CCState &State,
195 const SmallVectorImpl<ISD::InputArg> &Ins) const;
196
197public:
199 const AMDGPUSubtarget &AMDGPUSTI);
200
201 static inline SDValue stripBitcast(SDValue Val) {
202 return Val.getOpcode() == ISD::BITCAST ? Val.getOperand(0) : Val;
203 }
204
205 static bool shouldFoldFNegIntoSrc(SDNode *FNeg, SDValue FNegSrc);
206 static bool allUsesHaveSourceMods(const SDNode *N,
207 unsigned CostThreshold = 4);
208 bool isFAbsFree(EVT VT) const override;
209 bool isFNegFree(EVT VT) const override;
210 bool isTruncateFree(EVT Src, EVT Dest) const override;
211 bool isTruncateFree(Type *Src, Type *Dest) const override;
212
213 bool isZExtFree(Type *Src, Type *Dest) const override;
214 bool isZExtFree(EVT Src, EVT Dest) const override;
215
217 bool LegalOperations, bool ForCodeSize,
219 unsigned Depth) const override;
220
221 bool isNarrowingProfitable(SDNode *N, EVT SrcVT, EVT DestVT) const override;
222
224 CombineLevel Level) const override;
225
227 ISD::NodeType ExtendKind) const override;
228
229 unsigned getVectorIdxWidth(const DataLayout &) const override;
230 bool isSelectSupported(SelectSupportKind) const override;
231
233 bool ForCodeSize) const override;
234 bool ShouldShrinkFPConstant(EVT VT) const override;
236 std::optional<unsigned> ByteOffset) const override;
237
239 const MachineMemOperand &MMO) const final;
240 bool shouldCombineMemoryType(EVT VT) const;
241
242 bool storeOfVectorConstantIsCheap(bool IsZero, EVT MemVT,
243 unsigned NumElem,
244 unsigned AS) const override;
245 bool aggressivelyPreferBuildVectorSources(EVT VecVT) const override;
246 bool isCheapToSpeculateCttz(Type *Ty) const override;
247 bool isCheapToSpeculateCtlz(Type *Ty) const override;
248
249 bool isSDNodeAlwaysUniform(const SDNode *N) const override;
250
251 // FIXME: This hook should not exist
255
259
263
265 return false;
266 }
267
268 static CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg);
269 static CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg);
270
271 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
273 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
274 SelectionDAG &DAG) const override;
275
277 SelectionDAG &DAG,
278 MachineFrameInfo &MFI,
279 int ClobberedFI) const;
280
281 SDValue lowerUnhandledCall(CallLoweringInfo &CLI,
283 StringRef Reason) const;
284 SDValue LowerCall(CallLoweringInfo &CLI,
285 SmallVectorImpl<SDValue> &InVals) const override;
286
288 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
289 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
290
292 const APInt &OriginalDemandedBits,
293 const APInt &OriginalDemandedElts,
295 TargetLoweringOpt &TLO,
296 unsigned Depth) const override;
297
300 SelectionDAG &DAG) const override;
301
304 SDValue CC, SDNodeFlags Flags,
305 DAGCombinerInfo &DCI) const;
306
307 /// \p Flags must be the select flags, not the compare (SELECT_CC
308 /// flags come from the fcmp and say nothing about the selected value).
311 SDValue CC, SDNodeFlags Flags,
312 DAGCombinerInfo &DCI) const;
313
314 // FIXME: Turn off MergeConsecutiveStores() before Instruction Selection for
315 // AMDGPU. Commit r319036,
316 // (https://github.com/llvm/llvm-project/commit/db77e57ea86d941a4262ef60261692f4cb6893e6)
317 // turned on MergeConsecutiveStores() before Instruction Selection for all
318 // targets. Enough AMDGPU compiles go into an infinite loop (
319 // MergeConsecutiveStores() merges two stores; LegalizeStoreOps() un-merges;
320 // MergeConsecutiveStores() re-merges, etc. ) to warrant turning it off for
321 // now.
322 bool mergeStoresAfterLegalization(EVT) const override { return false; }
323
324 bool isFsqrtCheap(SDValue Operand, SelectionDAG &DAG) const override {
325 return true;
326 }
328 int &RefinementSteps, bool &UseOneConstNR,
329 bool Reciprocal) const override;
331 int &RefinementSteps) const override;
332
334 SelectionDAG &DAG) const = 0;
335
336 /// Determine which of the bits specified in \p Mask are known to be
337 /// either zero or one and return them in the \p KnownZero and \p KnownOne
338 /// bitsets.
341 const APInt &DemandedElts,
342 const SelectionDAG &DAG,
343 unsigned Depth = 0) const override;
344
345 unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts,
346 const SelectionDAG &DAG,
347 unsigned Depth = 0) const override;
348
350 Register R,
351 const APInt &DemandedElts,
353 unsigned Depth = 0) const override;
354
356 SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
357 UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override;
358
359 bool isKnownNeverNaNForTargetNode(SDValue Op, const APInt &DemandedElts,
360 const SelectionDAG &DAG, bool SNaN = false,
361 unsigned Depth = 0) const override;
362
364 Register N1) const override;
365
366 /// Helper function that adds Reg to the LiveIn list of the DAG's
367 /// MachineFunction.
368 ///
369 /// \returns a RegisterSDNode representing Reg if \p RawReg is true, otherwise
370 /// a copy from the register.
372 const TargetRegisterClass *RC,
373 Register Reg, EVT VT,
374 const SDLoc &SL,
375 bool RawReg = false) const;
377 const TargetRegisterClass *RC,
378 Register Reg, EVT VT) const {
379 return CreateLiveInRegister(DAG, RC, Reg, VT, SDLoc(DAG.getEntryNode()));
380 }
381
382 // Returns the raw live in register rather than a copy from it.
384 const TargetRegisterClass *RC,
385 Register Reg, EVT VT) const {
386 return CreateLiveInRegister(DAG, RC, Reg, VT, SDLoc(DAG.getEntryNode()), true);
387 }
388
389 /// Similar to CreateLiveInRegister, except value maybe loaded from a stack
390 /// slot rather than passed in a register.
392 EVT VT,
393 const SDLoc &SL,
394 int64_t Offset) const;
395
397 const SDLoc &SL,
398 SDValue Chain,
399 SDValue ArgVal,
400 int64_t Offset) const;
401
403 const TargetRegisterClass *RC,
404 EVT VT, const SDLoc &SL,
405 const ArgDescriptor &Arg) const;
406
413
414 /// Helper function that returns the byte offset of the given
415 /// type of implicit parameter.
417 const ImplicitParameter Param) const;
418 uint32_t getImplicitParameterOffset(const uint64_t ExplicitKernArgSize,
419 const ImplicitParameter Param) const;
420
421 MVT getFenceOperandTy(const DataLayout &DL) const override {
422 return MVT::i32;
423 }
424
425 bool hasMultipleConditionRegisters(EVT VT) const override {
426 // FIXME: This is only partially true. If we have to do vector compares, any
427 // SGPR pair can be a condition register. If we have a uniform condition, we
428 // are better off doing SALU operations, where there is only one SCC. For
429 // now, we don't have a way of knowing during instruction selection if a
430 // condition will be uniform and we always use vector compares. Assume we
431 // are using vector compares until that is fixed.
432 return true;
433 }
434};
435
436/// Strip fabs/fneg/fcopysign from a value to get the underlying source.
437/// Useful for comparing values where sign doesn't matter (e.g., frexp).
439 while (Val.getOpcode() == ISD::FNEG || Val.getOpcode() == ISD::FABS ||
440 Val.getOpcode() == ISD::FCOPYSIGN)
441 Val = Val.getOperand(0);
442 return Val;
443}
444
445} // End namespace llvm
446
447#endif
uint64_t uint64_t
uint64_t Imm
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
block Block Frequency Analysis
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
Register Reg
SmallVector< MachineOperand, 4 > Cond
RISCVCC::CondCode CC
MachineRegisterInfo & MRI
This file describes how to lower LLVM code to machine code.
TTI::PartialReductionExtendKind ExtendKind
Value * RHS
Value * LHS
static unsigned numBitsSigned(SDValue Op, SelectionDAG &DAG)
unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
This method can be implemented by targets that want to expose additional information about sign bits ...
SDValue performMulhuCombine(SDNode *N, DAGCombinerInfo &DCI) const
EVT getTypeForExtReturn(LLVMContext &Context, EVT VT, ISD::NodeType ExtendKind) const override
Return the type that should be used to zero or sign extend a zeroext/signext integer return value.
SDValue SplitVectorLoad(SDValue Op, SelectionDAG &DAG) const
Split a vector load into 2 loads of half the vector.
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const
SDValue performLoadCombine(SDNode *N, DAGCombinerInfo &DCI) const
void analyzeFormalArgumentsCompute(CCState &State, const SmallVectorImpl< ISD::InputArg > &Ins) const
The SelectionDAGBuilder will automatically promote function arguments with illegal types.
SDValue LowerF64ToF16Safe(SDValue Src, const SDLoc &DL, SelectionDAG &DAG) const
SDValue LowerFROUND(SDValue Op, SelectionDAG &DAG) const
SDValue storeStackInputValue(SelectionDAG &DAG, const SDLoc &SL, SDValue Chain, SDValue ArgVal, int64_t Offset) const
bool storeOfVectorConstantIsCheap(bool IsZero, EVT MemVT, unsigned NumElem, unsigned AS) const override
Return true if it is expected to be cheaper to do a store of vector constant with the given size and ...
SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const
void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
bool shouldCombineMemoryType(EVT VT) const
SDValue splitBinaryBitConstantOpImpl(DAGCombinerInfo &DCI, const SDLoc &SL, unsigned Opc, SDValue LHS, uint32_t ValLo, uint32_t ValHi) const
Split the 64-bit value LHS into two 32-bit components, and perform the binary operation Opc to it wit...
SDValue lowerUnhandledCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals, StringRef Reason) const
virtual SDValue LowerGlobalAddress(AMDGPUMachineFunctionInfo *MFI, SDValue Op, SelectionDAG &DAG) const
SDValue performAssertSZExtCombine(SDNode *N, DAGCombinerInfo &DCI) const
bool isTruncateFree(EVT Src, EVT Dest) const override
bool aggressivelyPreferBuildVectorSources(EVT VecVT) const override
SDValue LowerFCEIL(SDValue Op, SelectionDAG &DAG) const
TargetLowering::NegatibleCost getConstantNegateCost(const ConstantFPSDNode *C) const
SDValue LowerFLOGUnsafe(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, bool IsLog10, SDNodeFlags Flags) const
SDValue combineFMinMaxLegacy(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, SDValue True, SDValue False, SDValue CC, SDNodeFlags Flags, DAGCombinerInfo &DCI) const
Flags must be the select flags, not the compare (SELECT_CC flags come from the fcmp and say nothing a...
SDValue performMulhsCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue lowerFEXPUnsafeImpl(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, SDNodeFlags Flags, bool IsExp10) const
bool isSDNodeAlwaysUniform(const SDNode *N) const override
bool isDesirableToCommuteWithShift(const SDNode *N, CombineLevel Level) const override
Return true if it is profitable to move this shift by a constant amount through its operand,...
virtual SDNode * PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const =0
SDValue performShlCombine(SDNode *N, DAGCombinerInfo &DCI) const
bool isCheapToSpeculateCtlz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
SDValue LowerSDIVREM(SDValue Op, SelectionDAG &DAG) const
bool isFNegFree(EVT VT) const override
Return true if an fneg operation is free to the point where it is never worthwhile to replace it with...
FPImmAction getFPImmAction(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns how the legalizer should materialize the specified FP immediate.
SDValue LowerINT_TO_FP64(SDValue Op, SelectionDAG &DAG, bool Signed) const
unsigned computeNumSignBitsForTargetInstr(GISelValueTracking &Analysis, Register R, const APInt &DemandedElts, const MachineRegisterInfo &MRI, unsigned Depth=0) const override
This method can be implemented by targets that want to expose additional information about sign bits ...
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
SDValue LowerFP_TO_FP16(SDValue Op, SelectionDAG &DAG) const
SDValue addTokenForArgument(SDValue Chain, SelectionDAG &DAG, MachineFrameInfo &MFI, int ClobberedFI) const
bool isReassocProfitable(MachineRegisterInfo &MRI, Register N0, Register N1) const override
bool isKnownNeverNaNForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, bool SNaN=false, unsigned Depth=0) const override
If SNaN is false,.
static bool needsDenormHandlingF32(const SelectionDAG &DAG, SDValue Src, SDNodeFlags Flags)
SDValue lowerFPOW(SDValue Op, SelectionDAG &DAG) const
MVT getFenceOperandTy(const DataLayout &DL) const override
Return the type for operands of fence.
uint32_t getImplicitParameterOffset(const MachineFunction &MF, const ImplicitParameter Param) const
Helper function that returns the byte offset of the given type of implicit parameter.
SDValue lowerFEXPF64(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFFLOOR(SDValue Op, SelectionDAG &DAG) const
SDValue performSelectCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue performFNegCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const
bool isConstantCostlierToNegate(SDValue N) const
static KnownBits computeKnownBitsForMul24(const KnownBits &LHSKnown, const KnownBits &RHSKnown, unsigned BitWidth, bool IsSigned, bool SelfMultiply)
SDValue loadInputValue(SelectionDAG &DAG, const TargetRegisterClass *RC, EVT VT, const SDLoc &SL, const ArgDescriptor &Arg) const
SDValue lowerFEXP10Unsafe(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, SDNodeFlags Flags) const
Emit approx-funcs appropriate lowering for exp10.
bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtType, EVT ExtVT, std::optional< unsigned > ByteOffset) const override
Return true if it is profitable to reduce a load to a smaller type.
SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG) const
bool canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override
Return true if Op can create undef or poison from non-undef & non-poison operands.
SDValue CreateLiveInRegisterRaw(SelectionDAG &DAG, const TargetRegisterClass *RC, Register Reg, EVT VT) const
bool isCheapToSpeculateCttz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
SDValue performCtlz_CttzCombine(const SDLoc &SL, SDValue Cond, SDValue LHS, SDValue RHS, DAGCombinerInfo &DCI) const
SDValue performSraCombine(SDNode *N, DAGCombinerInfo &DCI) const
bool isSelectSupported(SelectSupportKind) const override
bool isZExtFree(Type *Src, Type *Dest) const override
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
SDValue lowerFEXP2(SDValue Op, SelectionDAG &DAG) const
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
AtomicExpansionKind shouldCastAtomicLoadInIR(LoadInst *LI) const override
Returns how the given (atomic) load should be cast by the IR-level AtomicExpand pass.
SDValue performSrlCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue lowerFEXP(SDValue Op, SelectionDAG &DAG) const
SDValue getIsFinite(SelectionDAG &DAG, SDValue Op, SDNodeFlags Flags) const
bool isLoadBitCastBeneficial(EVT, EVT, const SelectionDAG &DAG, const MachineMemOperand &MMO) const final
Return true if the following transform is beneficial: fold (conv (load x)) -> (load (conv*)x) On arch...
std::pair< SDValue, SDValue > splitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HighVT, SelectionDAG &DAG) const
Split a vector value into two parts of types LoVT and HiVT.
AMDGPUTargetLowering(const TargetMachine &TM, const TargetSubtargetInfo &STI, const AMDGPUSubtarget &AMDGPUSTI)
SDValue LowerFLOGCommon(SDValue Op, SelectionDAG &DAG) const
SDValue foldFreeOpFromSelect(TargetLowering::DAGCombinerInfo &DCI, SDValue N) const
SDValue LowerINT_TO_FP32(SDValue Op, SelectionDAG &DAG, bool Signed) const
bool isFAbsFree(EVT VT) const override
Return true if an fabs operation is free to the point where it is never worthwhile to replace it with...
bool isInt64ImmLegal(SDNode *Val, SelectionDAG &DAG) const
Check whether value Val can be supported by v_mov_b64, for the current target.
SDValue loadStackInputValue(SelectionDAG &DAG, EVT VT, const SDLoc &SL, int64_t Offset) const
Similar to CreateLiveInRegister, except value maybe loaded from a stack slot rather than passed in a ...
SDValue LowerFLOG2(SDValue Op, SelectionDAG &DAG) const
static EVT getEquivalentMemType(LLVMContext &Context, EVT VT)
SDValue LowerCTLS(SDValue Op, SelectionDAG &DAG) const
Split a vector store into multiple scalar stores.
SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps, bool &UseOneConstNR, bool Reciprocal) const override
Hooks for building estimates in place of slower divisions and square roots.
SDValue performTruncateCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG) const
static SDValue stripBitcast(SDValue Val)
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC, Register Reg, EVT VT, const SDLoc &SL, bool RawReg=false) const
Helper function that adds Reg to the LiveIn list of the DAG's MachineFunction.
SDValue SplitVectorStore(SDValue Op, SelectionDAG &DAG) const
Split a vector store into 2 stores of half the vector.
bool shouldIssueAtomicLoadForAtomicEmulationLoop() const override
SDValue LowerCTLZ_CTTZ(SDValue Op, SelectionDAG &DAG) const
SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOperations, bool ForCodeSize, NegatibleCost &Cost, unsigned Depth) const override
Return the newly negated expression if the cost is not expensive and set the cost in Cost to indicate...
AtomicExpansionKind shouldCastAtomicStoreInIR(StoreInst *SI) const override
Returns how the given (atomic) store should be cast by the IR-level AtomicExpand pass into.
std::pair< SDValue, SDValue > split64BitValue(SDValue Op, SelectionDAG &DAG) const
Return 64-bit value Op as two 32-bit integers.
SDValue performMulCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue combineFMinMaxLegacyImpl(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, SDValue True, SDValue False, SDValue CC, SDNodeFlags Flags, DAGCombinerInfo &DCI) const
SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps) const override
Return a reciprocal estimate value for the input operand.
SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC, Register Reg, EVT VT) const
bool hasMultipleConditionRegisters(EVT VT) const override
Does the target have multiple (allocatable) condition registers that can be used to store the results...
SDValue LowerFNEARBYINT(SDValue Op, SelectionDAG &DAG) const
SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const
static CCAssignFn * CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg)
std::pair< SDValue, SDValue > getScaledLogInput(SelectionDAG &DAG, const SDLoc SL, SDValue Op, SDNodeFlags Flags) const
If denormal handling is required return the scaled input to FLOG2, and the check for denormal range.
static CCAssignFn * CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg)
Selects the correct CCAssignFn for a given CallingConvention value.
bool SimplifyDemandedBitsForTargetNode(SDValue Op, const APInt &OriginalDemandedBits, const APInt &OriginalDemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth) const override
Attempt to simplify any target nodes based on the demanded bits/elts, returning true on success.
static bool allUsesHaveSourceMods(const SDNode *N, unsigned CostThreshold=4)
SDValue LowerFROUNDEVEN(SDValue Op, SelectionDAG &DAG) const
static unsigned numBitsUnsigned(SDValue Op, SelectionDAG &DAG)
SDValue lowerFEXPUnsafe(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, SDNodeFlags Flags) const
SDValue LowerFTRUNC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const
static bool allowApproxFunc(const SelectionDAG &DAG, SDNodeFlags Flags)
bool ShouldShrinkFPConstant(EVT VT) const override
If true, then instruction selection should seek to shrink the FP constant of the specified type to a ...
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array,...
SDValue performStoreCombine(SDNode *N, DAGCombinerInfo &DCI) const
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
SDValue performRcpCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue lowerCTLZResults(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFP_TO_INT_SAT(SDValue Op, SelectionDAG &DAG) const
SDValue performFAbsCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerFP_TO_INT64(SDValue Op, SelectionDAG &DAG, bool Signed) const
static bool shouldFoldFNegIntoSrc(SDNode *FNeg, SDValue FNegSrc)
bool isNarrowingProfitable(SDNode *N, EVT SrcVT, EVT DestVT) const override
Return true if it's profitable to narrow operations of type SrcVT to DestVT.
SDValue LowerFRINT(SDValue Op, SelectionDAG &DAG) const
SDValue performIntrinsicWOChainCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerUDIVREM(SDValue Op, SelectionDAG &DAG) const
SDValue performMulLoHiCombine(SDNode *N, DAGCombinerInfo &DCI) const
AtomicExpansionKind shouldCastAtomicRMWIInIR(AtomicRMWInst *) const override
Returns how the given atomic atomicrmw should be cast by the IR-level AtomicExpand pass.
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
SDValue lowerINT_TO_FPImpl(SDValue Op, SelectionDAG &DAG, bool Signed) const
void LowerUDIVREM64(SDValue Op, SelectionDAG &DAG, SmallVectorImpl< SDValue > &Results) const
SDValue WidenOrSplitVectorLoad(SDValue Op, SelectionDAG &DAG) const
Widen a suitably aligned v3 load.
bool mergeStoresAfterLegalization(EVT) const override
Allow store merging for the specified type after legalization in addition to before legalization.
SDValue LowerDIVREMToFloat(SDValue Op, SelectionDAG &DAG, bool sign) const
std::pair< EVT, EVT > getSplitDestVTs(const EVT &VT, SelectionDAG &DAG) const
Split a vector type into two parts.
SDValue getHiHalf64(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINT_TO_FP16(SDValue Op, SelectionDAG &DAG, EVT FP16Ty) const
bool isFsqrtCheap(SDValue Operand, SelectionDAG &DAG) const override
Return true if SQRT(X) shouldn't be replaced with X*RSQRT(X).
unsigned getVectorIdxWidth(const DataLayout &) const override
Returns the type to be used for the index operand vector operations.
Class for arbitrary precision integers.
Definition APInt.h:78
an instruction that atomically reads a memory location, combines it with another value,...
CCState - This class holds information needed while lowering arguments and return values.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
An instruction for reading from memory.
Machine Value Type.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
A description of a memory reference used in the backend.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
An SDNode that represents everything that will be needed to construct a MachineInstr.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
SelectSupportKind
Enum that describes what type of support for selects the target has.
FPImmAction
How the legalizer should materialize a floating-point immediate.
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
NegatibleCost
Enum that specifies when a float negation is beneficial.
TargetLowering(const TargetLowering &)=delete
Primary interface to the complete machine description for the target machine.
TargetSubtargetInfo - Generic base class for all target subtargets.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition ISDOpcodes.h:43
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
Definition ISDOpcodes.h:539
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
InstructionCost Cost
@ Known
Known to have no common set bits.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
@ Load
The value being inserted comes from a load (InsertElement only).
SDValue peekFPSignOps(SDValue Val)
Strip fabs/fneg/fcopysign from a value to get the underlying source.
CombineLevel
Definition DAGCombine.h:15
DWARFExpression::Operation Op
constexpr unsigned BitWidth
UndefPoisonKind
Enumeration to track whether we are interested in Undef, Poison, or both.
Definition UndefPoison.h:20
@ Enabled
Convert any .debug_str_offsets tables to DWARF64 if needed.
Definition DWP.h:31
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
#define N
Extended Value Type.
Definition ValueTypes.h:35
These are IR-level optimization flags that may be propagated to SDNodes.