LLVM 19.0.0git
Functions
TargetLowering.cpp File Reference
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/CodeGenCommonISel.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/DivisionByConstantInfo.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetMachine.h"
#include <cctype>

Go to the source code of this file.

Functions

static SDValue combineShiftToAVG (SDValue Op, SelectionDAG &DAG, const TargetLowering &TLI, const APInt &DemandedBits, const APInt &DemandedElts, unsigned Depth)
 
static APInt getKnownUndefForVectorBinop (SDValue BO, SelectionDAG &DAG, const APInt &UndefOp0, const APInt &UndefOp1)
 Given a vector binary operation and known undefined elements for each input operand, compute whether each element of the output is undefined.
 
static SDValue simplifySetCCWithCTPOP (const TargetLowering &TLI, EVT VT, SDValue N0, const APInt &C1, ISD::CondCode Cond, const SDLoc &dl, SelectionDAG &DAG)
 
static SDValue foldSetCCWithRotate (EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, const SDLoc &dl, SelectionDAG &DAG)
 
static SDValue foldSetCCWithFunnelShift (EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, const SDLoc &dl, SelectionDAG &DAG)
 
static unsigned getConstraintPiority (TargetLowering::ConstraintType CT)
 Return a number indicating our preference for chosing a type of constraint over another, for the purpose of sorting them.
 
static bool lowerImmediateIfPossible (TargetLowering::ConstraintPair &P, SDValue Op, SelectionDAG *DAG, const TargetLowering &TLI)
 If we have an immediate, see if we can lower it.
 
static SDValue BuildExactSDIV (const TargetLowering &TLI, SDNode *N, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDNode * > &Created)
 Given an exact SDIV by a constant, create a multiplication with the multiplicative inverse of the constant.
 
static void turnVectorIntoSplatVector (MutableArrayRef< SDValue > Values, std::function< bool(SDValue)> Predicate, SDValue AlternativeReplacement=SDValue())
 If all values in Values that don't match the predicate are same 'splat' value, then replace all values with that splat value.
 
static bool isNonZeroModBitWidthOrUndef (SDValue Z, unsigned BW)
 
static SDValue expandVPFunnelShift (SDNode *Node, SelectionDAG &DAG)
 
static std::optional< boolisFCmpEqualZero (FPClassTest Test, const fltSemantics &Semantics, const MachineFunction &MF)
 Returns a true value if if this FPClassTest can be performed with an ordered fcmp to 0, and a false value if it's an unordered fcmp to 0.
 
static bool canExpandVectorCTPOP (const TargetLowering &TLI, EVT VT)
 
static SDValue clampDynamicVectorIndex (SelectionDAG &DAG, SDValue Idx, EVT VecVT, const SDLoc &dl, ElementCount SubEC)
 

Function Documentation

◆ BuildExactSDIV()

static SDValue BuildExactSDIV ( const TargetLowering TLI,
SDNode N,
const SDLoc dl,
SelectionDAG DAG,
SmallVectorImpl< SDNode * > &  Created 
)
static

◆ canExpandVectorCTPOP()

static bool canExpandVectorCTPOP ( const TargetLowering TLI,
EVT  VT 
)
static

◆ clampDynamicVectorIndex()

static SDValue clampDynamicVectorIndex ( SelectionDAG DAG,
SDValue  Idx,
EVT  VecVT,
const SDLoc dl,
ElementCount  SubEC 
)
static

◆ combineShiftToAVG()

static SDValue combineShiftToAVG ( SDValue  Op,
SelectionDAG DAG,
const TargetLowering TLI,
const APInt DemandedBits,
const APInt DemandedElts,
unsigned  Depth 
)
static

◆ expandVPFunnelShift()

static SDValue expandVPFunnelShift ( SDNode Node,
SelectionDAG DAG 
)
static

◆ foldSetCCWithFunnelShift()

static SDValue foldSetCCWithFunnelShift ( EVT  VT,
SDValue  N0,
SDValue  N1,
ISD::CondCode  Cond,
const SDLoc dl,
SelectionDAG DAG 
)
static

