@steffengy noticed that the code to round allocation sizes up to the
neareset page size was incorrect. It was masking off the low bits rather
than the high bits.
Also, while here, add more comments to `Memory`'s implementation.
The dbg! macro expands to nothing in no_std mode, so variables that are
only used for debugging prompt unused variable warnings.
Also, allow unstable_features in no_std builds, since they use
feature(alloc), which is an unstable feature.
* test-no_std: use cargo +nightly
assume folks have rustup set to use stable by default
* cretonne-module, -faerie, -simplejit: use new ModuleError enum
CtonError is not really appropriate for use in the module system.
Instead, create a new enum ModuleError, which implements failure::Fail
(works with no_std). Translate existing panics and unimplemented
error cases to return ModuleErrors.
* cretonne-faerie: export FaerieProduct
* cretonne-module: expose FuncOrDataId, and Module::get_name to lookup
This is helpful for looking up a name that has already been declared.
Also, implement FuncOrDataId -> ExternalName conversion.
* cretonne-faerie: depend on faerie 0.3.0
which has bugfix for data relocations
* cretonne-module: change InvalidDefinition to InvalidImportDefinition
per dan's code review. plus another typo fix
* cretonne-faerie: add optional manifest of all traps from codegen
* cretonne-module: provide more context in panics
* cretonne-faerie: updates to docs
* cretonne-faerie: return an Err instead of debug_assert when isa not pic
regmove, regfill, and regspill have immediates which aren't value
operands, so they aren't in the set of things that can be described by
the existing constraint system. Consequently, constraints saying that
the non-REX encodings only support registers that don't need REX
prefixes don't work. Fow now, just remove the non-REX encodings, so
that they don't get selected when they aren't valid.
This fixes the last known issue with instruction shrinking, so it can
be re-enabled.
Add a calling-convention setting to the `Flags` used as part of the
`TargetIsa`. This allows Cretonne code that generates calls to use the
correct convention, such as when emitting libcalls during legalization
or when the wasm frontend is decoding functions. This setting can be
overridden per-function.
This also adds "fast", "cold", and "fastcall" conventions, with "fast"
as the new default. Note that "fast" and "cold" are not intended to be
ABI-compatible across Cretonne versions.
This will also ensure Windows users will get an `unimplemented!` rather
than silent calling-convention mismatches, which reflects the fact that
Windows calling conventions are not yet implemented.
This also renames SpiderWASM, which isn't camel-case, to Baldrdash,
which is, and which is also a more relevant name.
These are the main obvious place where ExternalName is exposed in the
Module API, so add comments advising users that they can use Module to
call these functions with the appropriate ExternalNames automatically.
When an instruction has multiple valid encodings, such as with and
without a REX prefix on x86-64, Cretonne typically picks the encoding
which gives the register allocator the most flexibility, which is
typically the longest encoding. This patch adds a pass that runs after
register allocation that picks the smallest encoding, working within the
constraints of the register allocator's choices. The result is smaller
and easier to read encodings.
In the future, we may want to merge this pass into the relaxation pass,
or possibly fold it into the final encoding step, however for now, a
discrete pass will suffice.
Choosing smaller instruction encodings on eg. x86 is an optimization,
rather than a useful discrete setting.
Use "is_compressed" only for ISAs that have an explicit compression feature
that users of the output may to be aware of, such as RISC-V's RVC or
ARM's Thumb-2.
Check for the `std` feature outside the macro body rather than inside,
so that we get the `std` feature in `cretonne-codegen`, rather than in
whatever crate the macro is being expanded in.
Rename the re-exported crates, so that prelude users can type
"cretonne::codegen" rather than "cretonne::cretonne_codegen".
And, add a few more useful items to the prelude.
This eliminates API confusion and surface area with respect to what state
the `Backend` needs to be in at different points.
Now, API users will construct a `Builder`, and pass it into the `Module`
which uses it to constrct a `Backend`. The `Backend` instance only lives
inside the `Module`. And when finished, the `Module` can return a
`Product` back to the user providing any outputs it has.
It turns out that "cargo test --release" doesn't use
`[profile.release]`; it uses `[profile.bench]` instead; see
[here](https://doc.rust-lang.org/cargo/reference/manifest.html) for details.
So the plan to run the tests in optimized mode but with debug-assertions
enabled didn't actually work, and we had an actual failing unit test that
was hidden because assertions were disabled.
So, this makes test-all.sh just run the unit tests in debug mode, as is
the norm for Rust packages, and fixes the buggy test.
This also removes the `[profile.release]` override from the top-level
Cargo.toml file too. We don't need it now that we're not running tests
in release mode, and it had confused multiple people because it made
Cretonne's in-tree builds different from how Cretonne is built when used as
a dependency in other projects.