Jakob Stoklund Olesen
2946cc54d3
Add more trap codes.
...
These are codes that come up naturally when translating WebAssembly and
legalizing the Cretonne instruction set.
2017-09-22 08:51:55 -07:00
Angus Holder
7fbf1cb810
Revert accidental change
2017-09-22 07:54:26 -07:00
Angus Holder
b003605132
Adapt intel to be able to correctly choose compressed instruction encodings: create a register class to identify the lower 8 registers, omit unnecessary REX prefixes, and fix the tests
2017-09-22 07:54:26 -07:00
Angus Holder
3b66c0be40
Emit compressed instruction encodings for instructions where constraints allow
2017-09-22 07:54:26 -07:00
Jakob Stoklund Olesen
2d4c860187
Convert legalizer::split and generated legalization code to FuncCursor.
2017-09-21 17:05:51 -07:00
Jakob Stoklund Olesen
a9acbd1afd
Convert the legalizer/boundary module to FuncCursor.
...
This is a larger refactoring because all the changes need to be done
together. Either you pass a Function reference around, or you pass
around references to the parts. There is no in between.
2017-09-21 16:43:47 -07:00
Jakob Stoklund Olesen
85e4e9f511
Assign source locations when translating WebAssembly to Cretonne.
...
The source locations are byte code offsets relative to the beginning of
the function.
2017-09-21 14:37:54 -07:00
Jakob Stoklund Olesen
4d4da2dc60
Add source location support to FuncCursor and EncCursor.
...
A cursor now also remembers a current source location which will be
assigned to all new instructions created with the cursor.
The old layout::Cursor can't support source locations because it doesn't
have a reference to the full ir::Function.
2017-09-21 14:37:54 -07:00
Jakob Stoklund Olesen
b2a314a229
Add per-instruction source locations to the Cretonne IR.
...
Source locations are opaque 32-bit entities that can be used to
represent WebAssembly byte-code positions or some other source
identifier.
2017-09-21 14:24:26 -07:00
Dan Gohman
16eb689dd1
Use Self instead of repeating the type name.
2017-09-21 14:21:30 -07:00
Dan Gohman
e5e4b59683
Tidy up some asserts.
2017-09-21 14:21:30 -07:00
Dan Gohman
e75558b800
Fix spelling of "adjustment".
2017-09-21 14:21:30 -07:00
Dan Gohman
dda8293668
Restructure code to avoid a heap allocation.
2017-09-21 14:21:30 -07:00
Dan Gohman
ff18772d0e
Avoid a heap allocation.
2017-09-21 14:21:30 -07:00
Dan Gohman
22b769b716
Convert use_var and predecessors_lookup into a state machine to avoid recursion.
2017-09-21 14:21:30 -07:00
Dan Gohman
9cda4eacde
Minor refactor.
2017-09-21 14:21:30 -07:00
Dan Gohman
df5ba8bbba
Correct a comment.
2017-09-21 14:21:30 -07:00
Dan Gohman
f524977920
Factor some logic out of seal_ebb_header_block into parts.
...
This allows append_jump_argument to call just the part that it needs
instead of the whole of seal_ebb_header_block, which is a nice cleanup
on its own, and it also eliminates a cycle from the static call graph.
2017-09-21 14:21:30 -07:00
Jakob Stoklund Olesen
218959ff65
Convert more tests to FuncCursor.
2017-09-21 13:30:00 -07:00
Jakob Stoklund Olesen
8e93aa7ce7
Remove layout::Cursor from the legalizer::split API.
...
We still use the cursor internally, but don't require callers to use it
too.
2017-09-21 13:07:17 -07:00
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
Jakob Stoklund Olesen
03dee5e442
Replace some uses of layout::Cursor with FuncCursor.
...
The layout::Cursor is unfortunate because it doesn't reference the whole
function.
2017-09-21 11:27:15 -07:00
Dan Gohman
ed6630dc02
Move verify calls back into Context, using FlagsOrIsa.
...
With FlagsOrIsa, we can pass around the information we need to run
the verifier from the Context even when a TargetIsa is not available.
2017-09-20 16:42:13 -07:00
Dan Gohman
f80ee7af39
Add a "host" crate for autodetecting the host. ( #159 )
...
* Add a "native" crate for autodetecting the host.
* Remove the redundant .gitignore.
* Use the proper builder for enabling subtarget flags.
2017-09-20 16:14:26 -07:00
Jakob Stoklund Olesen
8def91b4ad
Remove the unused Nullary instruction format.
...
This format was only used by the trap instruction which has its own
format now.
2017-09-20 15:59:13 -07:00
Jakob Stoklund Olesen
e8723be33f
Add trap codes to the Cretonne IL.
...
The trap and trapz/trapnz instructions now take a trap code immediate
operand which indicates the reason for trapping.
2017-09-20 15:50:02 -07:00
Jakob Stoklund Olesen
0f21fd342a
Remove the HeapLoad/HeapStore instruction formats.
...
These formats are not used any longer after the heap_load and heap_store
instructions were replaced by heap_addr.
Also drop the Uoffset32 immediate operand type which isn't used either.
2017-09-20 15:43:25 -07:00
Dan Gohman
d3f3fdf5af
Remove a redundant .gitignore file.
2017-09-20 15:35:26 -07:00
Dan Gohman
ce94a3fa39
Use ScopedHashMap in simple_gvn.
...
This avoids effectively ending up with most of a function body
stored in the hash map at once by removing elements promptly when
they go out of scope.
2017-09-20 14:21:44 -07:00
Dan Gohman
6710216e96
Add next_inst and prev_inst helper functions to Layout.
2017-09-20 12:38:13 -07:00
Dan Gohman
42af6d59bf
Add a ScopedHashMap class, for use in a future GVN implementation.
2017-09-20 11:28:55 -07:00
Dan Gohman
74845fed6c
Use more helper functions on CursorBase to reduce cursor repositioning.
2017-09-20 11:19:35 -07:00
Dan Gohman
482439c94b
Minor code cleanups in simple_gvn's main loop.
...
Redundant load/store elimination isn't critical for the use case of
optimizing wasm code which has already been optimized, so remove the
TODO for that for now.
2017-09-20 09:55:01 -07:00
Dan Gohman
b888894fbb
Use CursorBase utility functions to reduce repositioning clutter.
2017-09-20 09:06:17 -07:00
Dan Gohman
144d39a53d
Minor code simplification.
2017-09-20 08:17:40 -07:00
Dan Gohman
5194298d9b
Fix a typo in a comment.
2017-09-20 08:17:40 -07:00
Jakob Stoklund Olesen
fb827a2d4b
Add func_addr encodings for Intel.
2017-09-19 16:33:38 -07:00
Jakob Stoklund Olesen
d92686d1cd
Add a func_addr instruction.
...
Get the callable address of a function. Use for long distance calls and
for creating arguments to call_indirect in general.
2017-09-19 15:54:02 -07:00
Jakob Stoklund Olesen
0cfea8858a
Add uext() and sext() builder methods to ArgumentType.
...
This makes it simpler to construct arguments like:
ArgumentType::new(I32).uext()
2017-09-19 12:59:07 -07:00
Jakob Stoklund Olesen
1fdeddd0d3
Add Intel encodings for floating point load/store instructions.
...
Include wasm/*-memory64.cton tests too.
2017-09-19 09:32:54 -07:00
Jakob Stoklund Olesen
88348368a8
Add custom legalization for floating point constants.
...
Use the simplest expansion which materializes the bits of the floating
point constant as an integer and then bit-casts to the floating point
type. In the future, we may want to use constant pools instead. Either
way, we need custom legalization.
Also add a legalize_monomorphic() function to the Python targetISA class
which permits the configuration of a default legalization action for
monomorphic instructions, just like legalize_type() does for polymorphic
instructions.
2017-09-18 13:33:34 -07:00
Angus Holder
d2273c73ea
Make the verifier accept any of the legal encodings of an instruction
2017-09-18 13:00:19 -07:00
Jakob Stoklund Olesen
da4cde8117
Always insert the entry EBB before translating any WASM.
...
The FuncEnvironment callbacks (make_global in particular) may need to
insert code in the entry EBB. We need to make sure the entry EBB has
been inserted in the layout before making those callbacks.
2017-09-18 11:53:32 -07:00
Dan Gohman
f5f37ac4a6
Use FlagsOrIsa to avoid requiring a --isa argument in cton-util wasm.
2017-09-15 15:43:47 -07:00
Jakob Stoklund Olesen
446fcdd7c5
Fix the REX bits for load/store instruction encodings.
...
The two registers were swapped in the REX encoding, and the tests didn't
have any high bit set registers.
2017-09-15 13:02:36 -07:00
Jakob Stoklund Olesen
cc3707706c
Write and parse value locations for EBB arguments
...
Fixes #56 .
We now have complete support for value location annotations in the
textual IL format. Values defined by instructions as well as EBB
arguments are covered.
2017-09-15 11:21:29 -07:00
Jakob Stoklund Olesen
24a5a02752
Add a RegDiversions::display() function.
...
Display the current register diversions for debugging purposes.
2017-09-15 10:48:53 -07:00
Jakob Stoklund Olesen
cba7a03275
Give better verifier errors for missing instruction encodings.
...
When possible, provide the ISA's default encoding as a suggesting for
the missing instruction encoding.
2017-09-15 09:32:56 -07:00
Jakob Stoklund Olesen
1349a6bdbc
Always require a Flags reference for verifying functions.
...
Add a settings::FlagsOrIsa struct which represents a flags reference and
optionally the ISA it belongs to. Use this for passing flags/isa
information to the verifier.
The verify_function() and verify_context() functions are now generic so
they accept either a &Flags or a &TargetISa argument.
Fix the return_at_end verifier tests which no longer require an ISA
specified. The signle "set return_at_end" flag setting now makes it to
the verifier even when no ISA is present to carry it.
2017-09-14 17:51:15 -07:00
Dan Gohman
9e77af25a3
Add settings and isa command-line options to cton-util wasm. ( #158 )
...
* Add settings and isa command-line options to cton-util wasm.
* Use map_err to simplify error handling.
* Use `&*` instead of `.borrow()`.
2017-09-14 17:41:43 -07:00