class MinVersion<I32EnumAttrCase min> : MinVersionBase<
"QueryMinVersionInterface", SPV_VersionAttr, min> {
+ let cppNamespace = "::mlir::spirv";
let interfaceDescription = [{
Querying interface for minimal required SPIR-V version.
class MaxVersion<I32EnumAttrCase max> : MaxVersionBase<
"QueryMaxVersionInterface", SPV_VersionAttr, max> {
+ let cppNamespace = "::mlir::spirv";
let interfaceDescription = [{
Querying interface for maximal supported SPIR-V version.
}
class Extension<list<StrEnumAttrCase> extensions> : Availability {
+ let cppNamespace = "::mlir::spirv";
let interfaceName = "QueryExtensionInterface";
let interfaceDescription = [{
Querying interface for required SPIR-V extensions.
}
class Capability<list<I32EnumAttrCase> capabilities> : Availability {
+ let cppNamespace = "::mlir::spirv";
let interfaceName = "QueryCapabilityInterface";
let interfaceDescription = [{
Querying interface for required SPIR-V capabilities.
//===----------------------------------------------------------------------===//
#include "mlir/TableGen/Attribute.h"
+#include "mlir/TableGen/CodeGenHelpers.h"
#include "mlir/TableGen/Format.h"
#include "mlir/TableGen/GenInfo.h"
#include "mlir/TableGen/Operator.h"
using mlir::tblgen::EnumAttrCase;
using mlir::tblgen::NamedAttribute;
using mlir::tblgen::NamedTypeConstraint;
+using mlir::tblgen::NamespaceEmitter;
using mlir::tblgen::Operator;
//===----------------------------------------------------------------------===//
// instance.
StringRef getClass() const;
+ // Returns the generated C++ interface's class namespace.
+ StringRef getInterfaceClassNamespace() const;
+
// Returns the generated C++ interface's class name.
StringRef getInterfaceClassName() const;
// Returns the concrete availability instance carried in this case.
StringRef getMergeInstance() const;
+ // Returns the underlying LLVM TableGen Record.
+ const llvm::Record *getDef() const { return def; }
+
private:
// The TableGen definition of this availability.
const llvm::Record *def;
return parentClass.front()->getName();
}
+StringRef Availability::getInterfaceClassNamespace() const {
+ return def->getValueAsString("cppNamespace");
+}
+
StringRef Availability::getInterfaceClassName() const {
return def->getValueAsString("interfaceName");
}
static void emitInterfaceDef(const Availability &availability,
raw_ostream &os) {
+
+ os << availability.getQueryFnRetType() << " ";
+
+ StringRef cppNamespace = availability.getInterfaceClassNamespace();
+ cppNamespace.consume_front("::");
+ if (!cppNamespace.empty())
+ os << cppNamespace << "::";
+
StringRef methodName = availability.getQueryFnName();
- os << availability.getQueryFnRetType() << " "
- << availability.getInterfaceClassName() << "::" << methodName << "() {\n"
+ os << availability.getInterfaceClassName() << "::" << methodName << "() {\n"
<< " return getImpl()->" << methodName << "(getImpl(), getOperation());\n"
<< "}\n";
}
std::string interfaceTraitsName =
std::string(formatv("{0}Traits", interfaceName));
+ StringRef cppNamespace = availability.getInterfaceClassNamespace();
+ NamespaceEmitter nsEmitter(os, cppNamespace);
+
// Emit the traits struct containing the concept and model declarations.
os << "namespace detail {\n"
<< "struct " << interfaceTraitsName << " {\n";
emitConceptDecl(availability, os);
os << '\n';
emitModelDecl(availability, os);
- os << "};\n} // end namespace detail\n\n";
+ os << "};\n} // namespace detail\n\n";
// Emit the main interface class declaration.
os << "/*\n" << availability.getInterfaceDescription().trim() << "\n*/\n";