Commit Graph

10588 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
d73c2c9dc0 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
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
0ef0937016 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
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
bd2945ab5e Implement instruction order.
Each EBB has a linked list of instructions in layout order.
2016-07-18 15:05:26 -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
b8fbd0668c Merge pull request #9 from mrrrgn/testutils
Move test utility functions to their own module
2016-07-18 14:42:58 -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
0d924c67d0 Add Layout::ebbs() and the corresponding iterator.
Implement some tests, fix bugs in is_ebb_inserted().
2016-07-18 14:36:27 -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
ea3d2f0bbd Move test utility functions to their own module 2016-07-18 14:28:00 -07:00
Morgan Phillips
28c1eda4f6 Move test utility functions to their own module 2016-07-18 14:28:00 -07:00
Jakob Stoklund Olesen
c76ba3a7f6 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
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
Morgan Phillips
32f40168b5 Remove extra newline 2016-07-16 15:33:30 -07:00
Morgan Phillips
8bbc75e39f Remove extra newline 2016-07-16 15:33:30 -07:00
Jakob Stoklund Olesen
d3ed162bac Begin a layout module.
The Layout data structure will keep track of the order of EBBs and their
instructions.

WIP.
2016-07-15 16:12:31 -07:00
Jakob Stoklund Olesen
5c15dcdebb Begin a layout module.
The Layout data structure will keep track of the order of EBBs and their
instructions.

WIP.
2016-07-15 16:12:31 -07:00
Jakob Stoklund Olesen
4358a4d96e Implement EntityRef for most of the entities module.
The only exception is Value which has two dimensions.
2016-07-15 16:03:14 -07:00
Jakob Stoklund Olesen
99464bc29d Implement EntityRef for most of the entities module.
The only exception is Value which has two dimensions.
2016-07-15 16:03:14 -07:00
Jakob Stoklund Olesen
e874393419 Add an entity_map module.
This supports the pattern of creating structs wrapping a u32 and using them as
indexes into a vector of entities. These entity references should implement the
EntityRef trait.

The EntityMap is a generic map from an EntityRef to some value type. It expects
densely indexed entities and uses a Vec to represent the mapping compactly.
2016-07-15 15:17:11 -07:00
Jakob Stoklund Olesen
191c607bf9 Add an entity_map module.
This supports the pattern of creating structs wrapping a u32 and using them as
indexes into a vector of entities. These entity references should implement the
EntityRef trait.

The EntityMap is a generic map from an EntityRef to some value type. It expects
densely indexed entities and uses a Vec to represent the mapping compactly.
2016-07-15 15:17:11 -07:00
Morgan Phillips
c69ebe6a46 Merge pull request #8 from mrrrgn/graphviz
Graphviz
2016-07-14 13:44:57 -07:00
Morgan Phillips
2901198815 Merge pull request #8 from mrrrgn/graphviz
Graphviz
2016-07-14 13:44:57 -07:00
Morgan Phillips
41d4cdba46 Add print-cfg tests 2016-07-14 13:43:11 -07:00
Morgan Phillips
5bcce51bd9 Add print-cfg tests 2016-07-14 13:43:11 -07:00
Morgan Phillips
4e74d85056 Id CFG graphs by function name 2016-07-14 12:22:08 -07:00
Morgan Phillips
0cdcf29308 Id CFG graphs by function name 2016-07-14 12:22:08 -07:00
Morgan Phillips
c0a52d377e Merge pull request #7 from mrrrgn/graphviz
Add a print-cfg subcommand.
2016-07-13 14:49:42 -07:00
Morgan Phillips
428e89c566 Merge pull request #7 from mrrrgn/graphviz
Add a print-cfg subcommand.
2016-07-13 14:49:42 -07:00
Morgan Phillips
53ed7f5ea3 Add a print-cfg subcommand.
The command returns parses a .cton file, builds a CFG, and prints it to
stdout in graphviz format.
2016-07-13 14:31:05 -07:00
Morgan Phillips
4a6e53f90d Add a print-cfg subcommand.
The command returns parses a .cton file, builds a CFG, and prints it to
stdout in graphviz format.
2016-07-13 14:31:05 -07:00
Morgan Phillips
6a516c606c Merge pull request #6 from mrrrgn/cfg-1
Control Flow Graph
2016-07-13 11:13:51 -07:00
Morgan Phillips
83279026ba Merge pull request #6 from mrrrgn/cfg-1
Control Flow Graph
2016-07-13 11:13:51 -07:00
Morgan Phillips
985606b12c Replace Results with assertions in invariant cases.
It seems reasonable that certain non-recoverable errors during the building of the
CFG should crash.
2016-07-13 11:04:39 -07:00
Morgan Phillips
295a4eb03f Replace Results with assertions in invariant cases.
It seems reasonable that certain non-recoverable errors during the building of the
CFG should crash.
2016-07-13 11:04:39 -07:00
Morgan Phillips
24b421bd68 Remove misleading test comments 2016-07-12 14:46:24 -07:00
Morgan Phillips
79c7ae6233 Remove misleading test comments 2016-07-12 14:46:24 -07:00
Morgan Phillips
522227c965 Cargo-fmt fixes 2016-07-12 14:42:49 -07:00
Morgan Phillips
180eae3bb5 Cargo-fmt fixes 2016-07-12 14:42:49 -07:00
Morgan Phillips
e4a9c5c13c Add a Control Flow Graph representation.
The CFG must be instantiated against an existing function but may be
modified after creation
2016-07-12 14:37:37 -07:00
Morgan Phillips
c6b1388fdc Add a Control Flow Graph representation.
The CFG must be instantiated against an existing function but may be
modified after creation
2016-07-12 14:37:37 -07:00
Morgan Phillips
942c4b96c9 Ignore cargo-fmt and vim related files 2016-07-12 13:59:27 -07:00
Morgan Phillips
84357c3402 Ignore cargo-fmt and vim related files 2016-07-12 13:59:27 -07:00
Jakob Stoklund Olesen
27b2c90a27 Add tests for parsing call and return. 2016-07-08 16:28:19 -07:00
Jakob Stoklund Olesen
ad5e6b14cf Add tests for parsing call and return. 2016-07-08 16:28:19 -07:00
Jakob Stoklund Olesen
8cb198b23c Delete the concept of 'local SSA form'.
This was supposed to make verification fast, but WebAssembly is no longer in
this form since it's blocks can produce values.

Also, computing a flow graph and dominator tree is really fast anyway.
2016-07-08 16:26:11 -07:00
Jakob Stoklund Olesen
e7adcf9af9 Delete the concept of 'local SSA form'.
This was supposed to make verification fast, but WebAssembly is no longer in
this form since it's blocks can produce values.

Also, computing a flow graph and dominator tree is really fast anyway.
2016-07-08 16:26:11 -07:00
Jakob Stoklund Olesen
3839281414 Define a return instruction.
It is possible to return multiple values from a function, so ReturnData contains
a VariableArgs instance.

We don't want return instructions to appear as 'return (v1)', so tweak the
printing of VariableArgs so the parantheses are added externally.
2016-07-08 16:19:26 -07:00
Jakob Stoklund Olesen
520a438c42 Define a return instruction.
It is possible to return multiple values from a function, so ReturnData contains
a VariableArgs instance.

We don't want return instructions to appear as 'return (v1)', so tweak the
printing of VariableArgs so the parantheses are added externally.
2016-07-08 16:19:26 -07:00