Commit Graph

166 Commits

Author SHA1 Message Date
Aaron Watry 49614fbfd9 atomic: Add generic implementation of atom[ic]_max
Not used yet...

v2: Correct int/uint behavior

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 217912
2014-09-16 22:34:24 +00:00
Aaron Watry c9b88d32be atomic: define extension functions for existing atomic implementations
We were missing the local versions of the atom_* before

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 217911
2014-09-16 22:34:21 +00:00
Aaron Watry 947bdd059a math: Add tan implementation
Uses the algorithm:
tan(x) = sin(x) / sqrt(1-sin^2(x))

An alternative is:
tan(x) = sin(x) / cos(x)

Which produces more verbose bitcode and longer assembly.

Either way, the generated bitcode seems pretty nasty and a more optimized
but still precise-enough solution is welcome.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 217511
2014-09-10 15:43:35 +00:00
Aaron Watry 951ab64d19 math: Add asin implementation
asin(x) = atan2(x, sqrt( 1-x^2 ))

alternatively:
asin(x) = PI/2 - acos(x)

Use the atan2 implementation since it produces slightly shorter bitcode and
R600 machine code.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 217510
2014-09-10 15:43:32 +00:00
Aaron Watry 268beab921 math: Add acos implementation
Passes the tests that were submitted to the piglit list

Tested on R600 (Pitcairn)

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 217509
2014-09-10 15:43:29 +00:00
Jan Vesely 05a60b7ac3 add isordered builtin
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 217247
2014-09-05 13:59:15 +00:00
Jan Vesely 63486c1f0e add isunordered builtin
v2: remove trailing newline

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 217246
2014-09-05 13:59:13 +00:00
Jan Vesely 41a0c491de add islessgreater builtin
v2: remove trailing newline

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 217245
2014-09-05 13:59:11 +00:00
Jan Vesely 369e20353c add isnormal builtin
v2: simplify and remove isnan leftovers
    remove trailing newline

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 217244
2014-09-05 13:59:09 +00:00
Jan Vesely a5a3b023b4 add isfinite builtin
v2: simplify and remove isinf leftovers
    remove trailing newline

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 217243
2014-09-05 13:59:06 +00:00
Tom Stellard 7a9e2c6879 Implement isinf builtin
llvm-svn: 217046
2014-09-03 15:55:40 +00:00
Tom Stellard d8a73abfc3 Fix implementation of copysign
This was previously implemented with a macro and we were using
__builtin_copysign(), which takes double inputs for the float
version of copysign().

Reviewed-and-Tested-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 217045
2014-09-03 15:55:38 +00:00
Jan Vesely ef513d392b Implement generic mad_sat
v2: Fix trailing whitespace
    Fix signed long overflow
    improve comment

v3: fix typo

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 216923
2014-09-02 17:55:02 +00:00
Aaron Watry 9447097636 Revert "Implement generic mad_sat"
This reverts commit cf62eded8b623a1c10d3692d25e5882b7939f564.

I didn't mean to commit this...  Jan has a v3 incoming

llvm-svn: 216322
2014-08-23 14:06:01 +00:00
Aaron Watry a4fdda01b8 Add int3/uint3 to integer-gentype.inc
These were missing and caused mad24/mul24 with int3/uint3 arg type to fail

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 216321
2014-08-23 14:04:36 +00:00
Aaron Watry 6bfac7ae69 Implement generic mad_sat
v2: Fix trailing whitespace
    Fix signed long overflow
    improve comment

Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
llvm-svn: 216320
2014-08-23 14:04:33 +00:00
Tom Stellard b8478abd2e Add missing file from r216127
llvm-svn: 216128
2014-08-20 21:28:44 +00:00
Tom Stellard 2ad4243bf7 Implement prefetch builtin
The default implementation is a no-op.  Targets should override this
with their own implementations.

llvm-svn: 216127
2014-08-20 21:23:03 +00:00
Jan Vesely 12c660827e relational: Add islessequal(floatN) builtin
v2: remove the initial undef

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 214568
2014-08-01 21:50:59 +00:00
Jan Vesely acba2c98eb relational: Add isless(floatN) builtin
v2: remove the initial undef

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 214567
2014-08-01 21:50:55 +00:00
Tom Stellard 903a78b7c6 Implement sin builtin for float types
This double version still uses @llvm.sin.

llvm-svn: 213762
2014-07-23 15:16:21 +00:00
Tom Stellard c0ab2f81e3 Implement cos builtin for float types
The double version still uses @llvm.cos.

