2020-03-19 16:48:09 +08:00
|
|
|
//===--------------------- KrnlOps.hpp - Krnl Operations ------------------===//
|
2019-11-12 10:31:56 +08:00
|
|
|
//
|
2020-03-19 16:48:09 +08:00
|
|
|
// Copyright 2019-2020 The IBM Research Authors.
|
2019-11-12 10:31:56 +08:00
|
|
|
//
|
|
|
|
// =============================================================================
|
|
|
|
//
|
2020-03-19 16:48:09 +08:00
|
|
|
// This file contains declarations of krnl operations.
|
|
|
|
//
|
2019-11-12 10:31:56 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-08-20 00:57:40 +08:00
|
|
|
#include "mlir/Dialect/Shape/IR/Shape.h"
|
2019-11-12 10:31:56 +08:00
|
|
|
#include "mlir/IR/Builders.h"
|
|
|
|
#include "mlir/IR/Dialect.h"
|
2019-11-20 08:45:03 +08:00
|
|
|
#include "mlir/IR/DialectImplementation.h"
|
2019-12-22 13:25:02 +08:00
|
|
|
#include "mlir/IR/Function.h"
|
2019-11-12 10:31:56 +08:00
|
|
|
#include "mlir/IR/OpDefinition.h"
|
|
|
|
#include "mlir/IR/StandardTypes.h"
|
2020-09-09 23:12:01 +08:00
|
|
|
#include "llvm/ADT/TypeSwitch.h"
|
2019-11-12 10:31:56 +08:00
|
|
|
|
2020-03-19 16:48:09 +08:00
|
|
|
#include "KrnlHelper.hpp"
|
|
|
|
#include "KrnlTypes.hpp"
|
2019-11-12 10:31:56 +08:00
|
|
|
|
|
|
|
namespace mlir {
|
|
|
|
class KrnlOpsDialect : public Dialect {
|
2019-12-20 02:27:15 +08:00
|
|
|
public:
|
|
|
|
KrnlOpsDialect(MLIRContext *context);
|
2019-11-12 10:31:56 +08:00
|
|
|
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.
|
2019-12-20 02:27:15 +08:00
|
|
|
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-12 10:31:56 +08:00
|
|
|
|
2019-11-20 08:45:03 +08:00
|
|
|
parser.emitError(parser.getCurrentLocation(), "Unknown type");
|
2020-06-02 01:55:19 +08:00
|
|
|
return {};
|
2019-11-20 08:45:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Print a type registered to this dialect.
|
2019-12-20 02:27:15 +08:00
|
|
|
void printType(Type type, DialectAsmPrinter &os) const override {
|
2020-09-09 23:12:01 +08:00
|
|
|
TypeSwitch<Type>(type).Case<LoopType>([&](Type) {
|
2019-12-20 02:27:15 +08:00
|
|
|
os << "loop";
|
|
|
|
return;
|
2020-09-09 23:12:01 +08:00
|
|
|
});
|
2019-11-20 08:45:03 +08:00
|
|
|
}
|
2019-11-12 10:31:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GET_OP_CLASSES
|
2020-03-20 22:40:51 +08:00
|
|
|
#include "src/Dialect/Krnl/KrnlOps.hpp.inc"
|
2019-12-20 02:27:15 +08:00
|
|
|
} // namespace mlir
|