16 #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H 17 #define LLVM_LIB_CODEGEN_SELECTIONDAG_LEGALIZETYPES_H 60 TargetLowering::ValueTypeActionImpl ValueTypeActions;
64 return TLI.getTypeAction(*DAG.
getContext(), VT);
68 bool isTypeLegal(
EVT VT)
const {
73 bool isSimpleLegalType(
EVT VT)
const {
74 return VT.
isSimple() && TLI.isTypeLegal(VT);
81 bool isLegalInHWReg(
EVT VT)
const {
83 return VT == NVT && isSimpleLegalType(VT);
86 EVT getSetCCResultType(
EVT VT)
const {
91 bool IgnoreNodeResults(
SDNode *
N)
const {
101 TableId NextValueId = 1;
146 TableId getTableId(
SDValue V) {
149 auto I = ValueToIdMap.
find(V);
150 if (I != ValueToIdMap.
end()) {
153 assert(I->second &&
"All Ids should be nonzero");
157 ValueToIdMap.
insert(std::make_pair(V, NextValueId));
158 IdToValueMap.
insert(std::make_pair(NextValueId, V));
160 assert(NextValueId != 0 &&
161 "Ran out of Ids. Increase id type size or add compactification");
162 return NextValueId - 1;
167 assert(Id &&
"TableId should be non-zero");
168 return IdToValueMap[
Id];
173 : TLI(dag.getTargetLoweringInfo()), DAG(dag),
174 ValueTypeActions(TLI.getValueTypeActions()) {
176 "Too many value types for ValueTypeActions to hold!");
185 for (
unsigned i = 0, e = Old->
getNumValues(); i != e; ++i) {
186 TableId NewId = getTableId(
SDValue(New, i));
187 TableId OldId = getTableId(
SDValue(Old, i));
190 ReplacedValues[OldId] = NewId;
194 IdToValueMap.
erase(OldId);
195 PromotedIntegers.
erase(OldId);
196 ExpandedIntegers.
erase(OldId);
197 SoftenedFloats.
erase(OldId);
198 PromotedFloats.
erase(OldId);
199 ExpandedFloats.
erase(OldId);
200 ScalarizedVectors.
erase(OldId);
201 SplitVectors.
erase(OldId);
202 WidenedVectors.
erase(OldId);
210 void AnalyzeNewValue(
SDValue &Val);
211 void PerformExpensiveChecks();
212 void RemapId(TableId &Id);
219 bool CustomLowerNode(
SDNode *N,
EVT VT,
bool LegalizeResult);
220 bool CustomWidenLowerNode(
SDNode *N,
EVT VT);
231 SDNode *Node,
bool isSigned);
232 std::pair<SDValue, SDValue> ExpandAtomic(
SDNode *Node);
241 void AddToWorklist(
SDNode *N) {
260 TableId &PromotedId = PromotedIntegers[getTableId(Op)];
261 SDValue PromotedOp = getSDValue(PromotedId);
271 Op = GetPromotedInteger(Op);
280 Op = GetPromotedInteger(Op);
285 void PromoteIntegerResult(
SDNode *N,
unsigned ResNo);
286 SDValue PromoteIntRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo);
329 SDValue PromoteIntRes_ADDSUBCARRY(
SDNode *N,
unsigned ResNo);
335 bool PromoteIntegerOperand(
SDNode *N,
unsigned OpNo);
343 SDValue PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *N,
unsigned OpNo);
380 void ExpandIntegerResult(
SDNode *N,
unsigned ResNo);
420 void ExpandShiftByConstant(
SDNode *N,
const APInt &Amt,
426 bool ExpandIntegerOperand(
SDNode *N,
unsigned OpNo);
455 TableId Id = getTableId(Op);
456 auto Iter = SoftenedFloats.
find(Id);
457 if (Iter == SoftenedFloats.
end()) {
459 "Operand wasn't converted to integer?");
462 SDValue SoftenedOp = getSDValue(Iter->second);
463 assert(SoftenedOp.
getNode() &&
"Unconverted op in SoftenedFloats?");
469 bool SoftenFloatResult(
SDNode *N,
unsigned ResNo);
470 SDValue SoftenFloatRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo);
473 SDValue SoftenFloatRes_ConstantFP(
SDNode *N,
unsigned ResNo);
474 SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(
SDNode *N,
unsigned ResNo);
516 bool CanSkipSoftenFloatOperand(
SDNode *N,
unsigned OpNo);
519 bool SoftenFloatOperand(
SDNode *N,
unsigned OpNo);
548 void ExpandFloatResult(
SDNode *N,
unsigned ResNo);
582 bool ExpandFloatOperand(
SDNode *N,
unsigned OpNo);
600 TableId &PromotedId = PromotedFloats[getTableId(Op)];
601 SDValue PromotedOp = getSDValue(PromotedId);
607 void PromoteFloatResult(
SDNode *N,
unsigned ResNo);
623 bool PromoteFloatOperand(
SDNode *N,
unsigned OpNo);
640 TableId &ScalarizedId = ScalarizedVectors[getTableId(Op)];
641 SDValue ScalarizedOp = getSDValue(ScalarizedId);
642 assert(ScalarizedOp.
getNode() &&
"Operand wasn't scalarized?");
648 void ScalarizeVectorResult(
SDNode *N,
unsigned ResNo);
649 SDValue ScalarizeVecRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo);
672 bool ScalarizeVectorOperand(
SDNode *N,
unsigned OpNo);
697 void SplitVectorResult(
SDNode *N,
unsigned ResNo);
723 bool SplitVectorOperand(
SDNode *N,
unsigned OpNo);
753 TableId &WidenedId = WidenedVectors[getTableId(Op)];
754 SDValue WidenedOp = getSDValue(WidenedId);
761 void WidenVectorResult(
SDNode *N,
unsigned ResNo);
791 bool WidenVectorOperand(
SDNode *N,
unsigned OpNo);
860 GetSplitVector(Op, Lo, Hi);
862 GetExpandedInteger(Op, Lo, Hi);
864 GetExpandedFloat(Op, Lo, Hi);
872 void SplitRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo,
889 GetExpandedInteger(Op, Lo, Hi);
891 GetExpandedFloat(Op, Lo, Hi);
897 void IntegerToVector(
SDValue Op,
unsigned NumElements,
901 void ExpandRes_MERGE_VALUES (
SDNode *N,
unsigned ResNo,
void push_back(const T &Elt)
EVT getValueType() const
Return the ValueType of the referenced return value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
Compute iterated dominance frontiers using a linear time algorithm.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
bool isInteger() const
Return true if this is an integer or a vector integer type.
This takes an arbitrary SelectionDAG as input and hacks on it until only value types the target machi...
void setNodeId(int Id)
Set unique node id.
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.
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
const DataLayout & getDataLayout() const
This is an SDNode representing atomic operations.
SelectionDAG & getDAG() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This class is used to represent an MSTORE node.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification, or lowering of the constant.
This class is used to represent ISD::STORE nodes.
iterator find(const_arg_type_t< KeyT > Val)
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
bool erase(const KeyT &Val)
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
NodeIdFlags
This pass uses the NodeId on the SDNodes to hold information about the state of the node...
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...
void NoteDeletion(SDNode *Old, SDNode *New)
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...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Class for arbitrary precision integers.
bool isVector() const
Return true if this is a vector value type.
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
static bool isSigned(Value *V)
Can the given value generate sign bits.
This class is used to represent an MSCATTER node.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
This class is used to represent an MLOAD node.
This class is used to represent an MGATHER node.
SDValue getValueType(EVT)
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
LLVMContext * getContext() const
This file describes how to lower LLVM code to machine code.
DAGTypeLegalizer(SelectionDAG &dag)
This class is used to represent ISD::LOAD nodes.