summaryrefslogtreecommitdiffstats
path: root/mlir/lib/TableGen
diff options
context:
space:
mode:
authorJacques Pienaar <jpienaar@google.com>2019-10-07 08:40:29 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-10-07 08:41:13 -0700
commit27e8efedf868303961b8b081151c5dfe42acb9a5 (patch)
tree7f679fbfd285448f34b05541e306963be18650ca /mlir/lib/TableGen
parentc07a604f87216a21e815802ad0b186af34924f6b (diff)
downloadbcm5719-llvm-27e8efedf868303961b8b081151c5dfe42acb9a5.tar.gz
bcm5719-llvm-27e8efedf868303961b8b081151c5dfe42acb9a5.zip
Add DialectType and generate docs for dialect types
Add new `typeDescription` (description was already used by base constraint class) field to type to allow writing longer descriptions about a type being defined. This allows for providing additional information/rationale for a defined type. This currently uses `description` as the heading/name for the type in the generated documentation. PiperOrigin-RevId: 273299332
Diffstat (limited to 'mlir/lib/TableGen')
-rw-r--r--mlir/lib/TableGen/Dialect.cpp10
-rw-r--r--mlir/lib/TableGen/Type.cpp17
2 files changed, 19 insertions, 8 deletions
diff --git a/mlir/lib/TableGen/Dialect.cpp b/mlir/lib/TableGen/Dialect.cpp
index af567a63869..ace4ce3d0f6 100644
--- a/mlir/lib/TableGen/Dialect.cpp
+++ b/mlir/lib/TableGen/Dialect.cpp
@@ -26,11 +26,11 @@ namespace mlir {
namespace tblgen {
StringRef tblgen::Dialect::getName() const {
- return def.getValueAsString("name");
+ return def->getValueAsString("name");
}
StringRef tblgen::Dialect::getCppNamespace() const {
- return def.getValueAsString("cppNamespace");
+ return def->getValueAsString("cppNamespace");
}
static StringRef getAsStringOrEmpty(const llvm::Record &record,
@@ -44,15 +44,15 @@ static StringRef getAsStringOrEmpty(const llvm::Record &record,
}
StringRef tblgen::Dialect::getSummary() const {
- return getAsStringOrEmpty(def, "summary");
+ return getAsStringOrEmpty(*def, "summary");
}
StringRef tblgen::Dialect::getDescription() const {
- return getAsStringOrEmpty(def, "description");
+ return getAsStringOrEmpty(*def, "description");
}
bool Dialect::operator==(const Dialect &other) const {
- return &def == &other.def;
+ return def == other.def;
}
bool Dialect::operator<(const Dialect &other) const {
diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp
index 340fb4b89f8..a558be4c89d 100644
--- a/mlir/lib/TableGen/Type.cpp
+++ b/mlir/lib/TableGen/Type.cpp
@@ -23,16 +23,27 @@
#include "llvm/TableGen/Record.h"
using namespace mlir;
+using namespace mlir::tblgen;
-tblgen::TypeConstraint::TypeConstraint(const llvm::Record *record)
+TypeConstraint::TypeConstraint(const llvm::Record *record)
: Constraint(Constraint::CK_Type, record) {
assert(def->isSubClassOf("TypeConstraint") &&
"must be subclass of TableGen 'TypeConstraint' class");
}
-tblgen::TypeConstraint::TypeConstraint(const llvm::DefInit *init)
+TypeConstraint::TypeConstraint(const llvm::DefInit *init)
: TypeConstraint(init->getDef()) {}
-bool tblgen::TypeConstraint::isVariadic() const {
+bool TypeConstraint::isVariadic() const {
return def->isSubClassOf("Variadic");
}
+
+Type::Type(const llvm::Record *record) : TypeConstraint(record) {}
+
+StringRef Type::getTypeDescription() const {
+ return def->getValueAsString("typeDescription");
+}
+
+Dialect Type::getDialect() const {
+ return Dialect(def->getValueAsDef("dialect"));
+}
OpenPOWER on IntegriCloud