Commit Graph

2437 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
bd72439fbc Document binary encodings.
Describe the meta-language data structures that are built to represent
instruction encodings.

Begin a metaref glossary.
2016-08-02 16:02:20 -07:00
Jakob Stoklund Olesen
f5008567c9 Add PrimaryEntityData marker trait.
Require this trait on the value type stored in an EntityMap to 'unlock' the
methods intended for primary entity maps that are allowed to create references
with the 'push method.

This prevents accidentally depending on these methods in secondary maps.
2016-08-01 19:52:57 -07:00
Morgan Phillips
549a14bf96 Merge branch 'master' of github.com:stoklund/cretonne into cfg-fix 2016-08-01 18:06:59 -07:00
Morgan Phillips
80abf8b1f0 Remove uses of EntityMap::len. 2016-08-01 18:04:25 -07:00
Jakob Stoklund Olesen
2c1e80b0e0 Remove the cfg::predecessors_iter() method and iterator.
This iterator enumerates all EBB references whether they are in the layout or
not. That is usually not what is needed when working with the CFG.

It is better to iterate over EBB referrences in layout order, or in reverse
post-order and then call the get_predecessors() method for each Ebb reference.

See the new implementation of print_cfg::cfg_connections().
2016-08-01 15:18:34 -07:00
Jakob Stoklund Olesen
02c1bb8f2c Print CFG edges from func.layout instead of cfg.predecessors_iter.
EBBs not in the layout should never be printed as part of the CFG.
2016-08-01 15:18:34 -07:00
Morgan Phillips
e9cfcf4f78 Improve the structure and comments of the module. 2016-08-01 15:00:08 -07:00
Morgan Phillips
5a38ca2db7 Remove println\! 2016-08-01 12:15:08 -07:00
Morgan Phillips
19a47d57b3 Add a dominator tree implementation. 2016-07-31 21:40:11 -07:00
Morgan Phillips
0ce01c1b8d Clean up the CFG representation. 2016-07-31 21:31:18 -07:00
Jakob Stoklund Olesen
bbdae39cb9 Add EntityMap::with_capacity.
Create a secondary entity map with space reserved for a known range of entity
references.

Add dfg.num_ebbs() and dfg.num_insts() methods to provide capacities.
2016-07-29 15:59:09 -07:00
Jakob Stoklund Olesen
14027660c5 Use sub-shells instead of pushd / popd.
The push and pop commands print the directory stack to stdout, while subshells
and cd is quiet.
2016-07-29 12:35:56 -07:00
Morgan Phillips
a9748dff02 Remove innacurate comments. 2016-07-28 17:51:50 -07:00
Morgan Phillips
858d756631 Merge branch 'master' of github.com:stoklund/cretonne into bleh 2016-07-28 17:49:48 -07:00
Morgan Phillips
82ff64820c Simplify the reverse_postorder_ebbs implementation. 2016-07-28 17:49:25 -07:00
Jakob Stoklund Olesen
ad79ad753d Documentation typos. 2016-07-27 16:10:02 -07:00
Morgan Phillips
e94d7c2a99 Avoid cloning levels 2016-07-26 17:13:11 -07:00
Morgan Phillips
1cd6e35a42 Give the test module a more apt name. 2016-07-26 12:07:18 -07:00
Morgan Phillips
42b9835363 Fix broken reverse_postorder_ebbs implementation.
The previous implementation was actually a reverse preorder walk.
2016-07-26 02:54:42 -07:00
Morgan Phillips
71bf589af3 Fix the test-all script so that it works with directories 2016-07-25 19:19:46 -07:00
Morgan Phillips
400504d321 Cargo-fmt and cleanup. 2016-07-25 18:51:58 -07:00
Morgan Phillips
63b58214f7 Use cton_reader to simplify cfg traversal tests. 2016-07-25 18:49:39 -07:00
Morgan Phillips
bb7ecc8753 Change variable name to something more descriptive. 2016-07-25 01:05:15 -07:00
Morgan Phillips
91ced8df90 make postorder_ebbs into actually reverse_postorder_ebbs.
This is a more accurate description. Further return the ebbs in a
btreemap so that the index of each Ebb (its order of visitation) is
quick to lookup.
2016-07-25 00:41:34 -07:00
Jakob Stoklund Olesen
ae98edf8cc Add an analyze_branch method to InstructionData.
Rather than switching on instruction formats to discover the destination of a
branch, use the analyze_branch method which returns a BranchInfo enum with just
the relevant information.

This makes CFG algorithms independent of future instruction formats for
branches. Only analyze_branch needs to be updated when adding a new format.
2016-07-22 15:38:53 -07:00
Jakob Stoklund Olesen
20fc675fc0 Parse the BranchTable instruction format.
Resolve the jump table reference immediately since all jump tables are declared
in the preamble.
2016-07-22 15:16:14 -07:00
Jakob Stoklund Olesen
274671d12a Implement jump tables.
- Add a ir::jumptable module with a JumpTableData struct representing the vector
  of destinations.
