Commit Graph

1829 Commits

Author SHA1 Message Date
Dan Gohman
eefa1de4da Rename some local variables for consistency with the rest of the codebase. 2018-04-18 17:02:32 -07:00
Dan Gohman
d122d16f79 Style consistency: don't end error messages with exclamation points. 2018-04-18 16:59:24 -07:00
Dan Gohman
d874843a59 Merge pull request #301 from gmorenz/no_std
Update no_std branch to 0.5.0
2018-04-18 10:08:00 -07:00
morenzg
c791a4f8b1 Update to wasmparser 0.16.0 2018-04-18 12:46:55 -04:00
morenzg
fdf34e9d3e Fix up nostd dependencies 2018-04-18 12:01:27 -04:00
Dan Gohman
d7e13284b2 Mark emit_to_memory as unsafe, and introduce a safe emit. (#281)
* 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.
2018-04-18 06:35:47 -07:00
Dan Gohman
80da1a1e9f Add crate descriptions for cretonne-{module, faerie, simplejit}. 2018-04-17 23:19:10 -07:00
Dan Gohman
1ba468b230 Bump version to 0.5.1 2018-04-17 22:18:30 -07:00
Dan Gohman
d3e76b8a51 Add more tests for non-PIC calls on x86-64. 2018-04-17 22:12:41 -07:00
Dan Gohman
bf597b7abf Enable and fix several more clippy lints. 2018-04-17 17:05:03 -07:00
Dan Gohman
5c6cb202d8 Suppress cast_ptr_alignment clippy errors.
These are only used in places that use `write_unaligned`, so it's ok
that the pointer might be misaligned.
2018-04-17 17:04:56 -07:00
morenzg
a10a6a0df0 Merge branch 'master' into no_std 2018-04-17 16:56:33 -04:00
Dan Gohman
58380f38e8 Refactor SimpleJITTrapSink/FaerieTrapSink into NullTrapSink.
This publishes it for use outside of simpljie/faerie as well.
2018-04-17 11:22:11 -07:00
Dan Gohman
1f43ec09f3 Bump version to 0.5.0 2018-04-17 10:58:33 -07:00
Dan Gohman
76db9f022d [WIP] Module API (#294)
* 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.
2018-04-17 10:52:36 -07:00
Dan Gohman
a9edb28414 Rename InstructionFormat::IndirectCall for consistency with Opcode::CallIndirect. 2018-04-17 09:47:27 -07:00
Dan Gohman
e2f6705e28 Add a comment about why there's no is_pie setting. 2018-04-17 09:47:27 -07:00
Dan Gohman
635d14c251 Rename GlobalVarData::VmCtx for consistency with ArgumentPurpose::VMContext. 2018-04-17 09:47:27 -07:00
Dan Gohman
85662fbca9 Add an "umbrella" crate, which seeks to provide a convenient interface.
This currently pulls in cretonne-codegen and cretonne-frontend and
provides a simple prelude interface.

This fixes #287.
2018-04-17 09:47:13 -07:00
Dan Gohman
f43b6aca1a Use lower-case letters for github URLs.
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.
2018-04-17 09:47:11 -07:00
Dan Gohman
24fa169e1f Rename the 'cretonne' crate to 'cretonne-codegen'.
This fixes the next part of #287.
2018-04-17 09:46:56 -07:00
Dan Gohman
7767186dd0 Rename 'cton_*' library names to match the 'cretonne_*' crate names.
This renames `cton_frontend` to `cretonne_frontend` and so on.

This fixes the first part of #287.
2018-04-17 07:55:59 -07:00
Dan Gohman
f552c8768e Bump version to 0.4.4 2018-04-16 16:37:00 -07:00
Dan Gohman
56f11e76b4 Use PC-relative encodings for colocated functions on non-PIC.
Colocated functions are expected to be defined within the PC-relative
immediate range on x86-64, so allow this addressing for non-PIC as well
as PIC.
2018-04-16 16:27:27 -07:00
Dan Gohman
5977f2e45e Update packaging metadata for cretonne-entity. 2018-04-16 14:50:41 -07:00
Dan Gohman
a4523cf0b8 Bump version to 0.4.3 2018-04-16 14:48:11 -07:00
Dan Gohman
0e57f3d0ea Add a "colocated" flag to symbol references. (#298)
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.
2018-04-13 15:00:09 -07:00
Dan Gohman
645fa3e858 Minor code cleanup. 2018-04-13 13:50:26 -07:00
Dan Gohman
98a4e32236 Try a different syntax for allowing failures on rust beta. 2018-04-13 10:24:58 -07:00
Dan Gohman
25d2ab4c00 Change the Travis config to allow failures in rust beta.
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.
2018-04-13 09:58:36 -07:00
Dan Gohman
04746270b3 Rename X86Abs4/X86Abs8 to Abs4/Abs8.
These relocation codes are for simple absolute addresses and aren't
architecture-specific.
2018-04-13 09:11:14 -07:00
Dan Gohman
1c760ab179 Rename intel to x86.
x86 is the more accurate name, as there are non-Intel x86 implementations.

Fixes #263.
2018-04-12 10:02:16 -07:00
Amanieu d'Antras
9e17e62d68 Move entity into a separate crate (#297) 2018-04-10 11:06:49 -07:00
Dan Gohman
18b2f12150 Save/restore callee-saved registers used in regmove/regfill.
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.
2018-04-09 22:33:54 -07:00
Dan Gohman
eab57c0a40 Use large-model addressing for calls when in non-PIC mode.
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.
2018-04-08 22:37:35 -07:00
Dan Gohman
2703b8ce6f The current x86-32 encodings for symbolic addresses are non-PIC. 2018-04-08 22:30:55 -07:00
Dan Gohman
b0d414731c The addend for a PCRel4 reloc should be -4 too. 2018-04-07 06:15:33 -07:00
Dan Gohman
781d3ee3ff Bump version to 0.4.2 2018-04-03 16:04:54 -07:00
Dan Gohman
c47fa576b2 Convert some http links to https. 2018-04-03 16:00:29 -07:00
Dan Gohman
e2681a6303 Tidy up an unneeded mut. 2018-04-03 15:48:14 -07:00
Tyler McMullen
775c674b38 Only save callee-saved registers that are used (#293)
* 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.
2018-04-03 14:44:12 -07:00
Dan Gohman
0948ca9963 Add a status summary to the README. (#290)
* 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.
2018-04-03 10:12:03 -07:00
Dan Gohman
e107793b68 Pre-opt: Use the correct operand in the irsub_imm pattern. 2018-03-30 21:02:26 -07:00
Dan Gohman
95c09bbfde Add docs/_build to .gitignore.
It's generated by running "make html" or other make command in the docs
directory.
2018-03-30 17:09:21 -07:00
Dan Gohman
07693048f0 Merge remote-tracking branch 'origin/master' into no_std 2018-03-30 15:18:29 -07:00
Dan Gohman
b523b69c16 Make bash function syntax consistent with other scripts in the repo. 2018-03-30 13:38:30 -07:00
Dan Gohman
c50675deb8 Format with nightly rustfmt-preview, then with rustfmt-0.9 again. 2018-03-30 13:23:47 -07:00
Dan Gohman
8d5fecd324 Format with stable rustfmt-preview, then with rustfmt-0.9 again. 2018-03-30 13:17:15 -07:00
Dan Gohman
d7c66a8ec1 Don't run the DCE pass when optimization is disabled.
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.
2018-03-30 12:46:03 -07:00
Dan Gohman
72b7a4b3ef Add iter() and values() functions to PrimaryMap and EntityMap.
`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.
2018-03-30 12:45:52 -07:00