Commit Graph

8918 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
8422976d78 Add a ReplaceBuilder instruction builder.
The DataFlowGraph::replace(inst) method returns an instruction builder
that will replace an instruction in-place.

This will be used when transforming instructions, replacing an old
instruction with a new (legal) way of computing its primary value. Since
primary result values are essentially instruction pointers, this is the
only way of replacing the definition of a value.

If secondary result values match the old instruction in both number and
types, they can be reused. If not, added a detach_secondary_results()
method for detaching old secondary values.
2016-10-20 13:33:49 -07:00
Jakob Stoklund Olesen
bb0bb1e91c Add a ReplaceBuilder instruction builder.
The DataFlowGraph::replace(inst) method returns an instruction builder
that will replace an instruction in-place.

This will be used when transforming instructions, replacing an old
instruction with a new (legal) way of computing its primary value. Since
primary result values are essentially instruction pointers, this is the
only way of replacing the definition of a value.

If secondary result values match the old instruction in both number and
types, they can be reused. If not, added a detach_secondary_results()
method for detaching old secondary values.
2016-10-20 13:33:49 -07:00
Jakob Stoklund Olesen
d763bedeaa Rename Builder to InsertBuilder.
This instruction builder inserts an instruction at the cursor position.
We'll add other kinds of builders shortly.
2016-10-20 11:16:58 -07:00
Jakob Stoklund Olesen
634de93337 Rename Builder to InsertBuilder.
This instruction builder inserts an instruction at the cursor position.
We'll add other kinds of builders shortly.
2016-10-20 11:16:58 -07:00
Jakob Stoklund Olesen
5f140eddf7 Switch InstrBuilder to the one-shot builder pattern.
All the InstrBuilder methods now consume the builder, and the non-leaf
methods return the dfg mutable reference they were holding.

This makes it possible to construct instruction builders that are only
safe to use once because they are doing more advanced value rewriting.
2016-10-19 19:33:48 -07:00
Jakob Stoklund Olesen
6db94bb980 Switch InstrBuilder to the one-shot builder pattern.
All the InstrBuilder methods now consume the builder, and the non-leaf
methods return the dfg mutable reference they were holding.

This makes it possible to construct instruction builders that are only
safe to use once because they are doing more advanced value rewriting.
2016-10-19 19:33:48 -07:00
Jakob Stoklund Olesen
78312c6c46 Add a Cursor::ins() method which constructs a Builder.
Rewrite Builder uses in test cases to use this method and construct a
new builder for each instruction. This pattern allows us to change the
InstBuilder trait to a one-shot implementation that can only create a
single instruction.

Don't re-export the Builder struct, it is less important than the
InstBuilder trait, and we may get more implementations.
2016-10-19 19:33:19 -07:00
Jakob Stoklund Olesen
ab910b3f58 Add a Cursor::ins() method which constructs a Builder.
Rewrite Builder uses in test cases to use this method and construct a
new builder for each instruction. This pattern allows us to change the
InstBuilder trait to a one-shot implementation that can only create a
single instruction.

Don't re-export the Builder struct, it is less important than the
InstBuilder trait, and we may get more implementations.
2016-10-19 19:33:19 -07:00
Jakob Stoklund Olesen
4cd33b210e Use more precise lifetimes for Builder.
Distinguish the lifetime of the Cursor and its referenced function
layout.

Use two separate function lifetimes: 'fc and 'fd. The borrow checker
seems to get confused if we don't.
2016-10-19 19:32:57 -07:00
Jakob Stoklund Olesen
368b12e7cd Use more precise lifetimes for Builder.
Distinguish the lifetime of the Cursor and its referenced function
layout.

Use two separate function lifetimes: 'fc and 'fd. The borrow checker
seems to get confused if we don't.
2016-10-19 19:32:57 -07:00
Jakob Stoklund Olesen
eef5de1cf0 Generate an InstBuilder trait.
All of the instruction format an opcode methods are emitted as an
InstBuilder trait instead of adding them to the Bulder struct directly.
The methods only make use of the InstBuilderBase methods to create new
instructions.

This makes it possible to reuse the InstBuilder trait for different ways
of inserting instructions.
2016-10-19 18:21:17 -07:00
Jakob Stoklund Olesen
58168bcd07 Generate an InstBuilder trait.
All of the instruction format an opcode methods are emitted as an
InstBuilder trait instead of adding them to the Bulder struct directly.
The methods only make use of the InstBuilderBase methods to create new
instructions.

