15#ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H
16#define LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H
67 bool isTypeLegal(
EVT VT)
const {
68 return TLI.getTypeAction(*DAG.
getContext(), VT) == TargetLowering::TypeLegal;
72 bool isSimpleLegalType(
EVT VT)
const {
73 return VT.
isSimple() && TLI.isTypeLegal(VT);
76 EVT getSetCCResultType(
EVT VT)
const {
81 bool IgnoreNodeResults(
SDNode *
N)
const {
89 typedef unsigned TableId;
91 TableId NextValueId = 1;
140 TableId getTableId(
SDValue V) {
141 assert(
V.getNode() &&
"Getting TableId on SDValue()");
143 auto I = ValueToIdMap.
find(V);
144 if (
I != ValueToIdMap.
end()) {
147 assert(
I->second &&
"All Ids should be nonzero");
151 ValueToIdMap.
insert(std::make_pair(V, NextValueId));
152 IdToValueMap.
insert(std::make_pair(NextValueId, V));
154 assert(NextValueId != 0 &&
155 "Ran out of Ids. Increase id type size or add compactification");
156 return NextValueId - 1;
159 const SDValue &getSDValue(TableId &Id) {
161 assert(Id &&
"TableId should be non-zero");
162 auto I = IdToValueMap.
find(Id);
163 assert(
I != IdToValueMap.
end() &&
"cannot find Id in map");
169 : TLI(dag.getTargetLoweringInfo()), DAG(dag),
170 ValueTypeActions(TLI.getValueTypeActions()) {
172 "Too many value types for ValueTypeActions to hold!");
181 assert(Old != New &&
"node replaced with self");
182 for (
unsigned i = 0, e = Old->
getNumValues(); i != e; ++i) {
186 if (OldId != NewId) {
187 ReplacedValues[OldId] = NewId;
192 IdToValueMap.
erase(OldId);
193 PromotedIntegers.
erase(OldId);
194 ExpandedIntegers.
erase(OldId);
195 SoftenedFloats.
erase(OldId);
196 PromotedFloats.
erase(OldId);
197 SoftPromotedHalfs.
erase(OldId);
198 ExpandedFloats.
erase(OldId);
199 ScalarizedVectors.
erase(OldId);
200 SplitVectors.
erase(OldId);
201 WidenedVectors.
erase(OldId);
212 void AnalyzeNewValue(
SDValue &Val);
213 void PerformExpensiveChecks();
214 void RemapId(TableId &Id);
221 bool CustomLowerNode(
SDNode *
N,
EVT VT,
bool LegalizeResult);
231 std::pair<SDValue, SDValue> ExpandAtomic(
SDNode *Node);
254 TableId &PromotedId = PromotedIntegers[getTableId(
Op)];
255 SDValue PromotedOp = getSDValue(PromotedId);
263 EVT OldVT =
Op.getValueType();
265 Op = GetPromotedInteger(
Op);
272 EVT OldVT =
Op.getValueType();
274 Op = GetPromotedInteger(
Op);
285 void PromoteIntegerResult(
SDNode *
N,
unsigned ResNo);
345 template <
class MatchContextClass>
359 bool PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo);
421 void ExpandIntegerResult(
SDNode *
N,
unsigned ResNo);
482 bool ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo);
511 TableId
Id = getTableId(
Op);
512 auto Iter = SoftenedFloats.
find(Id);
513 if (Iter == SoftenedFloats.
end()) {
514 assert(isSimpleLegalType(
Op.getValueType()) &&
515 "Operand wasn't converted to integer?");
518 SDValue SoftenedOp = getSDValue(Iter->second);
519 assert(SoftenedOp.
getNode() &&
"Unconverted op in SoftenedFloats?");
525 void SoftenFloatResult(
SDNode *
N,
unsigned ResNo);
534 SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(
SDNode *
N,
unsigned ResNo);
581 bool SoftenFloatOperand(
SDNode *
N,
unsigned OpNo);
611 void ExpandFloatResult(
SDNode *
N,
unsigned ResNo);
654 bool ExpandFloatOperand(
SDNode *
N,
unsigned OpNo);
669 SDValue &Chain,
bool IsSignaling =
false);
676 TableId &PromotedId = PromotedFloats[getTableId(
Op)];
677 SDValue PromotedOp = getSDValue(PromotedId);
683 void PromoteFloatResult(
SDNode *
N,
unsigned ResNo);
704 bool PromoteFloatOperand(
SDNode *
N,
unsigned OpNo);
708 SDValue PromoteFloatOp_STRICT_FP_EXTEND(
SDNode *
N,
unsigned OpNo);
720 TableId &PromotedId = SoftPromotedHalfs[getTableId(
Op)];
721 SDValue PromotedOp = getSDValue(PromotedId);
727 void SoftPromoteHalfResult(
SDNode *
N,
unsigned ResNo);
746 bool SoftPromoteHalfOperand(
SDNode *
N,
unsigned OpNo);
766 TableId &ScalarizedId = ScalarizedVectors[getTableId(
Op)];
767 SDValue ScalarizedOp = getSDValue(ScalarizedId);
768 assert(ScalarizedOp.
getNode() &&
"Operand wasn't scalarized?");
774 void ScalarizeVectorResult(
SDNode *
N,
unsigned ResNo);
805 bool ScalarizeVectorOperand(
SDNode *
N,
unsigned OpNo);
836 std::pair<SDValue, SDValue> SplitMask(
SDValue Mask);
839 std::pair<SDValue, SDValue> SplitMask(
SDValue Mask,
const SDLoc &
DL);
847 void SplitVectorResult(
SDNode *
N,
unsigned ResNo);
856 void SplitVecRes_OverflowOp(
SDNode *
N,
unsigned ResNo,
875 bool SplitSETCC =
false);
883 void SplitVecRes_VECTOR_DEINTERLEAVE(
SDNode *
N);
884 void SplitVecRes_VECTOR_INTERLEAVE(
SDNode *
N);
890 bool SplitVectorOperand(
SDNode *
N,
unsigned OpNo);
926 TableId &WidenedId = WidenedVectors[getTableId(
Op)];
927 SDValue WidenedOp = getSDValue(WidenedId);
942 TargetLowering::TypeWidenVector &&
943 "Unable to widen binary VP op");
944 Mask = GetWidenedVector(Mask);
945 assert(
Mask.getValueType().getVectorElementCount() == EC &&
946 "Unable to widen binary VP op");
951 void WidenVectorResult(
SDNode *
N,
unsigned ResNo);
994 bool WidenVectorOperand(
SDNode *
N,
unsigned OpNo);
1071 if (
Op.getValueType().isVector())
1072 GetSplitVector(
Op,
Lo,
Hi);
1073 else if (
Op.getValueType().isInteger())
1074 GetExpandedInteger(
Op,
Lo,
Hi);
1076 GetExpandedFloat(
Op,
Lo,
Hi);
1084 void SplitRes_MERGE_VALUES(
SDNode *
N,
unsigned ResNo,
1103 if (
Op.getValueType().isInteger())
1104 GetExpandedInteger(
Op,
Lo,
Hi);
1106 GetExpandedFloat(
Op,
Lo,
Hi);
1112 void IntegerToVector(
SDValue Op,
unsigned NumElements,
1116 void ExpandRes_MERGE_VALUES (
SDNode *
N,
unsigned ResNo,
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
#define LLVM_LIBRARY_VISIBILITY
This file defines the DenseMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file describes how to lower LLVM code to machine code.
support::ulittle16_t & Lo
support::ulittle16_t & Hi
Class for arbitrary precision integers.
This is an SDNode representing atomic operations.
This takes an arbitrary SelectionDAG as input and hacks on it until only value types the target machi...
DAGTypeLegalizer(SelectionDAG &dag)
void NoteDeletion(SDNode *Old, SDNode *New)
SelectionDAG & getDAG() const
NodeIdFlags
This pass uses the NodeId on the SDNodes to hold information about the state of the node.
This class represents an Operation in the Expression.
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
This class is used to represent ISD::LOAD nodes.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
This is an abstract virtual class for memory operations.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
const DataLayout & getDataLayout() const
SDValue getValueType(EVT)
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVMContext * getContext() const
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
LegalizeTypeAction getTypeAction(MVT VT) const
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This class is used to represent an VP_GATHER node.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
This class is used to represent an EXPERIMENTAL_VP_STRIDED_LOAD node.
This class is used to represent an EXPERIMENTAL_VP_STRIDED_STORE node.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ TargetConstant
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification,...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit.
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
This class contains a discriminated union of information about pointers in memory operands,...