Commit Graph

118 Commits

Author SHA1 Message Date
Tom Stellard 6378f7a5e2 Add definition for M_PI_F v3
v2:
  - Use a hexadecimal constant.

v3:
  - Use a hexadecimal constant in floating-point notation.

llvm-svn: 204666
2014-03-24 20:36:44 +00:00
Tom Stellard 3a12fc6a07 Add sincos
Patch by: Jeroen Ketema

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 204478
2014-03-21 16:22:01 +00:00
Tom Stellard 074e7a8ed0 Add cross for double3 and double4
Patch by: Jeroen Ketema

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 204477
2014-03-21 16:21:58 +00:00
Tom Stellard 7aee1cfa99 Fix build since r202052
sys::fs_F_Binary has been replaced with sys::fs_F_Text

llvm-svn: 202081
2014-02-24 21:31:56 +00:00
Tom Stellard d873c8e05a Add generic nvptx targets
These do not import the code specific to nvidiacl

Patch by: Jeroen Ketema

llvm-svn: 201431
2014-02-14 20:33:53 +00:00
Tom Stellard 55d3746dbe Revert "Enforce python2 for systems that use python3 as their default."
This reverts commit r200413.

This was breaking the build on systems where the python 2.x executable
was called python.

llvm-svn: 201239
2014-02-12 14:54:17 +00:00
Tom Stellard 0d35ed912a Updated README.TXT with information about using DESTDIR and building with Ninja.
Patch by: Dan Liew

llvm-svn: 200416
2014-01-29 20:03:28 +00:00
Tom Stellard 8a3770ab97 Fixed rules names so they are unique when aliases are present.
This is necessary for building with Ninja because it does not allow
duplicate rule names.

Patch by: Dan Liew

llvm-svn: 200415
2014-01-29 20:03:27 +00:00
Tom Stellard 91d51db800 Fixed ninja build issues relating to use of $(DESTDIR)
We use ${DESTDIR} syntax now instead of $(DESTDIR) because that syntax
works both is the shell (at least it does for bash) and for make (at
least it does for GNU Make)

Patch By: Dan Liew

llvm-svn: 200414
2014-01-29 20:03:26 +00:00
Tom Stellard ac0fb621ce Enforce python2 for systems that use python3 as their default.
Patch by: Dan Liew

llvm-svn: 200413
2014-01-29 20:03:24 +00:00
Tom Stellard 8a63b15b3c Fix build broken by LLVM commit r199279
Patch by: Udo van den Heuvel

Tom Stellard:
  - Added ifdef and error handling

llvm-svn: 199687
2014-01-20 20:28:48 +00:00
NAKAMURA Takumi d40d387fb1 Update the copyright credits -- Happy new year 2014!
FIXME: Dragonegg may be updated at non-trivial changes.
llvm-svn: 198274
2014-01-01 08:27:31 +00:00
Aaron Watry 8ef48d07ef Pass -fno-builtin flag to clang to silence warnings
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 198168
2013-12-29 16:39:55 +00:00
Aaron Watry b38037f7b7 Fix build with LLVM 3.5
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 198167
2013-12-29 16:39:53 +00:00
Tom Stellard ce0709aa61 Add floating-point macro definitions v2
v2:
  - Fix typo.

Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 197784
2013-12-20 05:13:42 +00:00
Tom Stellard 1f3c9ba9f1 Implement trunc builtin.
OpenCL C lang says that trunc rounds towards zero.
llvm.trunc.* intrinsic rounds to integer not larger in magnitude.
These definitions are equivalent.

Patch by: Jan Vesely

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 197769
2013-12-20 02:08:46 +00:00
Tom Stellard 8bb6cb8009 Fix a C&P error in r195021 (65a950abab3cb8435ccb2646ac4773986c995c81)
Patch by: Kai Wasserbäch

