Commit Graph

91 Commits

Author SHA1 Message Date
NAKAMURA Takumi 74a0022fde clang/test/CodeGenOpenCL/opencl_types.cl: Tweak expressions according to r237548.
With MS mangler, the signature is:

  x86: define void @"\01?bad1@@$$J0YAXPAPAUocl_image1d@@PAPAUocl_image2d@@1@Z"  (%opencl.image1d_t** %b, %opencl.image2d_t** %c, %opencl.image2d_t** %d) nounwind
  x64: define void @"\01?bad1@@$$J0YAXPEAPAUocl_image1d@@PEAPAUocl_image2d@@1@Z"(%opencl.image1d_t** %b, %opencl.image2d_t** %c, %opencl.image2d_t** %d) nounwind

llvm-svn: 237551
2015-05-18 03:58:27 +00:00
Sanjay Patel a932bb93b0 Remove the cl-no-signed-zeros cc1 option
Use the driver flag -fno-signed-zeros instead.

This was recommended but not implemented in D6873:
http://reviews.llvm.org/D6873

which was checked in at r226915:
http://reviews.llvm.org/rL226915

llvm-svn: 234093
2015-04-04 14:54:24 +00:00
Tom Stellard b919c7d9eb Sema: Accept pointers to any address space for builtin functions
As long as they don't have an address space explicitly defined.

This allows builtins with pointer arguments to be used with OpenCL.

llvm-svn: 233706
2015-03-31 16:39:02 +00:00
Ahmed Bougacha 6ba3831ebe [CodeGen] Support native half inc/dec amounts.
We previously defaulted to long double, but it's also possible to have
a half inc/dec amount, when LangOpts NativeHalfType is set.
Currently, that's only true for OpenCL.

llvm-svn: 233135
2015-03-24 23:44:42 +00:00
David Blaikie bdf40a62a7 Test case updates for explicit type parameter to the gep operator
llvm-svn: 232187
2015-03-13 18:21:46 +00:00
Sameer Sahasrabuddhe a75db66eee Restores r228382, which was reverted in r228406.
The original commit failed to handle "shift assign" (<<=), which
broke the test mentioned in r228406. This is now fixed and the
test added to the lit tests under SemaOpenCL.

*** Original commit message from r228382 ***

OpenCL: handle shift operator with vector operands

Introduce a number of checks:
1. If LHS is a scalar, then RHS cannot be a vector.
2. Operands must be of integer type.
3. If both are vectors, then the number of elements must match.

Relax the requirement for "usual arithmetic conversions":
When LHS is a vector, a scalar RHS can simply be expanded into a
vector; OpenCL does not require that its rank be lower than the LHS.
For example, the following code is not an error even if the implicit
type of the constant literal is "int".

  char2 foo(char2 v) { return v << 1; }

Consolidate existing tests under CodeGenOpenCL, and add more tests
under SemaOpenCL.

llvm-svn: 230464
2015-02-25 05:48:23 +00:00
Matt Arsenault b8e668a52f Revert r229409: "Hack to try deleting file from build bots"
llvm-svn: 229411
2015-02-16 18:03:59 +00:00
Matt Arsenault 6f8c4cdcf6 Hack to try deleting file from build bots
llvm-svn: 229409
2015-02-16 17:33:12 +00:00
Matt Arsenault e7f4f86dff Don't create output file in test
llvm-svn: 229407
2015-02-16 17:11:58 +00:00
Matt Arsenault a03280de75 OpenCL: Accept -cl-strict-aliasing
This was in 1.0, but deprecated in 1.1. Accept it and do nothing
for compatability.

llvm-svn: 229403
2015-02-16 16:43:13 +00:00
Tom Stellard 96d5dc77fa Revert "OpenCL: handle shift operator with vector operands"
This reverts commit r228382.

This breaks the following case:  Reported by Jeroen Ketema:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150202/122961.html

typedef __attribute__((ext_vector_type(3))) char char3;

void foo() {
 char3 v = {1,1,1};
 char3 w = {1,2,3};

 w <<= v;
}

If I compile with:

 clang -x cl file.c

Then an error is produced:

file.c:10:5: error: expression is not assignable
 w <<= v;
 ~ ^
1 error generated.

