Commit Graph

1600 Commits

Author SHA1 Message Date
Pat Hickey
5834520bfe binemit: add PIC relocation types for Intel 2017-12-12 19:29:52 -08:00
Pat Hickey
90bc798e4f settings: add "is_pic" boolean setting to base 2017-12-12 19:29:52 -08:00
Pat Hickey
88b30ff386 refactor Reloc to an enum of every architecture's reloc types
https://github.com/stoklund/cretonne/pull/206#issuecomment-350905016
2017-12-12 13:57:10 -08:00
Jakob Stoklund Olesen
a888b2a6f1 Dominator tree pre-order.
Add a DominatorTreePreorder data structure which can be initialized for
a DominatorTree and used for queries involving a pre-order of the
dominator tree.

Print out the pre-order and send it through filecheck in "test domtree"
file tests.
2017-12-08 17:43:15 -08:00
Jakob Stoklund Olesen
7d5f2f0404 Convert the CFG traversal tests to file tests.
Add a "cfg_postorder:" printout to the "test domtree" file tests and use
that to check the computed CFG post-order instead of doing it manually
with Rust code.
2017-12-08 13:58:18 -08:00
Jakob Stoklund Olesen
a7eb13a151 Expand unknown instructions to runtime library calls. 2017-12-08 10:37:50 -08:00
Jakob Stoklund Olesen
f03729d742 Fix generated code for ISA predicates on encoding recipes.
The generated code had syntax errors and inverted logic.

Add an SSE 4.1 requirement to the floating point rounding instructions.
2017-12-08 10:37:50 -08:00
Jakob Stoklund Olesen
362a4bdc4c Add well-known names for runtime library functions.
Add a LibCall type which represents runtime library functions that many
be synthesized by Cretonne from pure instructions.

Add a LibCall variant to ExternalName to represent one of these runtime
functions.
2017-12-07 17:50:22 -08:00
Jakob Stoklund Olesen
60c456c1ec Add a compilation pass timing facility.
Individual compilation passes call the corresponding timing::*()
function and hold on to their timing token while they run. This causes
nested per-pass timing information to be recorded in thread-local
storage.

The --time-passes command line option prints a pass timing report to
stdout.
2017-12-06 17:04:23 -08:00
Jakob Stoklund Olesen
feaea238bc Use bforest::Map for representing live ranges.
Get rid of the per-value Vec in the LiveRange data type and use a
bforest::Map instead to represent the live-in intervals for non-local
live ranges.

This has some advantages:

- The memory footprint of a local live range is reduced from 40 to 20
  bytes, and
- Clearing the Liveness data structure is now a constant time operation
  which doesn't call free().
- The potentially quadratic behavior when computing large live ranges is
  controlled by the logarithmic B-tree operations.
2017-12-06 14:14:21 -08:00
Jakob Stoklund Olesen
27d5543adc Make LiveRange a type alias for GenLiveRange<Layout>.
This makes the whole LiveRange generic over the program order instead of
having a number of methods that are individually program order-generic.
This makes is possible to have data members that depend on the program
order, as we will shortly.

This also gives us stronger type checking on the public LiveRange
methods which now require a Layout argument, not just any program order.
2017-12-06 13:53:24 -08:00
Jakob Stoklund Olesen
f106e4266a Enable the IL verifier by default.
Change the default value for the "enable_verifier" setting so the
verifier runs unless it is explicitly disabled.

Most projects using Cretonne are best off running the verifier always
until they start caring about compile time performance. Then they can
easily disable the verifier.
2017-12-06 08:30:48 -08:00
Jakob Stoklund Olesen
c09ad06f96 Stop generating reserved_reg heaps in DummyEnvironment.
The reserved register heaps are not implemented in the Cretonne
legalizer, so IR generated by the dummy environment would trip
assertions when compiled.