- Add an entity map of jump tables to the Function.
- Parse and write jump tables in the function preamble.
- Rewrite EBB references in jumptables after parsing.
2016-07-22 14:48:53 -07:00
Jakob Stoklund Olesen
410c1390d1 Add a keys() iterator to EntityMap. 2016-07-22 14:48:53 -07:00
Jakob Stoklund Olesen
f116f03327 Move entry_block() into Layout.
The single entry block in a function is simply the first block in the layout.

Remove the 'entry' keyword from the textual IL, the lexer and parser.
2016-07-22 10:06:51 -07:00
Jakob Stoklund Olesen
38815dcca3 Rename the 'repr' module to 'ir'.
This module and its submodules define the Intermidiate Representation of the
Cretonne IL.
2016-07-22 09:34:28 -07:00
Morgan Phillips
367752be1d Replace btreesets with vectors. 2016-07-21 22:44:13 -07:00
Morgan Phillips
bdab73b0c7 Cargo-fmt fixes 2016-07-21 15:24:07 -07:00
Morgan Phillips
761fb54d8a Add support for postorder traversal of the cfg. 2016-07-21 15:22:27 -07:00
Morgan Phillips
30eb25d013 Track predecessors as well as successors in the CFG 2016-07-21 12:36:51 -07:00
Morgan Phillips
2caa802f50 Use EntityMap instead of BTreeMap 2016-07-21 12:08:02 -07:00
Jakob Stoklund Olesen
89ba9626c7 Move IR modules under repr/.
Use the cretonne::repr module as a common namespace for sub-modules defining the
in-memory representation of Cretonn IL.
2016-07-19 14:10:30 -07:00
Jakob Stoklund Olesen
6e04ec5df9 Prepare for repr sub-modules. 2016-07-19 13:53:02 -07:00
Jakob Stoklund Olesen
c1806d0ab0 Use DataFlowGraph in Function.
Replace the three tables instructions, extended_basic_blocks, and
extended_values with a single 'dfg' public member.

Clients using Function are changed to refer to func.layout and func.dfg
respectively.
2016-07-19 13:05:28 -07:00
Jakob Stoklund Olesen
39d3a8e3d7 Implement separate data flow graph module.
The DFG keeps track of instruction definitions, values, and EBBs.

Store the primary definition of each instruction: Opcode and operands.
Track SSA values as either the result of an instruction or EBB arguments.
2016-07-19 12:51:34 -07:00
Jakob Stoklund Olesen
d64e7fb576 Don't require Clone + Default for EntityMap values.
There are two kinds of entity maps:

- A primary map is used to allocate entity references and store the primary
  entity data. This map only grows when adding new entities with 'push'.

- A secondary map contains additional information about entities in a primary
  map. This map always grows with 'ensure', making default entries for any
  unknown primary entities.

Only require the 'Default + Clone' traits for values stored in a secondary map.

Also remove the 'grow automatically' feature of the IndexMut implementation.
This means that clients need to call 'ensure' whenever using a potentially
unknown entity reference.

The 'grow automatically' feature could not be implemented for the Index trait,
and it seems unfortunate to have different semantics for Index and IndexMut.
2016-07-19 09:53:55 -07:00
Morgan Phillips
f63d7941ed Fix formatting 2016-07-18 20:30:33 -07:00
Jakob Stoklund Olesen
8c58fe4631 Use EBB layout order almost everywhere.
The ebbs_numerically() function was a workaround for the unimplemented EBB layout
order.
2016-07-18 18:52:35 -07:00
Jakob Stoklund Olesen
4ee2ab5042 Implement IntoIterator for Layout. 2016-07-18 18:47:42 -07:00
Jakob Stoklund Olesen
e926674b4e Replace inst_order with Layout in Function.
The Layout also handles EBB layout, so new append_ebb calls are necessary.

- Rewrite callers to use the public data member 'layout'.
- Implement Debug for Function in terms of the write module to avoid deriving
  it.
2016-07-18 18:23:32 -07:00
Jakob Stoklund Olesen
2f74efd5fc More layout tests and bugfixes.
Fix bugs in append methods. Linked lists are hard.
2016-07-18 18:09:31 -07:00
Jakob Stoklund Olesen
21c2474d4d Implement instruction order.
Each EBB has a linked list of instructions in layout order.
2016-07-18 15:05:26 -07:00
Morgan Phillips
0bee6b3c96 Merge pull request #9 from mrrrgn/testutils
Move test utility functions to their own module
2016-07-18 14:42:58 -07:00
Jakob Stoklund Olesen
a641bdb1f2 Add Layout::ebbs() and the corresponding iterator.
Implement some tests, fix bugs in is_ebb_inserted().
2016-07-18 14:36:27 -07:00
Morgan Phillips
28c1eda4f6 Move test utility functions to their own module 2016-07-18 14:28:00 -07:00
Jakob Stoklund Olesen
b9975f77af Add an EntityRef::wrap() method.
This is the opposite of unwrap(). It converts the ad-hoc null references like
NO_EBB and NO_INST into the more standard Option<Ebb> type which unfortunately
takes twice as much space in data structures.
2016-07-18 14:27:12 -07:00