mirror of https://github.com/llvm/circt.git
Calyx dialect initial commit. (#1287)
* Initial commit for Calyx dialect (WIP). * ws * Remove empty test. * Calyx component printing (cont) * nit todo * Mess around with components. * Remove ops for scaffolding review. * [obvious] Remove extra `-`s. * Remove extra stuff. * nits * Address comments pt1. * address comments pt2. * Add Attrs.
This commit is contained in:
parent
e8065e6f3c
commit
5db02d71fb
|
@ -9,6 +9,7 @@
|
|||
##
|
||||
##===----------------------------------------------------------------------===//
|
||||
|
||||
add_subdirectory(Calyx)
|
||||
add_subdirectory(Comb)
|
||||
add_subdirectory(ESI)
|
||||
add_subdirectory(FIRRTL)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
add_circt_dialect(Calyx calyx)
|
||||
add_circt_doc(Calyx -gen-dialect-doc Calyx Dialects/)
|
||||
|
||||
set(LLVM_TARGET_DEFINITIONS Calyx.td)
|
||||
|
||||
mlir_tablegen(CalyxEnums.h.inc -gen-enum-decls)
|
||||
mlir_tablegen(CalyxEnums.cpp.inc -gen-enum-defs)
|
||||
add_public_tablegen_target(MLIRCalyxEnumsIncGen)
|
||||
add_dependencies(circt-headers MLIRCalyxEnumsIncGen)
|
||||
|
||||
mlir_tablegen(CalyxAttrs.h.inc -gen-struct-attr-decls)
|
||||
mlir_tablegen(CalyxAttrs.cpp.inc -gen-struct-attr-defs)
|
||||
add_public_tablegen_target(MLIRCalyxAttrsIncGen)
|
||||
add_dependencies(circt-headers MLIRCalyxAttrsIncGen)
|
|
@ -0,0 +1,45 @@
|
|||
//===- Calyx.td - Calyx dialect definition -----------------*- tablegen -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This is the top level file for the Calyx dialect.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CALYX_TD
|
||||
#define CALYX_TD
|
||||
|
||||
include "mlir/IR/OpBase.td"
|
||||
include "mlir/Interfaces/SideEffectInterfaces.td"
|
||||
include "mlir/IR/OpAsmInterface.td"
|
||||
include "mlir/IR/SymbolInterfaces.td"
|
||||
|
||||
def CalyxDialect : Dialect {
|
||||
let name = "calyx";
|
||||
let summary = "Types and operations for the Calyx dialect";
|
||||
let description = [{
|
||||
Calyx is an intermediate language and infrastructure for building
|
||||
compilers that generate custom hardware accelerators. For more
|
||||
information, visit the
|
||||
[documentation](https://capra.cs.cornell.edu/calyx/).
|
||||
}];
|
||||
let extraClassDeclaration = [{
|
||||
/// Register all Calyx types.
|
||||
void registerTypes();
|
||||
/// Register all Calyx attributes.
|
||||
void registerAttributes();
|
||||
}];
|
||||
let cppNamespace = "::circt::calyx";
|
||||
}
|
||||
|
||||
/// Base class for the operation in this dialect.
|
||||
class CalyxOp<string mnemonic, list<OpTrait> traits = []> :
|
||||
Op<CalyxDialect, mnemonic, traits>;
|
||||
|
||||
include "circt/Dialect/Calyx/CalyxStructure.td"
|
||||
|
||||
#endif // CALYX_TD
|
|
@ -0,0 +1,28 @@
|
|||
//===- CalyxDialect.h - Calyx dialect declaration ---------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the Calyx MLIR dialect.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CIRCT_DIALECT_CALYX_CALYXDIALECT_H
|
||||
#define CIRCT_DIALECT_CALYX_CALYXDIALECT_H
|
||||
|
||||
#include "circt/Support/LLVM.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
|
||||
// Pull in the Dialect definition.
|
||||
#include "circt/Dialect/Calyx/CalyxDialect.h.inc"
|
||||
|
||||
// Pull in all enum type definitions, attributes,
|
||||
// and utility function declarations.
|
||||
#include "circt/Dialect/Calyx/CalyxEnums.h.inc"
|
||||
#include "circt/Dialect/Calyx/CalyxAttrs.h.inc"
|
||||
|
||||
#endif // CIRCT_DIALECT_CALYX_CALYXDIALECT_H
|
|
@ -0,0 +1,28 @@
|
|||
//===- CalyxOps.h - Declare Calyx dialect operations ------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file declares the operation class for the Calyx IR.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CIRCT_DIALECT_CALYX_OPS_H
|
||||
#define CIRCT_DIALECT_CALYX_OPS_H
|
||||
|
||||
#include "circt/Dialect/Calyx/CalyxDialect.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/FunctionSupport.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/IR/RegionKindInterface.h"
|
||||
#include "mlir/IR/SymbolTable.h"
|
||||
#include "mlir/Interfaces/InferTypeOpInterface.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "circt/Dialect/Calyx/Calyx.h.inc"
|
||||
|
||||
#endif // CIRCT_DIALECT_CALYX_OPS_H
|
|
@ -0,0 +1,11 @@
|
|||
//===- CalyxStructure.td - Calyx Structure -------------*- tablegen -*-----===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This describes the Calyx structures.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
|
@ -14,6 +14,7 @@
|
|||
#ifndef CIRCT_INITALLDIALECTS_H_
|
||||
#define CIRCT_INITALLDIALECTS_H_
|
||||
|
||||
#include "circt/Dialect/Calyx/CalyxDialect.h"
|
||||
#include "circt/Dialect/Comb/CombDialect.h"
|
||||
#include "circt/Dialect/ESI/ESIDialect.h"
|
||||
#include "circt/Dialect/FIRRTL/FIRRTLDialect.h"
|
||||
|
@ -32,6 +33,7 @@ namespace circt {
|
|||
inline void registerAllDialects(mlir::DialectRegistry ®istry) {
|
||||
// clang-format off
|
||||
registry.insert<
|
||||
calyx::CalyxDialect,
|
||||
comb::CombDialect,
|
||||
esi::ESIDialect,
|
||||
firrtl::FIRRTLDialect,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
##
|
||||
##===----------------------------------------------------------------------===//
|
||||
|
||||
add_subdirectory(Calyx)
|
||||
add_subdirectory(Comb)
|
||||
add_subdirectory(ESI)
|
||||
add_subdirectory(FIRRTL)
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
##===- CMakeLists.txt - Calyx dialect code --------------------*- cmake -*-===//
|
||||
##
|
||||
## Implementation files for the Calyx dialect.
|
||||
##
|
||||
##===----------------------------------------------------------------------===//
|
||||
|
||||
set(srcs
|
||||
CalyxDialect.cpp
|
||||
CalyxOps.cpp
|
||||
)
|
||||
|
||||
set(Calyx_LinkLibs
|
||||
CIRCTSupport
|
||||
CIRCTComb
|
||||
CIRCTSV
|
||||
CIRCTHW
|
||||
MLIRIR
|
||||
MLIRTransforms
|
||||
MLIRTranslation
|
||||
)
|
||||
|
||||
set(Calyx_Deps
|
||||
${Calyx_LinkLibs}
|
||||
MLIRCalyxEnumsIncGen
|
||||
MLIRCalyxAttrsIncGen
|
||||
)
|
||||
|
||||
|
||||
|
||||
add_circt_dialect_library(CIRCTCalyx
|
||||
${srcs}
|
||||
|
||||
DEPENDS
|
||||
${Calyx_Deps}
|
||||
|
||||
LINK_COMPONENTS
|
||||
Core
|
||||
Support
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
${Calyx_LinkLibs}
|
||||
)
|
|
@ -0,0 +1,36 @@
|
|||
//===- CalyxDialect.cpp - Implement the Calyx dialect ---------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the Calyx dialect.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "circt/Dialect/Calyx/CalyxDialect.h"
|
||||
#include "circt/Dialect/Calyx/CalyxOps.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/DialectImplementation.h"
|
||||
|
||||
using namespace circt;
|
||||
using namespace circt::calyx;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Dialect specification.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void CalyxDialect::initialize() {
|
||||
// Register operations.
|
||||
addOperations<
|
||||
#define GET_OP_LIST
|
||||
#include "circt/Dialect/Calyx/Calyx.cpp.inc"
|
||||
>();
|
||||
}
|
||||
|
||||
// Provide implementations for the enums and attributes we use.
|
||||
#include "circt/Dialect/Calyx/CalyxEnums.cpp.inc"
|
||||
#include "circt/Dialect/Calyx/CalyxAttrs.cpp.inc"
|
|
@ -0,0 +1,36 @@
|
|||
//===- CalyxOps.cpp - Calyx op code defs ------------------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This is where op definitions live.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "circt/Dialect/Calyx/CalyxOps.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/IR/DialectImplementation.h"
|
||||
#include "mlir/IR/FunctionImplementation.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
|
||||
using namespace circt;
|
||||
using namespace circt::calyx;
|
||||
using namespace mlir;
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// TableGen generated logic.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Provide the autogenerated implementation guts for the Op classes.
|
||||
#define GET_OP_CLASSES
|
||||
#include "circt/Dialect/Calyx/Calyx.cpp.inc"
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
// DIALECT: Available Dialects:
|
||||
// DIALECT-NEXT: affine
|
||||
// DIALECT-NEXT: calyx
|
||||
// DIALECT-NEXT: comb
|
||||
// DIALECT-NEXT: esi
|
||||
// DIALECT-NEXT: firrtl
|
||||
|
|
|
@ -8,6 +8,7 @@ add_llvm_tool(circt-opt
|
|||
llvm_update_compile_flags(circt-opt)
|
||||
target_link_libraries(circt-opt
|
||||
PRIVATE
|
||||
CIRCTCalyx
|
||||
CIRCTFIRRTLTransforms
|
||||
CIRCTESI
|
||||
CIRCTFIRRTL
|
||||
|
|
Loading…
Reference in New Issue