* Mark emit_to_memory as unsafe, and provide a safe compile_and_emit.
Mark `Context::emit_to_memory` and `MemoryCodeSink::new` as unsafe, as
`MemoryCodeSink` does not perform bounds checking when writing to
memory.
Add a `Context::compile_and_emit` function which provides a convenient
interface for doing `compile` and `emit_to_memory` in one step, and
which can also provide a safe interface, since it allocates memory of
the needed size itself.
* Mention that `MemoryCodeSink` can't guarantee that the pointer is valid.
* Initial skeleton.
* Add basic faerie support.
This adds enough functionality to enable simple .o file writing through
faerie. This included adding the functionality to Module to support
RelocSink implementations.
* Add basic SimpleJIT support.
This adds enough functionality to enable a simple program to be jitted
and executed.
* Make declare_func_in_func take a Function instead of a Context.
It only needs the Function, and sometimes it's useful to call it from
places that don't have a full Context.
* Temporarily disable local and exported global variables in the Faerie backend.
Faerie assumes these variables use pc-relative offset instructions, and
Cretonne is not yet emitting those instructions.
* FaerieBackend depends on PIC.
Faerie itself only supports PIC objects for now, so add an assert to
Cretonne to check that it's using a PIC target flag.
* SimpleJIT support for data objects.
* Preliminary faerie support for data objects.
* Support for data objects in faerie using the new colocated flag.
* Unit tests for DataContext and friends.
* Add a Module::consume() function.
This consumes the Module and returns the contained Backend, so that
users can call Backend-specific functions with it. For example, the
Faerie backend has functions to write an object file.
* Update the new crates to version 0.4.4.
* Make FaerieBackend own its TargetIsa.
This simplifies its interface, as it eliminates a lifetime parameter.
While we may eventually want to look into allowing multiple clients to
share a TargetIsa, it isn't worth the complexity for FaerieBackend
right now.
* Don't try to protect faerie from multiple declarations.
Let faerie decide for itself whether it wants to consider two
declarations to be compatible.
* Use debug_assert_eq rather than debug_assert with ==.
* Fix FaerieRelocSink's reloc_external to handle data object names.
* Relax the asserts in get_function_definition and get_data_definition.
These functions don't require definable symbols, but they do require
that definable symbols be defined. This is needed for the simplejit
backend.
* Add a function to the faerie backend to retrieve the artifact name.
* Sync up with cretonne changes.
This makes it a little more consistent; now, "cretonne" is never capitalized
in identifier, path, or URL contexts. It is capitalized in natural
language contexts when referring to the project.
This adds a "colocated" flag to function and symbolic global variables which
indicates that they are defined along with the current function, so they can
use PC-relative addressing.
This also changes the function decl syntax; the name now always precedes the
signature, and the "function" keyword is no longer included.
Rustc beta and nightly crash when compiling Cretonne. I've filed
https://github.com/rust-lang/rust/issues/49528 to track this upstream.
For now, add Beta to the allow-failures list to temporarily work
around this.
The regmove and regfill instructions temporarily divert a value's
location, and these temporary diversions are not reflected in
`func.locations`. For now, make an extra scan through the instructions
of the function to find any regmove or regfill instructions in order to
find all used callee-saved registers.
This fixes#296.
The main use for non-PIC code at present is JIT code, and JIT code can
live anywhere in memory and reference other symbols defined anywhere in
memory, so it needs to use the "large" code model.
func_addr and globalsym_addr instructions were already using `movabs`
to support arbitrary 64-bit addresses, so this just makes calls be
legalized to support arbitrary 64-bit addresses also.
* Only save callee-saved registers that are actually being used.
* Rename AllocatableSet to RegisterSet
* Style cleanup and small renames for readability.
* Adjust x86 prologue-epilogue test to account for callee-saved register optimization.
* Add more tests for prologue-epilogue optimizations.
* Add a status summary to the README.
This adds a brief blurb about Cretonne's current status, so that people
looking at Cretonne have an idea of what to expect.
Also remove the "not yet functional" disclaimer, as Cretonne is
functional for some use cases now, and the new Status section explains
the current status.
The main purpose of the DCE pass is to clean up dead code left behind by
the optimizer, so it's not valuable to run it when the optimizer isn't
being run.
`iter()` iterates over both keys and values, while `values()` iterates over
just values. Also add `_mut()` versions.
These replace the otherwise common idiom of iterating with `keys()` and using
indexing to get the values, allowing for simpler code.