mirror of https://github.com/llvm/circt.git
[Pipeline] Python dialect and pass registration (#8612)
- Register the pipeline dialect - Register pipeline dialect passes - Add passes to the PyCDE pipelines
This commit is contained in:
parent
4f348d246d
commit
5c4d8ae62b
|
@ -41,7 +41,7 @@ class System:
|
|||
"mod", "top_modules", "name", "passed", "_old_system_token", "_op_cache",
|
||||
"_generate_queue", "output_directory", "files", "mod_files",
|
||||
"packaging_funcs", "sw_api_langs", "_instance_roots", "_placedb",
|
||||
"_appid_index", "platform"
|
||||
"_appid_index", "platform", "plugin_added_passes"
|
||||
]
|
||||
|
||||
def __init__(self,
|
||||
|
@ -87,6 +87,8 @@ class System:
|
|||
self.output_directory.mkdir(exist_ok=True)
|
||||
self.hw_output_dir.mkdir(exist_ok=True)
|
||||
|
||||
self.plugin_added_passes: Dict[str, List[str]] = {}
|
||||
|
||||
with self:
|
||||
[m._builder.circt_mod for m in self.top_modules]
|
||||
|
||||
|
@ -278,6 +280,10 @@ class System:
|
|||
# "builtin.module(lower-dc-to-hw)",
|
||||
# "builtin.module(map-arith-to-comb)",
|
||||
|
||||
# Lower the pipeline dialect.
|
||||
"builtin.module(pipeline-explicit-regs)",
|
||||
"builtin.module(lower-pipeline-to-hw)",
|
||||
|
||||
# Run ESI manifest passes.
|
||||
"builtin.module(esi-appid-hier{{top={tops} }}, esi-build-manifest{{top={tops} }})",
|
||||
"builtin.module(msft-lower-constructs, msft-lower-instances)",
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
//===- Pipeline.h - C interface for the Pipeline dialect ----------*- 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CIRCT_C_DIALECT_PIPELINE_H
|
||||
#define CIRCT_C_DIALECT_PIPELINE_H
|
||||
|
||||
#include "mlir-c/IR.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Pipeline, pipeline);
|
||||
MLIR_CAPI_EXPORTED void registerPipelinePasses(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CIRCT_C_DIALECT_PIPELINE_H
|
|
@ -0,0 +1,25 @@
|
|||
# REQUIRES: bindings_python
|
||||
# RUN: %PYTHON% %s
|
||||
|
||||
import circt
|
||||
|
||||
from circt.ir import Context, Module
|
||||
from circt import passmanager
|
||||
|
||||
with Context() as ctx:
|
||||
circt.register_dialects(ctx)
|
||||
mod = Module.parse("""
|
||||
hw.module @testSingle(in %arg0: i32, in %arg1: i32, in %go: i1, in %clk: !seq.clock, in %rst: i1, out out0: i32, out out1: i1) {
|
||||
%0:2 = pipeline.scheduled(%a0 : i32 = %arg0, %a1 : i32 = %arg1) clock(%clk) reset(%rst) go(%go) entryEn(%s0_enable) -> (out: i32){
|
||||
%1 = comb.sub %a0,%a1 : i32
|
||||
pipeline.stage ^bb1 regs(%1 : i32, %a0 : i32)
|
||||
^bb1(%6: i32, %7: i32, %s1_enable : i1): // pred: ^bb1
|
||||
%8 = comb.add %6, %7 : i32
|
||||
pipeline.return %8 : i32
|
||||
}
|
||||
hw.output %0#0, %0#1 : i32, i1
|
||||
}
|
||||
""")
|
||||
pm = passmanager.PassManager.parse(
|
||||
"builtin.module(pipeline-explicit-regs,lower-pipeline-to-hw)")
|
||||
pm.run(mod.operation)
|
|
@ -22,6 +22,7 @@
|
|||
#include "circt-c/Dialect/LTL.h"
|
||||
#include "circt-c/Dialect/MSFT.h"
|
||||
#include "circt-c/Dialect/OM.h"
|
||||
#include "circt-c/Dialect/Pipeline.h"
|
||||
#include "circt-c/Dialect/RTG.h"
|
||||
#include "circt-c/Transforms.h"
|
||||
#ifdef CIRCT_INCLUDE_TESTS
|
||||
|
@ -56,6 +57,7 @@ static void registerPasses() {
|
|||
registerHWArithPasses();
|
||||
registerHWPasses();
|
||||
registerHandshakePasses();
|
||||
registerPipelinePasses();
|
||||
mlirRegisterCIRCTConversionPasses();
|
||||
mlirRegisterCIRCTTransformsPasses();
|
||||
mlirRegisterTransformsCSE();
|
||||
|
@ -115,6 +117,10 @@ NB_MODULE(_circt, m) {
|
|||
mlirDialectHandleRegisterDialect(om, context);
|
||||
mlirDialectHandleLoadDialect(om, context);
|
||||
|
||||
MlirDialectHandle pipeline = mlirGetDialectHandle__pipeline__();
|
||||
mlirDialectHandleRegisterDialect(pipeline, context);
|
||||
mlirDialectHandleLoadDialect(pipeline, context);
|
||||
|
||||
MlirDialectHandle rtg = mlirGetDialectHandle__rtg__();
|
||||
mlirDialectHandleRegisterDialect(rtg, context);
|
||||
mlirDialectHandleLoadDialect(rtg, context);
|
||||
|
|
|
@ -45,6 +45,7 @@ set(PYTHON_BINDINGS_LINK_LIBS
|
|||
CIRCTCAPILTL
|
||||
CIRCTCAPIMSFT
|
||||
CIRCTCAPIOM
|
||||
CIRCTCAPIPipeline
|
||||
CIRCTCAPIRTG
|
||||
CIRCTCAPIRtgTool
|
||||
CIRCTCAPISeq
|
||||
|
|
|
@ -17,6 +17,7 @@ set(LLVM_OPTIONAL_SOURCES
|
|||
MSFT.cpp
|
||||
Moore.cpp
|
||||
OM.cpp
|
||||
Pipeline.cpp
|
||||
RTG.cpp
|
||||
RTGTest.cpp
|
||||
SV.cpp
|
||||
|
@ -131,6 +132,15 @@ add_circt_public_c_api_library(CIRCTCAPIOM
|
|||
CIRCTOMEvaluator
|
||||
)
|
||||
|
||||
add_circt_public_c_api_library(CIRCTCAPIPipeline
|
||||
Pipeline.cpp
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRCAPIIR
|
||||
CIRCTPipelineOps
|
||||
CIRCTPipelineTransforms
|
||||
)
|
||||
|
||||
add_circt_public_c_api_library(CIRCTCAPIRTG
|
||||
RTG.cpp
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
//===- Pipeline.cpp - C interface for the Pipeline 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "circt-c/Dialect/Pipeline.h"
|
||||
#include "circt/Dialect/Pipeline/PipelineDialect.h"
|
||||
#include "circt/Dialect/Pipeline/PipelinePasses.h"
|
||||
|
||||
#include "mlir/CAPI/Registration.h"
|
||||
|
||||
using namespace circt::pipeline;
|
||||
|
||||
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Pipeline, pipeline,
|
||||
circt::pipeline::PipelineDialect)
|
||||
|
||||
void registerPipelinePasses() { circt::pipeline::registerPasses(); }
|
Loading…
Reference in New Issue