Skip to content

Commit 6000a9f

Browse files
authored
Merge pull request #2116 from certik/asr_pass2
Clean up the pass names
2 parents dd5a694 + b03cd57 commit 6000a9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+162
-179
lines changed

src/libasr/codegen/asr_to_c.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include <libasr/asr_utils.h>
1212
#include <libasr/string_utils.h>
1313
#include <libasr/pass/unused_functions.h>
14-
#include <libasr/pass/class_constructor.h>
15-
#include <libasr/pass/array_op.h>
16-
#include <libasr/pass/subroutine_from_function.h>
14+
#include <libasr/pass/replace_class_constructor.h>
15+
#include <libasr/pass/replace_array_op.h>
16+
#include <libasr/pass/create_subroutine_from_function.h>
1717

1818
#include <map>
1919
#include <utility>

src/libasr/codegen/asr_to_x86.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include <libasr/containers.h>
77
#include <libasr/codegen/asr_to_x86.h>
88
#include <libasr/codegen/x86_assembler.h>
9-
#include <libasr/pass/do_loops.h>
10-
#include <libasr/pass/global_stmts.h>
9+
#include <libasr/pass/replace_do_loops.h>
10+
#include <libasr/pass/wrap_global_stmts.h>
1111
#include <libasr/exception.h>
1212
#include <libasr/asr_utils.h>
1313

src/libasr/gen_pass.py

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,44 @@
11
passes = [
2-
# name, optional prefix (pass_PREFIX_name())
3-
("arr_slice", "replace"),
4-
("array_op", "replace"),
5-
("class_constructor", "replace"),
6-
("dead_code_removal", ""),
7-
("div_to_mul", "replace"),
8-
("do_loops", "replace"),
9-
("flip_sign", "replace"),
10-
("fma", "replace"),
11-
("for_all", "replace"),
12-
("global_stmts", "wrap"),
13-
("global_stmts_program", "wrap"),
14-
("global_symbols", "wrap"),
15-
("implied_do_loops", "replace"),
16-
("init_expr", "replace"),
17-
("inline_function_calls", ""),
18-
("instantiate_template", ""),
19-
("intrinsic_function", "replace"),
20-
("loop_unroll", ""),
21-
("loop_vectorise", ""),
22-
("nested_vars", ""),
23-
("param_to_const", "replace"),
24-
("pass_array_by_data", ""),
25-
("pass_compare", ""),
26-
("pass_list_expr", ""),
27-
("print_arr", "replace"),
28-
("print_list_tuple", "replace"),
29-
("print_struct_type", "replace"),
30-
("select_case", "replace"),
31-
("sign_from_value", "replace"),
32-
("subroutine_from_function", "create"),
33-
("transform_optional_argument_functions", ""),
34-
("unused_functions", ""),
35-
("update_array_dim_intrinsic_calls", ""),
36-
("where", "replace"),
2+
"replace_arr_slice",
3+
"replace_array_op",
4+
"replace_class_constructor",
5+
"dead_code_removal",
6+
"replace_div_to_mul",
7+
"replace_do_loops",
8+
"replace_flip_sign",
9+
"replace_fma",
10+
"replace_for_all",
11+
"wrap_global_stmts",
12+
"wrap_global_stmts_program",
13+
"wrap_global_symbols",
14+
"replace_implied_do_loops",
15+
"replace_init_expr",
16+
"inline_function_calls",
17+
"replace_intrinsic_function",
18+
"loop_unroll",
19+
"loop_vectorise",
20+
"nested_vars",
21+
"replace_param_to_const",
22+
"array_by_data",
23+
"compare",
24+
"list_expr",
25+
"replace_print_arr",
26+
"replace_print_list_tuple",
27+
"replace_print_struct_type",
28+
"replace_select_case",
29+
"replace_sign_from_value",
30+
"create_subroutine_from_function",
31+
"transform_optional_argument_functions",
32+
"unused_functions",
33+
"update_array_dim_intrinsic_calls",
34+
"replace_where",
3735
]
3836

3937

