Commit Graph

1829 Commits

Author SHA1 Message Date
Bruce Mitchener
5c5e66cebd Update to capstone 0.4. 2018-06-06 10:15:09 -07:00
Dan Gohman
970045c309 Set clobbers_flags to False for urm_noflags_abcd.
`urm_noflags` is a variant of `urm` which doesn't clobber the flags, and
`urm_noflags_abcd` is a further variant for ABCD registers, so it also
doesn't clobber the flags.
2018-06-05 11:30:35 -07:00
Dan Gohman
eb94664285 Add assertions to check translate_call and translate_call_indirect.
Assert that the results produced by translate_call and
translate_call_indirect match the results of the call signatures.
2018-06-05 09:21:23 -07:00
Dan Gohman
4e64fc11c9 Rename subtest's Result to SubtestResult.
This avoids naming confusion with the standard `Result`, which is
included in the prelude.
2018-06-05 09:21:23 -07:00
Dan Gohman
1087ff3a01 Use to_string() instead of write!(&mut text, "{}", .... 2018-06-05 09:21:23 -07:00
Dan Gohman
4a4453dc47 Use to_string() instead of format!("{}", ...). 2018-06-05 09:21:23 -07:00
Dan Gohman
22a7c56108 Use Context::for_function to simplify the code. 2018-06-05 09:21:23 -07:00
Dan Gohman
ae8fc69406 Use &'static str rather than Cow<str> for pass names. 2018-06-05 09:20:59 -07:00
Dan Gohman
6c003d68cd Factor out pointer_bits() and pointer_bytes() helper functions. 2018-05-31 11:21:26 -07:00
Dan Gohman
35f2cae00c Add comments explaining the rustfmt installation dance. 2018-05-31 09:32:02 -07:00
Dan Gohman
f48c1d4f89 Update to target-lexicon 0.0.1 and faerie 0.4.1.
This fixes handling of custom targets.
2018-05-30 17:25:48 -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
Lachlan Sneff
2f3008aa40 Use "nightly" feature of raw-cpuid when possible. 2018-05-29 15:57:21 -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
7045c41418 Add a comment about implementing Keys in terms of Range in the future. 2018-05-29 10:21:52 -07:00
Dan Gohman
7733ca1173 Implement entity's Iter in terms of std::iter::Enumerate.
Entity's `Iter` is essentially an `Enumerate`, so just use an
`Enumerate` under the covers. This makes the code simpler.
2018-05-29 10:21:52 -07:00
Dan Gohman
c21af29c79 Legalize libcall signatures.
Explicitly legalize signatures created for libcalls.
2018-05-29 10:21:52 -07:00
Dan Gohman
d8eaa19dda Make an assert message more verbose. 2018-05-29 10:21:52 -07:00
Dan Gohman
7720a571fc Fix reverse iteration in cretonne-entity's Iter.
A `DoubleEndedIterator` needs to track both a forward position and a
reverse position, so that `next_back()` can pop from the back of the
sequence.
2018-05-29 10:21:52 -07:00
Dan Gohman
09fb914823 Make an assert message more verbose. 2018-05-25 11:41:55 -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
99f6055c55 Fix warnings reported by bashate.
See https://pypi.org/project/bashate/ for more info.
2018-05-24 16:53:34 -07:00
Dan Gohman
a6e6b79a2e Remove the install of the wasm-toolchain binary package.
With 8f4a3586e5a787fd32a9afe35df4a9811d92c66b, we now have proper wabt
integration, so we no longer need to download and install a separate
binary package.
2018-05-24 14:52:51 -07:00
Dan Gohman
d46ceedc98 Tidy up unneeded commmas. 2018-05-24 14:52:51 -07:00
data-pup
191bab162b Optimize 0.0 floating point constants. (#344)
* Optimize 0.0 floating point constants. Rather than using the existing
process of emitting bit patterns and moving them into floating point
registers, use the `xorps` instruction to zero out the register.

* is_zero predicate function will not accept negative zero. Fixed formatting for encoding recipe and filetests.
2018-05-24 14:16:25 -07:00
Ram
4afb28ef59 Use wabt, and make the wasm subcommand optional. (#347)
* Use wabt for wasm testing.

* Use wabt in cton-util.

* Make the wasm subcommand optional.
2018-05-24 08:23:00 -07:00
Dan Gohman
b855184ae1 Make WasmError and WasmResult public types. 2018-05-22 09:37:33 -07:00
Dan Gohman
f835a1b662 Followup to #345 to fix no_std errors. 2018-05-22 07:23:28 -07:00
Dan Gohman
89e7d56120 Allow wasm embedders to reject wasm modules with unsupported features. (#345)
Define `WasmError` (and an accompanying `WasmResult`) to represent
errors translating WebAssembly functions. Make `translate_call` and
related functions return `WasmResult`s so that embedders have the
flexibility to reject features they don't support.

Move `InvalidInput` out of `CtonError` and into `WasmError`, where it's
now named `InvalidWebAssembly`, as it's a WebAssembly-specific error
condition. Also extend it to preserve the original error message and
bytecode offset.
2018-05-21 20:49:19 -07:00
Dan Gohman
923ea8ada9 Add assertions to check that postopt encoding succeeds. 2018-05-18 15:40:45 -07:00
Amanieu d'Antras
e9d362d902 Improve coalescing performance by using a FxHashMap (#340)
* Use FxHashMap instead of HashMap for better performance

* Replace the binary search in the coalescing pass with a FxHashMap

This speeds up coalescing by up to 16% and overall compilation by 9%
2018-05-18 15:40:08 -07:00
Amanieu d'Antras
80fdfb2376 Optimize partition_slice (#341)
* Generate debug symbols in optimized builds.

This allows profiling tools to provide more accurate information,
especially details about inlined functions.

* Rewrite and optimize partition_slice

This improves the performance of the register allocation passes
which use LiveValueTracker.
2018-05-18 12:54:00 -07:00
Dan Gohman
4c150907bf Issue better error messages in use_var and def_var.
Include the name of the variable when diagnosing uses and defs of
undeclared variables. And, add an assert to def_var to check that the
declared type of a variable matches the value type of the def.

With this change, `Variable` implementations must now implement `Debug`.
2018-05-14 20:11:51 -10:00
Dan Gohman
f986acfe7c Correct an assert message, spotted by @MarkSwanson 2018-05-14 20:11:51 -10:00
Dan Gohman
842cd13bd1 Improve the error message when python isn't installed. 2018-05-14 20:11:51 -10:00
Jonathan Foote
1924039713 cargo fuzz integration (#306)
* added wip translate_module fuzzer

* use local binaryen-rs fork (with shim) for fuzzing

* minor doc cleanup

* check fuzzer integration via CI

* switch back to upstream binaryen-rs; add forgotten integration test directive
2018-05-14 09:31:27 -10:00
Bruce Mitchener
07c65bab11 Update to docopt 1.0. (#332) 2018-05-14 09:27:14 -10:00
Jordan Danford
e9a0a9977d Use SVG version of Gitter icon in README.md (#331) 2018-05-12 07:49:07 -10:00
pup
34b8c00d61 Minor typo fix in constant_hash comment. (#329) 2018-05-12 07:30:15 -10:00
pup
b36fc6b75f Issue 311 - Add a pass to make NaN bits deterministic. (#322) 2018-05-09 15:11:58 -05:00
Tyler McMullen
f636d795c5 load_complex and store_complex instructions (#309)
* Start adding the load_complex and store_complex instructions.

N.b.:
The text format is not correct yet. Requires changes to the lexer and parser.
I'm not sure why I needed to change the RuntimeError to Exception yet. Will fix.

* Get first few encodings of load_complex working. Still needs var args type checking.

* Clean up ModRM helper functions in binemit.

* Implement 32-bit displace for load_complex

* Use encoding helpers instead of doing them all by hand

* Initial implementation of store_complex

* Parse value list for load/store_complex with + as delimiter. Looks nice.

* Add sign/zero-extension and size variants for load_complex.

* Add size variants of store_complex.

* Add asm helper lines to load/store complex bin tests.

* Example of length-checking the instruction ValueList for an encoding. Extremely questionable implementation.

* Fix Python linting issues

* First draft of postopt pass to fold adds and loads into load_complex. Just simple loads for now.

* Optimization pass now works with all types of loads.

* Add store+add -> store_complex to postopt pass

* Put complex address optimization behind ISA flag.

* Add load/store complex for f32 and f64

* Fixes changes to lexer that broke NaN parsing.

Abstracts away the repeated checks for whether or not the characters
following a + or - are going to be parsed as a number or not.

* Fix formatting issues

* Fix register restrictions for complex addresses.

* Encoding tests for x86-32.

* Add documentation for newly added instructions, recipes, and cdsl changes.

* Fix python formatting again

* Apply value-list length predicates to all LoadComplex and StoreComplex instructions.

* Add predicate types to new encoding helpers for mypy.

* Import FieldPredicate to satisfy mypy.

* Add and fix some "asm" strings in the encoding tests.

* Line-up 'bin' comments in x86/binary64 test

* Test parsing of offset-less store_complex instruction.

* 'sNaN' not 'sNan'

* Bounds check the lookup for polymorphic typevar operand.

* Fix encodings for istore16_complex.
2018-05-09 14:07:00 -05:00
Steffen Butzer
5aa84a744b windows fastcall (x64) call convention (#314)
* initial set of work for windows fastcall (x64) call convention

- call conventions: rename `fastcall` to `windows_fastcall`
- add initial set of filetests
- ensure arguments are written after the shadow space/store (offset-wise)
  The shadow space available before the arguments (range 0..32)
  is not used as spill space yet.

* address review feedback
2018-05-09 13:18:30 -05:00
Ty Overby
09f883182d document that low bitsize integers don't have complete arithmetic support (#320)
* document that low bitsize integers don't have complete arithmetic support
2018-05-07 11:10:01 -05:00
Dan Gohman
5b69930e03 Legalize bnot using xor with -1. 2018-05-05 11:21:06 -05:00
Pat Hickey
bb612af37a x86 recipes: emit StackOverflow trap for all sp-relative loads and stores (#325)
* x86 recipes: emit StackOverflow trap for all sp-relative loads and stores

* x86 recipes: emit StackOverflow trap for push and pop

* x86 binary filetests: add stk_ovf trap annotations
2018-05-03 18:09:07 -07:00
Dan Gohman
846a71d93b Fixes for mypy 0.600 (#324)
* Remove the mypy version constraint and set strict_optional to False.

* Add type annotations for `ISA` variables.

mypy 0.600 seems to require explicit annotations here.

* Annotate the ISA variables in the defs.py files too.
2018-05-03 12:12:19 -07:00
Pat Hickey
69468915d5 cretonne-faerie: add a translation mechanism for LibCalls (#321)
* cretonne-faerie: add a translation mechanism for LibCalls

* cretonne-faerie: docs for libcall_names, rustfmt

* cretonne-faerie: switch libcall naming to use a closure

* travis: debug mypy version

* travis: pin mypy to 0.521

mypy released 0.600 today and even with `--no-strict-optional` flag
passed to it (in lib/codegen/meta/check.sh) it fails to infer the type
of values that did not need type annotations in the past

* faerie-backend: fix swapped nearbyint functions

* cretonne-faerie: move boxing out of FaerieBuilder
2018-05-03 06:54:55 -07:00
Dan Gohman
7e1f157692 Use %esp rather than %rsp in x86-32 test comments. 2018-05-02 09:41:34 -07:00
Dan Gohman
b4f9eb5e55 Bump versino to 0.8.0 2018-05-01 19:54:21 -07:00
Dan Gohman
5c2ada88f5 Add support for target_os = "nebulet". (#319) 2018-05-01 05:37:56 -07:00