Steve Naroff
69625f4925
Make sure the good old "function/array conversion" is done to function parameters.
...
This resulted in the following error...
[dylan:clang/test/Parser] admin% cat parmvardecl_conversion.c
// RUN: clang -parse-ast-check %s
void f (int p[]) { p++; }
[dylan:clang/test/Parser] admin% clang -parse-ast-check parmvardecl_conversion.c
Errors seen but not expected:
Line 3: cannot modify value of type 'int []'
With this fix, the test case above succeeds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40831 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-05 02:16:31 +00:00
Chris Lattner
94f05e3648
Implement codegen for __builtin_choose_expr. For example:
...
struct X { int A; };
void foo() {
struct X s;
int i;
i = __builtin_choose_expr(0, s, i);
}
compiles to:
%tmp = load i32* %i ; <i32> [#uses=1]
store i32 %tmp, i32* %i
wow :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40801 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-04 00:20:15 +00:00
Chris Lattner
345dc62fd5
the sse intrinsics are missing, leading to errors.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40800 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-04 00:19:10 +00:00
Chris Lattner
52e3de597c
fix hang in testsuite
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40799 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-04 00:18:28 +00:00
Chris Lattner
c1b607db38
fix constness issues.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40798 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-04 00:14:36 +00:00
Steve Naroff
608e0ee4b4
Restrict vector component access (using "." and "[]") to variables.
...
Chris suggested this, since it simplifies the code generator.
If this features is needed (and we don't think it is), we can revisit.
The following test case now produces an error.
[dylan:~/llvm/tools/clang] admin% cat t.c
typedef __attribute__(( ocu_vector_type(4) )) float float4;
static void test() {
float4 vec4;
vec4.rg.g;
vec4.rg[1];
}
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.c
t.c:8:12: error: vector component access limited to variables
vec4.rg.g;
^~
t.c:9:12: error: vector component access limited to variables
vec4.rg[1];
^~~
2 diagnostics generated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40795 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 22:40:33 +00:00
Steve Naroff
d04fdd5f99
Implement __builtin_choose_expr.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40794 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 21:21:27 +00:00
Steve Naroff
441995e92e
Add a test case to validate code gen for typeof/builtin_types_compatible.
...
This test case currently generates the following unexpected warnings (when compared with gcc).
[dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check builtin_types_compatible.c
Warnings seen but not expected:
Line 28: expression result unused
Line 29: expression result unused
Line 30: expression result unused
Line 31: expression result unused
Line 32: expression result unused
Line 33: expression result unused
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40789 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 18:38:22 +00:00
Chris Lattner
30bf3ae03f
implement codegen support for __builtin_types_compatible_p
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40788 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 17:51:03 +00:00
Chris Lattner
dd652cdb70
fix a buggy comment I added
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40787 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 17:47:51 +00:00
Chris Lattner
6481a57fef
Rename AddrLabel and OCUVectorComponent -> AddrLabelExpr and OCUVectorElementExpr respectively. This is for consistency with other expr nodes end with *Expr.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40785 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 17:31:20 +00:00
Chris Lattner
90997ac90d
testcase for vector element access stuff.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40783 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 16:42:43 +00:00
Chris Lattner
7e6b51b673
implement codegen for multidest ocuvector expressions, like:
...
vec2.yx = vec2; // reverse
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40782 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 16:37:04 +00:00
Chris Lattner
017d6aa8e6
add codegen support for storing into a single-element ocu lvalue, such as:
...
vec2.x = f;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40781 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 16:28:33 +00:00
Chris Lattner
34cdc86af5
refactor handling of ocuvector lvalue->rvalue codegen into its own method.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40780 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 16:18:34 +00:00
Chris Lattner
5cc2e45e2d
In the common case where we are shuffling a vector, emit an
...
llvm vector shuffle instead of a bunch of insert/extract operations.
For: vec4 = vec4.yyyy; // splat
Emit:
%tmp1 = shufflevector <4 x float> %tmp, <4 x float> undef, <4 x i32> < i32 1, i32 1, i32 1, i32 1 >
instead of:
%tmp1 = extractelement <4 x float> %tmp, i32 1
%tmp2 = insertelement <4 x float> undef, float %tmp1, i32 0
%tmp3 = extractelement <4 x float> %tmp, i32 1
%tmp4 = insertelement <4 x float> %tmp2, float %tmp3, i32 1
%tmp5 = extractelement <4 x float> %tmp, i32 1
%tmp6 = insertelement <4 x float> %tmp4, float %tmp5, i32 2
%tmp7 = extractelement <4 x float> %tmp, i32 1
%tmp8 = insertelement <4 x float> %tmp6, float %tmp7, i32 3
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40779 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 16:09:33 +00:00
Chris Lattner
4d0ac88428
add OCUVectorComponent::getNumComponents()
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40778 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 16:00:20 +00:00
Chris Lattner
3b126125ec
Add support for scalar-returning element accesses like V.x
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40777 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 15:52:31 +00:00
Chris Lattner
46ea8eb7cc
implement lvalue to rvalue conversion for ocuvector components. We can now compile stuff
...
like this:
typedef __attribute__(( ocu_vector_type(4) )) float float4;
float4 test1(float4 V) {
return V.wzyx+V;
}
to:
_test1:
pshufd $27, %xmm0, %xmm1
addps %xmm0, %xmm1
movaps %xmm1, %xmm0
ret
and:
_test1:
mfspr r2, 256
oris r3, r2, 4096
mtspr 256, r3
li r3, lo16(LCPI1_0)
lis r4, ha16(LCPI1_0)
lvx v3, r4, r3
vperm v3, v2, v2, v3
vaddfp v2, v3, v2
mtspr 256, r2
blr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40771 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 00:16:29 +00:00
Chris Lattner
349aaec106
add support for codegen of an OCUVectorComponent as an lvalue.
...
We can now codegen:
vec4.xy;
as nothing!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40769 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 23:37:31 +00:00
Chris Lattner
b8f849da3c
Add support for encoding a OCUVectorComponent into a single integer.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40768 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 23:36:59 +00:00
Chris Lattner
f13ebf03b7
oops, this is the real fix.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40766 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 22:41:43 +00:00
Chris Lattner
6f66c26c94
update test
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40765 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 22:36:03 +00:00
Chris Lattner
88dca04648
rename some helpers, have them return the idx of the field being accessed.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40764 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 22:33:49 +00:00
Chris Lattner
b4878f4a57
Use static methods, which don't require an instance of OCUVectorType
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40763 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 22:20:00 +00:00
Chris Lattner
667405a3b0
mark some methods static, don't consider a vector to be an ocuvector
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40762 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 22:19:39 +00:00
Chris Lattner
d14faaa7ec
silence some warnings.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40761 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 21:50:34 +00:00
Chris Lattner
cb92a11814
Minor comment improvements.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40760 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 21:47:28 +00:00
Chris Lattner
281a492261
make sure we don't lose the ability to parse carbon.h
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40759 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 21:40:29 +00:00
Reid Spencer
ad43ad4747
Hyphenate a word, to check auto-update feature. Third times the charm!
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40734 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 09:58:41 +00:00
Reid Spencer
06ddd81e13
Expand a contraction to test auto-update on commit.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40733 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 09:54:52 +00:00
Reid Spencer
2f291ba967
Test auto-update with minor grammaro fix.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40732 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 09:50:49 +00:00
Chris Lattner
c1e50fc734
Fix a bug in my previous commit
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40719 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 04:22:39 +00:00
Chris Lattner
4cabcfea26
switch a fixme to an assert.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40717 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 04:14:33 +00:00
Steve Naroff
7b658aa315
Tweak to Expr::isIntegerConstantExpr...make sure the result is appropriately size for TypesCompatibleExpr's.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40716 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 04:09:23 +00:00
Chris Lattner
991ae518e9
Increase the macro id cache to look up several recent entries, not just the last one.
...
This is important in insane cases like the one dannyb sent me recently:
#define F0(a) void a(){}
#define F1(a) F0(a##0) F0(a##1) F0(a##2) F0(a##3) F0(a##4) F0(a##5) F0(a##6) F0(a##7)
#define F2(a) F1(a##0) F1(a##1) F1(a##2) F1(a##3) F1(a##4) F1(a##5) F1(a##6) F1(a##7)
#define F3(a) F2(a##0) F2(a##1) F2(a##2) F2(a##3) F2(a##4) F2(a##5) F2(a##6) F2(a##7)
#define F4(a) F3(a##0) F3(a##1) F3(a##2) F3(a##3) F3(a##4) F3(a##5) F3(a##6) F3(a##7)
#define F5(a) F4(a##0) F4(a##1) F4(a##2) F4(a##3) F4(a##4) F4(a##5) F4(a##6) F4(a##7)
#define F6(a) F5(a##0) F5(a##1) F5(a##2) F5(a##3) F5(a##4) F5(a##5) F5(a##6) F5(a##7)
F6(f)
cpp is great. :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40715 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 03:55:37 +00:00
Steve Naroff
9dfa7b4e32
Tidy up Parser::ParseTypeofSpecifier()...implement FIXME and minor restructure.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40713 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 02:53:48 +00:00
Steve Naroff
7f28fe8e00
Add a couple const modifiers.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40708 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 00:19:14 +00:00
Steve Naroff
389cecc83f
Hack Expr::isConstantExpr() to allow for __builtin_types_compatible_p.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40705 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 00:13:27 +00:00
Steve Naroff
363bcff47d
- Finish hooking up support for __builtin_types_compatible_p().
...
- Fix type printing code for recently added TypeOfExpr/TypeOfType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40700 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 23:45:51 +00:00
Steve Naroff
d34e915f33
Add AST/Sema support for __builtin_types_compatible_p (a GNU extension).
...
Todo...still need to call the action from the parser...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40693 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 22:05:33 +00:00
Steve Naroff
9752f25748
Add comments to getTypeOfExpr/getTypeOfType.
...
Also add instances of TypeOfExpr/TypeOfType to the Types vector (so we can keep track of them).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40677 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 18:02:17 +00:00
Steve Naroff
8d1a3b8ca1
Two typeof() related changes...
...
- Changed the name of ASTContext::getTypeOfType(Expr*)->getTypeOfExpr().
- Remove FIXME for TypeOfExpr::getAsStringInternal(). This will work fine for printing the AST. It isn't ideal
for error diagnostics (since it's more natural to display the expressions type).
One "random" (or at least delayed:-) change...
- Changed all "ext_typecheck_*" diagnostics from EXTENSION->WARNING. Reason: Since -pedantic is now
off (by default), these diagnostics were never being emitted (which is bad). With this change, clang will
emit the warning all the time. The only downside (wrt GCC compatibility) is -pedantic-errors will not turn
this diagnostics into errors (a "feature" of making tagging them with EXTENSION). When/if this becomes
an issue, we can revisit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40676 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 17:20:42 +00:00
Chris Lattner
bf98651d42
update this to build with LLVM ToT
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40665 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 06:24:52 +00:00
Chris Lattner
86e499d952
Print floating point literal values better.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40659 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 00:23:58 +00:00
Steve Naroff
2cb64ecc86
Tighten up Parser::ParseTypeofSpecifier().
...
Add some more tests to typeof.c. Also added a couple of missing "expect" attributes that caused the test to fail.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40656 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 23:56:32 +00:00
Chris Lattner
02c642e8f4
remove more explicit accesses to the canonical type pointer.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40653 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 21:33:24 +00:00
Chris Lattner
2dcb6bb17d
simplify some type checking code, don't explicitly access
...
canonical types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40652 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 21:27:01 +00:00
Chris Lattner
611c1fff19
move trivial type predicates inline.
...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40651 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 21:13:58 +00:00
Chris Lattner
c8629630ce
split the rest of the type predicates into pure predicates:
...
there is now an isXXXType and a getAsXXXType
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40646 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 19:29:30 +00:00