summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/CodeGenIntrinsics.h7
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.cpp7
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp23
3 files changed, 30 insertions, 7 deletions
diff --git a/llvm/utils/TableGen/CodeGenIntrinsics.h b/llvm/utils/TableGen/CodeGenIntrinsics.h
index 0e70be2c0aa..83e780671b4 100644
--- a/llvm/utils/TableGen/CodeGenIntrinsics.h
+++ b/llvm/utils/TableGen/CodeGenIntrinsics.h
@@ -155,6 +155,13 @@ struct CodeGenIntrinsic {
return Properties & (1 << Prop);
}
+ /// Returns true if the parameter at \p ParamIdx is a pointer type. Returns
+ /// false if the parameter is not a pointer, or \p ParamIdx is greater than
+ /// the size of \p IS.ParamVTs.
+ ///
+ /// Note that this requires that \p IS.ParamVTs is available.
+ bool isParamAPointer(unsigned ParamIdx) const;
+
CodeGenIntrinsic(Record *R);
};
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index b6136346785..47e6934ab36 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -763,3 +763,10 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
// Sort the argument attributes for later benefit.
llvm::sort(ArgumentAttributes);
}
+
+bool CodeGenIntrinsic::isParamAPointer(unsigned ParamIdx) const {
+ if (ParamIdx >= IS.ParamVTs.size())
+ return false;
+ MVT ParamType = MVT(IS.ParamVTs[ParamIdx]);
+ return ParamType == MVT::iPTR || ParamType == MVT::iPTRAny;
+}
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index aba2b9c3a62..dc4f799a285 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -3482,6 +3482,13 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
}
// Match the used operands (i.e. the children of the operator).
+ bool IsIntrinsic =
+ SrcGIOrNull->TheDef->getName() == "G_INTRINSIC" ||
+ SrcGIOrNull->TheDef->getName() == "G_INTRINSIC_W_SIDE_EFFECTS";
+ const CodeGenIntrinsic *II = Src->getIntrinsicInfo(CGP);
+ if (IsIntrinsic && !II)
+ return failedImport("Expected IntInit containing intrinsic ID)");
+
for (unsigned i = 0, e = Src->getNumChildren(); i != e; ++i) {
TreePatternNode *SrcChild = Src->getChild(i);
@@ -3490,19 +3497,21 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
// Coerce integers to pointers to address space 0 if the context indicates a pointer.
bool OperandIsAPointer = SrcGIOrNull->isOperandAPointer(i);
- // For G_INTRINSIC/G_INTRINSIC_W_SIDE_EFFECTS, the operand immediately
- // following the defs is an intrinsic ID.
- if ((SrcGIOrNull->TheDef->getName() == "G_INTRINSIC" ||
- SrcGIOrNull->TheDef->getName() == "G_INTRINSIC_W_SIDE_EFFECTS") &&
- i == 0) {
- if (const CodeGenIntrinsic *II = Src->getIntrinsicInfo(CGP)) {
+ if (IsIntrinsic) {
+ // For G_INTRINSIC/G_INTRINSIC_W_SIDE_EFFECTS, the operand immediately
+ // following the defs is an intrinsic ID.
+ if (i == 0) {
OperandMatcher &OM =
InsnMatcher.addOperand(OpIdx++, SrcChild->getName(), TempOpIdx);
OM.addPredicate<IntrinsicIDOperandMatcher>(II);
continue;
}
- return failedImport("Expected IntInit containing instrinsic ID)");
+ // We have to check intrinsics for llvm_anyptr_ty parameters.
+ //
+ // Note that we have to look at the i-1th parameter, because we don't
+ // have the intrinsic ID in the intrinsic's parameter list.
+ OperandIsAPointer |= II->isParamAPointer(i - 1);
}
if (auto Error =
OpenPOWER on IntegriCloud