Commit Graph

92 Commits

Author SHA1 Message Date
Evgeniy Stepanov fa1d9f4860 Fix compilation of compiler_rt against libunwind.
libunwind defines _Unwind_GetLanguageSpecificData as returning long
instead of (uint8_t *).

llvm-svn: 226167
2015-01-15 14:27:38 +00:00
Saleem Abdulrasool a7452e434b builtins: avoid duplicating unwind declarations
Use unwind.h to get the declarations for unwinding interfaces.  This header is
already provided by clang and gcc, so this adds no additional dependencies for
building the builtins library.  It avoids the duplication which may drift over
time though.

llvm-svn: 225990
2015-01-14 15:55:17 +00:00
Roman Divacky 0c9c0c5a6d Add FreeBSD support for __clear_cache.
llvm-svn: 225610
2015-01-11 18:21:11 +00:00
Saleem Abdulrasool 5bbc718539 builtins: rely on the compiler for user label prefix
clang does not like the definition of builtins.  In order to work around this,
we use a SUN CC to redefine the generated name.  However, this requires that we
account for the user label prefix.  Rather than hard coding that into the file,
rely on the compiler to tell us the information and use the preprocessor to
generate the name as we do in the assembly routines.  NFC.

llvm-svn: 224597
2014-12-19 18:54:13 +00:00
Petar Jovanovic 7a6f5e47cf Do not define CRT_HAS_128BIT for MIPS64
Do not define it for MIPS64 until its backend supports it.
See the bug report [1] for more information.

[1] http://llvm.org/bugs/show_bug.cgi?id=20098

Differential Revision: http://reviews.llvm.org/D6703

llvm-svn: 224488
2014-12-18 01:21:33 +00:00
Saleem Abdulrasool 1fe0c18914 builtins: cleanup constant data section selection
Each of the object formats use a different directive for selecting the constant
section.  Use a macro to avoid the duplication across a number of files.  Also
correct a small macro mismatch on the Windows case (HIDDEN_DIRECTIVE -> HIDDEN).

Patch by Vadim Chugunov!

llvm-svn: 223910
2014-12-10 02:36:22 +00:00
Bob Wilson ec9a8c8b10 PR21518: Use unsigned arithmetic for trapping add/sub functions.
The code in {add,sub}v.i3 routines does not trap when it should, because
it performs the actual add/subtract operation in signed arithmetic,
rather than unsigned.

Patch by Francois-Xavie Coudert!

llvm-svn: 221826
2014-11-12 23:01:24 +00:00
Saleem Abdulrasool d888169d75 builtins: avoid endian.h in favour of compiler builtins
Use the __BYTE_ORDER__ macro which has been available in GCC since 4.6 and is
available in clang as well.

llvm-svn: 220626
2014-10-25 20:54:51 +00:00
Dan Albert c5d4bc7581 Fix checks for Android.
__ANDROID__ is a define that comes from the toolchain when building
for Android targets. ANDROID has a different meaning. ANDROID is
defined for _every_ Android build, including those done for host
modules. For host modules, we want to build the regular Linux
sanitizers and builtins, not the one for Android devices. This hasn't
been a problem until now because we only just started building the
sanitizers for the host.

llvm-svn: 220203
2014-10-20 15:35:01 +00:00
Bob Wilson ca0a38e0ae Add complex multiply/divide functions to arm64 iOS libclang_rt libraries.
Clang r219557 introduces libcalls to complex multiply/divide functions.
Since these functions are not available in iOS for arm64 devices, add them to
the static libraries.

llvm-svn: 219715
2014-10-14 20:33:36 +00:00
Tim Northover a5a06ad6fc AArch64: add support for ARM64 iOS versions of compiler-rt.
Just a dummy directory and a few sane choices in the Darwin SDK.

rdar://problem/18575597

llvm-svn: 219323
2014-10-08 17:28:37 +00:00
Saleem Abdulrasool 2cf5d82983 builtins: add missed change from previous commit
The macro rework was missing a trailing SEPARATOR for the .thumb_func, resulting
in assembly failures.

