onnx-mlir/src/Dialect/Krnl/KrnlOps.hpp

50 lines
1.3 KiB
C++
Raw Normal View History

//===--------------------- KrnlOps.hpp - Krnl Operations ------------------===//
//
// Copyright 2019-2020 The IBM Research Authors.
//
// =============================================================================
//
// This file contains declarations of krnl operations.
//
//===----------------------------------------------------------------------===//
#pragma once
#include "mlir/IR/Builders.h"
#include "mlir/IR/Dialect.h"
2019-11-20 08:45:03 +08:00
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/Function.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/StandardTypes.h"
#include "KrnlHelper.hpp"
#include "KrnlTypes.hpp"
namespace mlir {
class KrnlOpsDialect : public Dialect {
public:
KrnlOpsDialect(MLIRContext *context);
static StringRef getDialectNamespace() { return "krnl"; }
2019-12-21 13:51:05 +08:00
2019-11-20 08:45:03 +08:00
/// Parse a type registered to this dialect.
Type parseType(DialectAsmParser &parser) const override {
2019-11-20 08:45:03 +08:00
if (succeeded(parser.parseOptionalKeyword("loop")))
return LoopType::get(parser.getBuilder().getContext());
2019-11-20 08:45:03 +08:00
parser.emitError(parser.getCurrentLocation(), "Unknown type");
}
/// Print a type registered to this dialect.
void printType(Type type, DialectAsmPrinter &os) const override {
2019-11-20 08:45:03 +08:00
switch (type.getKind()) {
case KrnlTypes::Loop:
os << "loop";
return;
2019-11-20 08:45:03 +08:00
}
}
};
#define GET_OP_CLASSES
2019-12-23 13:13:52 +08:00
#include "src/krnl.hpp.inc"
} // namespace mlir