summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2017-07-11 08:57:29 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2017-07-11 08:57:29 +0000
commitfe12c0fa56f380f0a6acfe53ff84933e8902e753 (patch)
treea7b325a11818d5ff3ab60a48f27b9fea4708670e /llvm/utils/TableGen
parentb57bba831617a2e0d87bff3160b7118f238470ce (diff)
downloadbcm5719-llvm-fe12c0fa56f380f0a6acfe53ff84933e8902e753.tar.gz
bcm5719-llvm-fe12c0fa56f380f0a6acfe53ff84933e8902e753.zip
[globalisel][tablegen] Correct matching of intrinsic ID's.
TreePatternNode considers them to be plain integers but MachineInstr considers them to be a distinct kind of operand. The tweak to AArch64InstrInfo.td to produce a simple test case is a NFC for everything except GlobalISelEmitter (confirmed by diffing the tablegenerated files). GlobalISelEmitter is currently unable to infer the type of operands in the Dst pattern from the operands in the Src pattern. llvm-svn: 307634
Diffstat (limited to 'llvm/utils/TableGen')
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index ef65317c739..1d21042e95a 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -338,6 +338,7 @@ public:
enum PredicateKind {
OPM_ComplexPattern,
OPM_Instruction,
+ OPM_IntrinsicID,
OPM_Int,
OPM_LiteralInt,
OPM_LLT,
@@ -519,6 +520,26 @@ public:
}
};
+/// Generates code to check that an operand is an intrinsic ID.
+class IntrinsicIDOperandMatcher : public OperandPredicateMatcher {
+protected:
+ const CodeGenIntrinsic *II;
+
+public:
+ IntrinsicIDOperandMatcher(const CodeGenIntrinsic *II)
+ : OperandPredicateMatcher(OPM_IntrinsicID), II(II) {}
+
+ static bool classof(const OperandPredicateMatcher *P) {
+ return P->getKind() == OPM_IntrinsicID;
+ }
+
+ void emitPredicateOpcodes(raw_ostream &OS, RuleMatcher &Rule,
+ unsigned InsnVarID, unsigned OpIdx) const override {
+ OS << " GIM_CheckIntrinsicID, /*MI*/" << InsnVarID << ", /*Op*/"
+ << OpIdx << ", Intrinsic::" << II->EnumName << ",\n";
+ }
+};
+
/// Generates code to check that a set of predicates match for a particular
/// operand.
class OperandMatcher : public PredicateListMatcher<OperandPredicateMatcher> {
@@ -1513,14 +1534,10 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
// For G_INTRINSIC, the operand immediately following the defs is an
// intrinsic ID.
if (SrcGIOrNull->TheDef->getName() == "G_INTRINSIC" && i == 0) {
- if (!SrcChild->isLeaf())
- return failedImport("Expected IntInit containing intrinsic ID");
-
- if (IntInit *SrcChildIntInit =
- dyn_cast<IntInit>(SrcChild->getLeafValue())) {
+ if (const CodeGenIntrinsic *II = Src->getIntrinsicInfo(CGP)) {
OperandMatcher &OM =
InsnMatcher.addOperand(OpIdx++, SrcChild->getName(), TempOpIdx);
- OM.addPredicate<LiteralIntOperandMatcher>(SrcChildIntInit->getValue());
+ OM.addPredicate<IntrinsicIDOperandMatcher>(II);
continue;
}
OpenPOWER on IntegriCloud