Commit Graph

12 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
1cd91b6f30 Eliminate layout::Cursor from cton_frontend.
Replace all uses with a FuncCursor.

Avoid the anti-pattern of passing parts of a function around as
independent references.
2017-09-21 12:24:27 -07:00
Dan Gohman
5194298d9b Fix a typo in a comment. 2017-09-20 08:17:40 -07:00
Dan Gohman
bbe056bf9d Make passes assert their dependencies consistently. (#156)
* Make passes assert their dependencies consistently.

This avoids ambiguity about whose responsibility it is to run
to compute cfg, domtree, and loop_analysis data.

* Reset the `valid` flag in DominatorTree's `clear()`.

* Remove the redundant assert from DominatorTree::with_function.

* Remove the message strings from obvious asserts.

This avoids having them spill out into multiple lines.

* Refactor calls to `compute` on `Context` objects into helper functions.
2017-09-14 14:38:53 -07:00
Dan Gohman
e2f0fe58d1 Move logic out of cton-util wasm.
Give LoopAnalysis `is_valid` and `ensure` functions similar to
DominatorTree and others, so that it can be computed on demand in the
same way.

This removes the last need for src/wasm.rs to have embedded knowledge
of the dependencies of the passes it's running.
2017-09-12 16:32:47 -07:00
Dan Gohman
2efdc0ed37 Update rustfmt to 0.9.0. 2017-08-31 10:44:59 -07:00
Jakob Stoklund Olesen
7e08b14cf6 Split EntityMap into entity::PrimaryMap and entity::EntityMap.
The new PrimaryMap replaces the primary EntityMap and the PrimaryEntityData
marker trait which was causing some confusion. We now have a clear
division between the two types of maps:

- PrimaryMap is used to assign entity numbers to the primary data for an
  entity.
- EntityMap is a secondary mapping adding additional info.

The split also means that the secondary EntityMap can now behave as if
all keys have a default value. This means that we can get rid of the
annoying ensure() and get_or_default() methods ther were used everywhere
instead of indexing. Just use normal indexing now; non-existent keys
will return the default value.
2017-08-18 16:04:43 -07:00
Jakob Stoklund Olesen
dba0df787c Move most Cursor methods into a CursorBase trait.
The Cursor navigation methods all just depend on the cursor's position
and layout reference. Make a CursorBase trait that provides access to
this information with methods and implement the navigation methods on
top of that.

This makes it possible to have multiple types implement the cursor
interface.
2017-08-04 09:08:24 -07:00
Jakob Stoklund Olesen
b6cff6a98a Move EntityRef and entity_impl! into a new module.
The EntityRef trait is used by more than just the EntityMap now, so it
should live in its own module.

Also move the entity_impl! macro into the new module so it can be used
for defining new entity references anywhere.
2017-06-20 10:16:27 -07:00
Jakob Stoklund Olesen
ea8a8a95a8 Remove the ebb_dominates function.
This is now subsumed by the generic 'dominates' function.
2017-06-12 14:59:34 -07:00
Jakob Stoklund Olesen
f22461b4b3 Stop using cfg.postorder_ebbs().
Switch to the new domtree.cfg_postorder() which returns a reference to a
pre-computed post-order instead of allocating memory and computing a new
post-order.
2017-06-07 13:38:27 -07:00
Denis Merigoux
e47f4a49fb LICM pass (#87)
* LICM pass

* Uses loop analysis to detect loop tree
* For each loop (starting with the inner ones), create a pre-header and move there loop-invariant instructions
* An instruction is loop invariant if it does not use as argument a value defined earlier in the loop
* File tests to check LICM's correctness
* Optimized pre-header creation
If the loop already has a natural pre-header, we use it instead of creating a new one.
The natural pre-header of a loop is the only predecessor of the header it doesn't dominate.
2017-06-07 11:27:22 -07:00
Denis Merigoux
b02ccea8dc Loop analysis of the IL
* Implemented in two passes
* First pass discovers the loops headers (they dominate one of their predecessors)
* Second pass traverses the blocks of each loop
* Discovers the loop tree structure
* Offers a new LoopAnalysis data structure queried from outside the module
2017-06-02 15:30:45 -07:00