10 #include "llvm/ADT/FunctionExtras.h"
11 #include "llvm/ADT/StringExtras.h"
12 #include "llvm/ADT/StringSet.h"
13 #include "llvm/Support/FormatVariadic.h"
14 #include "llvm/TableGen/Error.h"
15 #include "llvm/TableGen/Record.h"
25 llvm::DagInit *args = def->getValueAsDag(
"arguments");
26 for (
unsigned i = 0, e = args->getNumArgs(); i != e; ++i) {
28 {llvm::cast<llvm::StringInit>(args->getArg(i))->getValue(),
29 args->getArgNameStr(i)});
34 return def->getValueAsString(
"returnType");
39 return def->getValueAsString(
"name");
44 return def->isSubClassOf(
"StaticInterfaceMethod");
49 auto value = def->getValueAsString(
"body");
50 return value.empty() ? std::optional<StringRef>() : value;
55 auto value = def->getValueAsString(
"defaultBody");
56 return value.empty() ? std::optional<StringRef>() : value;
61 auto value = def->getValueAsString(
"description");
62 return value.empty() ? std::optional<StringRef>() : value;
76 assert(def->isSubClassOf(
"Interface") &&
77 "must be subclass of TableGen 'Interface' class");
80 auto *listInit = dyn_cast<llvm::ListInit>(def->getValueInit(
"methods"));
81 for (llvm::Init *init : listInit->getValues())
82 methods.emplace_back(cast<llvm::DefInit>(init)->
getDef());
86 dyn_cast<llvm::ListInit>(def->getValueInit(
"baseInterfaces"));
89 llvm::unique_function<void(
Interface)> addBaseInterfaceFn =
92 for (
const auto &baseBaseInterface : baseInterface.getBaseInterfaces())
93 addBaseInterfaceFn(baseBaseInterface);
96 if (basesAdded.contains(baseInterface.getName()))
98 baseInterfaces.push_back(std::make_unique<Interface>(baseInterface));
99 basesAdded.insert(baseInterface.getName());
101 for (llvm::Init *init : basesInit->getValues())
107 return def->getValueAsString(
"cppInterfaceName");
114 if (cppNamespace.empty())
116 return (cppNamespace +
"::" + name).str();
121 return def->getValueAsString(
"cppNamespace");
129 auto value = def->getValueAsString(
"description");
130 return value.empty() ? std::optional<StringRef>() : value;
135 auto value = def->getValueAsString(
"extraClassDeclaration");
136 return value.empty() ? std::optional<StringRef>() : value;
141 auto value = def->getValueAsString(
"extraTraitClassDeclaration");
142 return value.empty() ? std::optional<StringRef>() : value;
147 auto value = def->getValueAsString(
"extraSharedClassDeclaration");
148 return value.empty() ? std::optional<StringRef>() : value;
152 auto value = def->getValueAsString(
"extraClassOf");
153 return value.empty() ? std::optional<StringRef>() : value;
159 if (!isa<OpInterface>(
this))
161 auto value = def->getValueAsString(
"verify");
162 return value.empty() ? std::optional<StringRef>() : value;
166 return def->getValueAsBit(
"verifyWithRegions");
174 return interface->
getDef().isSubClassOf(
"AttrInterface");
182 return interface->
getDef().isSubClassOf(
"OpInterface");
190 return interface->
getDef().isSubClassOf(
"TypeInterface");
InterfaceMethod(const llvm::Record *def)
StringRef getReturnType() const
std::optional< StringRef > getDefaultImplementation() const
ArrayRef< Argument > getArguments() const
std::optional< StringRef > getBody() const
StringRef getName() const
std::optional< StringRef > getDescription() const
Interface(const llvm::Record *def)
std::optional< StringRef > getExtraClassOf() const
std::optional< StringRef > getDescription() const
std::optional< StringRef > getExtraClassDeclaration() const
std::optional< StringRef > getExtraSharedClassDeclaration() const
ArrayRef< InterfaceMethod > getMethods() const
std::optional< StringRef > getExtraTraitClassDeclaration() const
bool verifyWithRegions() const
std::optional< StringRef > getVerify() const
std::string getFullyQualifiedName() const
StringRef getCppNamespace() const
const llvm::Record & getDef() const
StringRef getName() const
Include the generated interface declarations.
static bool classof(const Interface *interface)
static bool classof(const Interface *interface)
static bool classof(const Interface *interface)