Commit Graph

25 Commits

Author SHA1 Message Date
Saleem Abdulrasool 48d4e4dd35 builtins: rework use of DEFINE_COMPILERRT_THUMB_FUNCTION
This is simply to help clarity of the code.  The functions are built as thumb
only if Thumb2 is available (__ARM_ARCH_ISA_THUMB == 2).  Sink the selection
into the location of the definition and make DEFINE_COMPILERRT_THUMB_FUNCTION
always define a thumb function while DEFINE_COMPILERRT_FUNCTION always selects
the default.

Since the .thumb_func directive is always available (at least on Linux, Windows,
and BSD), sinking the macro right into the macro works just as well.

No functional change intended.

llvm-svn: 219182
2014-10-07 02:39:13 +00:00
Steven Wu 84610ba9b3 Fix the armv7 thumb builtins on darwin
The arm builtins converted into thumb in r213481 are not working
on darwin. On apple platforms, .thumb_func directive is required
to generated correct symbols for thumb functions.

<rdar://problem/18523605>

llvm-svn: 219040
2014-10-04 00:18:59 +00:00
Oliver Stannard 609e2e6a6e [compiler-rt] Do not use ldrexd or strexd on v7M
The ldrexd and strexd instructions are undefined for the ARMv7M
architecture, so we cannot use them to implement the
__sync_fetch_and_*_8 builtins. There is no other way to implement
these without OS support, so this patch #ifdef's these functions out
for M-class architectures.

There are no tests as I cannot find any existing tests for these
builtins.

I used the __ARM_ARCH_PROFILE predefine because __ARM_FEATURE_LDREX is
deprecated and not set by clang.

llvm-svn: 218601
2014-09-29 10:23:20 +00:00
Saleem Abdulrasool c89ae72e43 builtins: replace section symbol with reference to spec
Removes a non-ascii character that was committed.

llvm-svn: 217353
2014-09-08 01:49:24 +00:00
Saleem Abdulrasool a0a5873e28 builtins: add AEABI div0 functions
Add the missing AEABI functions that are part of the base platform ABI
specification.  The provided implementation does the bare minimum to avoid
requiring libc headers.  This permits the use of compiler-rt on bare-metal
environments which conform to EABI.

llvm-svn: 217322
2014-09-06 21:34:02 +00:00
Saleem Abdulrasool a0d65971d4 builtins: add signature to some assembly routines
Add a helpful description and a signature for the functions implemented in
assembly for the integral math routines.  NFC.

llvm-svn: 215296
2014-08-09 20:17:43 +00:00
Saleem Abdulrasool 6063983c30 builtins: correct __umodsi3, __udivsi3 on ARM
When building the builtins for a modern CPU (idiv support), __umodsi3 was
completely incorrect as it would behave as __udivmosi3, which takes a tertiary
parameter which is a pointer.

__udivsi3 was also incorrect, returning the remainder in r1.  Although this
would not result in any crash or invalid behaviour as r1 is a caller saved
register in AAPCS, this is unnecessary.  Simply perform the division ignoring
the remainder.

llvm-svn: 215295
2014-08-09 20:17:37 +00:00
Saleem Abdulrasool 3a2d6a3096 builtins: make ARM compilation with GAS work again
The LLVM IAS seems to accept wide instructions for add and sub in ARM mode even
though it is not permitted.  This uses a macro to ensure that the wide modifier
is only applied when building in THUMB mode.

This repairs building with GCC/GAS in ARM mode.

llvm-svn: 214046
2014-07-27 02:01:24 +00:00
Saleem Abdulrasool b6690c34cf builtins: move macro definitions into assembly.h
The macro definitions are shared across multiple files.  Define them once in the
assembly.h header rather than redefining it in each file.

llvm-svn: 214045
2014-07-27 02:01:20 +00:00
Saleem Abdulrasool 31306b1571 builtins: whitespace
llvm-svn: 214044
2014-07-27 02:01:15 +00:00
Renato Golin 8c714213d5 Fix incompatible assembly in ARM builtins library
Convert the CBNZ backward branch instruction to CMP and BNE
avoiding illegal backwards branch and making the assembly code
in synh-ops.h to be UAL compliant.

Patch by: Sumanth Gundapaneni

llvm-svn: 213685
2014-07-22 20:59:41 +00:00
Joerg Sonnenberger 9720fcf4bf Redo THUMB support.
Discussed with and tested by: Saleem Abdulrasool