llvm-svn: 213761
2014-07-23 15:16:18 +00:00
Tom Stellard f9caca8b9d Implement atan2 builtin
llvm-svn: 213760
2014-07-23 15:16:16 +00:00
Tom Stellard 47882923c7 Implement atan builtin
llvm-svn: 213759
2014-07-23 15:16:13 +00:00
Aaron Watry 9ef589e9cf Add several missing double constant definitions
These were present in CL 1.0, just not implemented yet.

v2: Use hex values and fix commit message

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jeroen Ketema <j.ketema@imperial.ac.uk>
CC: Matt Arsenault <Matthew.Arsenault@amd.com>
llvm-svn: 213321
2014-07-17 22:07:35 +00:00
Aaron Watry d7f022a582 relational: Implement isnotequal
v2: Use relational macros instead of hand-rolled ones

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 213320
2014-07-17 22:07:32 +00:00
Aaron Watry 30102536c0 relational: Implement isgreaterequal
v2: Use relational macros instead of hand-rolled macros

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 213319
2014-07-17 22:07:27 +00:00
Aaron Watry 803a992f04 relational: Implement isgreater
v2: Use relational macros instead of hand-rolled macros

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 213318
2014-07-17 22:07:19 +00:00
Aaron Watry 9335fe8eff relational/signbit: Refactor to use relational macros
Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 213317
2014-07-17 22:05:25 +00:00
Aaron Watry 13116cf01a relational: create re-usable macros for relational declarations
relational.h includes relational macros for defining functions which need to
return 1 for scalar true and -1 for vector true.

I believe that this is the only place that this behavior is required, so the
macro is placed at its lowest useful level (same directory as it is used in).

This also creates re-usable unary/binary declaration and floatn includes which
should simplify relational builtin declarations.

Mostly patterned off of include/math/[binary_decl|unary_decl|floatn].inc
but with required changes for relational functions.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 213315
2014-07-17 22:05:16 +00:00
Jeroen Ketema 575fb84cc3 OpenCL 1.1 does not define CL_VERSION_1_2 so use hardcoded number instead
Otherwise the test evaluates to true on OpenCL 1.1 and earlier. Since we
therefore cannot use the CL_VERSION_?_? macros move them to the proper
position in the top-level header.

llvm-svn: 211787
2014-06-26 15:26:38 +00:00
Aaron Watry d9ee196eab relational: Implement signbit
v2 Changes:
   - use __builtin_signbit instead of shifting by hand
   - significantly improve vector shuffling
   - Works correctly now for signbit(float16) on radeonsi

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
llvm-svn: 211696
2014-06-25 13:29:23 +00:00
Jeroen Ketema 42df5d2a8f Add exp10
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211680
2014-06-25 10:06:35 +00:00
Jeroen Ketema dd1fbc0082 Add half limits
These are apparently only defined in OpenCL 1.2.

HALF_MAX, HALF_MIN and HALF_EPSILON are currently omitted. Clang does
not seem to support the ‘h’ suffix for half float constants even with
the cl_khr_fp16 extension enabled.

Reviewed-by: Tom Sellard <tom@stellard.net>
llvm-svn: 211579
2014-06-24 09:51:01 +00:00
Jeroen Ketema 046b47fbbe Introduce CLC_VERSION macros v2
Add these out-of-order in clc.h so we can use these in other headers.

v2: Take into account the lack of a definition in OpenCL 1.0

Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211578
2014-06-24 09:46:52 +00:00
Jeroen Ketema 985a1381b2 Add MAXFLOAT
Align definitions while we are here.

Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211577
2014-06-24 09:41:28 +00:00
Jeroen Ketema 526fe2d501 Move clcmacro.h to avoid cluttering user namespace v2
v2: - use quotes instead of <>
    - add include to r600/lib/math/nextafter.c changed

Reviewed-by: Tom Stellard <tom@stellard.net>
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 211576
2014-06-24 09:36:32 +00:00
Jeroen Ketema 09516fa27d Add pown
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211211
2014-06-18 19:42:23 +00:00
Jeroen Ketema fdee0d3efe Add missing undefs
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211210
2014-06-18 19:37:34 +00:00
Aaron Watry d9afe9def0 Fix definition of INFINITY and add NAN/HUGE_VAL[F]
v3: change __builtin_nanf() to __builtin_nanf("")
    This doesn't work yet, but it was agreed to commit as-is with the logic
    that "broken" is better than "completely missing" and this should be
    fixed in clang.

v2: use __builtin_inff() and also add nan/huge_val definitions