llvm-svn: 228406
2015-02-06 17:30:04 +00:00
Sameer Sahasrabuddhe c65605d008 OpenCL: handle shift operator with vector operands
Introduce a number of checks:
1. If LHS is a scalar, then RHS cannot be a vector.
2. Operands must be of integer type.
3. If both are vectors, then the number of elements must match.

Relax the requirement for "usual arithmetic conversions":
When LHS is a vector, a scalar RHS can simply be expanded into a
vector; OpenCL does not require that its rank be lower than the LHS.
For example, the following code is not an error even if the implicit
type of the constant literal is "int".

  char2 foo(char2 v) { return v << 1; }

Consolidate existing tests under CodeGenOpenCL, and add more tests
under SemaOpenCL.

llvm-svn: 228382
2015-02-06 05:44:55 +00:00
Alexander Kornienko 21de0ae3d4 Re-apply "r226548 - Introduce SPIR calling conventions" reverted in r226558.
The test was fixed after a discussion with the revision author: the check
pattern was made more flexible as the "%call" part is not what we actually want
to check strictly there.

The original patch description:
===
Introduce SPIR calling conventions.

This implements Section 3.7 from the SPIR 1.2 spec:

    SPIR kernels should use "spir_kernel" calling convention.
    Non-kernel functions use "spir_func" calling convention. All
    other calling conventions are disallowed.

The patch works only for OpenCL source. Any other uses will need
to ensure that kernels are assigned the spir_kernel calling
convention correctly.
===

llvm-svn: 226561
2015-01-20 11:20:41 +00:00
Alexander Kornienko 22c9d67e34 Reverting r226548 as one of the tests fails in some configurations.
Here's the fail log from our internal setup:
===
  .../tools/clang/clang -cc1 -internal-isystem .../tools/clang/staging/include -nostdsysteminc .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl -triple spir-unknown-unknown -emit-llvm -o -
  FileCheck .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl
.../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl:11:12: error: expected string not found in input
 // CHECK: %call = tail call spir_func i32 @get_dummy_id(i32 0)
           ^
<stdin>:6:52: note: scanning from here
define spir_kernel void @foo(i32 addrspace(1)* %A) #0 {
                                                   ^
<stdin>:7:2: note: possible intended match here
 %1 = tail call spir_func i32 @get_dummy_id(i32 0) #2
 ^
===

Here's a failure on a public CI server:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/1183/

llvm-svn: 226558
2015-01-20 10:55:33 +00:00
Sameer Sahasrabuddhe 450a58b8af Introduce SPIR calling conventions.
This implements Section 3.7 from the SPIR 1.2 spec:

    SPIR kernels should use "spir_kernel" calling convention.
    Non-kernel functions use "spir_func" calling convention. All
    other calling conventions are disallowed.

The patch works only for OpenCL source. Any other uses will need
to ensure that kernels are assigned the spir_kernel calling
convention correctly.

llvm-svn: 226548
2015-01-20 06:44:32 +00:00
Matt Arsenault 6365ffea3e Add __builtin_amdgpu_class
llvm-svn: 225314
2015-01-06 23:14:57 +00:00
Tom Stellard d8e38a3206 R600: Handle amdgcn triple
For now there is no difference between amdgcn and r600.

llvm-svn: 225294
2015-01-06 20:34:47 +00:00
Pekka Jaaskelainen e94b0e1870 Fix an address space id reset with array decay's
implicit conversion. 

The issue was produced with OpenCL C code that 
called a function with a constant string literal
argument.

llvm-svn: 224592
2014-12-19 18:04:27 +00:00
Duncan P. N. Exon Smith b3a66691f8 IR: Make metadata typeless in assembly, clang side
Match LLVM changes from r224257.

llvm-svn: 224259
2014-12-15 19:10:08 +00:00
Pekka Jaaskelainen 3701450b06 OpenCL C: Add support for a set of floating point
arithmetic relaxation flags:

-cl-no-signed-zeros
-cl-unsafe-math-optimizations
-cl-finite-math-only
-cl-fast-relaxed-math

Propagate the info to FP instruction flags as well
as function attributes where they are available.

llvm-svn: 223928
2014-12-10 16:41:14 +00:00
Matt Arsenault 43fae6c855 Add attributes for AMDGPU register limits.
This is a performance hint that can be applied to kernels
to attempt to limit the number of used registers.

