Commit Graph

571 Commits

Author SHA1 Message Date
Dan Gohman
f276a021cb Update wasmstandalone for API changes.
This updates to the latest faerie and cretonne API changes.
2018-02-22 09:44:02 -08:00
Dan Gohman
be9e3e88e4 Emit wasm data initializers as faerie data segments.
This is a temporary measure while other parts of the system are being
developed, and will need to be replaced by a proper solution.
2017-11-04 15:28:19 -07:00
Dan Gohman
c30116d948 Fix copypasta in a FIXME message. 2017-11-02 07:42:03 -07:00
Dan Gohman
ca1b461375 Begin internal reorganization.
This begins reorganizing how translation and compilation occur, and
setting up infrastructure for imports/exports and relocations. It
splits parts out of StandaloneRuntime, forming Module, Compilation,
and Instance structs, which can be used more independently.

It also simplifies the command-line interface, in a step towards
making simple tools that just expose the functionality of the
libraries.
2017-10-13 14:47:01 -07:00
Dan Gohman
142b17a3f0 Delete an unused settings builder. 2017-10-10 09:47:04 -07:00
Dan Gohman
f90e7ade86 Enable the cretonne verifier by default in debug builds. 2017-10-05 18:01:27 -07:00
Dan Gohman
b5732bc200 On error, always print the error message and exit with non-zero status. 2017-10-05 08:49:32 -07:00
Dan Gohman
c8e015f31a Remove an unused argument. 2017-10-04 12:32:45 -07:00
Dan Gohman
fc857a758e Remove an unneeded block. 2017-10-04 12:22:32 -07:00
Dan Gohman
b4e7e918cc Use the correct index for printing function definitions when imports are present. 2017-10-04 12:22:07 -07:00
Dan Gohman
23bafd1218 Split the runtime and execution code into separate crates. 2017-10-03 14:57:52 -07:00
Dan Gohman
865a3d9f31 Rename wasmstandalone::StandaloneRuntime to wasmstandalone::Runtime. 2017-10-03 13:01:31 -07:00
Dan Gohman
6c4bbc643c Set the faerie target based on the cretonne target. 2017-10-03 12:39:52 -07:00
Dan Gohman
a68b2619bd Sniff the wasm magic bytes, rather than relying on the filename extension. 2017-10-03 12:23:59 -07:00
Dan Gohman
e5ed1517ce Fix the command name in the usage message. 2017-10-03 12:21:09 -07:00
Dan Gohman
324a395a95 Make the "wat2wasm" error message not panic. 2017-10-03 12:20:37 -07:00
Dan Gohman
5b0a083124 Avoid unnecessary BufReaders. 2017-10-03 06:56:23 -07:00
Dan Gohman
e64eb79aaf Fix dependency paths. wasmstandalone no longer depends on out-of-tree patches. 2017-09-23 15:38:38 -07:00
Dan Gohman
0c78a2f298 Import the wasm2obj experiment and minimally update it. 2017-09-23 15:38:38 -07:00
Dan Gohman
b583d75c7a Fix redundant borrows. 2017-09-22 16:11:11 -07:00
Dan Gohman
382415ed0c Fix a useless format!. 2017-09-22 16:09:10 -07:00
Dan Gohman
b89277d9ce Rename "wast" to "wat". 2017-09-22 15:57:32 -07:00
Dan Gohman
cdffc1b50a Roughly update for the recent Cretonne API changes.
Everything builds and simple modules run, though there's still lots more
to do.
2017-09-22 15:56:18 -07:00
Dan Gohman
73f5adb19d Clippy cleanups. 2017-09-06 09:56:14 -07:00
Dan Gohman
3868467917 Format with rustfmt 0.9.0. 2017-09-06 08:37:12 -07:00
Dan Gohman
d0fe50a2a8 Check in the wasmstandalone code.
This is based on the code in https://github.com/denismerigoux/cretonne/commits/wasm2cretonne
before wasmstandalone was removed, with minor updates for the new library structure.
It is not yet updated for the latest cretonne API changes.
2017-09-05 17:06:51 -07:00
Jakob Stoklund Olesen
2927878707 Track regmove instruction during binemit.
Register locations can change throughout an EBB. Make sure the
emit_inst() function considers this when encoding instructions and
update the register diversion tracker.
2017-07-18 12:52:53 -07:00
Jakob Stoklund Olesen
28457f82c3 Add a Context::emit_to_memory function.
This function will emit the binary machine code into contiguous raw
memory while sending relocations to a RelocSink.

Add a MemoryCodeSink for generating machine code directly into memory
efficiently. Allow the TargetIsa to provide emit_function
implementations that are specialized to the MemoryCodeSink type to avoid
needless small virtual callbacks to put1() et etc.
2017-07-18 08:03:53 -07:00
Jakob Stoklund Olesen
6cc729a69b Add a Context::compile() function which runs all compiler passes.
This is the main entry point to the code generator. It returns the
computed size of the functions code.