Signed-off-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 211065
2014-06-16 22:32:58 +00:00
Jeroen Ketema f3bd08ae63 Add remaining float constants
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 211062
2014-06-16 22:15:50 +00:00
Aaron Watry 50f518be65 Revert "clctypes.h: Don't rely on stddef.h for size_t and ptrdiff_t"
This reverts commit 4cf021ae67b6ea8cfd42aa76ce6f5e1c329e145a.

llvm-svn: 211049
2014-06-16 20:21:19 +00:00
Aaron Watry 6af2969a61 math: Implement mix builtin
Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211047
2014-06-16 19:53:59 +00:00
Aaron Watry f7f79d2a94 relational: Add isequal(floatN) builtin
Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211046
2014-06-16 19:53:57 +00:00
Aaron Watry e167db9238 Add all(igentype) builtin
Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 211045
2014-06-16 19:53:54 +00:00
Aaron Watry c164fc384b clctypes.h: Don't rely on stddef.h for size_t and ptrdiff_t
llvm-svn: 211044
2014-06-16 19:53:52 +00:00
Jan Vesely bd37b6884c Add intptr types
Based on clang's stdint.h

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 210933
2014-06-13 19:43:18 +00:00
Jeroen Ketema 82aaa41286 Implementations for exp(float) and exp(double) v2
Use separate implementations instead of a macro
to ensure the constant multiplied with is of
higher precision.

v2: Use the correct formula, spotted by Dan Liew <daniel.liew@imperial.ac.uk>

Reviewed-by: Aaron Warty <awatry@gmail.com>
Reviewed-by: Tom Stellard <tom@stellard.net>
llvm-svn: 210891
2014-06-13 09:40:09 +00:00
Jeroen Ketema 75c1a0c6e2 Add more log related float constants
llvm-svn: 209850
2014-05-29 21:30:28 +00:00
Jeroen Ketema d1bb82a722 Fix _F definitions
The 'f' was missing and, hence, the values were
considered to be doubles instead of floats.

Reviewed by: Tom Stellard

llvm-svn: 209849
2014-05-29 21:29:34 +00:00
Jeroen Ketema a16fdbfac2 Add definition for M_PI
Reviewed by: Tom Stellard

llvm-svn: 209848
2014-05-29 21:24:57 +00:00
Tom Stellard 998602dac2 Remove clc/gentype.inc
This file duplicates clc/math/gentype.inc and is not
actually being used.

Patch by: Jeroen Ketema

llvm-svn: 207684
2014-04-30 18:35:17 +00:00
Tom Stellard f83fe5a6dc Introduce M_LOG2E_F and M_LOG2E
Patch by: Jeroen Ketema

llvm-svn: 205055
2014-03-28 21:19:03 +00:00
Tom Stellard ce43db105e Replace tabs by spaces
Patch by: Jeroen Ketema

llvm-svn: 205054
2014-03-28 21:19:00 +00:00
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 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 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 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
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
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
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 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
Tom Stellard eaa534450c Add integer-gentype.inc: Missing file from r185839
llvm-svn: 186326
2013-07-15 15:20:05 +00:00
Tom Stellard 6f33168bb7 Implement mad24() and mul24() builtins
Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 185839
2013-07-08 17:27:13 +00:00
Tom Stellard d768ac0395 Add __CLC_ prefix to all macro definitions in headers
libclc was defining and undefing GENTYPE and several other macros with
common names in its header files.  This was preventing applications from
defining macros with identical names as command line arguments to the
compiler, because the definitions in the header files were masking the
macros defined as compiler arguements.

Reviewed-by: Aaron Watry <awatry@gmail.com>
llvm-svn: 185838
2013-07-08 17:27:02 +00:00
Tom Stellard a4cadba551 Add bitselect() builtin
Reviewed-By: Aaron Watry <awatry@gmail.com>
llvm-svn: 185836
2013-07-08 17:26:33 +00:00
Tom Stellard 51441f80c5 libclc: Initial vstore implementation
Assumes that the target supports byte-addressable stores.

Completely unoptimized.

Patch by: Aaron Watry

llvm-svn: 185007
2013-06-26 18:22:11 +00:00
Tom Stellard 66ecbc7c18 libclc: Initial vload implementation
Should work for all targets and data types.  Completely unoptimized.

Patch by: Aaron Watry

llvm-svn: 185006
2013-06-26 18:22:05 +00:00
Tom Stellard e78344dfae libclc: Implement clz() builtin
Squashed commit of the following:

