25#define DEBUG_TYPE "legalize-types"
34void DAGTypeLegalizer::ExpandRes_MERGE_VALUES(
SDNode *
N,
unsigned ResNo,
36 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
41 EVT OutVT =
N->getValueType(0);
48 switch (getTypeAction(InVT)) {
57 SplitInteger(GetSoftenedFloat(InOp),
Lo,
Hi);
65 GetExpandedOp(InOp,
Lo,
Hi);
74 GetSplitVector(InOp,
Lo,
Hi);
82 SplitInteger(BitConvertToInteger(GetScalarizedVector(InOp)),
Lo,
Hi);
90 InOp = GetWidenedVector(InOp);
105 unsigned NumElems = 2;
110 while (!isTypeLegal(NVT)) {
113 if (NewSizeInBits < 8)
120 if (isTypeLegal(NVT)) {
124 for (
unsigned i = 0; i < NumElems; ++i)
130 for (
unsigned e = Vals.
size(); e - Slot > 2; Slot += 2, e += 1) {
166 int SPFI = cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex();
174 Lo = DAG.
getLoad(NOutVT, dl, Store, StackPtr, PtrInfo, NOutAlign);
182 Hi = DAG.
getLoad(NOutVT, dl, Store, StackPtr,
193 Lo =
N->getOperand(0);
194 Hi =
N->getOperand(1);
199 GetExpandedOp(
N->getOperand(0),
Lo,
Hi);
203 "Type twice as big as expanded type not itself expanded!");
205 GetPairElements(Part,
Lo,
Hi);
217 EVT OldVT =
N->getValueType(0);
220 if (OldVT != OldEltVT) {
224 assert(OldEltVT.
bitsLT(OldVT) &&
"Result type smaller then element type!");
253 assert(!
LD->isAtomic() &&
"Atomics can not be split");
254 EVT ValueVT =
LD->getValueType(0);
263 LD->getOriginalAlign(),
LD->getMemOperand()->getFlags(),
270 NVT, dl, Chain,
Ptr,
LD->getPointerInfo().getWithOffset(IncrementSize),
271 LD->getOriginalAlign(),
LD->getMemOperand()->getFlags(), AAInfo);
284 ReplaceValueWith(
SDValue(
N, 1), Chain);
288 EVT OVT =
N->getValueType(0);
293 const unsigned Align =
N->getConstantOperandVal(3);
297 Chain =
Hi.getValue(1);
305 ReplaceValueWith(
SDValue(
N, 1), Chain);
313void DAGTypeLegalizer::IntegerToVector(
SDValue Op,
unsigned NumElements,
316 assert(
Op.getValueType().isInteger());
320 if (NumElements > 1) {
322 SplitInteger(
Op, Parts[0], Parts[1]);
325 IntegerToVector(Parts[0], NumElements, Ops, EltVT);
326 IntegerToVector(Parts[1], NumElements, Ops, EltVT);
334 if (
N->getValueType(0).isVector() &&
335 N->getOperand(0).getValueType().isInteger()) {
345 unsigned NumElts = 2;
346 EVT OVT =
N->getOperand(0).getValueType();
350 if (!isTypeLegal(NVT)) {
353 NumElts =
N->getValueType(0).getVectorNumElements();
354 NVT =
N->getValueType(0);
365 return CreateStackStoreLoad(
N->getOperand(0),
N->getValueType(0));
370 EVT VecVT =
N->getValueType(0);
372 EVT OldVT =
N->getOperand(0).getValueType();
377 "BUILD_VECTOR operand type doesn't match vector element type!");
383 GetExpandedOp(V,
Lo,
Hi);
393 for (
unsigned i = 0; i < NumElts; ++i) {
395 GetExpandedOp(
N->getOperand(i),
Lo,
Hi);
411 GetExpandedOp(
N->getOperand(0),
Lo,
Hi);
412 return N->getConstantOperandVal(1) ?
Hi :
Lo;
420 GetExpandedOp(
N->getOperand(1),
Lo,
Hi);
428 EVT VecVT =
N->getValueType(0);
437 "Inserted element type doesn't match vector element type!");
443 NewVecVT,
N->getOperand(0));
446 GetExpandedOp(Val,
Lo,
Hi);
464 EVT VT =
N->getValueType(0);
466 "SCALAR_TO_VECTOR operand type doesn't match vector element type!");
469 Ops[0] =
N->getOperand(0);
471 for (
unsigned i = 1; i < NumElts; ++i)
476SDValue DAGTypeLegalizer::ExpandOp_NormalStore(
SDNode *
N,
unsigned OpNo) {
478 assert(OpNo == 1 &&
"Can only expand the stored value so far");
520void DAGTypeLegalizer::SplitRes_MERGE_VALUES(
SDNode *
N,
unsigned ResNo,
522 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
529 unsigned Opcode =
N->getOpcode();
530 GetSplitOp(
N->getOperand(1), LL, LH);
531 GetSplitOp(
N->getOperand(2), RL, RH);
535 if (
Cond.getValueType().isVector()) {
536 if (
SDValue Res = WidenVSELECTMask(
N))
540 else if (getTypeAction(
Cond.getValueType()) ==
542 GetSplitVector(
Cond, CL,
CH);
549 EVT CondLHSVT =
Cond.getOperand(0).getValueType();
550 if (
Cond.getValueType().getVectorElementType() == MVT::i1 &&
551 isTypeLegal(CondLHSVT) &&
552 getSetCCResultType(CondLHSVT) ==
Cond.getValueType())
555 SplitVecRes_SETCC(
Cond.getNode(), CL,
CH);
560 if (Opcode != ISD::VP_SELECT && Opcode != ISD::VP_MERGE) {
567 std::tie(EVLLo, EVLHi) =
568 DAG.
SplitEVL(
N->getOperand(3),
N->getValueType(0), dl);
578 GetSplitOp(
N->getOperand(2), LL, LH);
579 GetSplitOp(
N->getOperand(3), RL, RH);
582 N->getOperand(1), LL, RL,
N->getOperand(4));
584 N->getOperand(1), LH, RH,
N->getOperand(4));
598 GetSplitOp(
N->getOperand(0), L,
H);
607 GetSplitOp(
N->getOperand(0), L,
H);
617 GetSplitOp(
N->getOperand(0), L,
H);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
support::ulittle16_t & Lo
support::ulittle16_t & Hi
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents an Operation in the Expression.
This class is used to represent ISD::LOAD nodes.
Flags getFlags() const
Return the raw flags of the source value,.
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
Align getOriginalAlign() const
Returns alignment and volatility of the memory access.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
const MachinePointerInfo & getPointerInfo() const
const SDValue & getChain() const
bool isAtomic() const
Return true if the memory operation ordering is Unordered or higher.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
EVT getValueType() const
Return the ValueType of the referenced return value.
Align getReducedAlign(EVT VT, bool UseABI)
In most cases this function returns the ABI alignment for a given type, except for illegal vector typ...
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), 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,...
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...
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
const DataLayout & getDataLayout() 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 getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
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.
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 provided VTs and return the low/high part.
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
std::pair< SDValue, SDValue > SplitEVL(SDValue N, EVT VecVT, const SDLoc &DL)
Split the explicit vector length parameter of a VP operation.
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
MachineFunction & getMachineFunction() const
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class is used to represent ISD::STORE nodes.
const SDValue & getBasePtr() const
const SDValue & getValue() const
@ TypeScalarizeScalableVector
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?...
virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ ADD
Simple integer binary arithmetic operators.
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
This is an optimization pass for GlobalISel generic memory operations.
Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
This struct is a compact representation of a valid (non-zero power of two) alignment.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
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.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool isInteger() const
Return true if this is an integer or a vector integer type.
This class contains a discriminated union of information about pointers in memory operands,...
MachinePointerInfo getWithOffset(int64_t O) const
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.