@@ -490,7 +490,11 @@ LogicalResult preparePassManager(PassManager &pm, const CompilerOptions &options
490
490
std::string tmp;
491
491
llvm::raw_string_ostream s{tmp};
492
492
s << *op;
493
- dumpToFile (options, output.nextPipelineDumpFilename (pipelineName.str ()), tmp);
493
+ std::string fileName = pipelineName.str ();
494
+ if (auto funcOp = dyn_cast<mlir::func::FuncOp>(op)) {
495
+ fileName += " _" + funcOp.getName ().str ();
496
+ }
497
+ dumpToFile (options, output.nextPipelineDumpFilename (fileName), tmp);
494
498
}
495
499
};
496
500
@@ -551,7 +555,7 @@ LogicalResult runPipeline(PassManager &pm, const CompilerOptions &options, Compi
551
555
llvm::errs () << " Failed to run pipeline: " << pipeline.getName () << " \n " ;
552
556
return failure ();
553
557
}
554
- if (options.keepIntermediate && options.checkpointStage .empty ()) {
558
+ if (options.keepIntermediate && ( options.checkpointStage .empty () || output. isCheckpointFound )) {
555
559
std::string tmp;
556
560
llvm::raw_string_ostream s{tmp};
557
561
s << moduleOp;
@@ -564,7 +568,7 @@ LogicalResult runLowering(const CompilerOptions &options, MLIRContext *ctx, Modu
564
568
CompilerOutput &output, TimingScope &timing)
565
569
566
570
{
567
- if (options.keepIntermediate && options.checkpointStage .empty ()) {
571
+ if (options.keepIntermediate && ( options.checkpointStage .empty () || output. isCheckpointFound )) {
568
572
std::string tmp;
569
573
llvm::raw_string_ostream s{tmp};
570
574
s << moduleOp;
@@ -861,26 +865,30 @@ int QuantumDriverMainFromCL(int argc, char **argv)
861
865
// ---------
862
866
// Any modifications made to the command-line interface should be documented in
863
867
// doc/catalyst-cli/catalyst-cli.rst
864
- cl::opt<std::string> WorkspaceDir (" workspace" , cl::desc (" Workspace directory" ), cl::init (" ." ));
868
+ cl::OptionCategory CatalystCat (" Catalyst-cli Options" , " " );
869
+ cl::opt<std::string> WorkspaceDir (" workspace" , cl::desc (" Workspace directory" ), cl::init (" ." ),
870
+ cl::cat (CatalystCat));
865
871
cl::opt<std::string> ModuleName (" module-name" , cl::desc (" Module name" ),
866
- cl::init (" catalyst_module" ));
872
+ cl::init (" catalyst_module" ), cl::cat (CatalystCat) );
867
873
868
874
cl::opt<enum SaveTemps> SaveAfterEach (
869
875
" save-ir-after-each" , cl::desc (" Keep intermediate files after each pass or pipeline" ),
870
876
cl::values (clEnumValN (SaveTemps::AfterPass, " pass" , " Save IR after each pass" )),
871
877
cl::values (clEnumValN (SaveTemps::AfterPipeline, " pipeline" , " Save IR after each pipeline" )),
872
- cl::init (SaveTemps::None));
878
+ cl::init (SaveTemps::None), cl::cat (CatalystCat) );
873
879
cl::opt<bool > KeepIntermediate (
874
880
" keep-intermediate" , cl::desc (" Keep intermediate files" ), cl::init (false ),
875
- cl::callback ([&](const bool &) { SaveAfterEach.setValue (SaveTemps::AfterPipeline); }));
881
+ cl::callback ([&](const bool &) { SaveAfterEach.setValue (SaveTemps::AfterPipeline); }),
882
+ cl::cat (CatalystCat));
876
883
cl::opt<bool > AsyncQNodes (" async-qnodes" , cl::desc (" Enable asynchronous QNodes" ),
877
- cl::init (false ));
878
- cl::opt<bool > Verbose (" verbose" , cl::desc (" Set verbose" ), cl::init (false ));
879
- cl::list<std::string> CatalystPipeline (" catalyst-pipeline" ,
880
- cl::desc (" Catalyst Compiler pass pipelines" ),
881
- cl::ZeroOrMore, cl::CommaSeparated);
884
+ cl::init (false ), cl::cat (CatalystCat));
885
+ cl::opt<bool > Verbose (" verbose" , cl::desc (" Set verbose" ), cl::init (false ),
886
+ cl::cat (CatalystCat));
887
+ cl::list<std::string> CatalystPipeline (
888
+ " catalyst-pipeline" , cl::desc (" Catalyst Compiler pass pipelines" ), cl::ZeroOrMore,
889
+ cl::CommaSeparated, cl::cat (CatalystCat));
882
890
cl::opt<std::string> CheckpointStage (" checkpoint-stage" , cl::desc (" Checkpoint stage" ),
883
- cl::init (" " ));
891
+ cl::init (" " ), cl::cat (CatalystCat) );
884
892
cl::opt<enum Action> LoweringAction (
885
893
" tool" , cl::desc (" Select the tool to isolate" ),
886
894
cl::values (clEnumValN (Action::OPT, " opt" , " run quantum-opt on the MLIR input" )),
@@ -889,9 +897,10 @@ int QuantumDriverMainFromCL(int argc, char **argv)
889
897
cl::values (clEnumValN (Action::LLC, " llc" , " run llc on the llvm IR input" )),
890
898
cl::values (clEnumValN (Action::All, " all" ,
891
899
" run quantum-opt, mlir-translate, and llc on the MLIR input" )),
892
- cl::init (Action::All));
893
- cl::opt<bool > DumpPassPipeline (
894
- " dump-catalyst-pipeline" , cl::desc (" Print the pipeline that will be run" ), cl::init (false ));
900
+ cl::init (Action::All), cl::cat (CatalystCat));
901
+ cl::opt<bool > DumpPassPipeline (" dump-catalyst-pipeline" ,
902
+ cl::desc (" Print the pipeline that will be run" ), cl::init (false ),
903
+ cl::cat (CatalystCat));
895
904
896
905
// Create dialect registry
897
906
DialectRegistry registry;
@@ -904,8 +913,13 @@ int QuantumDriverMainFromCL(int argc, char **argv)
904
913
905
914
// Register and parse command line options.
906
915
std::string inputFilename, outputFilename;
916
+ std::string helpStr = " Catalyst Command Line Interface options. \n "
917
+ " Below, there is a complete list of options for the Catalyst CLI tool"
918
+ " In the first section, you can find the options that are used to"
919
+ " configure the Catalyst compiler. Next, you can find the options"
920
+ " specific to the mlir-opt tool.\n " ;
907
921
std::tie (inputFilename, outputFilename) =
908
- registerAndParseCLIOptions (argc, argv, " quantum compiler " , registry);
922
+ registerAndParseCLIOptions (argc, argv, helpStr , registry);
909
923
llvm::InitLLVM y (argc, argv);
910
924
MlirOptMainConfig config = MlirOptMainConfig::createFromCLOptions ();
911
925
0 commit comments