@@ -59,7 +59,7 @@ namespace LCompilers {
59
59
std::vector<std::string> _passes;
60
60
std::vector<std::string> _with_optimization_passes;
61
61
std::vector<std::string> _user_defined_passes;
62
- std::vector<std::string> _skip_passes;
62
+ std::vector<std::string> _skip_passes, _c_skip_passes ;
63
63
std::map<std::string, pass_function> _passes_db = {
64
64
{" do_loops" , &pass_replace_do_loops},
65
65
{" global_stmts" , &pass_wrap_global_stmts_into_function},
@@ -90,6 +90,7 @@ namespace LCompilers {
90
90
91
91
bool is_fast;
92
92
bool apply_default_passes;
93
+ bool c_skip_pass; // This will contain the passes that are to be skipped in C
93
94
94
95
void _apply_passes (Allocator& al, ASR::TranslationUnit_t* asr,
95
96
std::vector<std::string>& passes, PassOptions &pass_options,
@@ -103,6 +104,9 @@ namespace LCompilers {
103
104
if (rtlib && passes[i] == " unused_functions" ) continue ;
104
105
if ( std::find (_skip_passes.begin (), _skip_passes.end (), passes[i]) != _skip_passes.end ())
105
106
continue ;
107
+ if (c_skip_pass && std::find (_c_skip_passes.begin (),
108
+ _c_skip_passes.end (), passes[i]) != _c_skip_passes.end ())
109
+ continue ;
106
110
_passes_db[passes[i]](al, *asr, pass_options);
107
111
#if defined(WITH_LFORTRAN_ASSERT)
108
112
if (!asr_verify (*asr, true , diagnostics)) {
@@ -142,7 +146,8 @@ namespace LCompilers {
142
146
}
143
147
}
144
148
145
- PassManager (): is_fast{false }, apply_default_passes{false } {
149
+ PassManager (): is_fast{false }, apply_default_passes{false },
150
+ c_skip_pass{false } {
146
151
_passes = {
147
152
" global_stmts" ,
148
153
" init_expr" ,
@@ -191,6 +196,12 @@ namespace LCompilers {
191
196
" inline_function_calls"
192
197
};
193
198
199
+ // These are well re-write passes which are already handled
200
+ // appropriately in C backend.
201
+ _c_skip_passes = {
202
+ " pass_list_expr" ,
203
+ " print_list_tuple"
204
+ };
194
205
_user_defined_passes.clear ();
195
206
}
196
207
@@ -227,8 +238,9 @@ namespace LCompilers {
227
238
is_fast = false ;
228
239
}
229
240
230
- void use_default_passes () {
241
+ void use_default_passes (bool _c_skip_pass= false ) {
231
242
apply_default_passes = true ;
243
+ c_skip_pass = _c_skip_pass;
232
244
}
233
245
234
246
void do_not_use_default_passes () {
0 commit comments