llvm-svn: 223384
2014-12-04 20:38:18 +00:00
Sameer Sahasrabuddhe c6093fea03 Always emit kernel arg info for SPIR.
http://llvm.org/bugs/show_bug.cgi?id=21555

Currently, kernel argument metadata is omitted unless the
"-cl-kernel-arg-info" option is specified. But the SPIR 1.2 spec
requires that all metadata except kernel_arg_name should always be
emitted, and kernel_arg_name is only emitted when
"-cl-kernel-arg-info" is specified.

Patch ported by Ryan Burn from the Khronos SPIR generator.
https://github.com/KhronosGroup/SPIR

llvm-svn: 223340
2014-12-04 05:30:58 +00:00
NAKAMURA Takumi ddd125a3f9 clang/test/CodeGenOpenCL/opencl_types.cl: Appease i686-msvc.
llvm-svn: 222969
2014-11-30 00:32:02 +00:00
NAKAMURA Takumi c3ee2c5a77 Tweak clang/test/CodeGenOpenCL/opencl_types.cl to appease msvc since r222941.
llvm-svn: 222956
2014-11-29 17:27:07 +00:00
David Majnemer eea02eefe7 AST: Consider pseudo-struct builtin types as substitutable
We didn't consider types like ObjCSel as a substitution candidate.

This fixes PR21688.

llvm-svn: 222941
2014-11-28 22:22:46 +00:00
Tim Northover 8603941057 OpenCL: fix test for lack of names in release builds
llvm-svn: 222853
2014-11-26 22:33:04 +00:00
Aaron Ballman eda0373900 Adding an explicit triple to this test to get it to pass all build bots.
llvm-svn: 222837
2014-11-26 16:17:20 +00:00
Anastasia Stulova 5d8ad8a7b8 [OpenCL] Implemented restrictions for pointer conversions specified in OpenCL v2.0.
OpenCL v2.0 s6.5.5 restricts conversion of pointers to different address spaces:
- the named address spaces (__global, __local, and __private) => __generic - implicitly converted;
- __generic => named - with an explicit cast;
- named <=> named - disallowed;
- __constant <=> any other - disallowed.

llvm-svn: 222834
2014-11-26 15:36:41 +00:00
Matt Arsenault 3f6469b4c6 Emit OpenCL local global variables without zeorinitializer
Local variables are not initialized, and every target has
been (incorrectly) ignoring the unnecessary request for
zero initialization.

llvm-svn: 221162
2014-11-03 16:51:53 +00:00
NAKAMURA Takumi 729be14435 Prune CRLF.
llvm-svn: 220678
2014-10-27 12:37:26 +00:00
Matt Arsenault 2174a9dc28 R600: Update for div_fmas intrinsic change
llvm-svn: 220339
2014-10-21 22:21:41 +00:00
Tom Stellard ade13b2a4e OpenCL: Emit global variables in the constant addr space as constant globals
llvm-svn: 219929
2014-10-16 15:29:19 +00:00
Tom Stellard f414fb75b0 Driver: Implement -cl-denorms-are-zero
This is currently a no-op, which is allowed by the OpenCL specification.

llvm-svn: 216179
2014-08-21 13:58:36 +00:00
Matt Arsenault dbb84916d9 R600: Add ldexp intrinsic
llvm-svn: 215738
2014-08-15 17:44:32 +00:00
Fraser Cormack dadc371e85 Add OpenCL/SPIR kernel_arg_base_type metadata node
As defined in the SPIR 1.2 specification, this node behaves similarly to
kernel_arg_type but will print the underlying type name, e.g., without
typedefs.

Example:
  typedef unsigned int myunsignedint;
would report:
  'myunsignedint' in the kernel_arg_type node
  'uint' in the kernel_arg_base_type node

llvm-svn: 214308
2014-07-30 14:39:53 +00:00
Fraser Cormack 152493b635 Fix OpenCL/SPIR kernel_arg_type metadata node
This fixes a bug where kernel_arg_type was always changing 'unsigned ' to 'u'
for any parameter type, including non-canonical types.

Example:
  typedef unsigned int myunsignedint;
would report:
  "myunt"