llvm-svn: 213481
2014-07-20 20:53:37 +00:00
Joerg Sonnenberger 8f6cf7085a Revert r213467, it breaks non-thumb mode.
llvm-svn: 213479
2014-07-20 20:00:26 +00:00
Saleem Abdulrasool 8817bfe7e2 ARM: fix division in some cases
For ARM cores that are ARMv6T2+ but not ARMv7ve or ARMv7-r and not an updated
ARMv7-a that has the idiv extension (chips with clz but not idiv), an incorrect
jump would be calculated due to the preference to thumb instructions over ARM.

Rather than computing the target at runtime, use a jumptable instead.  This
trades a bit of storage for performance.  The overhead is 32-bytes for each of
the three routines, but avoid the calculation of the offset.

Because clz was introduced in ARMv6T2 and idiv in certain versions of ARMv7,
the non-clz, non-idiv case implies a target which does not support Thumb-2, and
thus we cannot use Thumb on those targets (as it is unlikely that the assembly
will assemble).

Take the opportunity to refactor the IT block macros into assembly.h rather than
redefining them in the TUs where they are used.

Existing tests cover the full change already, so no new tests are added.

This effectively reverts SVN r213309.

llvm-svn: 213467
2014-07-20 04:44:21 +00:00
Stephen Hines 31a38cc32f Revert Thumb-2 conversion of some ARM builtins.
The udivmodsi4/modsi3/umodsi3 code computes jump targets based on ARM encodings
(if CLZ is present and IDIV is not present).

Reverts parts of r211032 and r211035.

llvm-svn: 213309
2014-07-17 20:41:01 +00:00
Saleem Abdulrasool 8f2efc3a91 builtins: add it blocks for Thumb-2
Add the missing IT-blocks for Thumb-2 compilation for code paths exercised by
older ARM CPUs.  This should fix the buildbots.

llvm-svn: 211035
2014-06-16 16:36:25 +00:00
Saleem Abdulrasool 1b8f1a4430 compiler-rt: prefer thumb over ARM
When possible, use Thumb or Thumb-2 over ARM instructions.  This is particularly
important for pure-Thumb environments (e.g. Windows on ARM).  Although, it is
possible to conditionalise this for that target specifically, this is available
on most newer ARM CPUs, and the code remains compatible with older CPUs with no
adverse effects.  It therefore feels better to always prefer Thumb when
possible.

llvm-svn: 211032
2014-06-16 16:05:24 +00:00
Saleem Abdulrasool 57aa97f53a compiler-rt: whitespace and uniformity for arm
Make the whitespace a bit more uniform in the various assembly routines.  This
also makes the assembly files a bit more uniform on the ARM side by explicitly
stating that it is using the unified syntax and that the contents of the code is
in the text section (or segment).  No functional change.

llvm-svn: 209985
2014-06-01 04:07:03 +00:00
Alp Toker 1ee7fc7a1a Fix typos
llvm-svn: 208841
2014-05-15 02:22:34 +00:00
Jonathan Roelofs b351c1aba2 Move .subsections_via_symbols directives into DEFINE_COMPILERRT_PRIVATE_FUNCTION
llvm-svn: 208603
2014-05-12 17:38:36 +00:00
Saleem Abdulrasool 310874ae3c [CompilerRT] use .p2align, .balign instead of .align
The .align statements in ARM assembly routines is actually meant to be a power
of 2 alignment (e.g. .align 2 == 4 byte alignment, not 2).  Switch to using
.p2align.  .p2align is guaranteed to be a power-of-two alignment always and much
more explicit.

The .align in the case of x86_64 is byte alignment, use .balign instead of
.align.

llvm-svn: 208578
2014-05-12 15:23:37 +00:00
Tim Northover 65fe9377f0 ARM: fix file's header comment
llvm-svn: 203247
2014-03-07 14:56:29 +00:00
Tim Northover d3405cbb5d ARM: fix built-bots trying to use Thumb2 code on armv6m
llvm-svn: 202819
2014-03-04 11:10:58 +00:00
Tim Northover 1683caab3a ARM: implement __sync_fetch_and_* operations
Since these are primarily useful for deeply embedded targets where code size is
very important, they are each in a separate file making use of infrastructure
in sync-ops.h. This allows a linker to include just the functions that are
actually used.

rdar://problem/14736665

llvm-svn: 202812
2014-03-04 10:10:17 +00:00
Alexey Samsonov a6b264b51d Move original compiler-rt functions (libgcc replacement) to lib/builtins directory
llvm-svn: 201393
2014-02-14 09:20:33 +00:00