Commit Graph

7 Commits

Author SHA1 Message Date
Peter Collingbourne bcf909d737 Update clang for D20348
Differential Revision: http://reviews.llvm.org/D20339

llvm-svn: 272710
2016-06-14 21:02:05 +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
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
David Tweed c38f11de40 r172047 lacked a test (due to incomplete OpenCL support in clang). Use a modified
version of a test by Joey Gouly to use attributes to materialise the unsupported
types and test vector shifts.

llvm-svn: 172053
2013-01-10 10:42:08 +00:00
NAKAMURA Takumi 160087b1f6 clang/test/CodeGenOpenCL/shifts.cl: Fixup for -Asserts.
llvm-svn: 171820
2013-01-08 00:15:53 +00:00
David Tweed 042e0883cb Scalar shifts in the OpenCL specification (as of v. 1.2) are defined to be
with respect to the lower "left-hand-side bitwidth" bits, even when negative);
see OpenCL spec 6.3j. This patch both implements this behaviour in the code
generator and "constant folding" bits of Sema, and also prevents tests
to detect undefinedness in terms of the weaker C99 or C++ specifications
from being applied. 

llvm-svn: 171755
2013-01-07 16:43:27 +00:00