25 #define DEBUG_TYPE "legalize-types" 34 void DAGTypeLegalizer::ExpandRes_MERGE_VALUES(
SDNode *
N,
unsigned ResNo,
36 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
37 GetExpandedOp(Op, Lo, Hi);
48 switch (getTypeAction(InVT)) {
56 SplitInteger(GetSoftenedFloat(InOp), Lo, Hi);
64 GetExpandedOp(InOp, Lo, Hi);
73 GetSplitVector(InOp, Lo, Hi);
81 SplitInteger(BitConvertToInteger(GetScalarizedVector(InOp)), Lo, Hi);
87 InOp = GetWidenedVector(InOp);
90 std::tie(Lo, Hi) = DAG.
SplitVector(InOp, dl, LoVT, HiVT);
102 unsigned NumElems = 2;
107 while (!isTypeLegal(NVT)) {
110 if (NewSizeInBits < 8)
117 if (isTypeLegal(NVT)) {
121 for (
unsigned i = 0; i < NumElems; ++i)
128 for (
unsigned e = Vals.
size();
e - Slot > 2; Slot += 2,
e += 1) {
160 int SPFI = cast<FrameIndexSDNode>(StackPtr.
getNode())->getIndex();
168 Lo = DAG.
getLoad(NOutVT, dl, Store, StackPtr, PtrInfo);
175 Hi = DAG.
getLoad(NOutVT, dl, Store, StackPtr,
177 MinAlign(Alignment, IncrementSize));
184 void DAGTypeLegalizer::ExpandRes_BUILD_PAIR(
SDNode *N,
SDValue &Lo,
191 void DAGTypeLegalizer::ExpandRes_EXTRACT_ELEMENT(
SDNode *N,
SDValue &Lo,
198 "Type twice as big as expanded type not itself expanded!");
200 GetPairElements(Part, Lo, Hi);
203 void DAGTypeLegalizer::ExpandRes_EXTRACT_VECTOR_ELT(
SDNode *N,
SDValue &Lo,
215 if (OldVT != OldEltVT) {
219 assert(OldEltVT.
bitsLT(OldVT) &&
"Result type smaller then element type!");
243 void DAGTypeLegalizer::ExpandRes_NormalLoad(
SDNode *N,
SDValue &Lo,
265 Hi = DAG.
getLoad(NVT, dl, Chain, Ptr,
281 ReplaceValueWith(
SDValue(N, 1), Chain);
302 ReplaceValueWith(
SDValue(N, 1), Chain);
310 void DAGTypeLegalizer::IntegerToVector(
SDValue Op,
unsigned NumElements,
317 if (NumElements > 1) {
319 SplitInteger(Op, Parts[0], Parts[1]);
322 IntegerToVector(Parts[0], NumElements, Ops, EltVT);
323 IntegerToVector(Parts[1], NumElements, Ops, EltVT);
342 unsigned NumElts = 2;
347 if (!isTypeLegal(NVT)) {
375 "BUILD_VECTOR operand type doesn't match vector element type!");
382 for (
unsigned i = 0; i < NumElts; ++i) {
387 NewElts.push_back(Lo);
388 NewElts.push_back(Hi);
398 SDValue DAGTypeLegalizer::ExpandOp_EXTRACT_ELEMENT(
SDNode *N) {
401 return cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue() ?
Hi :
Lo;
404 SDValue DAGTypeLegalizer::ExpandOp_INSERT_VECTOR_ELT(
SDNode *N) {
415 "Inserted element type doesn't match vector element type!");
424 GetExpandedOp(Val, Lo, Hi);
440 SDValue DAGTypeLegalizer::ExpandOp_SCALAR_TO_VECTOR(
SDNode *N) {
444 "SCALAR_TO_VECTOR operand type doesn't match vector element type!");
449 for (
unsigned i = 1; i < NumElts; ++i)
454 SDValue DAGTypeLegalizer::ExpandOp_NormalStore(
SDNode *N,
unsigned OpNo) {
456 assert(OpNo == 1 &&
"Can only expand the stored value so far");
481 Hi = DAG.
getStore(Chain, dl, Hi, Ptr,
499 void DAGTypeLegalizer::SplitRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo,
501 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
502 GetSplitOp(Op, Lo, Hi);
506 SDValue LL, LH, RL, RH, CL, CH;
513 if (Cond.getValueType().isVector()) {
514 if (
SDValue Res = WidenVSELECTAndMask(N))
515 std::tie(CL, CH) = DAG.
SplitVector(Res->getOperand(0), dl);
518 else if (getTypeAction(Cond.getValueType()) ==
520 GetSplitVector(Cond, CL, CH);
527 EVT CondLHSVT = Cond.getOperand(0).getValueType();
528 if (Cond.getValueType().getVectorElementType() ==
MVT::i1 &&
529 isTypeLegal(CondLHSVT) &&
530 getSetCCResultType(CondLHSVT) == Cond.getValueType())
533 SplitVecRes_SETCC(Cond.getNode(), CL, CH);
542 void DAGTypeLegalizer::SplitRes_SELECT_CC(
SDNode *N,
SDValue &Lo,
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
virtual MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
EVT getValueType() const
Return the ValueType of the referenced return value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents lattice values for constants.
const SDValue & getBasePtr() const
void push_back(const T &Elt)
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
const SDValue & getValue() const
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
const SDValue & getChain() const
unsigned getAlignment() const
bool isInteger() const
Return true if this is an integer or a vector integer type.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
void reserve(size_type N)
bool isByteSized() const
Return true if the bit size is a multiple of 8.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, int64_t Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object...
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool hasBigEndianPartOrdering(EVT VT, const DataLayout &DL) const
When splitting a value of the specified type into parts, does the Lo or Hi part come first...
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const DataLayout & getDataLayout() const
MachineFunction & getMachineFunction() const
Simple integer binary arithmetic operators.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
std::pair< EVT, EVT > GetSplitDestVTs(const EVT &VT) const
Compute the VTs needed for the low/hi parts of a type which is split (or expanded) into two not neces...
This class is used to represent ISD::STORE nodes.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
const SDValue & getBasePtr() const
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
const SDValue & getOperand(unsigned Num) const
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
This class contains a discriminated union of information about pointers in memory operands...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
SDValue CreateStackTemporary(EVT VT, unsigned minAlign=1)
Create a stack temporary, suitable for holding the specified value type.
TokenFactor - This node takes multiple tokens as input and produces a single token result...
SDValue getMemBasePlusOffset(SDValue Base, int64_t Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the vector with EXTRACT_SUBVECTOR using the provides VTs and return the low/high part...
bool isAtomic() const
Return true if the memory operation ordering is Unordered or higher.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
MachinePointerInfo getWithOffset(int64_t O) const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT...
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ANY_EXTEND - Used for integer types. The high bits are undefined.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
bool isVector() const
Return true if this is a vector value type.
Flags getFlags() const
Return the raw flags of the source value,.
SDValue getValue(unsigned R) const
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
VAArg produces a result and token chain, and takes a pointer and a source value as input...
const MachinePointerInfo & getPointerInfo() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
SetCC operator - This evaluates to a true value iff the condition is true.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
LLVMContext * getContext() const
This class is used to represent ISD::LOAD nodes.