Signed-off-by: Kai Wasserbäch <kai@dev.carbon-project.org>
llvm-svn: 195898
2013-11-28 00:17:29 +00:00
Tom Stellard eedd3064de R600: Add aliases for Sea Islands GPUs
llvm-svn: 195023
2013-11-18 18:21:30 +00:00
Tom Stellard 5abf149bf3 Implement round builtin
llvm-svn: 195022
2013-11-18 18:21:27 +00:00
Tom Stellard 457e35912e Implement builtins for cl_khr_global_int32_base_atomics extension
llvm-svn: 195021
2013-11-18 18:21:23 +00:00
Tom Stellard 3a9632d544 s/_CLC_DECL/_CLC_DEF/
Some function definitions were using _CLC_DECL, which meant that they
weren't being marked as always_inline.

Reviewed-by and Tested-by: Aaron Watry <awatry@gmail.com>

llvm-svn: 193754
2013-10-31 15:50:53 +00:00
Tom Stellard d2e83929a9 R600: Set the noduplicate attribute on barrier() intrinsics
This will prevent LLVM optimization passes from creating illegal uses
of the barrier() intrinsic (e.g. calling barrier() from a conditional
that is not executed by all threads).

llvm-svn: 193753
2013-10-31 15:50:48 +00:00
Tom Stellard 9fabcb3edb Clean-up dependency files
Patch by: Jeroen Ketema

llvm-svn: 193221
2013-10-23 02:49:33 +00:00
Tom Stellard 9f48bb3b9a Make C++ compiler configurable
The C++ compiler used to build prepare-builtins
may differ from the llvm/clang for which we are
building libclc.

Use 'clang++' as the default compiler.

Patch by: Jeroen Ketema

llvm-svn: 193220
2013-10-23 02:49:27 +00:00
Tom Stellard f21e3ea972 Port pocl's gen_convert.py script to libclc
This script generates implementations for the entire set of convert_*
functions,

llvm-svn: 192385
2013-10-10 19:09:01 +00:00
Tom Stellard 436bf70519 Implement sign() builtin
llvm-svn: 192384
2013-10-10 19:08:56 +00:00
Tom Stellard 6c7b86c106 Implement nextafter() builtin
There are two implementations of nextafter():
1. Using clang's __builtin_nextafter.  Clang replaces this builtin with
a call to nextafter which is part of libm.  Therefore, this
implementation will only work for targets with an implementation of
libm (e.g. most CPU targets).

2. The other implementation is written in OpenCL C.  This function is
known internally as __clc_nextafter and can be used by targets that
don't have access to libm.

llvm-svn: 192383
2013-10-10 19:08:51 +00:00
Tom Stellard e36e9dec65 Implement isnan() builtin
llvm-svn: 192382
2013-10-10 19:08:41 +00:00
Tom Stellard ef13294c93 Add missing as_{float,double} functions
llvm-svn: 192381
2013-10-10 19:08:29 +00:00
Aaron Watry dfd8afa02b Parenthesize arguments for mad_hi
Thanks to Jordon Rose <jordan_rose@apple.com> for pointing this out.

llvm-svn: 190310
2013-09-09 14:36:21 +00:00
Aaron Watry 3466342f57 Implement mad_hi built-in
We already have a working mul_hi, and the spec gives us the implementation as:
Returns mul_hi(a,b)+c.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 190211
2013-09-06 22:09:51 +00:00
Aaron Watry 283e3fa011 Add atomic_sub and atomic_dec builtin functions
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 190201
2013-09-06 20:20:21 +00:00
Tom Stellard 93d674f7b3 Place pkg-config file in $prefix/share/pkgconfig.
libclc is ABI-agnostic, and $prefix/lib/pkgconfig causes issues
on multilib setups. Using $prefix/share/pkgconfig allows us to reuse
a single libclc build across all system ABIs.

Patch by: Michał Górny

llvm-svn: 190107
2013-09-05 23:27:58 +00:00
Aaron Watry 7171a2f965 Remove unneeded semi-colons
Reviewed-By: Aaron Watry <awatry@gmail.com>
llvm-svn: 190059
2013-09-05 16:04:07 +00:00
Aaron Watry 50a7bcbac9 Add atomic_inc and atomic_add builtins
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 190058
2013-09-05 16:04:01 +00:00
Aaron Watry fbe439f8c0 Add mul_hi implementation [v2]
Everything except long/ulong is handled by just casting to the next larger type,
doing the math and then shifting/casting the result.

