Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes related to Pass options #2418

Merged
merged 3 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ integration_tests/b5/*
integration_tests/b6/*
integration_tests/_lpython-tmp-test-*
inst/bin/*
*.clj
pass_fortran_*.f90
pass_json_*.json
pass_tree_*.txt
*.tmp
*.tlog
*.filters
Expand Down
20 changes: 7 additions & 13 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ int emit_asr(const std::string &infile,
std::cout << LCompilers::pickle_tree(*asr,
compiler_options.use_colors, with_intrinsic_modules) << std::endl;
} else if (compiler_options.po.json) {
std::cout << LCompilers::pickle_json(*asr, lm, false, with_intrinsic_modules) << std::endl;
std::cout << LCompilers::pickle_json(*asr, lm, compiler_options.po.no_loc, with_intrinsic_modules) << std::endl;
} else if (compiler_options.po.visualize) {
std::string astr_data_json = LCompilers::pickle_json(*asr, lm, false, with_intrinsic_modules);
std::string astr_data_json = LCompilers::pickle_json(*asr, lm, compiler_options.po.no_loc, with_intrinsic_modules);
return visualize_json(astr_data_json, compiler_options.platform);
} else {
std::cout << LCompilers::pickle(*asr, compiler_options.use_colors,
Expand Down Expand Up @@ -365,18 +365,11 @@ int emit_c_to_file(const std::string &infile, const std::string &outfile,
}
LCompilers::ASR::TranslationUnit_t* asr = r1.result;

// Apply ASR passes
LCompilers::PassOptions pass_options;
pass_manager.use_default_passes(true);
pass_options.run_fun = "f";
pass_options.always_run = true;
pass_options.verbose = compiler_options.po.verbose;
pass_options.all_symbols_mangling = compiler_options.po.all_symbols_mangling;
pass_options.module_name_mangling = compiler_options.po.module_name_mangling;
pass_options.global_symbols_mangling = compiler_options.po.global_symbols_mangling;
pass_options.intrinsic_symbols_mangling = compiler_options.po.intrinsic_symbols_mangling;
compiler_options.po.run_fun = "f";
compiler_options.po.always_run = true;

pass_manager.apply_passes(al, asr, pass_options, diagnostics);
pass_manager.use_default_passes(true);
pass_manager.apply_passes(al, asr, compiler_options.po, diagnostics);

diagnostics.diagnostics.clear();
auto res = LCompilers::asr_to_c(al, *asr, diagnostics, compiler_options, 0);
Expand Down Expand Up @@ -1571,6 +1564,7 @@ int main(int argc, char *argv[])
app.add_flag("--no-indent", arg_no_indent, "Turn off Indented print ASR/AST");
app.add_flag("--tree", compiler_options.po.tree, "Tree structure print ASR/AST");
app.add_flag("--json", compiler_options.po.json, "Print ASR/AST Json format");
app.add_flag("--no-loc", compiler_options.po.no_loc, "Skip location information in ASR/AST Json format");
app.add_flag("--visualize", compiler_options.po.visualize, "Print ASR/AST Visualization");
app.add_option("--pass", arg_pass, "Apply the ASR pass and show ASR (implies --show-asr)");
app.add_option("--skip-pass", skip_pass, "Skip an ASR pass in default pipeline");
Expand Down
Loading