4038

41-
for pass_name, prefix in passes:
42-
print(f"Processing: {pass_name}")
43-
name = pass_name
44-
if name.startswith("pass"):
45-
name = name[5:]
39+
for name in passes:
40+
print(f"Processing: {name}")
4641
name_up = name.upper()
47-
if prefix != "":
48-
prefix += "_"
49-
arguments = r"""Allocator &al, ASR::TranslationUnit_t &unit,
50-
const PassOptions &pass_options"""
51-
return_type = "void"
52-
if pass_name == "instantiate_template":
53-
arguments = r"""Allocator &al,
54-
std::map<std::string, ASR::ttype_t*> subs, std::map<std::string, ASR::symbol_t*> rt_subs,
55-
SymbolTable *current_scope, std::string new_func_name, ASR::symbol_t *sym"""
56-
return_type = "ASR::symbol_t*"
57-
58-
59-
6042
header = rf"""#ifndef LIBASR_PASS_{name_up}_H
6143
#define LIBASR_PASS_{name_up}_H
6244
@@ -65,12 +47,13 @@
6547
6648
namespace LCompilers {{
6749
68-
{return_type} pass_{prefix}{name}({arguments});
50+
void pass_{name}(Allocator &al, ASR::TranslationUnit_t &unit,
51+
const PassOptions &pass_options);
6952
7053
}} // namespace LCompilers
7154
7255
#endif // LIBASR_PASS_{name_up}_H
7356
"""
74-
header_filename = f"pass/{pass_name}.h"
57+
header_filename = f"pass/{name}.h"
7558
f = open(header_filename, "w")
7659
f.write(header)

src/libasr/pass/arr_slice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <libasr/asr_utils.h>
55
#include <libasr/asr_verify.h>
66
#include <libasr/pass/pass_utils.h>
7-
#include <libasr/pass/arr_slice.h>
7+
#include <libasr/pass/replace_arr_slice.h>
88

99
#include <vector>
1010
#include <utility>

src/libasr/pass/array_op.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <libasr/exception.h>
44
#include <libasr/asr_utils.h>
55
#include <libasr/asr_verify.h>
6-
#include <libasr/pass/array_op.h>
6+
#include <libasr/pass/replace_array_op.h>
77
#include <libasr/pass/pass_utils.h>
88
#include <libasr/pass/intrinsic_function_registry.h>
99

src/libasr/pass/class_constructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <libasr/exception.h>
44
#include <libasr/asr_utils.h>
55
#include <libasr/asr_verify.h>
6-
#include <libasr/pass/class_constructor.h>
6+
#include <libasr/pass/replace_class_constructor.h>
77
#include <libasr/pass/pass_utils.h>
88

99
#include <vector>

src/libasr/pass/subroutine_from_function.h renamed to src/libasr/pass/create_subroutine_from_function.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIBASR_PASS_SUBROUTINE_FROM_FUNCTION_H
2-
#define LIBASR_PASS_SUBROUTINE_FROM_FUNCTION_H
1+
#ifndef LIBASR_PASS_CREATE_SUBROUTINE_FROM_FUNCTION_H
2+
#define LIBASR_PASS_CREATE_SUBROUTINE_FROM_FUNCTION_H
33

44
#include <libasr/asr.h>
55
#include <libasr/utils.h>
@@ -11,4 +11,4 @@ namespace LCompilers {
1111

1212
} // namespace LCompilers
1313

14-
#endif // LIBASR_PASS_SUBROUTINE_FROM_FUNCTION_H
14+
#endif // LIBASR_PASS_CREATE_SUBROUTINE_FROM_FUNCTION_H

src/libasr/pass/div_to_mul.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <libasr/exception.h>
44
#include <libasr/asr_utils.h>
55
#include <libasr/asr_verify.h>
6-
#include <libasr/pass/div_to_mul.h>
6+
#include <libasr/pass/replace_div_to_mul.h>
77
#include <libasr/pass/pass_utils.h>
88

99
#include <vector>

0 commit comments

Comments
 (0)