This makes it possible to reuse the InstBuilder trait for different ways
of inserting instructions.
2016-10-19 18:21:17 -07:00
Jakob Stoklund Olesen
499fefebd9 Rename lifetimes in layout.rs to 'f
These lifetimes all represent the lifetime of the Function.
2016-10-19 16:23:08 -07:00
Jakob Stoklund Olesen
c8f28e5902 Rename lifetimes in layout.rs to 'f
These lifetimes all represent the lifetime of the Function.
2016-10-19 16:23:08 -07:00
Jakob Stoklund Olesen
cdb141d138 Also rebuild if build.rs itself changes.
We already have all the meta/**.py as dependencies.
2016-10-19 12:03:50 -07:00
Jakob Stoklund Olesen
cba5cdd22e Also rebuild if build.rs itself changes.
We already have all the meta/**.py as dependencies.
2016-10-19 12:03:50 -07:00
Jakob Stoklund Olesen
a5913e6489 Add more expansion patterns.
RISC-V does not have a flags register, and thus no add-with-carry
instructions. Neither does MIPS.

Add expansions of these instructions in terms of iadd and icmp.
2016-10-19 11:24:08 -07:00
Jakob Stoklund Olesen
b068bace9d Add more expansion patterns.
RISC-V does not have a flags register, and thus no add-with-carry
instructions. Neither does MIPS.

Add expansions of these instructions in terms of iadd and icmp.
2016-10-19 11:24:08 -07:00
Jakob Stoklund Olesen
1e18e66ebe Bump filecheck version to 0.0.1, allow publication. 2016-10-18 13:33:39 -07:00
Jakob Stoklund Olesen
0b674fb28b Bump filecheck version to 0.0.1, allow publication. 2016-10-18 13:33:39 -07:00
Jakob Stoklund Olesen
df06f19979 Parse signature and function declarations.
Also add support for parsing call and call_indirect instructions.
2016-10-18 13:19:24 -07:00
Jakob Stoklund Olesen
d85225c537 Parse signature and function declarations.
Also add support for parsing call and call_indirect instructions.
2016-10-18 13:19:24 -07:00
Jakob Stoklund Olesen
cdb63a547e Add result values to call instructions too.
The make_inst_results() method now understands direct and indirect
calls, and can allocate result values matching the return types of the
function call.
2016-10-18 13:08:50 -07:00
Jakob Stoklund Olesen
7d7a7875d5 Add result values to call instructions too.
The make_inst_results() method now understands direct and indirect
calls, and can allocate result values matching the return types of the
function call.
2016-10-18 13:08:50 -07:00
Jakob Stoklund Olesen
1bcb8e25a2 Add signatures and ext_funcs tables to DataFlowGraph.
These two tables are used to keep track of type signatures of function
calls as well as external function references used in direct function
calls.

Also add an ExtFuncData struct representing an external function that
can be called directly.
2016-10-18 11:28:03 -07:00
Jakob Stoklund Olesen
c961e89fdc Add signatures and ext_funcs tables to DataFlowGraph.
These two tables are used to keep track of type signatures of function
calls as well as external function references used in direct function
calls.

Also add an ExtFuncData struct representing an external function that
can be called directly.
2016-10-18 11:28:03 -07:00
Jakob Stoklund Olesen
bdc95990d4 Add call and call_indirect instructions.
Add a new IndirectCall instruction format which has a value callee as
well as the call arguments.

Define call and call_indirect instructions.
2016-10-18 10:04:06 -07:00
Jakob Stoklund Olesen
e4e1c30f87 Add call and call_indirect instructions.
Add a new IndirectCall instruction format which has a value callee as
well as the call arguments.

Define call and call_indirect instructions.
2016-10-18 10:04:06 -07:00
Jakob Stoklund Olesen
b8a76822cf Track signatures and function references in the source map. 2016-10-18 09:43:20 -07:00
Jakob Stoklund Olesen
8055ac681c Track signatures and function references in the source map. 2016-10-18 09:43:20 -07:00
Jakob Stoklund Olesen
80a6ae203d Generalize def_inst() to def_entity().
Use this source map method for assigning a location to any entity whose
source number is not exposed. This could be

- Instructions.
- Signatures defined implicitly by function decls.

These entities only appear in the location map, not the entity number
maps.
2016-10-18 09:38:05 -07:00
Jakob Stoklund Olesen
45cf655ce4 Generalize def_inst() to def_entity().
Use this source map method for assigning a location to any entity whose
source number is not exposed. This could be

- Instructions.
- Signatures defined implicitly by function decls.

These entities only appear in the location map, not the entity number
maps.
2016-10-18 09:38:05 -07:00
Jakob Stoklund Olesen
f9734458f8 Promote the src/tools crate to the top-level workspace.
The 'src' and 'tests' top-level directories now contain tools sources
and integration tests for any of the library crates.
2016-10-17 15:04:29 -07:00
Jakob Stoklund Olesen
a8a79df620 Promote the src/tools crate to the top-level workspace.
The 'src' and 'tests' top-level directories now contain tools sources
and integration tests for any of the library crates.
2016-10-17 15:04:29 -07:00
Jakob Stoklund Olesen
846db00a21 Move library crates under 'lib/'.
Give these crates each a more standard directory layout with sources in
a 'src' sub-sirectory and Cargo.toml in the top lib/foo directory.

Add license and description fields to each.

The build script for the cretonne crate now lives in
'lib/cretonne/build.rs' separating it from the normal library sources
under 'lib/cretonne/src'.
2016-10-17 14:44:43 -07:00
Jakob Stoklund Olesen
0764df28b5 Move library crates under 'lib/'.
Give these crates each a more standard directory layout with sources in
a 'src' sub-sirectory and Cargo.toml in the top lib/foo directory.

Add license and description fields to each.

The build script for the cretonne crate now lives in
'lib/cretonne/build.rs' separating it from the normal library sources
under 'lib/cretonne/src'.
2016-10-17 14:44:43 -07:00
Jakob Stoklund Olesen
af6355e2ef Move the 'meta' dir to 'lib/cretonne/meta'.
The 'lib/cretonne' directory will be the new root of a stand-alone
cretonne crate containg both Python and Rust sources.

This is in preparation for publishing crates on crates.io.
2016-10-17 14:19:23 -07:00
Jakob Stoklund Olesen
e7f30a40b4 Move the 'meta' dir to 'lib/cretonne/meta'.
The 'lib/cretonne' directory will be the new root of a stand-alone
cretonne crate containg both Python and Rust sources.

This is in preparation for publishing crates on crates.io.
2016-10-17 14:19:23 -07:00
Jakob Stoklund Olesen
680387a53a Remove test_utils.
These test utilities have been subsumed by ir::Builder.
2016-10-14 15:17:34 -07:00
Jakob Stoklund Olesen
8480879f3e Remove test_utils.
These test utilities have been subsumed by ir::Builder.
2016-10-14 15:17:34 -07:00
Jakob Stoklund Olesen
98308177cc Switch domtree tests to using Builder. 2016-10-14 15:16:29 -07:00
Jakob Stoklund Olesen
af8f8d98e6 Switch domtree tests to using Builder. 2016-10-14 15:16:29 -07:00
Jakob Stoklund Olesen
8fb8a41f8e Give Builder a Cursor.
The Builder keeps track of a position in the layout and inserts new
instructions there.

Add insert_ebb() and ebb() methods to Builder.

Use Builder in the cfg tests.
2016-10-14 15:02:58 -07:00
Jakob Stoklund Olesen
d4197ca731 Give Builder a Cursor.
The Builder keeps track of a position in the layout and inserts new
instructions there.

Add insert_ebb() and ebb() methods to Builder.

Use Builder in the cfg tests.
2016-10-14 15:02:58 -07:00
Jakob Stoklund Olesen
7aef6bd535 Add Cursor::insert_ebb() method.
Insert an EBB at the current position and switch to inserting
instructions there. Call the relevant Layout methods to do so.
2016-10-14 14:01:49 -07:00
Jakob Stoklund Olesen
eb5cea7c6a Add Cursor::insert_ebb() method.
Insert an EBB at the current position and switch to inserting
instructions there. Call the relevant Layout methods to do so.
2016-10-14 14:01:49 -07:00
Jakob Stoklund Olesen
a41b34c11c Add Layout::insert_ebb_after() method.
Symmetrical with the existing insert_ebb().
2016-10-14 13:54:26 -07:00
Jakob Stoklund Olesen
8592979fc9 Add Layout::insert_ebb_after() method.
Symmetrical with the existing insert_ebb().
2016-10-14 13:54:26 -07:00
Jakob Stoklund Olesen
d1fd91021d Add Layout::split_ebb().
This method splits an EBB in two and moves trailing instructions to a
new EBB.
2016-10-14 12:33:54 -07:00
Jakob Stoklund Olesen
10c579e0cd Add Layout::split_ebb().
This method splits an EBB in two and moves trailing instructions to a
new EBB.
2016-10-14 12:33:54 -07:00