--- /dev/null
+// RUN: mlir-tblgen -gen-bytecode -bytecode-dialect=Test -I %S/../../include %s 2>&1 | FileCheck %s
+
+include "mlir/IR/BuiltinDialectBytecode.td"
+
+def TestDialectTypes : DialectTypes<"Test"> {
+// CHECK: static Type readType
+ let elems = [
+// CHECK: case 0:
+// CHECK-NEXT: return readIntegerType(context, reader);
+ IntegerType,
+// No case 1 generated as only reserved.
+ ReservedOrDead,
+// CHECK-NEXT: case 2:
+// CHECK-NEXT: return readIndexType(context, reader);
+ IndexType,
+// CHECK-NEXT: case 3:
+// CHECK-NEXT: return readBFloat16Type(context, reader);
+ BFloat16Type,
+// No case 4 generated as only reserved.
+ ReservedOrDead,
+// CHECK-NEXT: case 5:
+// CHECK-NEXT: return readFloat16Type(context, reader);
+ Float16Type
+ ];
+}
+
{
auto switchScope = os.scope("{\n", "}\n");
for (const auto &it : llvm::enumerate(vec)) {
+ if (it.value()->getName() == "ReservedOrDead")
+ continue;
+
os << formatv("case {1}:\n return read{0}(context, reader);\n",
it.value()->getName(), it.index());
}
}
void Generator::emitParse(StringRef kind, Record &x) {
+ if (x.getNameInitAsString() == "ReservedOrDead")
+ return;
+
char const *head =
R"(static {0} read{1}(MLIRContext* context, DialectBytecodeReader &reader) )";
mlir::raw_indented_ostream os(output);
void Generator::emitPrint(StringRef kind, StringRef type,
ArrayRef<std::pair<int64_t, Record *>> vec) {
+ if (type == "ReservedOrDead")
+ return;
+
char const *head =
R"(static void write({0} {1}, DialectBytecodeWriter &writer) )";
mlir::raw_indented_ostream os(output);
<< ")";
auto switchScope = os.scope("", "");
for (StringRef type : vec) {
+ if (type == "ReservedOrDead")
+ continue;
+
os << "\n.Case([&](" << type << " t)";
auto caseScope = os.scope(" {\n", "})");
os << "return write(t, writer), success();\n";