Skip to content

Commit

Permalink
PASS: Rename pass print_list to print_list_tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Mar 13, 2023
1 parent 3876018 commit 63588a7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def is_included(backend):
pass_ = test.get("pass", None)
optimization_passes = ["flip_sign", "div_to_mul", "fma", "sign_from_value",
"inline_function_calls", "loop_unroll",
"dead_code_removal", "loop_vectorise", "print_list"]
"dead_code_removal", "loop_vectorise", "print_list_tuple"]

if pass_ and (pass_ not in ["do_loops", "global_stmts"] and
pass_ not in optimization_passes):
Expand Down
2 changes: 1 addition & 1 deletion src/libasr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ set(SRC
pass/class_constructor.cpp
pass/arr_slice.cpp
pass/print_arr.cpp
pass/print_list.cpp
pass/print_list_tuple.cpp
pass/pass_utils.cpp
pass/unused_functions.cpp
pass/flip_sign.cpp
Expand Down
8 changes: 4 additions & 4 deletions src/libasr/pass/pass_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <libasr/pass/global_stmts.h>
#include <libasr/pass/param_to_const.h>
#include <libasr/pass/print_arr.h>
#include <libasr/pass/print_list.h>
#include <libasr/pass/print_list_tuple.h>
#include <libasr/pass/arr_slice.h>
#include <libasr/pass/flip_sign.h>
#include <libasr/pass/div_to_mul.h>
Expand Down Expand Up @@ -66,7 +66,7 @@ namespace LCompilers {
{"array_op", &pass_replace_array_op},
{"arr_slice", &pass_replace_arr_slice},
{"print_arr", &pass_replace_print_arr},
{"print_list", &pass_replace_print_list},
{"print_list_tuple", &pass_replace_print_list_tuple},
{"class_constructor", &pass_replace_class_constructor},
{"unused_functions", &pass_unused_functions},
{"flip_sign", &pass_replace_flip_sign},
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace LCompilers {
"array_op",
"pass_array_by_data",
"print_arr",
"print_list",
"print_list_tuple",
"array_dim_intrinsics_update",
"do_loops",
"forall",
Expand All @@ -170,7 +170,7 @@ namespace LCompilers {
"subroutine_from_function",
"array_op",
"print_arr",
"print_list",
"print_list_tuple",
"loop_vectorise",
"loop_unroll",
"array_dim_intrinsics_update",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include <libasr/asr_utils.h>
#include <libasr/asr_verify.h>
#include <libasr/pass/pass_utils.h>
#include <libasr/pass/print_list.h>
#include <libasr/pass/print_list_tuple.h>

namespace LCompilers {

/*
This ASR pass replaces print list or print tuple with print every value,
comma_space, brackets and newline. The function
`pass_replace_print_list` transforms the ASR tree in-place.
`pass_replace_print_list_tuple` transforms the ASR tree in-place.
Converts:
Expand Down Expand Up @@ -62,14 +62,14 @@ For tuples:
It also works the same way for nested lists/tuples using recursion.
*/

class PrintListVisitor
: public PassUtils::PassVisitor<PrintListVisitor> {
class PrintListTupleVisitor
: public PassUtils::PassVisitor<PrintListTupleVisitor> {
private:
std::string rl_path;

public:
Vec<ASR::stmt_t*> print_pass_result_tmp;
PrintListVisitor(Allocator &al, const std::string &rl_path_)
PrintListTupleVisitor(Allocator &al, const std::string &rl_path_)
: PassVisitor(al, nullptr), rl_path(rl_path_) {
pass_result.reserve(al, 1);
print_pass_result_tmp.reserve(al, 1);
Expand Down Expand Up @@ -376,11 +376,11 @@ class PrintListVisitor
}
};

void pass_replace_print_list(
void pass_replace_print_list_tuple(
Allocator &al, ASR::TranslationUnit_t &unit,
const LCompilers::PassOptions &pass_options) {
std::string rl_path = pass_options.runtime_library_dir;
PrintListVisitor v(al, rl_path);
PrintListTupleVisitor v(al, rl_path);
v.visit_TranslationUnit(unit);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#ifndef LFORTRAN_PASS_PRINT_LIST_H
#define LFORTRAN_PASS_PRINT_LIST_H
#ifndef LFORTRAN_PASS_PRINT_LIST_TUPLE_H
#define LFORTRAN_PASS_PRINT_LIST_TUPLE_H

#include <libasr/asr.h>
#include <libasr/utils.h>

namespace LCompilers {

void pass_replace_print_list(
void pass_replace_print_list_tuple(
Allocator &al, ASR::TranslationUnit_t &unit,
const LCompilers::PassOptions &pass_options);

} // namespace LCompilers

#endif // LFORTRAN_PASS_PRINT_LIST_H
#endif // LFORTRAN_PASS_PRINT_LIST_TUPLE_H
2 changes: 1 addition & 1 deletion tests/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ cpp = true
[[test]]
filename = "../integration_tests/print_02.py"
asr = true
pass = "print_list"
pass = "print_list_tuple"

[[test]]
filename = "../integration_tests/print_04.py"
Expand Down

0 comments on commit 63588a7

Please sign in to comment.