llvm-svn: 219183
2014-10-07 03:00:17 +00:00
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
Bob Wilson 115547464e Try harder to fix ARM/Linux after r219040.
llvm-svn: 219066
2014-10-04 20:11:10 +00:00
Bob Wilson d2f1281e6c Attempt to fix ARM/Linux after r219040.
llvm-svn: 219064
2014-10-04 18:13:41 +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
Evgeniy Stepanov 0f7ab59adc [sanitizer] Add i686 arch to compiler-rt.
This is needed so we can produce -i686- named libraries for
x86 Android (which is i686-linux-android).

An alternative solution would be keeping the "i386" name internally and
tweaking the OUTPUT_NAME of compiler-rt libraries.

llvm-svn: 218761
2014-10-01 12:55:06 +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 8bf8409be8 builtins: 80-column
Re-wrap a couple of lines.  NFC.

llvm-svn: 218096
2014-09-19 01:35:08 +00:00
Saleem Abdulrasool c5ff406f5f builtins: remove definition of __ARM_ARCH
__ARM_ARCH is part of the ACLE specification.  At least clang and GCC have
supported this part of the ACLE for some time now.  Let the compiler provide the
proper definition for the macro rather than try to guess it.

llvm-svn: 218095
2014-09-19 01:34:03 +00:00
Joerg Sonnenberger ed35a3e717 Implement floatsitf, floatunstfsi, which perform
(signed/unsigned)integer to quad-precision conversion.

Submitted by GuanHong Liu.

Differential Revision: http://reviews.llvm.org/D2805

llvm-svn: 217901
2014-09-16 20:34:41 +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 b6a85b4f6a builtins: remove unnecessary COMPILER_RT_EXPORT
This macro did not do anything at this point, and is not particularly needed for
Windows unless building the builtins as a shared library.  NFC.

llvm-svn: 217321
2014-09-06 21:33:55 +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
Saleem Abdulrasool b72a2fdd72 builtins: avoid multiple definitions of symbols
The architecture specific implementation of routines would be built and included
along with the generic implementation.  This would result in multiple
definitions of those symbols.

The linker is free to select either of the two.  Most of the time, this
shouldn't be too terrible as the forward iteration should catch the architecture
version due to the ordering.  Rather than relying on the linker and build
infrastructure ordering things in a specific manner, only provide the
architecture version when available.

This reduces the size of compiler-rt, simplifies inspection of the library
implementations, and guarantees that the desired version is selected at a
slightly complex build system.

llvm-svn: 214040
2014-07-26 23:44:22 +00:00
Saleem Abdulrasool 24c68b26d8 builtins: add missed files from previous commits
This adds missed files in SVN r214033 for alignment and corrects a change from
SVN r214034 for fixing compilation with GCC.

llvm-svn: 214039
2014-07-26 23:44:18 +00:00
Saleem Abdulrasool 12ae9a8704 builtins: move the readonly constants into rodata
Place the floating point constants into the read-only data section.  This was
already being done for x86_64, this simply mirrors the behaviour for i686.

llvm-svn: 214034
2014-07-26 21:08:41 +00:00
Saleem Abdulrasool 15a906cf37 builtins: correct constant alignments
MMX/SSE instructions expect 128-bit alignment (16-byte) for constants that they
reference.  Correct the alignment on the constant values.  Although it is quite
possible for the data to end up aligned, there is no guarantee that this will
occur unless it is explicitly aligned to the desired location.  If the data ends
up being unaligned, the resultant binary would fault at runtime due to the
unaligned access.

As an example, the follow would fault previously:
  cc -c lib/builtins/x86_64/floatundidf.S -o floatundidf.o
  cc -c test/builtins/Unit/floatundidf_test.c -o floatundidf_test.c
  ld -m elf_x86_64 floatundidf.o floatundidf_test.o -lc -o floatundidf