commit a0df0a0e86c55c1bdc0b9c0f5a739e5adef4b056
Author: Aaron Watry <awatry@gmail.com>
Date:   Mon Apr 15 18:42:04 2013 -0500

    libclc: Rename clz.ll to clz_if.ll to ensure it gets built.

    configure.py treats files that have the same name with the .cl and .ll
    extensions as overriding eachother.

    E.g. If you have clz.cl and clz.ll both specified to be built in the same
    SOURCES file, only the first file listed will actually be built.

    Since the contents of clz.ll were an interface that is implemented in
    clz_impl.ll, rename clz.ll to clz_if.ll to make sure that the interface is
    built.

commit 931b62bed05c58f737de625bd415af09571a6a5a
Author: Aaron Watry <awatry@gmail.com>
Date:   Sat Apr 13 12:32:54 2013 -0500

    libclc: llvm assembly implementation of clz

    Untested... currently crashes in the same manner as add_sat.

commit 6ef0b7b0b6d2e5584086b4b9a9243743b2e0538f
Author: Aaron Watry <awatry@gmail.com>
Date:   Sat Mar 23 12:35:27 2013 -0500

    libclc: Add stub clz builtin

    For scalar int/uint, attempt to use the clz llvm builtin.. for all others
    return 0 until an actual implementation is finished.

Patch by: Aaron Watry

llvm-svn: 185004
2013-06-26 18:21:55 +00:00
Tom Stellard 34f513df7c libclc: Add clamp(vec, scalar, scalar) and max(vec, scalar)
For any GENTYPE that isn't scalar, we need to implement a mixed
vector/scalar version of clamp/max.

This depends on the min() patches I sent to the list a few minutes ago.

Patch by: Aaron Watry

llvm-svn: 185003
2013-06-26 18:21:49 +00:00
Tom Stellard 075b31a2fa libclc: Implement the min(vec, scalar) version of the min builtin.
Checks if the current GENTYPE is scalar, and if not, then defines a separate
implementation of the function which casts the second arg to vector before
proceeding.

Patch by: Aaron Watry

llvm-svn: 185002
2013-06-26 18:21:44 +00:00
Tom Stellard 0be3acfc70 libclc: implement initial version of min()
This doesn't handle the integer cases for min(vector, scalar).

Patch by: Aaron Watry

llvm-svn: 185001
2013-06-26 18:21:38 +00:00
Tom Stellard 8c1e72f46a Simplify rotate implementation a bit..
Much more understandable/readable as a result, and probably more efficient.

Patch by: Aaron Watry

llvm-svn: 184997
2013-06-26 18:21:18 +00:00
Tom Stellard 0bb381eaec libclc: implement rotate builtin
This implementation does a lot of bit shifting and masking. Suffice to say,
this is somewhat suboptimal... but it does look to produce correct results
(after the piglit tests were corrected for sign extension issues).

Someone who knows LLVM better than I could re-write this more efficiently.

Patch by: Aaron Watry

llvm-svn: 184996
2013-06-26 18:21:13 +00:00
Tom Stellard cb133c9322 libclc: Move max builtin to shared/
Max(x,y) is available for all integer/floating types.

Patch by: Aaron Watry

llvm-svn: 184995
2013-06-26 18:21:06 +00:00
Tom Stellard fe23a30ef5 libclc: Add clamp() builtin for integer/floating point
Created under a new shared/ directory for functions which are available for
both integer and floating point types.

Patch by: Aaron Watry

llvm-svn: 184994
2013-06-26 18:20:56 +00:00
Tom Stellard ec87fb0b0c libclc: Add max() builtin function
Adds this function for both int and floating data types.

Patch by: Aaron Watry

llvm-svn: 184992
2013-06-26 18:20:46 +00:00
Tom Stellard 207345820f Implement ceil() builtin
llvm-svn: 184988
2013-06-26 18:20:30 +00:00
Tom Stellard 509b3b2104 Implement fmax() and fmin() builtins
llvm-svn: 184987
2013-06-26 18:20:25 +00:00
Tom Stellard d84c7f5d0f Remove the static keyword from the _CLC_INLINE macro
static functions are not allowed in OpenCL C

llvm-svn: 184986
2013-06-26 18:20:18 +00:00
Tom Stellard 560dbee27a Fix typo in include/clc/geometric/length.inc
llvm-svn: 184984
2013-06-26 18:20:12 +00:00
Tom Stellard 10b6c22e8d PTX: move implementations of work-item and synchronisation functions
to lib, and add header files in generic.  Incorporates a patch by
Tom Stellard!

llvm-svn: 184979
2013-06-26 18:19:54 +00:00
Tom Stellard 9d804dae35 Move R600 headers into generic directory
llvm-svn: 184978
2013-06-26 18:19:50 +00:00