Commit Graph

447 Commits

Author SHA1 Message Date
David Hoppenbrouwers
e7a8932e3b Fix CI, better memcmp tests 2022-05-28 00:10:55 +02:00
David Hoppenbrouwers
4dbd8387f9 Implement faster memcmp for x86_64
x86_64 can load unaligned words in a single cache line as fast as
aligned words. Even when crossing cache or page boundaries it is just as
fast to do an unaligned word read instead of multiple byte reads.

Also add a couple more tests & benchmarks.
2022-05-27 21:58:39 +02:00
Amanieu d'Antras
18623bffad Merge pull request #464 from m-ou-se/floatconv2 2022-05-26 20:53:14 +02:00
Mara Bos
ca517a25e7 Explicitly use parentheses for associativity of shift operators. 2022-05-26 17:21:21 +02:00
Patryk Wychowaniec
ac47841ce2 Add avr_skip for __udivti3 & __umodti3 2022-05-24 19:49:08 +02:00
Amanieu d'Antras
092bbb67d4 Merge pull request #465 from thomcc/cast-before-transmute 2022-05-24 19:24:15 +02:00
Amanieu d'Antras
f1fe94e882 Merge pull request #462 from Patryk27/avr 2022-05-24 16:41:59 +02:00
Thom Chiovoloni
dcdd9bbc56 Avoid int to ptr transmute by casting first 2022-05-23 23:34:10 -07:00
Mara Bos
425c78ee7a Faster int<->float conversions. 2022-05-20 16:25:18 +02:00
Mara Bos
7ed26a7e7a De-duplicate 128 bit float conv intrinsics using cfg_attr. 2022-05-20 15:04:36 +02:00
Mara Bos
2063e07b35 Support cfg_attr attributes in intrinsics!() macro. 2022-05-20 15:01:50 +02:00
Patryk Wychowaniec
a695a800d5 Fix division on AVRs
For division and modulo, AVR uses a custom calling convention that does
not match compiler_builtins' expectations, leading to non-working code¹.

Ideally we'd just use hand-written naked functions (as, afair, ARM
does), but that's a lot of code to port², so hopefully we'll be able to
do it gradually later.

For the time being, I'd suggest not compiling problematic functions for
AVR target - this causes avr-gcc (which is a mandatory part of Rust+AVR
toolchain anyway) to link hand-written assembly from libgcc, which is
confirmed to work.

I've tested the code locally on simavr and the patch seems to be working
correctly :-)

¹ https://github.com/rust-lang/rust/issues/82242,
  https://github.com/rust-lang/rust/issues/83281
² 31048012db/libgcc/config/avr/lib1funcs.S

Closes https://github.com/rust-lang/rust/issues/82242
Closes https://github.com/rust-lang/rust/issues/83281
2022-05-17 23:21:45 +02:00
Johannes Stoelp
65ec71d386 rv32 rv64: adapt conditional compilation
Adapt conditional compilation as:
rv32i : riscv:__mulsi3, riscv:__muldi3
rv32im: riscv:__mulsi3, int/mul:__muldi3
rv64i : riscv:__mulsi3, riscv:__muldi3
rv64im: riscv:__mulsi3, int/mul:__muldi3
2022-05-12 00:34:49 +02:00
Johannes Stoelp
10971912e8 rv64 implement muldi3 intrinsic
Implement the __muldi3 intrinsic to prevent infinite recursion during
multiplication on rv64 without the 'm' extension.
2022-05-02 23:00:12 +02:00
Vadim Petrochenkov
7f535824f5 Provide an implementation of strlen to be used as a fallback 2022-03-18 21:42:11 +03:00
Nikita Popov
0575846f80 Handle Win64 builtins ABI change in LLVM 14
As of https://reviews.llvm.org/D110413, these no longer use the
unadjusted ABI (and use normal C ABI instead, passing i128
indirectly and returning it as <2 x i64>).

To support both LLVM 14 and older versions, rustc will expose a
"llvm14-builtins-abi" target feature, based on which
compiler-builtins can chose the appropriate ABI.

