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);
420 void ExpandIntegerResult(
SDNode *
N,
unsigned ResNo);
481 bool ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo);
510 TableId
Id = getTableId(
Op);
511 auto Iter = SoftenedFloats.
find(Id);
512 if (Iter == SoftenedFloats.
end()) {
513 assert(isSimpleLegalType(
Op.getValueType()) &&
514 "Operand wasn't converted to integer?");
517 SDValue SoftenedOp = getSDValue(Iter->second);
518 assert(SoftenedOp.
getNode() &&
"Unconverted op in SoftenedFloats?");
524 void SoftenFloatResult(
SDNode *
N,
unsigned ResNo);
533 SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(
SDNode *
N,
unsigned ResNo);
580 bool SoftenFloatOperand(
SDNode *
N,
unsigned OpNo);
610 void ExpandFloatResult(
SDNode *
N,
unsigned ResNo);
653 bool ExpandFloatOperand(
SDNode *
N,
unsigned OpNo);
668 SDValue &Chain,
bool IsSignaling =
false);
675 TableId &PromotedId = PromotedFloats[getTableId(
Op)];
676 SDValue PromotedOp = getSDValue(PromotedId);
682 void PromoteFloatResult(
SDNode *
N,
unsigned ResNo);
703 bool PromoteFloatOperand(
SDNode *
N,
unsigned OpNo);
707 SDValue PromoteFloatOp_STRICT_FP_EXTEND(
SDNode *
N,
unsigned OpNo);
719 TableId &PromotedId = SoftPromotedHalfs[getTableId(
Op)];
720 SDValue PromotedOp = getSDValue(PromotedId);
726 void SoftPromoteHalfResult(
SDNode *
N,
unsigned ResNo);
745 bool SoftPromoteHalfOperand(
SDNode *
N,
unsigned OpNo);
765 TableId &ScalarizedId = ScalarizedVectors[getTableId(
Op)];
766 SDValue ScalarizedOp = getSDValue(ScalarizedId);
767 assert(ScalarizedOp.
getNode() &&
"Operand wasn't scalarized?");
773 void ScalarizeVectorResult(
SDNode *
N,
unsigned ResNo);
804 bool ScalarizeVectorOperand(
SDNode *
N,
unsigned OpNo);
835 std::pair<SDValue, SDValue> SplitMask(
SDValue Mask);
838 std::pair<SDValue, SDValue> SplitMask(
SDValue Mask,
const SDLoc &
DL);
846 void SplitVectorResult(
SDNode *
N,
unsigned ResNo);
855 void SplitVecRes_OverflowOp(
SDNode *
N,
unsigned ResNo,
874 bool SplitSETCC =
false);
882 void SplitVecRes_VECTOR_DEINTERLEAVE(
SDNode *
N);
883 void SplitVecRes_VECTOR_INTERLEAVE(
SDNode *
N);
889 bool SplitVectorOperand(
SDNode *
N,
unsigned OpNo);
925 TableId &WidenedId = WidenedVectors[getTableId(
Op)];
926 SDValue WidenedOp = getSDValue(WidenedId);
941 TargetLowering::TypeWidenVector &&
942 "Unable to widen binary VP op");
943 Mask = GetWidenedVector(Mask);
944 assert(
Mask.getValueType().getVectorElementCount() == EC &&
945 "Unable to widen binary VP op");
950 void WidenVectorResult(
SDNode *
N,
unsigned ResNo);
993 bool WidenVectorOperand(
SDNode *
N,
unsigned OpNo);
1070 if (
Op.getValueType().isVector())
1071 GetSplitVector(
Op,
Lo,
Hi);
1072 else if (
Op.getValueType().isInteger())
1073 GetExpandedInteger(
Op,
Lo,
Hi);
1075 GetExpandedFloat(
Op,
Lo,
Hi);
1083 void SplitRes_MERGE_VALUES(
SDNode *
N,
unsigned ResNo,
1102 if (
Op.getValueType().isInteger())
1103 GetExpandedInteger(
Op,
Lo,
Hi);
1105 GetExpandedFloat(
Op,
Lo,
Hi);
1111 void IntegerToVector(
SDValue Op,
unsigned NumElements,
1115 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,...