[hlstool] add top-level-function option for calyx flow (#8434)

This commit is contained in:
Kelvin Chung 2025-04-28 13:22:05 +01:00 committed by GitHub
parent e123e5230a
commit 0ab7ab0366
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 7 deletions

View File

@ -31,7 +31,8 @@ static constexpr std::string_view sPortNameAttr = "calyx.port_name";
} // namespace scfToCalyx
/// Create an SCF to Calyx conversion pass.
std::unique_ptr<OperationPass<ModuleOp>> createSCFToCalyxPass();
std::unique_ptr<OperationPass<ModuleOp>>
createSCFToCalyxPass(std::string topLevelFunction = "");
} // namespace circt

View File

@ -2578,8 +2578,10 @@ using namespace circt::scftocalyx;
//===----------------------------------------------------------------------===//
class SCFToCalyxPass : public circt::impl::SCFToCalyxBase<SCFToCalyxPass> {
public:
SCFToCalyxPass()
: SCFToCalyxBase<SCFToCalyxPass>(), partialPatternRes(success()) {}
SCFToCalyxPass(std::string topLevelFunction)
: SCFToCalyxBase<SCFToCalyxPass>(), partialPatternRes(success()) {
this->topLevelFunctionOpt = topLevelFunction;
}
void runOnOperation() override;
LogicalResult setTopLevelFunction(mlir::ModuleOp moduleOp,
@ -3042,8 +3044,9 @@ void SCFToCalyxPass::runOnOperation() {
// Pass initialization
//===----------------------------------------------------------------------===//
std::unique_ptr<OperationPass<ModuleOp>> createSCFToCalyxPass() {
return std::make_unique<SCFToCalyxPass>();
std::unique_ptr<OperationPass<ModuleOp>>
createSCFToCalyxPass(std::string topLevelFunction) {
return std::make_unique<SCFToCalyxPass>(topLevelFunction);
}
} // namespace circt

View File

@ -5,3 +5,4 @@
// CHECK: Generic Options
// CHECK: hlstool Options
// CHECK: --lowering-options=
// CHECK: --top-level-function=

View File

@ -224,6 +224,14 @@ static cl::opt<bool> withDC("dc", cl::desc("Use the DC flow"), cl::init(false),
static LoweringOptionsOption loweringOptions(mainCategory);
// --------------------------------------------------------------------------
// Calyx options
// --------------------------------------------------------------------------
static cl::opt<std::string> topLevelFunction("top-level-function",
cl::desc("Top level function"),
cl::init(""),
cl::cat(mainCategory));
// --------------------------------------------------------------------------
// (Configurable) pass pipelines
// --------------------------------------------------------------------------
@ -412,8 +420,9 @@ static LogicalResult doHLSFlowCalyx(
});
// Lower to Calyx
addIRLevel(IRLevel::Core,
[&]() { pm.addPass(circt::createSCFToCalyxPass()); });
addIRLevel(IRLevel::Core, [&]() {
pm.addPass(circt::createSCFToCalyxPass(topLevelFunction));
});
// Run Calyx transforms
addIRLevel(IRLevel::PostCompile, [&]() {