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);
291 Op = GetPromotedInteger(Op);
292 if (TLI.isSExtCheaperThanZExt(OldVT, Op.
getValueType()))
299 void PromoteIntegerResult(
SDNode *N,
unsigned ResNo);
300 SDValue PromoteIntRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo);
343 SDValue PromoteIntRes_ADDSUBCARRY(
SDNode *N,
unsigned ResNo);
352 bool PromoteIntegerOperand(
SDNode *N,
unsigned OpNo);
360 SDValue PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *N,
unsigned OpNo);
400 void ExpandIntegerResult(
SDNode *N,
unsigned ResNo);
442 void ExpandShiftByConstant(
SDNode *N,
const APInt &Amt,
448 bool ExpandIntegerOperand(
SDNode *N,
unsigned OpNo);
477 TableId Id = getTableId(Op);
478 auto Iter = SoftenedFloats.
find(Id);
479 if (Iter == SoftenedFloats.
end()) {
481 "Operand wasn't converted to integer?");
484 SDValue SoftenedOp = getSDValue(Iter->second);
485 assert(SoftenedOp.
getNode() &&
"Unconverted op in SoftenedFloats?");
491 bool SoftenFloatResult(
SDNode *N,
unsigned ResNo);
492 SDValue SoftenFloatRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo);
495 SDValue SoftenFloatRes_ConstantFP(
SDNode *N,
unsigned ResNo);
496 SDValue SoftenFloatRes_EXTRACT_VECTOR_ELT(
SDNode *N,
unsigned ResNo);
538 bool CanSkipSoftenFloatOperand(
SDNode *N,
unsigned OpNo);
541 bool SoftenFloatOperand(
SDNode *N,
unsigned OpNo);
570 void ExpandFloatResult(
SDNode *N,
unsigned ResNo);
604 bool ExpandFloatOperand(
SDNode *N,
unsigned OpNo);
622 TableId &PromotedId = PromotedFloats[getTableId(Op)];
623 SDValue PromotedOp = getSDValue(PromotedId);
629 void PromoteFloatResult(
SDNode *N,
unsigned ResNo);
645 bool PromoteFloatOperand(
SDNode *N,
unsigned OpNo);
662 TableId &ScalarizedId = ScalarizedVectors[getTableId(Op)];
663 SDValue ScalarizedOp = getSDValue(ScalarizedId);
664 assert(ScalarizedOp.
getNode() &&
"Operand wasn't scalarized?");
670 void ScalarizeVectorResult(
SDNode *N,
unsigned ResNo);
671 SDValue ScalarizeVecRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo);
697 bool ScalarizeVectorOperand(
SDNode *N,
unsigned OpNo);
722 void SplitVectorResult(
SDNode *N,
unsigned ResNo);
750 bool SplitVectorOperand(
SDNode *N,
unsigned OpNo);
780 TableId &WidenedId = WidenedVectors[getTableId(Op)];
781 SDValue WidenedOp = getSDValue(WidenedId);
788 void WidenVectorResult(
SDNode *N,
unsigned ResNo);
819 bool WidenVectorOperand(
SDNode *N,
unsigned OpNo);
886 GetSplitVector(Op, Lo, Hi);
888 GetExpandedInteger(Op, Lo, Hi);
890 GetExpandedFloat(Op, Lo, Hi);
898 void SplitRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo,
915 GetExpandedInteger(Op, Lo, Hi);
917 GetExpandedFloat(Op, Lo, Hi);
923 void IntegerToVector(
SDValue Op,
unsigned NumElements,
927 void ExpandRes_MERGE_VALUES (
SDNode *N,
unsigned ResNo,
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.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
void push_back(const T &Elt)
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)
BlockVerifier::State From
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 ...
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
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.