Use a heap with a vmctx base address instead, and also demonstrate how
vmctx arguments are added to all signatures to achieve this.
2017-12-05 16:31:10 -08:00
Jakob Stoklund Olesen
b8fe6bf0f5 Add a MapCursor::value_mut() method.
It's ok to alter a value stored in a map, but not the keys.
2017-12-05 15:07:28 -08:00
Jakob Stoklund Olesen
c64428b698 Add a Map::get_or_less() method.
Find the largest (k,v) pair with k <= key.
2017-12-05 15:07:28 -08:00
Tyler McMullen
7988d0c54c Add 8-bit variation of adjust_sp_imm for 32-bit and 64-bit Intel. 2017-12-05 11:49:12 -08:00
Tyler McMullen
3b937f5917 Add separate spiderwasm prologue/epilogue to intel's abi.rs 2017-12-05 11:49:12 -08:00
Tyler McMullen
5783ea2c9a Account for return address when reserving stack space for CSRs. 2017-12-05 11:49:12 -08:00
Tyler McMullen
a75248d2cf Move the initial stack pointer adjustment to after the CSR pushes. 2017-12-05 11:49:12 -08:00
Tyler McMullen
ebcbd54f61 Add 'compile' test and confirm the pro/epilogue is added. Fix regression this revealed. 2017-12-05 11:49:12 -08:00
Tyler McMullen
694658b949 Move entirety of prologue_epilogue logic to abi module. 2017-12-05 11:49:12 -08:00
Tyler McMullen
0fb59dc589 Fix the ordering of return values. 2017-12-05 11:49:12 -08:00
Tyler McMullen
c156eb9ff7 Refactor prologue_epilogue. Break out into functions. Remove Vecs. 2017-12-05 11:49:12 -08:00
Tyler McMullen
c78a191294 Use layout.last_inst to find 'return' opcodes, rather than iterating. 2017-12-05 11:49:12 -08:00
Tyler McMullen
66eccb7859 Use opcode's is_return() rather than pattern-matching. 2017-12-05 11:49:12 -08:00
Tyler McMullen
a26d438b30 Use returned Value from append_ebb_param in prologue_epilogue. 2017-12-05 11:49:12 -08:00
Tyler McMullen
ced39f5186 Fix up adjust_sp_imm instruction.
* Use imm64 rather than offset32
* Add predicate to enforce signed 32-bit limit to imm
* Remove AdjustSpImm format
* Add encoding tests for adjust_sp_imm
* Adjust use of adjust_sp_imm in Intel prologue_epilogue to match
2017-12-05 11:49:12 -08:00
Tyler McMullen
1a11c351b5 Add tests and documentation for x86_(push|pop). Fix up encoding issues revealed by tests. 2017-12-05 11:49:12 -08:00
Tyler McMullen
3b1b33e0ac Add docs and tests for copy_special instruction. Fixes encoding issue that tests revealed. 2017-12-05 11:49:12 -08:00
Tyler McMullen
4eb9a54096 Convert x86_(push|pop) operations to be explicitly limited to 32-bit and 64-bit values. 2017-12-05 11:49:12 -08:00
Tyler McMullen
2f3edc1bc6 Fix issue in which CSR returns were incorrectly ordered. 2017-12-05 11:49:12 -08:00
Tyler McMullen
6ec4bfc4ca Fix up the encodings for new instructions, both expected and actual. Make the test more accurate. 2017-12-05 11:49:12 -08:00
Tyler McMullen
daa7a21d05 Adjust prologue/epilogue generation to work with 32-bit Intel arch. 2017-12-05 11:49:12 -08:00
Tyler McMullen
e6481bb4eb Add 32-bit encodings for x86_push, x86_pop, copy_special, and adjust_sp_imm. 2017-12-05 11:49:12 -08:00
Tyler McMullen
c92d49963a Simplify x86_(push|pop) encodings. 2017-12-05 11:49:12 -08:00
Tyler McMullen
cf9d287bea Pop the callee-saved registers in the function epilogue(s). 2017-12-05 11:49:12 -08:00
Tyler McMullen
f31a764fc8 Save all callee-saved registers in prologue. 2017-12-05 11:49:12 -08:00
Tyler McMullen
b049916d35 Move %rsp to %rbp, not the reverse.
This also takes away %rsp and %rbp from regalloc again. This may cause
tests to fail temporarily.
2017-12-05 11:49:12 -08:00
Tyler McMullen
e0c8ab49e1 Only emit an adjust_sp_imm if the stack_size is non-zero. 2017-12-05 11:49:12 -08:00
Tyler McMullen
d12587f218 Assign explicit register location to result of frame-pointer pop. 2017-12-05 11:49:12 -08:00
Tyler McMullen
544c148b25 Fix the stack slots, so the locations of local var slots are correct. 2017-12-05 11:49:12 -08:00
Tyler McMullen
c1a64a5dc7 Insert a basic epilogue. 2017-12-05 11:49:12 -08:00
Tyler McMullen
60b6bc3ab7 Sketch of prologue generation 2017-12-05 11:49:12 -08:00
Tyler McMullen
fdfe24760a Add missing newline to prologue epilogue test 2017-12-05 11:49:12 -08:00
Tyler McMullen
d4311d2b1d Add prologue-epilogue test that exercises new instructions and binary emission. 2017-12-05 11:49:12 -08:00
Tyler McMullen
ffab87318e Add adjust_sp_imm instruction. Note: This enables using rsp and rbp as normal registers. Which is... wrong. 2017-12-05 11:49:12 -08:00
Tyler McMullen
32509ebacd Fix push/pop encoding for extended registers. Add copy_special encoding. 2017-12-05 11:49:12 -08:00
Tyler McMullen
b8275f5713 Add (some) encodings for x86_push/pop instructions. Simple uses actually pass the legalizer now. 2017-12-05 11:49:12 -08:00
Tyler McMullen
cdf70ccb77 Add copy_special instruction. 2017-12-05 11:49:12 -08:00
Tyler McMullen
8ed37e352e Add x86_push and x86_pop instructions. 2017-12-05 11:49:12 -08:00