diff --git a/src/compiler/dialect/krnl/krnl_ops.hpp b/src/compiler/dialect/krnl/krnl_ops.hpp index c9dda35..b985066 100644 --- a/src/compiler/dialect/krnl/krnl_ops.hpp +++ b/src/compiler/dialect/krnl/krnl_ops.hpp @@ -10,6 +10,7 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/Dialect.h" +#include "mlir/IR/DialectImplementation.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/StandardTypes.h" @@ -20,30 +21,24 @@ class KrnlOpsDialect : public Dialect { public: KrnlOpsDialect(MLIRContext* context); static StringRef getDialectNamespace() { return "krnl"; } + + /// Parse a type registered to this dialect. + Type parseType(DialectAsmParser& parser) const override { + if (succeeded(parser.parseOptionalKeyword("loop"))) + return LoopType::get(parser.getBuilder().getContext()); -// /// Parse a type registered to this dialect. Overriding this method is -// /// required for dialects that have custom types. -// /// Technically this is only needed to be able to round-trip to textual IR. -// mlir::Type parseType( -// llvm::StringRef tyData, mlir::Location loc) const override { -// MLIRContext* context = getContext(); -// -// if (tyData.consume_front("loop")) -// return LoopType::get(context); -// else -// return (emitError(loc, "Unexpected type: " + tyData), Type()); -// } -// -// /// Print a type registered to this dialect. Overriding this method is -// /// only required for dialects that have custom types. -// /// Technically this is only needed to be able to round-trip to textual IR. -// void printType(mlir::Type type, llvm::raw_ostream& os) const override { -// switch (type.getKind()) { -// case KrnlTypes::Loop: -// os << "loop"; -// return; -// } -// } + parser.emitError(parser.getCurrentLocation(), "Unknown type"); + } + + /// Print a type registered to this dialect. + void printType(Type type, DialectAsmPrinter& os) const override { + switch (type.getKind()) { + case KrnlTypes::Loop: + os << "loop"; + return; + } + } +>>>>>>> 011cc1b... Update type parser (#376) }; #define GET_OP_CLASSES