Commit Graph

82 Commits

Author SHA1 Message Date
Khem Raj 5017de8ba4 [builtins] Do not force thumb mode directive in arm/sync-ops.h
.thumb_func was not switching mode until [1]
so it did not show up but now that .thumb_func (without argument) is
switching mode, its causing build failures on armv6 ( rpi0 ) even when
build is explicitly asking for this file to be built with -marm (ARM
mode), therefore use DEFINE_COMPILERRT_FUNCTION macro to add function
header which considers arch and mode from compiler cmdline to decide if
the function is built using thumb mode or arm mode.

[1] https://reviews.llvm.org/D101975

Note that it also needs https://reviews.llvm.org/D99282

Reviewed By: peter.smith, MaskRay

Differential Revision: https://reviews.llvm.org/D104183
2022-03-11 16:25:49 -08:00
Khem Raj a11d1cc41c [builtins] Use mcr for dmb instruction on armv6
At present compiler-rt cross compiles for armv6 ( -march=armv6 ) but includes
dmb instructions which are only available in armv7+ this causes SIGILL on
clang+compiler-rt compiled components on rpi0w platforms.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D99282
2022-03-10 19:30:00 -08:00
Eli Friedman 0389f2edf7 Revert "[compiler-rt] Implement ARM atomic operations for architectures without SMP support"
This reverts commit 910a642c0a.

There are serious correctness issues with the current approach: __sync_*
routines which are not actually atomic should not be enabled by default.

I'll continue discussion on the review.
2022-02-17 02:17:27 -08:00
Eli Friedman d20e01bb06 Revert "[NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h"
This reverts commit f165c23bf3.