For 64-bit types, we break the high/low parts of each operand apart, and do
a FOIL-based multiplication.

v2:
  Discard the stack-overflow implementation due to copyright concerns.
  - The implementation is still FOIL-based, but discards the previous code.

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 188684
2013-08-19 18:31:49 +00:00
Aaron Watry 8548725f29 Add rhadd builtin
rhadd = (x+y+1)>>1

Implemented as:
(x>>1) + (y>>1) + ((x&1)|(y&1))

This prevents us having to do assembly addition and overflow detection

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 188477
2013-08-15 19:21:10 +00:00
Aaron Watry 7659157f1b Add hadd builtin
(x + y) >> 1 gets changed to:
(x>>1) + (y>>1) + (x&y&1)

Saves us having to do any llvm assembly and overflow checking in the addition.

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 188476
2013-08-15 19:21:07 +00:00
Aaron Watry 0c21c7c747 Add intN vloadN() implementations for address spaces 3 and 4
Not hooked up to R600 yet due to current lack of support, at least on EG.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 188181
2013-08-12 14:42:51 +00:00
Aaron Watry c0aa6e0291 Enable assembly vload3 int/uint constant/global for R600
It's supported by the R600 LLVM back-end now, at least for evergreen.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 188180
2013-08-12 14:42:50 +00:00
Aaron Watry 7d52565321 Add vload* for addrspace(2) and use as constant load for R600
Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 188179
2013-08-12 14:42:49 +00:00
Tom Stellard 41ef85df0a Add some missing convert_* functions
llvm-svn: 188131
2013-08-10 03:40:37 +00:00
Tom Stellard abbfd2bde0 Implement generic rint()
llvm-svn: 188130
2013-08-10 03:40:33 +00:00
Tom Stellard da920eab42 configure: Fix build when clang is installed to a non-standard prefix
llvm-svn: 188129
2013-08-10 03:40:26 +00:00
Aaron Watry 88ac12591c Add missing integer min/max definitions
Found in CL 1.1 spec section 6.11.3

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 187200
2013-07-26 13:02:02 +00:00
Aaron Watry bde11213e7 Added get_num_groups
The get_num_groups function was missing for r600g. I did the same
thing as the other workitem functions.

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 187059
2013-07-24 18:03:38 +00:00
Aaron Watry 1769b1fca9 Implement generic upsample()
Reduces all vector upsamples down to its scalar components, so probably
not the most efficient thing in the world, but it does what the
spec says it needs to do.

Another possible implementation would be to convert/cast everything as
unsigned if necessary, upsample the input vectors, create the upsampled
value, and then cast back to signed if required.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
llvm-svn: 186691
2013-07-19 16:44:37 +00:00
Aaron Watry 0da3d3b5ba Fix build with LLVM 3.4
F_Binary and friends were moved to include/Support/FileSystem.h

v2: Maintain compatibility with LLVM 3.3

Signed-off-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 186610
2013-07-18 21:24:35 +00:00
Aaron Watry 99a2f3b274 Fix and re-enable R600 vload/vstore assembly
The assembly optimizations were making unsafe assumptions about which address
spaces had which identifiers.

Also, fix vload/vstore with 64-bit pointers. This was broken previously on
Radeon SI.

This version still only has assembly versions of int/uint 2/4/8/16 for global
loads and stores on R600, but it does it in a way that would be very easily
extended to private/local/constant and could also be handled easily on other
architectures.

v2: 1) Leave v[load|store]_impl.ll in generic/lib
    2) Remove vload_if.ll and vstore_if.ll interfaces
    3) Fix address+offset calculations
    3) Remove offset from assembly arg list
llvm-svn: 186416
2013-07-16 14:29:01 +00:00
Aaron Watry 4cb7cf276d libclc: vload/vstore disable assembly and fix offset calculation
This commit gets us back to pure CLC and fixes offset calculations.

The next commit will re-enable the assembly implementation for R600,
fix bugs related to 64-bit address spaces, and also fix the
incorrect assumption that address space identifiers are the same in
all architectures.

llvm-svn: 186415
2013-07-16 14:28:58 +00:00