However, if the object files were reversed, the data would end up aligned and
the problem would go unnoticed.

llvm-svn: 214033
2014-07-26 21:08:34 +00:00
Saleem Abdulrasool 7618240aa9 builtins: re-enable building assembly sources
Re-apply SVN r213684 which was reverted in SVN r213724 since it broke the
build bots.  Add a tweak to enable inclusion of the assembly sources in
standalone build as well.

Original commit message:

This patch address the PR20360. The CMake assembler build system
ignores the .S assembly files in builtins library build. This patch
fixes the issue.

llvm-svn: 214013
2014-07-26 04:04:02 +00:00
Saleem Abdulrasool 93efc78a04 builtins: make the x86_64 compatible with GAS
The .rodata directive was added on the IA-64 (Itanium) platform.  The LLVM IAS
supports the .rodata on i386 and x86_64 as well.  There is no reason to really
restrict compilation of the builtins to just clang.  By explicitly indicating
that the data is meant to be pushed into the .rodata section via the .section
.rodata, the assembly is made compatible with clang and gcc (with GAS).

This will enable building these routines on the Linux buildbots via CMake.

llvm-svn: 214012
2014-07-26 04:03:59 +00:00
Renato Golin bb3d7b5e81 Revert "Include assembly files in builtins library build"
This reverts commit r213684, since it was breaking the compiler-rt
build and the sanitizers' bot.

llvm-svn: 213724
2014-07-23 04:46:23 +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
Renato Golin aad0347c8b Include assembly files in builtins library build
The CMake assembler build system ignores the .S assembly files in builtins
library build. This patch fixes the issue.

Patch by: Sumanth Gundapaneni

llvm-svn: 213684
2014-07-22 20:59:38 +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
Tim Northover 9775cffe14 MachO: add dummy armv6m architecture directory so clang_macho_embedded builds things.
Without some mention of armv6m in a subdirectory of builtins, the make code
doesn't even know that armv6m exists and is something it should be looking for
in the platform-specific Makefiles. This means that none of the functions
listed actually get built and we end up with an almost entirely empty
libclang_rt.a for armv6m.

Unfortunately, the assembly code in the usual arm directory has no hope of
running on armv6m, which only supports Thumb-1 (not even ARM mode), so adding
it there won't work. Realistically, we probably *will* want to put any
optimised versions in a separate directory, so creating it now is harmless.

rdar://problem/17613576

llvm-svn: 212696
2014-07-10 10:06:42 +00:00
Viktor Kutuzov cc02abbb20 Support building floating-point facilities on FreeBSD 9.2 in 32-bit mode
Differential Revision: http://reviews.llvm.org/D3909

llvm-svn: 212518
2014-07-08 08:52:57 +00:00
Saleem Abdulrasool d0d1638f96 builtins: assembly routines are not static
Storage Class 3 is static storage.  These symbols need to be marked as external
(storage class 2) so that they can be referenced.  Note that this external is
not the same as ELF "external" visibility, which is indicated by DLL Storage
Class (i.e. __declspec(dllexport) or __declspec(dllimport)).

llvm-svn: 211428
2014-06-21 01:41:21 +00:00
Joerg Sonnenberger 61d5d38e80 Provide mul for IEEE quad. From GuanHong Liu.
Differential Revision: http://reviews.llvm.org/D2799

llvm-svn: 211313
2014-06-19 20:34:03 +00:00
Joerg Sonnenberger 361519f409 Provide add and sub for IEEE quad. From GuanHong Liu.
Differential Revision: http://reviews.llvm.org/D2798

llvm-svn: 211312
2014-06-19 20:24:49 +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 2fd910dc72 compiler-rt: prefer .rodata for non MachO targets
Place constants into .rdata if targeting ELF or COFF/PE.  This should be
functionally identical, however, the data would be placed into a different
section.  This is purely a cleanup change.

llvm-svn: 209986
2014-06-01 04:07:07 +00:00