Commit Graph

29 Commits

Author SHA1 Message Date
Dan Gohman
1b55a2d005 Rename more Error and Result types. 2018-06-12 05:02:25 -07:00
Dan Gohman
43bd3cb2a3 Introduce a ModuleResult alias for Result<T, ModuleError>.
This follows the pattern used by cretonne-codegen, cretonne-wasm, and
others.
2018-06-12 05:02:25 -07:00
Dan Gohman
6971ae1c26 Export CodegenError and CodegenResult at the top level.
Make cretonne-codegen's `result` module private, and instead just export
`CodegenError` and `CodegenResult` at the top level of the
cretonne-codegen crate. This makes them more consistent with Result and
Error types in other cretonne crates.
2018-06-12 05:02:25 -07:00
Dan Gohman
8a26a50475 Rename CtonError and CtonResult to CodegenError and CodegenResult. 2018-06-12 05:02:25 -07:00
Dan Gohman
944251260b Bump version to 0.9.0 2018-06-07 11:46:36 -07:00
Dan Gohman
b2b20a95a1 Fix missing no_std support in cretonne-module.
And, tidy up the extern crate declarations in the std replacement modules.
2018-06-07 11:34:55 -07:00
Dan Gohman
750483b9ac Update to hashmap_core 0.1.6. 2018-06-07 10:45:30 -07:00
Dan Gohman
4e67e08efd Use the target-lexicon crate.
This switches from a custom list of architectures to use the
target-lexicon crate.

 - "set is_64bit=1; isa x86" is replaced with "target x86_64", and
   similar for other architectures, and the `is_64bit` flag is removed
   entirely.

 - The `is_compressed` flag is removed too; it's no longer being used to
   control REX prefixes on x86-64, ARM and Thumb are separate
   architectures in target-lexicon, and we can figure out how to
   select RISC-V compressed encodings when we're ready.
2018-05-30 06:13:35 -07:00
Dan Gohman
a1fe0f82e1 Update to the latest stable rustfmt, 0.4.2-stable (febbb36 2018-04-12). 2018-05-29 10:37:38 -07:00
Dan Gohman
6b88cd44a8 Update to rustfmt-preview (#348)
* Update to rustfmt-preview.

* Run "cargo fmt --all" with rustfmt 0.4.1.

rustfmt 0.4.1 is the latest release of rustfmt-preview available on the
stable channel.

* Fix a long line that rustfmt 0.4.1 can't handle.

* Remove unneeded commas left behind by rustfmt.
2018-05-25 11:38:38 -07:00
Dan Gohman
f986acfe7c Correct an assert message, spotted by @MarkSwanson 2018-05-14 20:11:51 -10:00
Dan Gohman
b4f9eb5e55 Bump versino to 0.8.0 2018-05-01 19:54:21 -07:00
Dan Gohman
525f01713b Bump version to 0.7.0 2018-04-27 06:10:15 -07:00
Dan Gohman
c40a4ddc53 Add functions to Module for initializing Contexts.
This allows Module to assign the Context the TargetIsa's default calling
convention.
2018-04-27 06:02:59 -07:00
Pat Hickey
ee9dcb8367 Improvements to Modules API (#307)
* 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
2018-04-26 22:02:35 -07:00
Dan Gohman
e356c742aa Bump version to 0.6.0 2018-04-23 14:35:23 -07:00
Dan Gohman
834df5290d Add more comments to module.rs. 2018-04-23 10:26:33 -07:00
Dan Gohman
56b3465ed0 Use more lower-case letters for github URLs.
This is a continuation of 362f8f13e2b8c7dd79b043c491479bb9fc6f69e9.
2018-04-22 22:09:31 -07:00
Dan Gohman
7079c72b28 Add comments to DataContext's import_function and import_global_var.
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.
2018-04-20 16:36:08 -07:00
Dan Gohman
e876529152 Merge pull request #303 from sunfishcode/no_std_merge
Merge no_std into master
2018-04-20 12:11:53 -07:00
Dan Gohman
c9a606da69 Use more lower-case letters for github URLs.
This is a continuation of 362f8f13e2b8c7dd79b043c491479bb9fc6f69e9.
2018-04-19 13:44:07 -07:00
Dan Gohman
acabcc5c8f Merge remote-tracking branch 'origin/master' into no_std 2018-04-19 12:40:10 -07:00
Dan Gohman
830ee60d28 Add no_std support in module, simplejit, and umbrella. 2018-04-19 12:39:56 -07:00
Dan Gohman
cb37c25d3a Introduce Builder and Product types to the Module workflow.
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.
2018-04-19 11:19:14 -07:00
Dan Gohman
07576d3ed0 Make test-all.sh run unit tests in debug mode.
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.
2018-04-19 07:07:41 -07:00
Dan Gohman
1ba468b230 Bump version to 0.5.1 2018-04-17 22:18:30 -07:00
Dan Gohman
bf597b7abf Enable and fix several more clippy lints. 2018-04-17 17:05:03 -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