[HLSCppDialect] add ApplyPragmasOp and PragmaOpInterface
This commit is contained in:
parent
45fe55af67
commit
1a6491b4fd
|
@ -1 +1,6 @@
|
|||
add_mlir_dialect(HLSCpp hlscpp)
|
||||
|
||||
set(LLVM_TARGET_DEFINITIONS Interfaces.td)
|
||||
mlir_tablegen(HLSCppInterfaces.h.inc -gen-op-interface-decls)
|
||||
mlir_tablegen(HLSCppInterfaces.cpp.inc -gen-op-interface-defs)
|
||||
add_public_tablegen_target(MLIRHLSCppInterfacesIncGen)
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
//===------------------------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SCALEHLS_DIALECT_HLSCPP_DIALECT_H
|
||||
#define SCALEHLS_DIALECT_HLSCPP_DIALECT_H
|
||||
|
||||
#include "mlir/IR/Dialect.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace scalehls {
|
||||
namespace hlscpp {
|
||||
|
||||
#include "Dialect/HLSCpp/HLSCppDialect.h.inc"
|
||||
|
||||
} // namespace hlscpp
|
||||
} // namespace scalehls
|
||||
} // namespace mlir
|
||||
|
||||
#endif // SCALEHLS_DIALECT_HLSCPP_DIALECT_H
|
|
@ -1,28 +0,0 @@
|
|||
//===-------------------------------------------------------*- tablegen -*-===//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
include "mlir/IR/OpBase.td"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// HLSCpp dialect definition.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def HLSCppDialect : Dialect {
|
||||
let name = "hlscpp";
|
||||
let summary = "An HLSCpp out-of-tree MLIR dialect.";
|
||||
let description = [{
|
||||
This dialect is designed for HLS-specific C++ operations, attributes, and
|
||||
types. Operations in this dialect can be emitted as optimization directives
|
||||
decorated C++ code, which is fully synthesizable for commercial HLS tools,
|
||||
such as Vivado HLS.
|
||||
}];
|
||||
let cppNamespace = "hlscpp";
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Base HLSCpp operation definition.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
class HLSCppOp<string mnemonic, list<OpTrait> traits = []> :
|
||||
Op<HLSCppDialect, mnemonic, traits>;
|
|
@ -2,10 +2,26 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SCALEHLS_DIALECT_HLSCPP_TD
|
||||
#define SCALEHLS_DIALECT_HLSCPP_TD
|
||||
#ifndef SCALEHLS_DIALECT_HLSCPP_HLSCPP_TD
|
||||
#define SCALEHLS_DIALECT_HLSCPP_HLSCPP_TD
|
||||
|
||||
include "mlir/IR/OpBase.td"
|
||||
|
||||
def HLSCppDialect : Dialect {
|
||||
let name = "hlscpp";
|
||||
let summary = "An HLSCpp out-of-tree MLIR dialect.";
|
||||
let description = [{
|
||||
This dialect is designed for HLS-specific C++ operations, attributes, and
|
||||
types. Operations in this dialect can be emitted as optimization directives
|
||||
decorated C++ code, which is fully synthesizable for commercial HLS tools,
|
||||
such as Vivado HLS.
|
||||
}];
|
||||
let cppNamespace = "hlscpp";
|
||||
}
|
||||
|
||||
class HLSCppOp<string mnemonic, list<OpTrait> traits = []> :
|
||||
Op<HLSCppDialect, mnemonic, traits>;
|
||||
|
||||
include "Dialect.td"
|
||||
include "Ops.td"
|
||||
|
||||
#endif // SCALEHLS_DIALECT_HLSCPP_TD
|
||||
#endif // SCALEHLS_DIALECT_HLSCPP_HLSCPP_TD
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
//===-------------------------------------------------------*- tablegen -*-===//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SCALEHLS_DIALECT_HLSCPP_INTERFACES_TD
|
||||
#define SCALEHLS_DIALECT_HLSCPP_INTERFACES_TD
|
||||
|
||||
include "mlir/IR/OpBase.td"
|
||||
|
||||
def PragmaOpInterface : OpInterface<"PragmaOpInterface"> {
|
||||
let description = [{
|
||||
This interface indicates the operation represents one pragma directive or a
|
||||
set of pragmas.
|
||||
}];
|
||||
}
|
||||
|
||||
#endif // SCALEHLS_DIALECT_HLSCPP_INTERFACES_TD
|
|
@ -5,13 +5,16 @@
|
|||
#ifndef SCALEHLS_DIALECT_HLSCPP_OPS_H
|
||||
#define SCALEHLS_DIALECT_HLSCPP_OPS_H
|
||||
|
||||
#include "Dialect/HLSCpp/Dialect.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace scalehls {
|
||||
namespace hlscpp {
|
||||
|
||||
#include "Dialect/HLSCpp/HLSCppDialect.h.inc"
|
||||
#include "Dialect/HLSCpp/HLSCppInterfaces.h.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "Dialect/HLSCpp/HLSCpp.h.inc"
|
||||
|
||||
|
|
|
@ -2,8 +2,29 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SCALEHLS_DIALECT_HLSCPP_OPS_TD
|
||||
#define SCALEHLS_DIALECT_HLSCPP_OPS_TD
|
||||
|
||||
include "Interfaces.td"
|
||||
include "mlir/Interfaces/SideEffectInterfaces.td"
|
||||
|
||||
def HLSCppApplyPragmasOp : HLSCppOp<"apply_pragmas",
|
||||
[NoSideEffect, PragmaOpInterface]> {
|
||||
let summary = "apply_pragmas operation";
|
||||
let description = [{
|
||||
This hlscpp.apply_pragmas operation owns one region containing one or more
|
||||
concrete pragmas, and applies all of them to its parent operation (e.g.,
|
||||
functions, loops, or other regions). This operation should always be
|
||||
inserted to the front of its parent operation.
|
||||
|
||||
This operations takes nothing and returns nothing.
|
||||
}];
|
||||
|
||||
let regions = (region SizedRegion<1> : $pragmaRegion);
|
||||
}
|
||||
|
||||
|
||||
|
||||
def HLSCppFooOp : HLSCppOp<"foo", [NoSideEffect, SameOperandsAndResultType]> {
|
||||
let summary = "Illustrates how to define an operation.";
|
||||
let description = [{
|
||||
|
@ -28,3 +49,5 @@ def HLSCppFooOp : HLSCppOp<"foo", [NoSideEffect, SameOperandsAndResultType]> {
|
|||
$input attr-dict `:` type($input)
|
||||
}];
|
||||
}
|
||||
|
||||
#endif // SCALEHLS_DIALECT_HLSCPP_OPS_TD
|
||||
|
|
|
@ -8,7 +8,8 @@ add_mlir_dialect_library(MLIRHLSCpp
|
|||
|
||||
DEPENDS
|
||||
MLIRHLSCppIncGen
|
||||
MLIRHLSCppInterfacesIncGen
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRIR
|
||||
)
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRIR
|
||||
)
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
//===------------------------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Dialect/HLSCpp/Dialect.h"
|
||||
#include "Dialect/HLSCpp/Ops.h"
|
||||
|
||||
using namespace mlir;
|
||||
using namespace scalehls;
|
||||
using namespace hlscpp;
|
||||
|
||||
HLSCppDialect::HLSCppDialect(mlir::MLIRContext *context)
|
||||
: Dialect(getDialectNamespace(), context) {
|
||||
|
||||
addOperations<
|
||||
#define GET_OP_LIST
|
||||
#include "Dialect/HLSCpp/HLSCpp.cpp.inc"
|
||||
>();
|
||||
}
|
|
@ -9,5 +9,16 @@ using namespace mlir;
|
|||
using namespace scalehls;
|
||||
using namespace hlscpp;
|
||||
|
||||
HLSCppDialect::HLSCppDialect(mlir::MLIRContext *context)
|
||||
: Dialect(getDialectNamespace(), context) {
|
||||
|
||||
addOperations<
|
||||
#define GET_OP_LIST
|
||||
#include "Dialect/HLSCpp/HLSCpp.cpp.inc"
|
||||
>();
|
||||
}
|
||||
|
||||
#include "Dialect/HLSCpp/HLSCppInterfaces.cpp.inc"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "Dialect/HLSCpp/HLSCpp.cpp.inc"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Support/ToolOutputFile.h"
|
||||
|
||||
#include "Dialect/HLSCpp/Dialect.h"
|
||||
#include "Dialect/HLSCpp/Ops.h"
|
||||
|
||||
static llvm::cl::opt<std::string> inputFilename(llvm::cl::Positional,
|
||||
llvm::cl::desc("<input file>"),
|
||||
|
|
Loading…
Reference in New Issue