Also add a 'test compile' command which runs the whole code generation
pipeline.
2017-07-12 12:22:49 -07:00
Jakob Stoklund Olesen
b6d4b884ad Add an ISA argument to dfg.display_inst().
Include ISA-specific annotations in tracing and error messages.
2017-07-12 10:13:13 -07:00
Jakob Stoklund Olesen
71af555e6f Include ISA-specific information in verifier errors.
When the test driver reports a verifier error, make sure to include the
TargetIsa when printing the failing function.
2017-07-12 10:13:13 -07:00
Jakob Stoklund Olesen
e7c6efa31e Update docopt dependency to 0.8.0.
This breaks our depending on two different versions of the regex
library.

This updated docopt uses serde instead of rustc_serialize.
2017-06-14 10:38:06 -07:00
Denis Merigoux
9b06f76057 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
Dan Gohman
dc809628f4 Start a very simple GVN pass (#79)
* Skeleton simple_gvn pass.
* Basic testing infrastructure for simple-gvn.
* Add can_load and can_store flags to instructions.
* Move the replace_values function into the DataFlowGraph.
* Make InstructionData derive from Hash, PartialEq, and Eq.
* Make EntityList's hash and eq functions panic.
* Change Ieee32 and Ieee64 to store u32 and u64, respectively.
2017-05-18 18:18:57 -07:00
Benjamin Bouvier
a2fd9cf0cc Update rustfmt to 0.8.4; (#81) 2017-05-15 15:10:47 -07:00
Dan Gohman
526feb161a Fix rustfmt diffs. 2017-05-11 06:57:55 -07:00
Dan Gohman
c571975a5c Use write! in utility code, rather than calling write_function directly. 2017-05-11 06:57:55 -07:00
Jakob Stoklund Olesen
15606fa735 Upgrade to rustfmt 0.8.3. 2017-04-27 12:52:41 -07:00
Jakob Stoklund Olesen
962a3a6a5e Upgrade to Rust 1.17.
- Remove some uses of 'static in const and static globals that are no
  longer needed.
- Use the new struct initialization shorthand.
2017-04-27 12:46:44 -07:00
Jakob Stoklund Olesen
c36aedfd03 Add an EntityMap::get_or_default() method.
This covers a common pattern for secondary entity maps: Get the value in
the map or the default value for out-of-range keys.
2017-04-25 15:53:30 -07:00
Eric Anholt
100666e300 Verify that the instruction encoding matches what the ISA would encode.
Fixes #69
2017-04-23 17:21:32 -07:00
Jakob Stoklund Olesen
85f277a2fb Add a liveness verifier.
The liveness verifier will check that the live ranges are consistent
with the function. It runs as part of the register allocation pipeline
when enable_verifier is set.

The initial implementation checks the live ranges, but not the
ISA-specific constraints and affinities.
2017-04-21 16:01:08 -07:00
Jakob Stoklund Olesen
225ed39fbd Run the verifier in the Context methods when it is enabled.
The test drivers can stop calling comp_ctx.verify because legalize() and
regalloc() do it themselves now.

This also makes it possible for those two passes to return other
CtonError codes in the future, not just verifier errors.
2017-04-21 12:36:35 -07:00
Jakob Stoklund Olesen
9c6a36d36d Move the ctrl_typevar function into dfg.
Soon, InstructionData won't have sufficient information to compute this.

Give TargetIsa::encode() an explicit ctrl_typevar argument. This
function does not require the instruction to be inserted in the DFG
tables.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
e56482d0fd Fix a bug in the binemit file test.
Only emit each instruction once, or the offset computations go all
wrong.
2017-04-06 11:17:46 -07:00
Jakob Stoklund Olesen
b5c74fdc25 Add a branch relaxation pass for #72.
Compute exact EBB header offsets and check that branches are in range.

Not implemented yet: Relax branches that are not in range.

Invoke the relax_branches() pass from the 'test binemit' file tests so
they can verify the proper encoding of branch instructions too.
2017-04-05 15:11:39 -07:00
Jakob Stoklund Olesen
847c8045fd Add a CodeOffset type and CodeSink::offset() method.
We need to keep track of code offsets in order to compute accurate
branch displacements.
2017-04-05 09:12:12 -07:00
Jakob Stoklund Olesen
8353651559 rustfmt 0.8.1 2017-04-05 09:00:11 -07:00
Jakob Stoklund Olesen
39e102b155 Add conditional branch encodings for RISC-V.
Not all br_icmp opcodes are present in the ISA. The missing ones can be
reached by commuting operands.

Don't attempt to encode EBB offsets yet. For now just emit an EBB
relocation for the branch instruction.
2017-04-03 15:16:25 -07:00
Jakob Stoklund Olesen
ffeeba7c93 Use pretty_verifier_error in runone too. 2017-03-29 15:30:44 -07:00