◆ foldSetCCWithRotate()

static SDValue foldSetCCWithRotate ( EVT  VT,
SDValue  N0,
SDValue  N1,
ISD::CondCode  Cond,
const SDLoc dl,
SelectionDAG DAG 
)
static

◆ getConstraintPiority()

static unsigned getConstraintPiority ( TargetLowering::ConstraintType  CT)
static

Return a number indicating our preference for chosing a type of constraint over another, for the purpose of sorting them.

Immediates are almost always preferrable (when they can be emitted). A higher return value means a stronger preference for one constraint type relative to another. FIXME: We should prefer registers over memory but doing so may lead to unrecoverable register exhaustion later. https://github.com/llvm/llvm-project/issues/20571

Definition at line 5796 of file TargetLowering.cpp.

References llvm::TargetLowering::C_Address, llvm::TargetLowering::C_Immediate, llvm::TargetLowering::C_Memory, llvm::TargetLowering::C_Other, llvm::TargetLowering::C_Register, llvm::TargetLowering::C_RegisterClass, llvm::TargetLowering::C_Unknown, and llvm_unreachable.

◆ getKnownUndefForVectorBinop()

static APInt getKnownUndefForVectorBinop ( SDValue  BO,
SelectionDAG DAG,
const APInt UndefOp0,
const APInt UndefOp1 
)
static

◆ isFCmpEqualZero()

static std::optional< bool > isFCmpEqualZero ( FPClassTest  Test,
const fltSemantics Semantics,
const MachineFunction MF 
)
static

Returns a true value if if this FPClassTest can be performed with an ordered fcmp to 0, and a false value if it's an unordered fcmp to 0.

Returns std::nullopt if it cannot be performed as a compare with 0.

Definition at line 8352 of file TargetLowering.cpp.

References llvm::fcNan, llvm::fcNone, llvm::fcSubnormal, llvm::fcZero, llvm::MachineFunction::getDenormalMode(), llvm::DenormalMode::IEEE, llvm::DenormalMode::Input, llvm::DenormalMode::inputsAreZero(), and llvm::Test.

Referenced by llvm::TargetLowering::expandIS_FPCLASS().

◆ isNonZeroModBitWidthOrUndef()

static bool isNonZeroModBitWidthOrUndef ( SDValue  Z,
unsigned  BW 
)
static

Definition at line 7788 of file TargetLowering.cpp.

References llvm::CallingConv::C, and llvm::ISD::matchUnaryPredicate().

◆ lowerImmediateIfPossible()

static bool lowerImmediateIfPossible ( TargetLowering::ConstraintPair P,
SDValue  Op,
SelectionDAG DAG,
const TargetLowering TLI 
)
static

If we have an immediate, see if we can lower it.

Return true if we can, false otherwise.

Definition at line 5943 of file TargetLowering.cpp.

References assert(), llvm::TargetLowering::C_Immediate, llvm::TargetLowering::C_Other, llvm::TargetLowering::LowerAsmOperandForConstraint(), and P.

Referenced by llvm::TargetLowering::ComputeConstraintToUse().

◆ simplifySetCCWithCTPOP()

static SDValue simplifySetCCWithCTPOP ( const TargetLowering TLI,
EVT  VT,
SDValue  N0,
const APInt C1,
ISD::CondCode  Cond,
const SDLoc dl,
SelectionDAG DAG 
)
static

◆ turnVectorIntoSplatVector()

static void turnVectorIntoSplatVector ( MutableArrayRef< SDValue Values,
std::function< bool(SDValue)>  Predicate,
SDValue  AlternativeReplacement = SDValue() 
)
static

If all values in Values that don't match the predicate are same 'splat' value, then replace all values with that splat value.

Else, if AlternativeReplacement was provided, then replace all values that do match predicate with AlternativeReplacement value.

Definition at line 6513 of file TargetLowering.cpp.

References llvm::all_of(), llvm::MutableArrayRef< T >::begin(), llvm::MutableArrayRef< T >::end(), and llvm::find_if_not().