Update type parser (#376)

This commit is contained in:
Tian Jin 2019-11-19 19:45:03 -05:00 committed by Tian Jin
parent 0c36057404
commit 6c7ff180f9
1 changed files with 18 additions and 23 deletions

View File

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