llvm-svn: 214305
2014-07-30 13:41:12 +00:00
Matt Arsenault 8587711164 Add codegen for more R600 builtins
llvm-svn: 213079
2014-07-15 17:23:46 +00:00
Matt Arsenault 56f008d538 Add R600 builtin codegen.
llvm-svn: 211631
2014-06-24 20:45:01 +00:00
Rafael Espindola df540cbf92 Update for llvm api change.
llvm-svn: 210303
2014-06-06 01:20:47 +00:00
Matt Arsenault 10e3ef8d2d Bug 18567: Fix constantexpr pointer casts with address spaces.
Getting a pointer into a struct at a non-zero offset would try to
use the default address space.

llvm-svn: 206478
2014-04-17 17:45:37 +00:00
Joey Gouly 92a47442f4 When printing types for the OpenCL kernel metadata, use the PrintingPolicy.
This allows 'half' to be printed as 'half' and not as '__fp16'.

Patch by Fraser Cormack!

llvm-svn: 205624
2014-04-04 13:43:57 +00:00
Hans Wennborg c9bd88e681 Remove the -cxx-abi command-line flag.
This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples,
Itanium otherwise. It's no longer possible to do weird combinations.

To be able to run a test with a specific ABI without constraining it to a
specific triple, new substitutions are added to lit: %itanium_abi_triple and
%ms_abi_triple can be used to get the current target triple adjusted to the
desired ABI. For example, if the test suite is running with the i686-pc-win32
target, %itanium_abi_triple will expand to i686-pc-mingw32.

Differential Revision: http://llvm-reviews.chandlerc.com/D2545

llvm-svn: 199250
2014-01-14 19:35:09 +00:00
Hans Wennborg 9125b08b52 Update tests in preparation for using the MS ABI for Win32 targets
In preparation for making the Win32 triple imply MS ABI mode,
make all tests pass in this mode, or make them use the Itanium
mode explicitly.

Differential Revision: http://llvm-reviews.chandlerc.com/D2401

llvm-svn: 199130
2014-01-13 19:48:13 +00:00
Pekka Jaaskelainen 3587b32e1c The OpenCL specification states that images are allocated
from the global address space (6.5.1 of the OpenCL 1.2 specification).
This makes clang construct the image arguments in the global address 
space and generate the argument metadata with the correct address space 
descriptor. 

Patch by Pedro Ferreira!

llvm-svn: 198868
2014-01-09 13:37:30 +00:00
Joey Gouly cf4143b55e Fix a crash in EmitStoreThroughExtVectorComponentLValue for vectors of odd sizes.
In OpenCL a vector of 3 elements, acts like a vector of four elements.
So for a vector of size 3 the '.hi' and '.odd' accessors, would access
the elements {2, 3} and {1, 3} respectively.
However, in EmitStoreThroughExtVectorComponentLValue we are still operating on
a vector of size 3, so we should only access {2} and {1}. We do this by checking
the last element to be accessed, and ignore it if it is out-of-bounds.

EmitLoadOfExtVectorElementLValue doesn't have a similar problem, because it does
a direct shufflevector with undef, so an out-of-bounds access just gives an undef
value.

Patch by Anastasia Stulova!

llvm-svn: 195367
2013-11-21 17:09:05 +00:00
Joey Gouly 561bba2e9f [OpenCL] Make sure we put string literals in the constant address space.
llvm-svn: 194717
2013-11-14 18:26:10 +00:00
David Tweed 31d09b0cef Certain multi-platform languages, such as OpenCL, have the concept of
address spaces which is both (1) a "semantic" concept and
(2) possibly a hardware level restriction. It is desirable to
be able to discard/merge the LLVM-level address spaces on arguments for which
there is no difference to the current backend while keeping
track of the semantic address spaces in a funciton prototype. To do this
enable addition of the address space into the name-mangling process. Add
some tests to document this behaviour against inadvertent changes.

Patch by Michele Scandale!

llvm-svn: 190684
2013-09-13 12:04:22 +00:00
Rafael Espindola ff7cea8c1a Don't pass -O0 to clang_cc1, it is the default.
llvm-svn: 189910
2013-09-04 04:12:25 +00:00
Stephen Lin 4362261b00 CHECK-LABEL-ify some code gen tests to improve diagnostic experience when tests fail.
llvm-svn: 188447
2013-08-15 06:47:53 +00:00
Justin Holewinski 368374308d Use kernel metadata to differentiate between kernel and device
functions for the NVPTX target.

llvm-svn: 178418
2013-03-30 14:38:24 +00:00