Commit Graph

264 Commits

Author SHA1 Message Date
pca006132 c21d3aeec3 Added memcpy with neon optimization for zynq. 2020-09-02 12:34:12 +08:00
Aaron Kutch f4c7940d3b
Improve `__clzsi2` performance (#366) 2020-07-28 13:09:18 -05:00
Joseph Richey f3846bc05d
lint: Allow improper_ctypes_definitions (#364)
https://github.com/rust-lang/rust/pull/72700 caused the existing
`allow(improper_ctypes)` guard to stop working, we now need
`allow(improper_ctypes_definitions)` instead.

We keep the old one to avoid any issues with older nightlies.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-07-08 09:07:19 -05:00
jethrogb f853d6d9b7
Manually patch ret instruction for LVI (#359)
Co-authored-by: Jethro Beekman <jethro@fortanix.com>
2020-06-01 10:55:42 -05:00
Alex Crichton d837cce3d3 Add back in unsafe for bootstrapping
And add an `#[allow]` for now to appease stage0
2020-05-29 13:43:21 -07:00
Alex Crichton 4bf8cad593
Expand wasm32 testing on CI (#360)
* Expand wasm32 testing on CI

Run the full `run.sh` test script to get full assertions, including that
nothing in the wasm compiler-builtins is panicking. Unfortunately it's
currently panicking, so this is good to weed out!

* Update libm
2020-05-29 14:38:29 -05:00
Tomasz Miąsko d0ea0765aa
Use crate visibility for traits (#358)
Co-authored-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
2020-05-26 15:12:10 -05:00
Alex Crichton cde22bc180
Switch to using `llvm_asm!` instead of `asm!` (#351)
* Switch to using `llvm_asm!` instead of `asm!`

* Run rustfmt

* Fix how LTO is specified on nightly
2020-04-29 15:30:10 -05:00
Tomasz Miąsko 2541f27e8c
Place intrinsics in individual object files (#349)
Co-authored-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
2020-04-10 17:00:50 -05:00
Tyler Mandry cae3e6ea23
Set probestack visibility to hidden on ELF targets (#340) 2020-02-11 22:21:12 -08:00
Daniel Frampton 0a15c9bdfe Don't modify the intrinsic abi for aarch64 windows (#337) 2020-01-14 15:28:10 -06:00
Adam Schwalm d7191b14c1 Add separate rust_probestack definition for uefi (#335)
This is necessary because the Mach-O definition must have the
triple underscore, but the UEFI one must not.
2020-01-06 10:22:30 -06:00
Runji Wang 9193bbee5d Fix compile error on x86_64-unknown-uefi target (#331)
* fix compile error on x86_64-unknown-uefi target

* Fix tests on nightly
2019-12-10 09:02:14 -08:00
Tyler Mandry 2566aa663b Add control flow information to __rust_probestack (#328) 2019-12-06 08:51:42 -06:00
Alex Crichton d6a13419f6
Gate atomic intrinsics on presence of instructions (#324)
Don't emit the intrinsics for platforms which don't actually have the
instructions to do atomic loads/stores.

Closes #322
2019-11-11 12:38:50 -06:00
Alex Crichton 40ef6cb749
Allow FFI-unsafe warnings for u128/i128 (#323)
* Allow FFI-unsafe warnings for u128/i128

Handle new warnings on nightly, and we shouldn't need to worry about
these with compiler-builtins since this is tied to a particular compiler.

* Clean up crate attributes

* No need for stability marker
* Rustdoc docs not used for this crate
* Remove old build-system related cruft from rustc itself.

* Run `cargo fmt`
2019-11-11 12:19:10 -06:00
Oliver Scherer 7a8161dab7 Emit `_fltused` on `uefi` targets as a short-term workaround (#317)
* Emit `_fltused` on `uefi` targets as a short-term workaround

* Remove stray docker container
2019-11-07 13:04:11 -06:00
Ian Kronquist 462b73c1fe Implement bcmp (#315)
As of LLVM 9.0, certain calls to memcmp may be converted to bcmp, which I guess
could save a single subtraction on some architectures. [1]

bcmp is just like memcmp except instead of returning the difference between the
two differing bytes, it returns non-zero instead. As such, memcmp is a valid
implementation of bcmp.

If we care about size, bcmp should just call memcmp.
If we care about speed, we can change bcmp to look like this instead:
```rust
pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
    let mut i = 0;
    while i < n {
        let a = *s1.offset(i as isize);
        let b = *s2.offset(i as isize);
        if a != b {
            return 1;
        }
        i += 1;
    }
    0
}
```

In this PR I do not address any changes which may or may not be needed for arm
aebi as I lack proper test hardware.

[1]: https://releases.llvm.org/9.0.0/docs/ReleaseNotes.html#noteworthy-optimizations
2019-09-30 11:02:47 -05:00
Benjamin Saunders 9775f08b1d Tidy up unordered elementwise atomic memory intrinsics 2019-08-23 10:20:09 -07:00
Benjamin Saunders 997b86d767 Implement LLVM's elementwise unordered atomic memory intrinsics
Allows uses of intrinsics of the form
llvm.(memcpy|memmove|memset).element.unordered.atomic.* to be linked.
2019-08-21 18:21:58 -07:00
Alex Crichton c8b08eb470
Merge pull request #306 from da-x/probestack-frame-pointer
probestack: add frame pointers for easier traceback
2019-07-24 09:04:02 -05:00
Dan Aloni 985a43095c probestack: add frame pointers for easier traceback
This turns the following backtrace,

```
>> bt
 #0  0x0000555555576f73 in __rust_probestack () at /cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.14/src/probestack.rs:55
Backtrace stopped: Cannot access memory at address 0x7fffff7fedf0
```

To this:

```
>>> bt
 #0  0x0000555555574e47 in __rust_probestack ()
 #1  0x00005555555595ba in test::main ()
 #2  0x00005555555594f3 in std::rt::lang_start::{{closure}} ()
 #3  0x0000555555561ae3 in std::panicking::try::do_call ()
 #4  0x000055555556595a in __rust_maybe_catch_panic ()
 #5  0x000055555555af9b in std::rt::lang_start_internal ()
 #6  0x00005555555594d5 in std::rt::lang_start ()
 #7  0x000055555555977b in main ()
```
2019-07-24 10:18:30 +03:00
Alex Crichton e578d47247
Merge pull request #302 from bjorn3/no_128bit_lang_items
Replace {u,i}128_* lang items with __rust_{u,i}128_* unmangled functions
2019-07-19 09:44:00 -05:00
bjorn3 783430e6ae Replace {u,i}128_* lang items with __rust_{u,i}128_* unmangled functions
The -Zlower-128bit-ops feature is completely broken, as libcore needs
those lang items to compile with this feature, but they are only
provided by compiler_builtins, which itself depends on libcore.
According to rust-lang/rust#58969 the feature never got finished.

This commit removes the associated lang items and replaces them with
normal unmangled functions, when there is no existing intrinsic. This
makes it easier for alternative codegen backends to implement 128bit
integer support.
2019-07-13 11:38:35 +02:00
Ralf Jung 25edd204fa remove unused imports 2019-07-13 11:00:15 +02:00
Ralf Jung ebeace71ce avoid ptr::write which might panic in debug mode 2019-07-13 10:55:54 +02:00
varkor bf3a9e9d0b Update libm for fmin/fmax/fminf/fmaxf 2019-06-05 23:41:18 +01:00
Alex Crichton cf98161da7 Remove the need for #[cfg] in #[use_c_shim_if]
This commit tweaks the implementation of the synthetic
`#[use_c_shim_if]` attribute, renaming it to
`#[maybe_use_optimized_c_shim]` in the process. This no longer requires
specifying a `#[cfg]` clause indicating when the optimized intrinsic
should be used, but rather this is inferred and printed from the build
script.

The build script will now print out appropriate `#[cfg]` directives for
rustc to indicate what intrinsics it's compiling. This should remove the
need for us to keep the build script and the source in sync, but rather
the build script can simply take care of everything.
2019-05-15 12:59:31 -07:00
Alex Crichton c88c9502b7 Run rustfmt over everything 2019-05-14 14:40:38 -07:00
Alex Crichton 8521530f49 Fix __divsi3 and __udivsi3 on thumbv6m targets
This commit fixes a bug accidentally introduced in #285 where some
lingering references remained to `#[cfg(thumbv6m)]` but this, since the
historical revert, was renamed to `#[cfg(thumb_1)]`. This caused on the
thumbv6m platform for the intrinsics to be accidentally omitted because
the build script didn't actually compile them but the Rust code thought
the C code was in use.

After correcting the `#[cfg]` statements the CI configuration for the
`thumb*` family of targets was all updated. The support for xargo
testing was removed from `run.sh` since it had long since bitrotted, and
the script was updated to simply build the intrinsics example to attempt
to link for each of these targets. This in turn exposed the bug locally
and allowed to confirm a fix once the `#[cfg]` statements were
corrected.

cc rust-lang/rust#60782
2019-05-14 12:26:09 -07:00
Alex Crichton 4addb9bab9
Merge pull request #286 from alexcrichton/fix-dupe
Fix duplicate symbol __clzsi2
2019-05-02 17:17:52 -05:00
Alex Crichton 80a998df92 Fix duplicate floatdisf symbol on Windows MSVC 2019-05-02 14:22:19 -07:00
Alex Crichton 2668e5754d
Merge pull request #284 from alexcrichton/ldexp
Include `ldexp*` intrinsics on the wasm target
2019-05-02 16:17:33 -05:00
Alex Crichton 752e35a11f Fix duplicate symbol __clzsi2
Looks like our tests weren't quite testing compiler-builtins when it was
compiled with unmangled symbols, so update the tests to catch this and
then fix the compilation of the `__clzsi2` intrinsic to use the C
version if it's compiled.
2019-05-02 13:35:50 -07:00
Alex Crichton 4bbc838ac7 Revert "Use the Rust implementation of udivsi3 on ARM"
This reverts commit 681aaa914d.
2019-05-02 12:49:19 -07:00
Alex Crichton 4012b9c4f5 Include `ldexp*` intrinsics on the wasm target
Looks like LLVM optimizes programs like:

    fn foo(a: u8) -> f32 {
        2.0f32.powf(a as f32)
    }

to actually invoking `ldexpf`, so let's be sure to include bindings so
there's not undefined symbols.
2019-05-02 12:40:39 -07:00
Goirad aec945a708
Added missing fdim signature 2019-04-29 14:42:14 -07:00
Alex Crichton e95ef7a5ef Don't compile math symbols on wasm32-unknown-wasi
These are already provided by the C sysroot, so no need for us to
duplicate them!
2019-04-02 07:46:06 -07:00
Hugues de Valon c924aed0b9 Fix Armv8-M Baseline compilation
Armv8-M Baseline, ie thumbv8m.base-none-eabi, is a superset of the
Armv6-M architecture profile. As it shares almost the same instruction
set, this commit copies the configuration for thumbv6m-none-eabi to
enable it.
2019-03-14 12:58:23 +00:00
Jordan Rhee 803d16ee84 Fix undefined symbol errors on windows/arm
Fix undefined symbol linker errors when building rust for windows/arm
by excluding unneeded symbols. The errors are:

  = note: lib.def : error LNK2001: unresolved external symbol __aeabi_memclr4
  lib.def : error LNK2001: unresolved external symbol __aeabi_memclr8
  lib.def : error LNK2001: unresolved external symbol __aeabi_memmove4
  lib.def : error LNK2001: unresolved external symbol __aeabi_memmove8
2019-02-27 11:39:49 -08:00
Cyryl Płotnicki b570ccfd2d Fix compilation on new nightly.
Compilation on rustc 1.33.0-nightly (c76f3c374 2019-01-18) failed with
```
error: the feature `cfg_target_vendor` has been stable since 1.33.0 and no longer requires an attribute to enable
  --> src/lib.rs:19:12
   |
19 | #![feature(cfg_target_vendor)]
   |            ^^^^^^^^^^^^^^^^^
   |
```

Removed the attribute to make it compile.
2019-01-20 09:33:55 +00:00
Alex Crichton 9710af9a33
Merge pull request #267 from Lokathor/master
Adding __clzsi2
2019-01-07 09:36:45 -06:00
Lokathor 9a68e74ebd Attempt to use `intrinsics!` 2019-01-04 19:17:02 -07:00
Yu Ding a9a108548c Fix SGX target_env collision
Signed-off-by: Yu Ding <dingelish@gmail.com>
2019-01-03 12:53:08 -08:00
akashfortanix 09a2d437f5 expose ceil, floor and trunc on sgx-target 2018-12-27 19:13:50 +05:30
Lokathor 4e3fc640df Move clzi2 into the int module 2018-12-21 18:02:12 -07:00
Lokathor a74490a75b modify to fit into standard rustfmt output 2018-12-20 17:53:10 -07:00
Lokathor 3080360beb start of __clzsi2 2018-12-20 17:47:57 -07:00
Jethro Beekman e43c838450 Add SGX target 2018-11-21 14:07:57 +05:30
Jethro Beekman 14685d238b Add f32 versions of WebAssembly math functions 2018-11-21 14:07:03 +05:30