LLVM 17.0.0git
|
#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>
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) |
|
static |
Given an exact SDIV by a constant, create a multiplication with the multiplicative inverse of the constant.
Definition at line 5767 of file TargetLowering.cpp.
References llvm::APInt::ashrInPlace(), assert(), llvm::ISD::BUILD_VECTOR, llvm::CallingConv::C, llvm::APInt::countTrailingZeros(), llvm::APInt::getBitWidth(), llvm::SelectionDAG::getBuildVector(), llvm::SelectionDAG::getConstant(), llvm::SelectionDAG::getDataLayout(), llvm::SDValue::getNode(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::EVT::getScalarType(), llvm::TargetLoweringBase::getShiftAmountTy(), llvm::SelectionDAG::getSplatVector(), llvm::ISD::matchUnaryPredicate(), llvm::ISD::MUL, N, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), llvm::ISD::SPLAT_VECTOR, and llvm::ISD::SRA.
Referenced by llvm::TargetLowering::BuildSDIV().
|
static |
Definition at line 8229 of file TargetLowering.cpp.
References llvm::ISD::ADD, llvm::ISD::AND, assert(), llvm::EVT::getScalarSizeInBits(), llvm::TargetLoweringBase::isOperationLegalOrCustom(), llvm::TargetLoweringBase::isOperationLegalOrCustomOrPromote(), llvm::EVT::isVector(), llvm::ISD::MUL, llvm::ISD::SRL, and llvm::ISD::SUB.
Referenced by llvm::TargetLowering::expandCTLZ(), llvm::TargetLowering::expandCTPOP(), and llvm::TargetLowering::expandCTTZ().
|
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 5671 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().
|
static |
Definition at line 9353 of file TargetLowering.cpp.
References llvm::ISD::AND, assert(), llvm::SelectionDAG::getConstant(), llvm::EVT::getFixedSizeInBits(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::APInt::getLowBitsSet(), llvm::SelectionDAG::getNode(), llvm::EVT::getSizeInBits(), llvm::EVT::getVectorMinNumElements(), llvm::SelectionDAG::getVScale(), Idx, llvm::EVT::isFixedLengthVector(), llvm::isPowerOf2_32(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::EVT::isScalableVector(), llvm::Log2_32(), llvm::ISD::SUB, llvm::ISD::UMIN, and llvm::ISD::USUBSAT.
|
static |
Definition at line 932 of file TargetLowering.cpp.
References llvm::Add, llvm::ISD::ADD, assert(), llvm::ISD::AVGCEILS, llvm::ISD::AVGCEILU, llvm::ISD::AVGFLOORS, llvm::ISD::AVGFLOORU, llvm::bit_ceil(), llvm::SelectionDAG::computeKnownBits(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::KnownBits::countMinLeadingZeros(), llvm::Depth, DL, llvm::SelectionDAG::getContext(), llvm::EVT::getIntegerVT(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), llvm::EVT::getScalarSizeInBits(), llvm::EVT::getVectorElementCount(), llvm::EVT::getVectorVT(), llvm::isConstOrConstSplat(), llvm::ConstantSDNode::isOne(), llvm::TargetLoweringBase::isOperationLegalOrCustom(), llvm::EVT::isVector(), llvm_unreachable, llvm::ISD::SIGN_EXTEND, llvm::ISD::SRA, llvm::ISD::SRL, llvm::ISD::TRUNCATE, and llvm::ISD::ZERO_EXTEND.
Referenced by llvm::TargetLowering::SimplifyDemandedBits().
|
static |
Definition at line 7457 of file TargetLowering.cpp.
References DL, llvm::SelectionDAG::getAllOnesConstant(), llvm::SelectionDAG::getConstant(), llvm::SelectionDAG::getNode(), llvm::EVT::getScalarSizeInBits(), isNonZeroModBitWidthOrUndef(), llvm::isPowerOf2_32(), X, and Y.
Referenced by llvm::TargetLowering::expandFunnelShift().
|
static |
Definition at line 4135 of file TargetLowering.cpp.
References llvm::BitWidth, Cond, llvm::ISD::FSHL, llvm::ISD::FSHR, llvm::SelectionDAG::getConstant(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), llvm::SDValue::getScalarValueSizeInBits(), llvm::SelectionDAG::getSetCC(), llvm::SDValue::getValueType(), llvm::SDValue::hasOneUse(), llvm::isConstOrConstSplat(), llvm::ConstantSDNode::isZero(), llvm::Or, llvm::ISD::OR, llvm::Other, llvm::ISD::SETEQ, llvm::ISD::SETNE, llvm::ISD::SHL, llvm::ISD::SRL, X, and Y.
Referenced by llvm::TargetLowering::SimplifySetCC().
|
static |
Definition at line 4092 of file TargetLowering.cpp.
References Cond, llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), llvm::SelectionDAG::getSetCC(), llvm::SDValue::getValueType(), llvm::SDValue::hasOneUse(), llvm::ConstantSDNode::isAllOnes(), llvm::isConstOrConstSplat(), llvm::ConstantSDNode::isZero(), llvm::ISD::OR, llvm::ISD::ROTL, llvm::ISD::ROTR, llvm::ISD::SETEQ, llvm::ISD::SETNE, and X.
Referenced by llvm::TargetLowering::SimplifySetCC().
|
static |
Return an integer indicating how general CT is.
Definition at line 5561 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.
|
static |
Given a vector binary operation and known undefined elements for each input operand, compute whether each element of the output is undefined.
Definition at line 2770 of file TargetLowering.cpp.
References assert(), llvm::CallingConv::C, llvm::APInt::getBitWidth(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), llvm::SDNode::getOperand(), llvm::SelectionDAG::getTargetLoweringInfo(), llvm::SelectionDAG::getUNDEF(), llvm::SDValue::getValueType(), llvm::EVT::getVectorElementType(), llvm::EVT::getVectorNumElements(), llvm::APInt::getZero(), llvm::TargetLoweringBase::isBinOp(), llvm::EVT::isFixedLengthVector(), llvm::SDValue::isUndef(), isUndef(), llvm::EVT::isVector(), and llvm::APInt::setBit().
Referenced by llvm::TargetLowering::SimplifyDemandedVectorElts().
Definition at line 7450 of file TargetLowering.cpp.
References llvm::CallingConv::C, and llvm::ISD::matchUnaryPredicate().
|
static |
Definition at line 4026 of file TargetLowering.cpp.
References llvm::Add, llvm::ISD::ADD, llvm::And, llvm::ISD::AND, assert(), CC, Cond, llvm::ISD::CTPOP, llvm::SelectionDAG::getAllOnesConstant(), llvm::SelectionDAG::getConstant(), llvm::TargetLoweringBase::getCustomCtpopCost(), llvm::APInt::getLimitedValue(), llvm::SelectionDAG::getNode(), llvm::SDValue::getOpcode(), llvm::SDValue::getOperand(), llvm::SDValue::getScalarValueSizeInBits(), llvm::SelectionDAG::getSetCC(), llvm::ISD::getSetCCInverse(), llvm::SDValue::hasOneUse(), llvm::EVT::isInteger(), llvm::TargetLoweringBase::isOperationLegal(), llvm::EVT::isVector(), LHS, llvm::Log2_32(), llvm::ISD::OR, Passes, RHS, llvm::ISD::SETEQ, llvm::ISD::SETNE, llvm::ISD::SETUGT, llvm::ISD::SETULT, llvm::ISD::TRUNCATE, and llvm::APInt::ugt().
Referenced by llvm::TargetLowering::SimplifySetCC().
|
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 6192 of file TargetLowering.cpp.
References llvm::all_of(), llvm::MutableArrayRef< T >::begin(), llvm::MutableArrayRef< T >::end(), and llvm::find_if_not().