26 #define DEBUG_TYPE "legalize-types" 35 void DAGTypeLegalizer::ExpandRes_MERGE_VALUES(
SDNode *
N,
unsigned ResNo,
37 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
38 GetExpandedOp(Op, Lo, Hi);
49 switch (getTypeAction(InVT)) {
59 auto SoftenedOp = GetSoftenedFloat(InOp);
60 if (isLegalInHWReg(SoftenedOp.getValueType()))
62 SplitInteger(SoftenedOp, Lo, Hi);
71 GetExpandedOp(InOp, Lo, Hi);
80 GetSplitVector(InOp, Lo, Hi);
88 SplitInteger(BitConvertToInteger(GetScalarizedVector(InOp)), Lo, Hi);
94 InOp = GetWidenedVector(InOp);
97 std::tie(Lo, Hi) = DAG.
SplitVector(InOp, dl, LoVT, HiVT);
109 unsigned NumElems = 2;
114 while (!isTypeLegal(NVT)) {
117 if (NewSizeInBits < 8)
124 if (isTypeLegal(NVT)) {
128 for (
unsigned i = 0; i < NumElems; ++i)
135 for (
unsigned e = Vals.
size(); e - Slot > 2; Slot += 2, e += 1) {
167 int SPFI = cast<FrameIndexSDNode>(StackPtr.
getNode())->getIndex();
175 Lo = DAG.
getLoad(NOutVT, dl, Store, StackPtr, PtrInfo);
179 StackPtr = DAG.
getNode(
ISD::ADD, dl, StackPtr.getValueType(), StackPtr,
181 StackPtr.getValueType()));
184 Hi = DAG.
getLoad(NOutVT, dl, Store, StackPtr,
186 MinAlign(Alignment, IncrementSize));
193 void DAGTypeLegalizer::ExpandRes_BUILD_PAIR(
SDNode *N,
SDValue &Lo,
200 void DAGTypeLegalizer::ExpandRes_EXTRACT_ELEMENT(
SDNode *N,
SDValue &Lo,
207 "Type twice as big as expanded type not itself expanded!");
209 GetPairElements(Part, Lo, Hi);
212 void DAGTypeLegalizer::ExpandRes_EXTRACT_VECTOR_ELT(
SDNode *N,
SDValue &Lo,
224 if (OldVT != OldEltVT) {
228 assert(OldEltVT.
bitsLT(OldVT) &&
"Result type smaller then element type!");
252 void DAGTypeLegalizer::ExpandRes_NormalLoad(
SDNode *N,
SDValue &Lo,
274 Hi = DAG.
getLoad(NVT, dl, Chain, Ptr,
290 ReplaceValueWith(
SDValue(N, 1), Chain);
311 ReplaceValueWith(
SDValue(N, 1), Chain);
319 void DAGTypeLegalizer::IntegerToVector(
SDValue Op,
unsigned NumElements,
326 if (NumElements > 1) {
328 SplitInteger(Op, Parts[0], Parts[1]);
331 IntegerToVector(Parts[0], NumElements, Ops, EltVT);
332 IntegerToVector(Parts[1], NumElements, Ops, EltVT);
351 unsigned NumElts = 2;
356 if (!isTypeLegal(NVT)) {
384 "BUILD_VECTOR operand type doesn't match vector element type!");
391 for (
unsigned i = 0; i < NumElts; ++i) {
396 NewElts.push_back(Lo);
397 NewElts.push_back(Hi);
407 SDValue DAGTypeLegalizer::ExpandOp_EXTRACT_ELEMENT(
SDNode *N) {
410 return cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue() ?
Hi :
Lo;
413 SDValue DAGTypeLegalizer::ExpandOp_INSERT_VECTOR_ELT(
SDNode *N) {
424 "Inserted element type doesn't match vector element type!");
433 GetExpandedOp(Val, Lo, Hi);
449 SDValue DAGTypeLegalizer::ExpandOp_SCALAR_TO_VECTOR(
SDNode *N) {
453 "SCALAR_TO_VECTOR operand type doesn't match vector element type!");
458 for (
unsigned i = 1; i < NumElts; ++i)
463 SDValue DAGTypeLegalizer::ExpandOp_NormalStore(
SDNode *N,
unsigned OpNo) {
465 assert(OpNo == 1 &&
"Can only expand the stored value so far");
489 Hi = DAG.
getStore(Chain, dl, Hi, Ptr,
507 void DAGTypeLegalizer::SplitRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo,
509 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
510 GetSplitOp(Op, Lo, Hi);
527 return std::make_pair(Lo, Hi);
531 SDValue LL, LH, RL, RH, CL, CH;
538 if (Cond.getValueType().isVector()) {
539 if (
SDValue Res = WidenVSELECTAndMask(N))
540 std::tie(CL, CH) = DAG.
SplitVector(Res->getOperand(0), dl);
544 std::tie(CL, CH) =
SplitVSETCC(Cond.getNode(), DAG);
547 else if (getTypeAction(Cond.getValueType()) ==
549 GetSplitVector(Cond, CL, CH);
558 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.
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
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.
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.
const DataLayout & getDataLayout() const
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
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...
std::pair< SDValue, SDValue > SplitVectorOperand(const SDNode *N, unsigned OpNo)
Split the node's operand with EXTRACT_SUBVECTOR and return the low/high part.
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
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.
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...
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...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
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
static std::pair< SDValue, SDValue > SplitVSETCC(const SDNode *N, SelectionDAG &DAG)
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.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, int64_t Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object...
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.