21 SS <<
"invalid node: " <<
Msg <<
'\n';
22 N->printrWithDepth(SS, &DAG, 2);
27 unsigned ResIdx,
EVT ExpectedVT) {
28 EVT ActualVT =
N->getValueType(ResIdx);
29 if (ActualVT != ExpectedVT)
32 "result #" +
Twine(ResIdx) +
" has invalid type; expected " +
37 unsigned OpIdx,
EVT ExpectedVT) {
38 EVT ActualVT =
N->getOperand(OpIdx).getValueType();
39 if (ActualVT != ExpectedVT)
42 "operand #" +
Twine(OpIdx) +
" has invalid type; expected " +
56 SDNodeValue(
const SDNode *N,
unsigned Idx,
bool IsRes)
57 : N(N), Idx(Idx), IsRes(IsRes) {}
60 return IsRes ? SDValue(
const_cast<SDNode *
>(N), Idx) : N->getOperand(Idx);
65 friend raw_ostream &
operator<<(raw_ostream &OS,
const SDNodeValue &
Op) {
66 return OS << (
Op.IsRes ?
"result" :
"operand") <<
" #" <<
Op.Idx;
80 unsigned ActualNumResults =
N->getNumValues();
81 unsigned ExpectedNumResults =
Desc.NumResults + HasChain + HasOutGlue;
83 if (ActualNumResults != ExpectedNumResults)
85 "invalid number of results; expected " +
86 Twine(ExpectedNumResults) +
", got " +
87 Twine(ActualNumResults));
91 unsigned ChainResIdx =
Desc.NumResults;
97 unsigned GlueResIdx =
Desc.NumResults + HasChain;
105 bool HasOptionalOperands =
Desc.NumOperands < 0 || IsVariadic;
107 unsigned ActualNumOperands =
N->getNumOperands();
108 unsigned ExpectedMinNumOperands =
109 (
Desc.NumOperands >= 0 ?
Desc.NumOperands : 0) + HasChain + HasInGlue;
112 if (ActualNumOperands < ExpectedMinNumOperands) {
113 StringRef How = HasOptionalOperands ?
"at least " :
"";
115 "invalid number of operands; expected " + How +
116 Twine(ExpectedMinNumOperands) +
", got " +
117 Twine(ActualNumOperands));
122 if (
Desc.NumOperands >= 0 && !IsVariadic) {
124 unsigned ExpectedMaxNumOperands = ExpectedMinNumOperands + HasOptInGlue;
125 if (ActualNumOperands > ExpectedMaxNumOperands) {
126 StringRef How = HasOptInGlue ?
"at most " :
"";
128 "invalid number of operands; expected " + How +
129 Twine(ExpectedMaxNumOperands) +
", got " +
130 Twine(ActualNumOperands));
141 if (HasOptInGlue && ActualNumOperands >= 1 &&
142 N->getOperand(ActualNumOperands - 1).getValueType() == MVT::Glue)
146 if (IsVariadic &&
Desc.NumOperands >= 0) {
147 unsigned VarOpStart = HasChain +
Desc.NumOperands;
148 unsigned VarOpEnd = ActualNumOperands - HasInGlue;
149 for (
unsigned OpIdx = VarOpStart; OpIdx != VarOpEnd; ++OpIdx) {
150 unsigned OpOpcode =
N->getOperand(OpIdx).getOpcode();
153 "variadic operand #" +
Twine(OpIdx) +
154 " must be Register or RegisterMask");
165 auto GetConstraintValue = [&](
unsigned ValIdx) {
166 if (ValIdx <
Desc.NumResults)
167 return SDNodeValue(
N, ValIdx,
true);
168 return SDNodeValue(
N, HasChain + (ValIdx -
Desc.NumResults),
175 for (
auto [Mode, VT] :
ArrayRef(&VTByHwModeTable[
C.VT],
C.NumHwModes))
176 if (Mode == VTHwMode)
186 auto CheckSmallerThan = [&](
const SDNodeValue &SmallVal,
EVT SmallVT,
187 const SDNodeValue &BigVal) {
188 EVT BigVT = BigVal.getValueType();
190 if (SmallVT.isInteger() != BigVT.
isInteger() ||
192 SS << SmallVal <<
" type " << SmallVT
193 <<
" must be the same kind of type as " << BigVal <<
" (" << BigVT
197 if (SmallVT.isVector() != BigVT.
isVector()) {
198 SS << SmallVal <<
" type " << SmallVT <<
" and " << BigVal <<
" ("
199 << BigVT <<
") must both be vectors or both be scalars";
207 if (SmallScalarSize != BigScalarSize) {
208 IsSmaller = SmallScalarSize < BigScalarSize;
210 TypeSize SmallSize = SmallVT.getSizeInBits();
213 SS << SmallVal <<
" type " << SmallVT <<
" and " << BigVal <<
" ("
214 << BigVT <<
") cannot be compared; one is scalable and the "
221 SS << SmallVal <<
" type " << SmallVT <<
" must be smaller than "
222 << BigVal <<
" (" << BigVT <<
")";
228 SDNodeValue Val = GetConstraintValue(
C.ConstrainedValIdx);
229 EVT VT = Val.getValueType();
233 EVT ExpectedVT = GetConstraintVT(
C);
235 bool IsPtr = ExpectedVT == MVT::iPTR;
240 if (VT != ExpectedVT) {
241 SS << Val <<
" must have type " << ExpectedVT;
244 SS <<
", but has type " << VT;
252 AS = MemSD->getAddressSpace();
256 SS << Val <<
" must have pointer type " << PtrVT <<
", but has type "
264 SS << Val <<
" must have integer type, but has type " << VT;
270 SS << Val <<
" must have floating-point type, but has type " << VT;
276 SS << Val <<
" must have vector type, but has type " << VT;
285 SS << Val <<
" must be a VT node";
288 EVT SmallVT = VTNode->getVT();
290 CheckSmallerThan(Val, SmallVT, GetConstraintValue(
C.ConstrainingValIdx));
294 CheckSmallerThan(Val, VT, GetConstraintValue(
C.ConstrainingValIdx));
297 SDNodeValue VecVal = GetConstraintValue(
C.ConstrainingValIdx);
298 EVT VecVT = VecVal.getValueType();
301 SS << VecVal <<
" must have vector type, but has type " << VecVT;
306 <<
" type (element type of " << VecVal <<
"), but has type " << VT;
312 SDNodeValue VecVal = GetConstraintValue(
C.ConstrainingValIdx);
313 EVT VecVT = VecVal.getValueType();
316 SS << Val <<
" must have vector type, but has type " << VT;
320 SS << VecVal <<
" must have vector type, but has type " << VecVT;
324 SS << Val <<
" must have the same element type as " << VecVal <<
" ("
330 SS << Val <<
" is a scalable vector, but " << VecVal
331 <<
" is not; a scalable vector cannot be a sub-vector of a fixed "
339 SS << Val <<
" must have fewer elements than " << VecVal;
345 EVT ExpectedVT = GetConstraintVT(
C);
348 SS << Val <<
" must have vector type";
352 SS << Val <<
" must have " << ExpectedVT <<
" element type, but has "
359 SDNodeValue OtherVal = GetConstraintValue(
C.ConstrainingValIdx);
360 EVT OtherVT = OtherVal.getValueType();
368 SS << Val <<
" and " << OtherVal
369 <<
" must have the same number of elements, but have " << VT
370 <<
" and " << OtherVT;
376 SDNodeValue OtherVal = GetConstraintValue(
C.ConstrainingValIdx);
377 EVT OtherVT = OtherVal.getValueType();
380 SS << Val <<
" must have the same size as " << OtherVal <<
" ("
381 << OtherVT <<
"), but has type " << VT;
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static constexpr Value * getValue(Ty &ValueOrUse)
static void checkOperandType(const SelectionDAG &DAG, const SDNode *N, unsigned OpIdx, EVT ExpectedVT)
static void reportNodeError(const SelectionDAG &DAG, const SDNode *N, const Twine &Msg)
static void checkResultType(const SelectionDAG &DAG, const SDNode *N, unsigned ResIdx, EVT ExpectedVT)
This file describes how to lower LLVM code to machine code.
virtual unsigned getHwMode(enum HwModeType type=HwMode_Default) const
HwMode ID corresponding to the 'type' parameter is retrieved from the HwMode bit set of the current s...
const SDNodeDesc & getDesc(unsigned Opcode) const
Returns the description of a node with the given opcode.
LLVM_ABI void verifyNode(const SelectionDAG &DAG, const SDNode *N) const
ArrayRef< SDTypeConstraint > getConstraints(unsigned Opcode) const
Returns operand constraints for a node with the given opcode.
Represents one node in the SelectionDAG.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
const TargetSubtargetInfo & getSubtarget() const
const TargetLowering & getTargetLoweringInfo() const
const DataLayout & getDataLayout() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Represent a constant reference to a string, i.e.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
A raw_ostream that writes to an std::string.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getValueType(Value *V, bool ReVec, bool LookThroughCmp)
Returns the "element type" of the given value/instruction V.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
LLVM_ABI std::string getEVTString() const
This function returns value type as a string, e.g. "i32".
bool isVector() const
Return true if this is a vector value type.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool isVectorOf(EVT EltVT) const
Return true if this is a vector with matching element type.
bool isInteger() const
Return true if this is an integer or a vector integer type.