This is an experimental example based on https://github.com/llvm/llvm-project/tree/main/mlir/examples/standalone for implementing pass pipeline for CIRCT dialects.
standalone-switch-bar-foo
implements a tranformation to replace a wire bar
with foo
.
DIR=<install path of CIRCT>
cd build
cmake .. -GNinja -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DCIRCT_DIR=$DIR/lib/cmake/circt \
-DMLIR_DIR=$DIR/lib/cmake/mlir \
-DLLVM_DIR=$DIR/lib/cmake/llvm \
-DLLVM_ENABLE_ZSTD=Off
ninja check-standalone
ls build/StandalonePlugin.so
firtool must be built on https://github.com/llvm/circt/tree/dev/hidetou/load-pass
$ cat foo.fir
circuit Bar: %[[
{ "target": "~Bar|Bar>bar", "class": "firrtl.transforms.DontTouchAnnotation"}
]]
module Bar:
input w: UInt<1>
wire bar:UInt<1>
bar <= w
$ firtool foo.fir
// Generated by CIRCT firtool-1.56.1-118-g195ae0749
module Bar(
input w
);
wire bar = w;
endmodule
$ firtool foo.fir -load-pass-plugin=$PWD/build/lib/StandalonePlugin.so -low-firrtl-pass-plugin='firrtl.circuit(standalone-switch-bar-foo)'
// Generated by CIRCT firtool-1.56.1-118-g195ae0749
module Bar(
input w
);
wire foo = w;
endmodule