summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/builtins
Commit message (Collapse)AuthorAgeFilesLines
...
* builtins: implement __emutls_get_addressChih-Hung Hsieh2015-08-314-1/+195
| | | | | | | | | | For targets like Android that depends on libgcc's emulated thread local storage. clang/llvm can generate calls to __emutls_get_address since http://reviews.llvm.org/D10522 and http://reviews.llvm.org/D10524 Differential Revision: http://reviews.llvm.org/D12001 llvm-svn: 246454
* [CMake] merge add_compiler_rt_runtime and add_compiler_rt_darwin_runtime ↵Chris Bieneman2015-08-251-3/+10
| | | | | | | | | | | | | | | | into a single function Summary: This refactoring moves much of the Apple-specific behavior into a function in AddCompilerRT. The next cleanup patch will remove more of the if(APPLE) checks in the outlying CMakeLists. This patch adds a bunch of new functionality to add_compiler_rt_runtime so that the target names don't need to be reconstructed outside the call. It also updates some of the call sites to exercise the new functionality, but does not update all uses fully. Subsequent patches will further update call sites and move to using the new features. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: beanz, rengolin, llvm-commits Differential Revision: http://reviews.llvm.org/D12292 llvm-svn: 245970
* builtins: restrict aliasesSaleem Abdulrasool2015-08-214-0/+10
| | | | | | | | MachO and COFF do not support aliases. Restrict the alias to ELF targets. This should also fix the Darwin build. Make the FNALIAS usage an error on non-ELF targets. llvm-svn: 245669
* [compiler-rt] Add libgcc compatibility aliases for __cmp{s,d,f}f2.Josh Gao2015-08-214-0/+12
| | | | | | | | | | Reviewers: compnerd Subscribers: asl, llvm-commits Differential Revision: http://reviews.llvm.org/D12091 llvm-svn: 245663
* Implement __aeabi_c{d,f}{cmpeq,cmple,rcmple}.Josh Gao2015-08-216-0/+232
| | | | | | | | | | | | Summary: Implement more missing ARM EABI runtime functions. Reviewers: rengolin, compnerd Subscribers: pirama, srhines, danalbert, aemerson, llvm-commits Differential Revision: http://reviews.llvm.org/D12089 llvm-svn: 245648
* Implement __aeabi_{f,d}rsub.Dan Albert2015-08-185-2/+40
| | | | | | | | | | | | Summary: Implement the missing ARM EABI functions _aeabi_frsub and __aeabi_drsub. Reviewers: rengolin, compnerd Subscribers: pirama, srhines, danalbert, aemerson, llvm-commits Differential Revision: http://reviews.llvm.org/D12088 llvm-svn: 245321
* [compiler-rt] Add AArch64 to CMake configuration and several missing builtinsSergey Dmitrouk2015-08-184-1/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently CMake doesn't build builtins for AArch64 and if one does this anyway it's likely that at least `__multc3`, `__floatditf` and `__floatunditf` will be missing. There is actually more builtins to add, but these come from different libc implementations, thus providing them makes compiler-rt for AArch64 good enough at least for basic usage. Builtins implementation were originally taken from FreeBSD project: * [[ https://reviews.freebsd.org/D2173 | __multc3 ]] * [[ https://reviews.freebsd.org/D2174 | __floatditf and __floatunditf ]] Until they have been tested to find mistakes in `__float*` functions. `__floatditf` was based on `__floatsitf`, which had the same mistakes (fixed it in r243746). Version of the builtins in this patch are fixed and complemented with basic tests. Additionally they were tested via GCC's torture (this is what revealed these issues). P.S. Ed (author of FreeBSD patches) asked for feedback on the list some time ago (here [[ http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-March/084064.html | here ]]) and got no response, but it seems to be worth adding these builtins as is and extracting common part later. Reviewers: howard.hinnant, t.p.northover, jmolloy, enefaim, rengolin, zatrazz Subscribers: asl, emaste, samsonov, aemerson, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D11679 llvm-svn: 245296
* Fix __floatsitf() for negative inputSergey Dmitrouk2015-07-311-5/+3
| | | | | | | | | Negative numbers were handled properly initially, but got broken during addressing review, so none of them did actually work. Issues: * Wrong negation. * Wrong exponent calculation. llvm-svn: 243746
* Let cmake infer source file language by the file extension.Douglas Katzman2015-07-281-1/+0
| | | | | | | | | | | | | | | | | | This applies default compiler flags to .S files, in particular removing the "-pedantic" option, which is desirable because there is nothing to reasonably warn about; and the only thing that gcc warns about is that you allegedly can't correctly invoke GLUE2 in lib/builtins/assembly.h on platforms for which USER_LABEL_PREFIX is the empty string. In the gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33305 that added the warning, a commenter notes that giving a macro of zero characters to another macro is not precisely the same as failing to supply an argument, and "there is a widespread belief in C++ community that such usage is valid". Unfortunately the only way to silence the warning is to avoid -pedantic. Differential Revision: http://reviews.llvm.org/D10713 llvm-svn: 243446
* Add missing chkstk.S files from r242539Reid Kleckner2015-07-172-0/+73
| | | | llvm-svn: 242540
* compiler-rt: add support for mingw-w64 in builtinsReid Kleckner2015-07-172-1/+27
| | | | | | | | | | | | | | | | | The is so that we can avoid using libgcc and use compiler-rt with mingw-w64. Related driver patch http://reviews.llvm.org/D11077 I have tested this with mingw-w64 and everything seems to be in order. I also sent this patch to the mingw-w64 mailing list for them to look at. Patch by Martell Malone. Differential Revision: http://reviews.llvm.org/D11085 llvm-svn: 242539
* Fix incorrect truncation at the overflow boundaryPirama Arumuga Nainar2015-06-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch fixes incorrect truncation when the input wider value is exactly 2^dstBits. For that value, the overflow to infinity is not correctly handled. The fix is to replace a strict '>' with '>='. Currently, __truncdfsf2(340282366900000000000000000000000000000.0) returns infinity __truncdfsf2(340282366920938463463374607431768211456.0) returns 0 __truncdfsf2(400000000000000000000000000000000000000.0) returns infinity Likewise, __truncdfhf2 and __truncsfhf2 (and consequently gnu_f2h_ieee) are discontinuous at 65536.0. This patch adds tests for all three cases, along with adding a missing header include to fp_test.h. Reviewers: joerg, ab, srhines Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10594 llvm-svn: 240450
* builtins: mark functions as aapcs on WindowsSaleem Abdulrasool2015-05-221-1/+5
| | | | | | | | Windows does not use AAPCS, but rather AAPCS-VFP, and thus the functions which are assumed to be AAPCS will cause invalid argument setup. Ensure that the functions are marked as AAPCS. llvm-svn: 238056
* [Builtins] Implement f2h/h2f by jumping to trunc/extend.Ahmed Bougacha2015-05-142-4/+8
| | | | | | | | | | | | Follow-up to r237161; seems like we can't use aliases, but we can do better than duplicating the bodies, especially when that body, after inlining, isn't as small as it looks. Better approaches welcome. Perhaps the best thing is just to have an #ifndef __APPLE__ over the GNUEABI names, since they're not used there. llvm-svn: 237323
* [Builtins] Implement half-precision conversions.Ahmed Bougacha2015-05-127-5/+92
| | | | | | | | | | | | | | | | | Mostly uninteresting, except: - in __extendXfYf2, when checking if the number is normal, the old code relied on the unsignedness of src_rep_t, which is a problem when sizeof(src_rep_t) < sizeof(int): the result gets promoted to int, the signedness of which breaks the comparison. I added an explicit cast; it shouldn't affect other types. - we can't pass __fp16, so src_t and src_rep_t are the same. - the gnu_*_ieee symbols are simply duplicated definitions, as aliases are problematic on mach-o (where only weak aliases are supported; that's not what we want). Differential Revision: http://reviews.llvm.org/D9693 llvm-svn: 237161
* builtins: Implement the functions from stdatomic.hJustin Bogner2015-05-086-0/+116
| | | | | | | | | | | Talking to John and Doug, we concluded that these functions from stdatomic really do belong here in compiler-rt rather than in libc, since the compiler owns stdatomic.h and these need to refer to clang-specific builtins. Nonetheless, I've only added these on darwin for now - other platforms should probably do the same unless their libc does implement these functions. llvm-svn: 236805
* Fix float->uint conversion for inputs less than 0Derek Schuff2015-05-013-1/+3
| | | | | | | | | | | | | | | | | | | | Summary: The spec for these functions says that they should return 0 in this case but this regressed in r234148. That revision essentially delegates the conversion to the hardware, but that has different behavior on different platforms (e.g. it is wrong on x86). Also fix a typo in the name of __fixunsdfti Test Plan: The existing unit tests now pass Reviewers: joerg, howard.hinnant Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9305 llvm-svn: 236319
* Add hard float versions of FP to LL conversionsSergey Dmitrouk2015-04-064-4/+97
| | | | | | | | | | | | | | | | | | | | | | | | | This adds hard-float implementation for the following builtins: * __fixdfdi() * __fixsfdi() * __fixunsdfdi() * __fixunssfdi() The soft-float implementation does never raise floating point exceptions, which doesn't allow clients to detect floating point conversion errors. I must mention that I had to refer to libgcc's implementation to write these functions. Related unit-tests of compiler-rt passed with these changes. Patch was somewhat out-dated, so was updated locally without any functional changes. Differential Revision: http://reviews.llvm.org/D5376 llvm-svn: 234148
* We want single precision here.Joerg Sonnenberger2015-03-131-0/+3
| | | | llvm-svn: 232125
* Use signed int implementation for __fixintEd Maste2015-03-123-3/+3
| | | | llvm-svn: 232107
* Be nicer to C90 environments and avoid the declaration of variables in forJoerg Sonnenberger2015-03-111-2/+3
| | | | | | | | header. From Alexander Esilevich. llvm-svn: 231975
* Always include stddef.h to make sure size_t exists.Joerg Sonnenberger2015-03-111-0/+1
| | | | | | From Alexander Esilevich. llvm-svn: 231972
* Refactor float to integer conversion to share the same code.Joerg Sonnenberger2015-03-1125-376/+329
| | | | | | | | | | | | | 80bit Intel/PPC long double is excluded due to lacking support for the abstraction. Consistently provide saturation logic. Extend to long double on 128bit IEEE extended platforms. Initial patch with test cases from GuanHong Liu. Reviewed by Steve Canon. Differential Revision: http://reviews.llvm.org/D2804 llvm-svn: 231965
* Allow compiler-rt build on BitrigRenato Golin2015-03-021-2/+2
| | | | | | | | | This is the only patch Bitrig uses for compiler-rt. It adds support for Bitrig/arm in the clear cache code. Patch by Patrick Wildt. llvm-svn: 231012
* [MIPS] Add missing header for syscallPetar Jovanovic2015-02-281-0/+1
| | | | | | | | | | The syscall function itself is declared in <unistd.h> Compiling compiler-rt with -Werror-implicit-function-declaration will cause a build failure. This change fixes it. Differential Revision: http://reviews.llvm.org/D7949 llvm-svn: 230838
* Use compiler provided endianness definitions if available.Ed Schouten2015-02-231-12/+16
| | | | | | | | This makes int_endianness.h work on operating systems for which we haven't written explicit constructs, as long as GCC or Clang are being used. llvm-svn: 230208
* [mips] Add __clear_cache() definition for non-Android systemsPetar Jovanovic2015-02-101-4/+4
| | | | | | | | | Make sure clear_cache() builtin has an appropriate definition for Linux. Call syscall(NR_cacheflush, ...). Differential Revision: http://reviews.llvm.org/D7205 llvm-svn: 228767
* Remove invalid const qualifier for r0, since it is written by svc.Stephen Hines2015-02-031-1/+1
| | | | | | | | | | | | | | Summary: This causes an invalid lvalue error when building for Android. Reviewers: danalbert Reviewed By: danalbert Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7306 llvm-svn: 227907
* [MIPS64] Make __clear_cache more optimalPetar Jovanovic2015-01-201-1/+56
| | | | | | | | | Use synci implementation of clear_cache for short address ranges. For long address ranges, make a kernel call. Differential Revision: http://reviews.llvm.org/D6661 llvm-svn: 226567
* Fix compilation of compiler_rt against libunwind.Evgeniy Stepanov2015-01-151-1/+1
| | | | | | | libunwind defines _Unwind_GetLanguageSpecificData as returning long instead of (uint8_t *). llvm-svn: 226167
* builtins: avoid duplicating unwind declarationsSaleem Abdulrasool2015-01-142-44/+9
| | | | | | | | | 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
* Add FreeBSD support for __clear_cache.Roman Divacky2015-01-111-1/+6
| | | | llvm-svn: 225610
* builtins: rely on the compiler for user label prefixSaleem Abdulrasool2014-12-191-12/+6
| | | | | | | | | | 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
* Do not define CRT_HAS_128BIT for MIPS64Petar Jovanovic2014-12-181-1/+2
| | | | | | | | | | | 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
* builtins: cleanup constant data section selectionSaleem Abdulrasool2014-12-108-58/+14
| | | | | | | | | | 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
* PR21518: Use unsigned arithmetic for trapping add/sub functions.Bob Wilson2014-11-126-6/+6
| | | | | | | | | | 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
* builtins: avoid endian.h in favour of compiler builtinsSaleem Abdulrasool2014-10-251-4/+3
| | | | | | | Use the __BYTE_ORDER__ macro which has been available in GCC since 4.6 and is available in clang as well. llvm-svn: 220626
* Fix checks for Android.Dan Albert2014-10-201-4/+4
| | | | | | | | | | | | __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
* Add complex multiply/divide functions to arm64 iOS libclang_rt libraries.Bob Wilson2014-10-141-13/+0
| | | | | | | | 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
* AArch64: add support for ARM64 iOS versions of compiler-rt.Tim Northover2014-10-084-1/+37
| | | | | | | | Just a dummy directory and a few sane choices in the Darwin SDK. rdar://problem/18575597 llvm-svn: 219323
* builtins: add missed change from previous commitSaleem Abdulrasool2014-10-071-1/+1
| | | | | | | The macro rework was missing a trailing SEPARATOR for the .thumb_func, resulting in assembly failures. llvm-svn: 219183
* builtins: rework use of DEFINE_COMPILERRT_THUMB_FUNCTIONSaleem Abdulrasool2014-10-0711-8/+44
| | | | | | | | | | | | | | | 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
* Try harder to fix ARM/Linux after r219040.Bob Wilson2014-10-041-1/+6
| | | | llvm-svn: 219066
* Attempt to fix ARM/Linux after r219040.Bob Wilson2014-10-041-1/+1
| | | | llvm-svn: 219064
* Fix the armv7 thumb builtins on darwinSteven Wu2014-10-0412-12/+24
| | | | | | | | | | 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
* [sanitizer] Add i686 arch to compiler-rt.Evgeniy Stepanov2014-10-011-1/+4
| | | | | | | | | | 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
* [compiler-rt] Do not use ldrexd or strexd on v7MOliver Stannard2014-09-2910-0/+20
| | | | | | | | | | | | | | | | 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
* builtins: 80-columnSaleem Abdulrasool2014-09-191-2/+4
| | | | | | Re-wrap a couple of lines. NFC. llvm-svn: 218096
* builtins: remove definition of __ARM_ARCHSaleem Abdulrasool2014-09-191-27/+0
| | | | | | | | __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
* Implement floatsitf, floatunstfsi, which performJoerg Sonnenberger2014-09-162-0/+92
| | | | | | | | | | (signed/unsigned)integer to quad-precision conversion. Submitted by GuanHong Liu. Differential Revision: http://reviews.llvm.org/D2805 llvm-svn: 217901
OpenPOWER on IntegriCloud