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/Dialect.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/StandardTypes.h"
@ -21,29 +22,23 @@ class KrnlOpsDialect : public Dialect {
KrnlOpsDialect(MLIRContext* context);
static StringRef getDialectNamespace() { return "krnl"; }
// /// 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;
// }
// }
/// Parse a type registered to this dialect.
Type parseType(DialectAsmParser& parser) const override {
if (succeeded(parser.parseOptionalKeyword("loop")))
return LoopType::get(parser.getBuilder().getContext());
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