Part of revert sequence for 910a642c0a.
2022-02-17 02:16:25 -08:00
Pavel Kosov f165c23bf3 [NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h 2022-02-17 10:21:22 +03:00
Pavel Kosov 910a642c0a [compiler-rt] Implement ARM atomic operations for architectures without SMP support
ARMv5 and older architectures don’t  support SMP and do not have atomic instructions. Still they’re in use in IoT world, where one has to stick to libgcc.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D116088
2022-02-17 10:11:25 +03:00
Kazuaki Ishizaki a1e7e401d2 [compiler-rt] NFC: Fix trivial typo
Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D77457
2021-09-04 14:12:58 +05:30
Alex Richardson ed0bf875a9 [builtins] Avoid enum name conflicts with fenv.h
After a follow-up change (D98332) this header can be included the same time
as fenv.h when running the tests. To avoid enum members conflicting with
the macros/enums defined in the host fenv.h, prefix them with CRT_.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D98333
2021-04-09 18:48:49 +01:00
Alex Richardson e2cd2f7d08 [builtins] Fix value of ARM_INEXACT
The existing value of 0x1000 sets the IXE bit (Inexact floating-point exception
trap enable), but we really want to be setting IXC, bit 4:
Inexact cumulative floating-point exception bit. This bit is set to 1 to
indicate that the Inexact floating-point exception has occurred since 0 was
last written to this bit.

Reviewed By: kongyi, peter.smith
Differential Revision: https://reviews.llvm.org/D98353
2021-03-12 11:15:24 +00:00
Yi Kong 33b8a55329 Revert "Revert "[builtins] Rounding mode support for addxf3/subxf3""
Test failure fixed.

This reverts commit e204d244ba.

llvm-svn: 371003
2019-09-05 01:05:05 +00:00
Nikita Popov a205ebb09c [builtins] Fix assembly in arm sync-ops.h
This assembly is part of a macro that was reformatted in D60351.
The missing space between push and { results in:

    Error: bad instruction `push{r4, r5,r6,lr}'

llvm-svn: 365957
2019-07-12 20:52:02 +00:00
Saleem Abdulrasool aad5d51882 builtins: correct function name for AEABI
If `COMPILER_RT_ARMHF_TARGET` is set , the definition of the AEABI runtime
function `__aeabi_fcmpun` is misspelt: `__aeabi_fcmpum` instead of
`__aeabi_fcmpun`.

Patch by Konstantin Schwarz!

llvm-svn: 362424
2019-06-03 17:08:13 +00:00
Petr Hosek 529118fc87 [builtins] Move the compare2f definition outside of the macro
This should hopefully address the error we're seeing in older versions
of Clang.

Differential Revision: https://reviews.llvm.org/D62554

llvm-svn: 361909
2019-05-29 01:51:56 +00:00
Petr Hosek 48140db797 [builtins] Deduplicate __eqsf2 and __gtsf2 via macro
The only difference between __eqsf2 and __gtsf2 is whether they return
1 or -1 on NaN. Rather than duplicating all the code, use a macro to
define the function twice and use an argument to decide whether to
negate the return value.

Differential Revision: https://reviews.llvm.org/D61919

llvm-svn: 361207
2019-05-20 23:34:24 +00:00
Petr Hosek 0ba22f51d1 [builtins] Use single line C++/C99 comment style
Use the uniform single line C++/99 style for code comments.

This is part of the cleanup proposed in "[RFC] compiler-rt builtins
cleanup and refactoring".

Differential Revision: https://reviews.llvm.org/D60352

llvm-svn: 359411
2019-04-28 22:47:49 +00:00
Petr Hosek 082b89b25f [builtins] Reformat builtins with clang-format
Update formatting to use the LLVM style.

This is part of the cleanup proposed in "[RFC] compiler-rt builtins
cleanup and refactoring".

Differential Revision: https://reviews.llvm.org/D60351

llvm-svn: 359410
2019-04-28 21:53:32 +00:00
Yi Kong 64c32362f0 [builtins] Add __cmpsf2 for ARM version of comparesf2
The generic version of comparesf2 defines __cmpsf2 alias for libgcc
compatibility, but the ARM overlay is missing the alias.

Differential Revision: https://reviews.llvm.org/D60805

llvm-svn: 358542
2019-04-17 01:30:33 +00:00
Yi Kong e204d244ba Revert "[builtins] Rounding mode support for addxf3/subxf3"
This reverts commit 2cabea054e.

Test failure on buildbots.

llvm-svn: 357048
2019-03-27 04:18:37 +00:00
Yi Kong 2cabea054e [builtins] Rounding mode support for addxf3/subxf3
Implement rounding mode support for addxf3/subxf3.

On architectures that implemented the support, this will access the
corresponding floating point environment register to apply the
correct rounding. For other architectures, it will keep the current
behaviour and use IEEE-754 default rounding mode (to nearest, ties
to even).

ARM32/AArch64 support implemented in this change. i386 and AMD64
will be added in a follow up change.

Differential Revision: https://reviews.llvm.org/D57143

llvm-svn: 357035
2019-03-26 22:01:22 +00:00
Chandler Carruth 57b08b0944 Update more file headers across all of the LLVM projects in the monorepo
to reflect the new license. These used slightly different spellings that
defeated my regular expressions.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351648
2019-01-19 10:56:40 +00:00
Kristina Brooks 59500f7a0b [Arm builtins] Remove non-necessary IS check
This patch removes the instruction set check to make the msr APSR_nzcvq,
ip instruction only execute if Thumb2 is used.
The APSR is a subset of the bits of the CPSR
(B.1.3.3 of the Arm v7 A and R ARM [1]) and is only available for A and
R profiles.
However in section B.9.3.11 of the same document we see that:

"In the A and R profiles, APSR_nzcvq is the same as CPSR_f"
"ARM recommends the APSR forms when only the N, Z, C, V, Q, and GE[3:0]
bits are being written."

This patch also make those files assemble for Armv8-M Mainline
architecture profile.

The builtins were cross-compiled for Arm, Aarch64 and Armv6-M, Armv7-M
and Armv7E-M targets.
Cross-compiled tests were executed for Arm target.

[1]: https://developer.arm.com/docs/ddi0406/latest/arm-architecture-reference-manual-armv7-a-and-armv7-r-edition

Patch by hug-dev (Hugues de Valon).

Differential Revision: https://reviews.llvm.org/D51854

llvm-svn: 343601
2018-10-02 16:32:32 +00:00
Tim Northover 8f141016ee ARM: wrap call to __clzsi2 so that the name is correct on MachO.
MachO symbols are prefixed with an extra '_' (that's 3 in total for this
function), so assembly calls have to go through a wrapper to insert any prefix
needed.

llvm-svn: 341540
2018-09-06 12:13:46 +00:00
Martin Storsjo 946a81f5b0 [builtins] Implement the __chkstk function for ARM for MinGW
This function is available for linking in from kernel32.dll, but
it's not allowed to link that function from there in Windows Store
apps.

Differential Revision: https://reviews.llvm.org/D49055

llvm-svn: 337313
2018-07-17 19:14:47 +00:00
Weiming Zhao e58bb5dc4e [Builtins] Do not use tailcall for Thumb1
Summary:
The `b` instruction in Thumb1 has limited range, which may cause link-time errors if the jump target is far away.
This patch guards the tailcalls for non-Thumb1

Reviewers: peter.smith, compnerd, rengolin, eli.friedman

Reviewed By: rengolin

Subscribers: joerg, dalias, javed.absar, llvm-commits

Differential Revision: https://reviews.llvm.org/D39700

llvm-svn: 317814
2017-11-09 17:32:57 +00:00
Manoj Gupta e2ff2ba57d [builtins] ARM: Reland fix for assembling builtins in thumb state.
Summary:
clang does not assemble files in thumb mode unless .thumb declaration
is present. Add .thumb/.arm decl to _FUNCTION macros to ensure 	that
files are assembled correctly.

Also add a fix to ensure that armv7k-watchos can assemble the
aeabi_c{f|d}cmp.S files.

Fixes PR 34715.

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, efriedma, t.p.northover, fjricci

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D38390

llvm-svn: 314718
2017-10-02 20:56:49 +00:00
Manoj Gupta bfa662ae4e [builtins] ARM: Revert r314284, r314285 and r314289
Revert r314284, r314285 and r314289 because of a reported
breakage in armv7k watchos builder.

llvm-svn: 314333
2017-09-27 19:06:47 +00:00
Manoj Gupta 9c277321e3 [Builtins] ARM: Fix msr assembly instruction use for Thumb2.
Summary:
MSR instruction in Thumb2 does not support immediate operand.
Fix this by moving the condition for V7-M to Thumb2 since V7-M support
Thumb2 only. With this change, aeabi_cfcmp.s and aeabi_cdcmp.S files can
be assembled in Thumb2 mode. (This is split out from the review D38227).

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, kristof.beyls

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits

Differential Revision: https://reviews.llvm.org/D38268

llvm-svn: 314284
2017-09-27 09:29:57 +00:00
Manoj Gupta 347ff633f7 [Builtins] Use 4 byte alignment for __aeabi_memclr.
Summary:
Align __aeabi_memclr to 4 bytes. All other ARM functions are already aligned to
4-bytes in compiler-rt.
(Split off from review D38227)

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, kristof.beyls

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits

Differential Revision: https://reviews.llvm.org/D38271

llvm-svn: 314255
2017-09-26 22:37:08 +00:00
Oleg Ranevskyy 6c75b51bb5 [ARM][Compiler-rt] Fix AEABI builtins to correctly pass arguments to non-AEABI functions on HF targets
Summary:
This is a patch for PR34167.

On HF targets functions like `__{eq,lt,le,ge,gt}df2` and `__{eq,lt,le,ge,gt}sf2` expect their arguments to be passed in d/s registers, while some of the AEABI builtins pass them in r registers.

Reviewers: compnerd, peter.smith, asl

Reviewed By: peter.smith, asl

Subscribers: peter.smith, aemerson, dberris, javed.absar, llvm-commits, asl, kristof.beyls

Differential Revision: https://reviews.llvm.org/D36675

llvm-svn: 311555
2017-08-23 14:26:31 +00:00
Weiming Zhao 8bf15723ae [builtins][ARM] Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
 mode (-mthumb, -marm), it reflect's capability of given CPU.

Due to this:
•use tbumb and thumb2 insteand of __ARM_ARCH_ISA_THUMB
•use '.thumb' directive consistently in all affected files
•decorate all thumb functions using DEFINE_COMPILERRT_THUMB_FUNCTION()

(This is based off  Michal's patch https://reviews.llvm.org/D30938)

Reviewers: dim, rengolin, compnerd, strejda

Reviewed By: compnerd

Subscribers: peter.smith, kubamracek, mgorny, javed.absar, kristof.beyls, jamesduley, aemerson, llvm-commits

Differential Revision: https://reviews.llvm.org/D31220

llvm-svn: 310884
2017-08-14 20:48:47 +00:00
Jonathan Roelofs dc62b80c82 Allow armv{7,7s,7k,7m,7em} builds
llvm-svn: 303765
2017-05-24 15:53:24 +00:00
Saleem Abdulrasool 92a239b225 builtins: one more case of a missing header
llvm-svn: 303195
2017-05-16 18:19:44 +00:00
Saleem Abdulrasool 369f74c16b builtins: add missing includes
This inclusion is needed to fix the ARM build.  The int_lib.h include is
slightly ugly, but allows us to use the `AEABI_RTABI` macro to decorate
the CC for the functions.

llvm-svn: 303190
2017-05-16 17:06:48 +00:00
Saleem Abdulrasool 36ac5ddff7 builtins: expand out the AEABI function stubs
These actually may change calling conventions.  We cannot simply provide
function aliases as the aliased function may have a different calling
convention.  Provide a forwarding function instead to permit the
compiler to synthesize the calling convention adjustment thunk.

Remove the `ARM_EABI_FNALIAS` macro as that is not safe to use.

Resolves PR33030!

llvm-svn: 303188
2017-05-16 16:41:37 +00:00
Weiming Zhao fbe67da29b [Builtins] Fix div0 error in udivsi3
Summary: Need to save `lr` before bl to aeabi_div0

Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31716

llvm-svn: 299628
2017-04-06 06:13:39 +00:00
Weiming Zhao a78ae8a172 Revert "builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA."
This reverts commit c3709191b6d36c4c936173f4a9a29a734b12cb15.
(commit by mistake)

llvm-svn: 298715
2017-03-24 17:08:35 +00:00
Weiming Zhao 19bf8bfa15 builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA.
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.

Due to this:
 - use  __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB
 - use '.thumb' directive consistently  in all affected files
 - decorate all thumb functions using
   DEFINE_COMPILERRT_THUMB_FUNCTION()

---------
Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 !

Reviewers: weimingz, rengolin, compnerd

Subscribers: aemerson, dim

Differential Revision: https://reviews.llvm.org/D30938

llvm-svn: 298713
2017-03-24 17:06:00 +00:00
Weiming Zhao a164f470e6 [Builtin][ARM] Fix subsf3vfp for non-HF target
Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: hans, aemerson

Differential Revision: https://reviews.llvm.org/D29869

llvm-svn: 294886
2017-02-12 05:10:25 +00:00
Weiming Zhao d53f34618b [Builtin][ARM] Implement addsf3/__aeabi_fadd for Thumb1
Summary:
This patch implements addsf3/__aeabi_fadd in asm for Thumb1.
Compared with generic C version (lib/fp_add_impl.inc), it
1. all constants are materialized instead of loading from constant pool
2. no stack spills (C version uses 136 bytes stack space)
3. clz() is called only when necessary. (C version always calls it)

Reviewers: compnerd, rengolin, asl

Reviewed By: asl

Subscribers: efriedma, aemerson, mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D29485

llvm-svn: 294172
2017-02-06 06:04:10 +00:00
Weiming Zhao a000b467d3 [Bultin][ARM] Make aeabi_uldivmod and aeabi_ldivmod be Thumb1 compatible
Summary:
in aeabi_ldivmod and uldivmod, using r6 instead of r12 as the temp reg due to limitation of Thumb1 ISA.
Now, all EABI sources are Thumb1 compatible.

Also added test cases by reusing the test cases from divmodsi4_test.c, udivmodsi4_test and udivmoddi4_test.c

Reviewers: rengolin, compnerd

Reviewed By: rengolin

Subscribers: javed.absar, aemerson, mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D29226

llvm-svn: 293527
2017-01-30 18:48:05 +00:00
Weiming Zhao 68e20da3f9 [Builtin][ARM] Add Thumb1 support for aeabi_c{f,d}cmp.S and dcmp.S
Reviewers: compnerd, rengolin

Reviewed By: rengolin

Subscribers: aemerson, llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28985

llvm-svn: 293247
2017-01-27 01:21:00 +00:00
Saleem Abdulrasool 309b3bfa6a builtins: remove an errant ':'
Thanks to Dave Lee for pointing this out!

llvm-svn: 293120
2017-01-26 00:37:55 +00:00
Weiming Zhao 19f47ace40 [Bultin][ARM] Make aeabi_memset be Thumb1 compatible and other asm
syntax fix

Summary:
Make the asm of  aeabi_memset be assembled for thumb1.
Also fix some instructions to conform with the syntax of ARM reference manual.
For example, muls requires the form of "Rd, Rn, Rd" and orrs requires
the form of "Rd, Rm". Clang-as is benign but it may fail other assembler
if not in the exact form.

Reviewers: rengolin, compnerd, kubamracek

Reviewed By: rengolin, compnerd

Subscribers: aemerson, llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28971

llvm-svn: 292727
2017-01-21 18:24:55 +00:00
Saleem Abdulrasool 9c287bca23 builtins: support building ARM builtins for a HF target
The `-target` impacts the CC for the builtins.  HF targets (with either
floating point ABI) always use AAPCS VFP for the builtins unless they
are AEABI builtins, in which case they use AAPCS.  Non-HF targets (with
either floating point ABI) always use AAPCS for the builtins and AAPCS
for the AEABI builtins.  This introduces the thunks necessary to switch
CC for the floating point operations.  This is not currently enabled,
and should be dependent on the target being used to build compiler-rt.
However, as a stop-gap, a define can be added for ASFLAGS to get the
thunks.

llvm-svn: 291677
2017-01-11 16:19:25 +00:00
Saleem Abdulrasool 7a0838b9b6 builtins: repair __gtsf2 after SVN r291396
The argument adjustment was accidentally removed, resulting in the use
of stale register values.

llvm-svn: 291591
2017-01-10 19:48:50 +00:00
Weiming Zhao ccd3e6803c [Builtins] [ARM] Adding Thumb1 support for fcmp
Summary: Mainly translate IT block into cmp/branch for functions in comparesf2.S

Reviewers: rengolin, compnerd

Subscribers: aemerson, llvm-commits

Differential Revision: https://reviews.llvm.org/D28016

llvm-svn: 291396
2017-01-08 18:51:12 +00:00
Weiming Zhao 0a274c5954 [builtin] Add Thumb1 implementation for idivsi3 and aeabi_idivmod
Summary:
For idivsi3, convert the Thumb2 only instruction to thumb1.
For aeabi_idivmod, using __divsi3.

Reviewers: rengolin, compnerd

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D27472

llvm-svn: 288960
2016-12-07 19:14:29 +00:00
Weiming Zhao 05fec0907d builtins: Add ARM Thumb1 implementation for uidiv and uidivmod
This is a resubmit of r288710 due to breakage of Darwin armv7em.

llvm-svn: 288777
2016-12-06 07:13:15 +00:00
Chris Bieneman 31150cbdc9 Revert "builtins: Add ARM Thumb1 implementation for uidiv and uidivmod"
This reverts commit r288710.

r288710 breaks building the builtin libraries on Darwin for armv7em.

Build logs may still be avaialable here:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/12035/console

llvm-svn: 288773
2016-12-06 05:41:32 +00:00
Weiming Zhao adf4258f50 builtins: Add ARM Thumb1 implementation for uidiv and uidivmod
Summary:
The current uidiv supports archs without clz. However, the asm is for thumb2/arm.
For uidivmod, the existing code calls the C version of uidivmodsi4, which then calls uidiv. The extra push/pop/bl makes it less efficient.

Reviewers: jmolloy, jroelofs, joerg, compnerd, rengolin

Subscribers: llvm-commits, aemerson

Differential Revision: https://reviews.llvm.org/D27309

llvm-svn: 288710
2016-12-05 21:40:36 +00:00