LLVM 20.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, TargetLowering::TargetLoweringOpt &TLO, 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 SDValue | BuildExactUDIV (const TargetLowering &TLI, SDNode *N, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDNode * > &Created) |
Given an exact UDIV 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< bool > | isFCmpEqualZero (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) |
|
static |
Given an exact SDIV by a constant, create a multiplication with the multiplicative inverse of the constant.
Ref: "Hacker's Delight" by Henry Warren, 2nd Edition, p. 242
Definition at line 6148 of file TargetLowering.cpp.
References llvm::APInt::ashrInPlace(), assert(), llvm::ISD::BUILD_VECTOR, llvm::CallingConv::C, llvm::APInt::countr_zero(), llvm::SDNodeFlags::Exact, 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, llvm::APInt::multiplicativeInverse(), 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 |
Given an exact UDIV by a constant, create a multiplication with the multiplicative inverse of the constant.
Ref: "Hacker's Delight" by Henry Warren, 2nd Edition, p. 242
Definition at line 6208 of file TargetLowering.cpp.
References assert(), llvm::ISD::BUILD_VECTOR, llvm::CallingConv::C, llvm::APInt::countr_zero(), llvm::SDNodeFlags::Exact, 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::APInt::lshrInPlace(), llvm::ISD::matchUnaryPredicate(), llvm::ISD::MUL, llvm::APInt::multiplicativeInverse(), N, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), llvm::ISD::SPLAT_VECTOR, and llvm::ISD::SRL.
Referenced by llvm::TargetLowering::BuildUDIV().
|
static |
Definition at line 9075 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 |
Definition at line 10414 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.
Referenced by llvm::TargetLowering::getVectorSubVecPointer().
|
static |
Definition at line 986 of file TargetLowering.cpp.
References A, 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::TargetLowering::TargetLoweringOpt::DAG, llvm::Depth, DL, llvm::SelectionDAG::getContext(), llvm::SelectionDAG::getExtOrTrunc(), 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::isOperationLegal(), llvm::EVT::isVector(), llvm::TargetLowering::TargetLoweringOpt::LegalOperations(), llvm::TargetLowering::TargetLoweringOpt::LegalTypes(), llvm_unreachable, llvm::ISD::SRA, llvm::ISD::SRL, and llvm::SelectionDAG::willNotOverflowAdd().
Referenced by llvm::TargetLowering::SimplifyDemandedBits().
|
static |
Definition at line 7978 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 4438 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 4395 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 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 5924 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 3032 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().
|
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 8705 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().
Definition at line 7971 of file TargetLowering.cpp.
References llvm::CallingConv::C, and llvm::ISD::matchUnaryPredicate().
|
static |
If we have an immediate, see if we can lower it.
Return true if we can, false otherwise.
Definition at line 6071 of file TargetLowering.cpp.
References assert(), llvm::TargetLowering::C_Immediate, llvm::TargetLowering::C_Other, llvm::TargetLowering::LowerAsmOperandForConstraint(), and P.
Referenced by llvm::TargetLowering::ComputeConstraintToUse().
|
static |
Definition at line 4321 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::SDValue::hasOneUse(), llvm::TargetLoweringBase::isCtpopFast(), llvm::EVT::isInteger(), llvm::SelectionDAG::isKnownNeverZero(), llvm::EVT::isVector(), llvm::Log2_32(), Passes, RHS, llvm::ISD::SETEQ, llvm::ISD::SETNE, llvm::ISD::SETUGT, llvm::ISD::SETULE, llvm::ISD::SETULT, llvm::ISD::TRUNCATE, llvm::APInt::ugt(), llvm::Xor, and llvm::ISD::XOR.
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 6701 of file TargetLowering.cpp.
References llvm::all_of(), llvm::MutableArrayRef< T >::begin(), llvm::MutableArrayRef< T >::end(), and llvm::find_if_not().