LLVM 17.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/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>
Include dependency graph for TargetLowering.cpp:

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 getConstraintGenerality (TargetLowering::ConstraintType CT)
 Return an integer indicating how general CT is.
 
static void ChooseConstraint (TargetLowering::AsmOperandInfo &OpInfo, const TargetLowering &TLI, SDValue Op, SelectionDAG *DAG)
 If there are multiple different constraints that we could pick for this operand (e.g.
 
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 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

◆ ChooseConstraint()

static void ChooseConstraint ( TargetLowering::AsmOperandInfo OpInfo,
const TargetLowering TLI,
SDValue  Op,
SelectionDAG DAG 
)
static

If there are multiple different constraints that we could pick for this operand (e.g.

"imr") try to pick the 'best' one. This is somewhat tricky: constraints fall into four classes: Other -> immediates and magic values Register -> one specific register RegisterClass -> a group of regs Memory -> memory Ideally, we would pick the most specific constraint possible: if we have something that fits into a register, we would pick it. The problem here is that if we have something that could either be in a register or in memory that use of the register could cause selection of other operands to fail: they might only succeed if we pick memory. Because of this the heuristic we use is:

1) If there is an 'other' constraint, and if the operand is valid for that constraint, use it. This makes us take advantage of 'i' constraints when available. 2) Otherwise, pick the most general constraint present. This prefers 'm' over 'r', for example.

Definition at line 5669 of file TargetLowering.cpp.

References assert(), llvm::TargetLowering::C_Immediate, llvm::TargetLowering::C_Memory, llvm::TargetLowering::C_Other, llvm::TargetLowering::C_Register, llvm::TargetLowering::C_RegisterClass, llvm::TargetLowering::C_Unknown, llvm::InlineAsm::ConstraintInfo::Codes, llvm::TargetLowering::AsmOperandInfo::ConstraintCode, llvm::TargetLowering::AsmOperandInfo::ConstraintType, getConstraintGenerality(), llvm::TargetLowering::getConstraintType(), llvm::InlineAsm::ConstraintInfo::hasMatchingInput(), llvm::InlineAsm::ConstraintInfo::isIndirect, and llvm::TargetLowering::LowerAsmOperandForConstraint().

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

◆ 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

◆ getConstraintGenerality()

static unsigned getConstraintGenerality ( TargetLowering::ConstraintType  CT)
static

◆ getKnownUndefForVectorBinop()

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

◆ isNonZeroModBitWidthOrUndef()

static bool isNonZeroModBitWidthOrUndef ( SDValue  Z,
unsigned  BW 
)
static

Definition at line 7447 of file TargetLowering.cpp.

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

◆ 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 6189 of file TargetLowering.cpp.

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