@@ -18,7 +18,6 @@ class Cleaner {
1818 : world_(world)
1919 {}
2020
21- World& world () { return world_; }
2221 void cleanup ();
2322 void eliminate_tail_rec ();
2423 void eta_conversion ();
@@ -49,7 +48,7 @@ void Cleaner::eliminate_tail_rec() {
4948 } else if (use->isa_nom <Param>())
5049 continue ; // ignore params
5150
52- world () .ELOG (" non-recursive usage of {} index:{} use:{}" , scope.entry ()->name (), use.index (), use.def ()->to_string ());
51+ world_ .ELOG (" non-recursive usage of {} index:{} use:{}" , scope.entry ()->name (), use.index (), use.def ()->to_string ());
5352 only_tail_calls = false ;
5453 break ;
5554 }
@@ -88,7 +87,7 @@ void Cleaner::eliminate_tail_rec() {
8887 }
8988
9089 if (new_args.size () != n) {
91- world () .DLOG (" tail recursive: {}" , entry);
90+ world_ .DLOG (" tail recursive: {}" , entry);
9291 auto dropped = drop (scope, args);
9392
9493 entry->jump (dropped, new_args);
@@ -102,7 +101,7 @@ void Cleaner::eliminate_tail_rec() {
102101void Cleaner::eta_conversion () {
103102 for (bool todo = true ; todo;) {
104103 todo = false ;
105- for (auto def : world () .copy_defs ()) {
104+ for (auto def : world_ .copy_defs ()) {
106105 auto continuation = def->isa_nom <Continuation>();
107106 if (!continuation || !continuation->has_body ()) continue ;
108107
@@ -111,7 +110,7 @@ void Cleaner::eta_conversion() {
111110 auto body = continuation->body ();
112111 if (callee == continuation) break ;
113112
114- if (callee->has_body () && !world () .is_external (callee) && callee->can_be_inlined ()) {
113+ if (callee->has_body () && !world_ .is_external (callee) && callee->can_be_inlined ()) {
115114 auto callee_body = callee->body ();
116115 for (size_t i = 0 , e = body->num_args (); i != e; ++i)
117116 callee->param (i)->replace_uses (body->arg (i));
@@ -131,7 +130,7 @@ void Cleaner::eta_conversion() {
131130 // try to subsume continuations which call a parameter
132131 // (that is free within that continuation) with that parameter
133132 if (auto param = body->callee ()->isa <Param>()) {
134- if (param->continuation () == continuation || world () .is_external (continuation))
133+ if (param->continuation () == continuation || world_ .is_external (continuation))
135134 continue ;
136135
137136 if (body->args () == continuation->params_as_defs ()) {
@@ -181,11 +180,11 @@ void Cleaner::eta_conversion() {
181180
182181void Cleaner::eliminate_params () {
183182 // TODO
184- for (auto ocontinuation : world () .copy_continuations ()) {
183+ for (auto ocontinuation : world_ .copy_continuations ()) {
185184 std::vector<size_t > proxy_idx;
186185 std::vector<size_t > param_idx;
187186
188- if (ocontinuation->has_body () && !world () .is_external (ocontinuation)) {
187+ if (ocontinuation->has_body () && !world_ .is_external (ocontinuation)) {
189188 auto obody = ocontinuation->body ();
190189 for (auto use : ocontinuation->uses ()) {
191190 if (use.index () != 0 || !use->isa_nom <Continuation>())
@@ -201,8 +200,8 @@ void Cleaner::eliminate_params() {
201200 }
202201
203202 if (!proxy_idx.empty ()) {
204- auto ncontinuation = world () .continuation (
205- world () .fn_type (ocontinuation->type ()->ops ().cut (proxy_idx)),
203+ auto ncontinuation = world_ .continuation (
204+ world_ .fn_type (ocontinuation->type ()->ops ().cut (proxy_idx)),
206205 ocontinuation->attributes (), ocontinuation->debug_history ());
207206 size_t j = 0 ;
208207 for (auto i : param_idx) {
@@ -236,14 +235,14 @@ void Cleaner::rebuild() {
236235 importer.type_old2new_ .rehash (world_.types ().capacity ());
237236 importer.def_old2new_ .rehash (world_.defs ().capacity ());
238237
239- for (auto && [_, cont] : world () .externals ()) {
238+ for (auto && [_, cont] : world_ .externals ()) {
240239 if (cont->is_exported ())
241240 importer.import (cont);
242241 }
243242
244243 swap (importer.world (), world_);
245244
246- // verify(world() );
245+ // verify(world_ );
247246
248247 todo_ |= importer.todo ();
249248}
@@ -262,20 +261,20 @@ void Cleaner::verify_closedness() {
262261 }
263262 };
264263
265- for (auto def : world () .defs ())
264+ for (auto def : world_ .defs ())
266265 check (def);
267266}
268267
269268void Cleaner::within (const Def* def) {
270269 if (def->isa <Param>()) return ; // TODO remove once Params are within World's sea of nodes
271- assert (world () .types ().contains (def->type ()));
272- assert_unused (world () .defs ().contains (def));
270+ assert (world_ .types ().contains (def->type ()));
271+ assert_unused (world_ .defs ().contains (def));
273272}
274273
275274void Cleaner::clean_pe_info (std::queue<Continuation*> queue, Continuation* cur) {
276275 assert (cur->has_body ());
277276 auto body = cur->body ();
278- assert (body->arg (1 )->type () == world () .ptr_type (world () .indefinite_array_type (world () .type_pu8 ())));
277+ assert (body->arg (1 )->type () == world_ .ptr_type (world_ .indefinite_array_type (world_ .type_pu8 ())));
279278 auto next = body->arg (3 );
280279 auto msg = body->arg (1 )->as <Bitcast>()->from ()->as <Global>()->init ()->as <DefiniteArray>();
281280
@@ -296,7 +295,7 @@ void Cleaner::clean_pe_infos() {
296295 queue.push (continuation);
297296 };
298297
299- for (auto && [_, cont] : world () .externals ())
298+ for (auto && [_, cont] : world_ .externals ())
300299 if (cont->has_body ()) enqueue (cont);
301300
302301 while (!queue.empty ()) {
@@ -326,9 +325,9 @@ void Cleaner::cleanup_fix_point() {
326325 eta_conversion ();
327326 eliminate_params ();
328327 rebuild (); // resolve replaced defs before going to resolve_loads
329- todo_ |= resolve_loads (world () );
328+ todo_ |= resolve_loads (world_ );
330329 rebuild ();
331- if (!world () .is_pe_done ())
330+ if (!world_ .is_pe_done ())
332331 todo_ |= partial_evaluation (world_);
333332 else
334333 clean_pe_infos ();
@@ -339,9 +338,9 @@ void Cleaner::cleanup() {
339338 world_.VLOG (" start cleanup" );
340339 cleanup_fix_point ();
341340
342- if (!world () .is_pe_done ()) {
343- world () .mark_pe_done ();
344- for (auto def : world () .defs ()) {
341+ if (!world_ .is_pe_done ()) {
342+ world_ .mark_pe_done ();
343+ for (auto def : world_ .defs ()) {
345344 if (auto cont = def->isa_nom <Continuation>())
346345 cont->destroy_filter ();
347346 }
@@ -353,7 +352,7 @@ void Cleaner::cleanup() {
353352 world_.VLOG (" end cleanup" );
354353#if THORIN_ENABLE_CHECKS
355354 verify_closedness ();
356- debug_verify (world () );
355+ debug_verify (world_ );
357356#endif
358357}
359358
0 commit comments