summaryrefslogtreecommitdiffstats
path: root/mlir/lib/TableGen
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-06-03 08:03:20 -0700
committerMehdi Amini <joker.eph@gmail.com>2019-06-03 19:26:12 -0700
commit252de8eca01a54ccac3f9b3aa6b7e104315f6f86 (patch)
tree2e3b226f421a3089ce0f2b26f9dfa8d51f10ecd5 /mlir/lib/TableGen
parent3ea85750585c2779cd97358ad24fd53e11b91da6 (diff)
downloadbcm5719-llvm-252de8eca01a54ccac3f9b3aa6b7e104315f6f86.tar.gz
bcm5719-llvm-252de8eca01a54ccac3f9b3aa6b7e104315f6f86.zip
Introduce OpOperandAdaptors and emit them from ODS
When manipulating generic operations, such as in dialect conversion / rewriting, it is often necessary to view a list of Values as operands to an operation without creating the operation itself. The absence of such view makes dialect conversion patterns, among others, to use magic numbers to obtain specific operands from a list of rewritten values when converting an operation. Introduce XOpOperandAdaptor classes that wrap an ArrayRef<Value *> and provide accessor functions identical to those available in XOp. This makes it possible for conversions to use these adaptors to address the operands with names rather than rely on their position in the list. The adaptors are generated from ODS together with the actual operation definitions. This is another step towards making dialect conversion patterns specific for a given operation. Illustrate the approach on conversion patterns in the standard to LLVM dialect conversion. PiperOrigin-RevId: 251232899
Diffstat (limited to 'mlir/lib/TableGen')
-rw-r--r--mlir/lib/TableGen/Operator.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp
index cd3537dfdbf..87494c2246e 100644
--- a/mlir/lib/TableGen/Operator.cpp
+++ b/mlir/lib/TableGen/Operator.cpp
@@ -87,6 +87,8 @@ StringRef tblgen::Operator::getExtraClassDeclaration() const {
return def.getValueAsString(attr);
}
+const llvm::Record &tblgen::Operator::getDef() const { return def; }
+
tblgen::TypeConstraint
tblgen::Operator::getResultTypeConstraint(int index) const {
DagInit *results = def.getValueAsDag("results");
OpenPOWER on IntegriCloud