This is needed for rust-lang/rust#93577.
2022-02-15 16:29:29 +01:00
Amanieu d'Antras
5bdeade2c4 Fix typo in __aeabi_uldivmod
Accidentally introduced in #452
2022-02-09 21:01:07 +00:00
Amanieu d'Antras
f03c7fd6af Wrap all intrinsics in the intrinsics! macro
This ensures that each intrinsic ends up in a separate module, which in
turn (because rustc treats compiler_builtins specially) will result in
each intrinsic ending up in its own object file. This allows the linker
to only pick up object files for intrinsics that are missing and avoids
duplicate symbol definition errors.
2022-02-06 09:20:43 +00:00
Ayrton
9124cdc7ec Remove truncdfsf2.c from sources in build.rs and add test for __truncdfsf2vfp
Also fixed the calling convention for truncdfsf2 on ARM
2021-12-12 21:12:42 -05:00
Ayrton
03b4f62337 Add __truncdfsf2vfp for ARM 2021-12-12 15:36:09 -05:00
Ayrton
39cd6082e4 Add attribute for ARM alias 2021-12-12 15:19:05 -05:00
Ayrton
9e65060184 Add __truncdfsf2 intrinsic
This adds the truncdfsf2 intrinsic and a corresponding fuzz test case. The
implementation of trunc is generic to make it easy to add truncdfhs2 and
truncsfhf2 if rust ever gets `f16` support.
2021-12-12 15:01:34 -05:00
Amanieu d'Antras
0928b32141 Fix clippy lints 2021-12-10 00:04:25 +00:00
Amanieu d'Antras
4abfecabef Import the asm! macro from core::arch
It is going to be removed from the prelude due to the decision in
https://github.com/rust-lang/rust/issues/87228
2021-12-09 23:57:26 +00:00
William D. Jones
f275e26e3d Use fully-qualified syntax for abs_diff to avoid warning, which can trigger a compiler error. 2021-11-27 19:38:43 -05:00
William D. Jones
e6d7983889 Do not use atomic reads on platforms without atomic support in LLVM. 2021-11-27 17:47:46 -05:00
Alex Crichton
9a01750b1b Use more concise directives 2021-10-28 16:32:30 -07:00
Alex Crichton
b7fb6c594a Adjust some build directives for wasm64
This is still an experimental target but this should get the wasm64
target to behave more like wasm32.
2021-10-28 10:29:37 -07:00
Scott Mabin
3b4d10f6bc Add xtensa to list of soft math targets. 2021-10-16 15:27:40 +01:00
Georgy Shepelev
29dd109959 expose some math to UEFI envs 2021-10-15 23:18:56 +04:00
Gary Guo
1f0cbb2945 Use atomic_load_unordered for first word load in misaligned case 2021-08-31 00:22:43 +01:00
Gary Guo
709bd6e11c Add different misaligned path for archs with unaligned support 2021-08-21 03:48:56 +01:00
Gary Guo
45715eb7f7 Implement word-sized copy 2021-08-21 03:03:06 +01:00
Amanieu d'Antras
502370f277 Don't panic if the shift intrinsics receive out-of-range shifts
LLVM sometimes emits calls with out-of-range shifts but then discards
the results. We should avoid panics in these cases.
2021-07-30 00:25:36 +02:00
Aaron Kutch
fdcc30c3a3 Add public-test-deps feature for better visibility control 2021-06-02 14:13:54 -05:00
Tilmann Meyer
31e3ae708c Include Linux atomic emulation on androideabi
The old androideabi uses armv5 and thus also needs the atomic emulation
and because Android is basically Linux it can use the same
implementation.
2021-05-31 16:32:46 +02:00
Yuki Okushi
c041104afd Suppress some warnings 2021-05-31 20:53:15 +09:00
Amanieu d'Antras
fdbeb187ec Add missing .att_syntax from #414 2021-05-02 21:29:00 +01:00
Amanieu d'Antras
22a1874e5d Merge pull request #414 from Amanieu/global_asm
Mark global_asm! code with .att_syntax
2021-04-11 14:51:56 +01:00
Amanieu d'Antras
68df0eb817 Mark global_asm! code with .att_syntax
global_asm! will soon change to use Intel syntax by default.
2021-04-10 19:19:21 +01:00
bjorn3
5dd043525a Fix typo 2021-04-10 16:03:19 +02:00
Scott Mabin
8c4127d044 Add #[linkage = "weak"] attribute to all mem instrinics. 2021-04-04 19:15:33 +01:00
Amanieu d'Antras
c31c2e0556 Merge pull request #397 from AaronKutch/float_refactor 2021-04-02 23:36:28 +01:00
Aaron Kutch
500c8e0b2c add clippy to CI 2021-04-02 16:53:09 -05:00
Amanieu d'Antras
2608f8392c Replace llvm_asm! with asm! 2021-04-02 20:43:11 +01:00
Aaron Kutch
9ae3728e5e fix CTFE cycle 2021-04-02 09:24:00 -05:00
Aaron Kutch
1cf47804df Fix all clippy warnings 2021-04-02 08:58:50 -05:00
Aaron Kutch
3871282eee fix powi 2021-04-02 08:58:50 -05:00
Aaron Kutch
ec4fc5dab5 refactor float conversion 2021-04-02 08:58:50 -05:00
Aaron Kutch
0ce47b3c1f fix abs_diff bug 2021-04-02 08:57:25 -05:00