Commit Graph

1439 Commits

Author SHA1 Message Date
Steve Naroff 04e8bc8e35 Remove a space from "typeof" printing. It was causing the following error...
[dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check typeof.c 
Warnings expected but not seen:
  Line 21: incompatible types assigning 'typeof(*pi) const' to 'int *'
Warnings seen but not expected:
  Line 21: incompatible types assigning 'typeof(*pi)  const' to 'int *'

Also corrected a typo from my previous commit.

llvm-svn: 40832
2007-08-05 03:24:45 +00:00
Steve Naroff 8a4cf97aa9 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.

llvm-svn: 40831
2007-08-05 02:16:31 +00:00
Chris Lattner 81a9688e93 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 :)

llvm-svn: 40801
2007-08-04 00:20:15 +00:00
Chris Lattner 374b06a080 the sse intrinsics are missing, leading to errors.
llvm-svn: 40800
2007-08-04 00:19:10 +00:00
Chris Lattner 2f48d5e2ed fix hang in testsuite
llvm-svn: 40799
2007-08-04 00:18:28 +00:00
Chris Lattner c9a15cabdc fix constness issues.
llvm-svn: 40798
2007-08-04 00:14:36 +00:00
Steve Naroff 0104731e62 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.

llvm-svn: 40795
2007-08-03 22:40:33 +00:00
Steve Naroff 9efdabc565 Implement __builtin_choose_expr.
llvm-svn: 40794
2007-08-03 21:21:27 +00:00
Steve Naroff 7d451d614c 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

llvm-svn: 40789
2007-08-03 18:38:22 +00:00
Chris Lattner 4048005ad8 implement codegen support for __builtin_types_compatible_p
llvm-svn: 40788
2007-08-03 17:51:03 +00:00
Chris Lattner 477ac778ed fix a buggy comment I added
llvm-svn: 40787
2007-08-03 17:47:51 +00:00
Chris Lattner d268a7a268 Rename AddrLabel and OCUVectorComponent -> AddrLabelExpr and OCUVectorElementExpr respectively. This is for consistency with other expr nodes end with *Expr.
llvm-svn: 40785
2007-08-03 17:31:20 +00:00
Chris Lattner b20b94de3a testcase for vector element access stuff.
llvm-svn: 40783
2007-08-03 16:42:43 +00:00
Chris Lattner 3a44aa7461 implement codegen for multidest ocuvector expressions, like:
vec2.yx = vec2; // reverse
 

llvm-svn: 40782
2007-08-03 16:37:04 +00:00
Chris Lattner 41d480e4d8 add codegen support for storing into a single-element ocu lvalue, such as:
vec2.x = f;

llvm-svn: 40781
2007-08-03 16:28:33 +00:00
Chris Lattner 40ff701674 refactor handling of ocuvector lvalue->rvalue codegen into its own method.
llvm-svn: 40780
2007-08-03 16:18:34 +00:00
Chris Lattner fb837dccac 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             

llvm-svn: 40779
2007-08-03 16:09:33 +00:00
Chris Lattner 177bd450e0 add OCUVectorComponent::getNumComponents()
llvm-svn: 40778
2007-08-03 16:00:20 +00:00
Chris Lattner a1036f9155 Add support for scalar-returning element accesses like V.x
llvm-svn: 40777
2007-08-03 15:52:31 +00:00
Chris Lattner 73ab9b3c14 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 

llvm-svn: 40771
2007-08-03 00:16:29 +00:00
Chris Lattner 9e751cae27 add support for codegen of an OCUVectorComponent as an lvalue.
We can now codegen:

  vec4.xy;

as nothing!

llvm-svn: 40769
2007-08-02 23:37:31 +00:00
Chris Lattner 885b4959b6 Add support for encoding a OCUVectorComponent into a single integer.
llvm-svn: 40768
2007-08-02 23:36:59 +00:00
Chris Lattner 30709dc432 oops, this is the real fix.
llvm-svn: 40766
2007-08-02 22:41:43 +00:00
Chris Lattner 7aa350019a update test
llvm-svn: 40765
2007-08-02 22:36:03 +00:00
Chris Lattner 7e152dbb1f rename some helpers, have them return the idx of the field being accessed.
llvm-svn: 40764
2007-08-02 22:33:49 +00:00
Chris Lattner f1cb1c8d70 Use static methods, which don't require an instance of OCUVectorType
llvm-svn: 40763
2007-08-02 22:20:00 +00:00
Chris Lattner 585afabddd mark some methods static, don't consider a vector to be an ocuvector
llvm-svn: 40762
2007-08-02 22:19:39 +00:00
Chris Lattner acbd22aaec silence some warnings.
llvm-svn: 40761
2007-08-02 21:50:34 +00:00
Chris Lattner 680918a6fc Minor comment improvements.
llvm-svn: 40760
2007-08-02 21:47:28 +00:00
Chris Lattner 181b01bcfd make sure we don't lose the ability to parse carbon.h
llvm-svn: 40759
2007-08-02 21:40:29 +00:00
Reid Spencer 3d5386d545 Hyphenate a word, to check auto-update feature. Third times the charm!
llvm-svn: 40734
2007-08-02 09:58:41 +00:00
Reid Spencer 1d32b07d28 Expand a contraction to test auto-update on commit.
llvm-svn: 40733
2007-08-02 09:54:52 +00:00
Reid Spencer 28f1c63015 Test auto-update with minor grammaro fix.
llvm-svn: 40732
2007-08-02 09:50:49 +00:00
Chris Lattner 6a340b4351 Fix a bug in my previous commit
llvm-svn: 40719
2007-08-02 04:22:39 +00:00
Chris Lattner 016f19a37d switch a fixme to an assert.
llvm-svn: 40717
2007-08-02 04:14:33 +00:00
Steve Naroff a5645cbea9 Tweak to Expr::isIntegerConstantExpr...make sure the result is appropriately size for TypesCompatibleExpr's.
llvm-svn: 40716
2007-08-02 04:09:23 +00:00
Chris Lattner 04e3d20a51 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.  :)

llvm-svn: 40715
2007-08-02 03:55:37 +00:00
Steve Naroff 4bd2f71cc7 Tidy up Parser::ParseTypeofSpecifier()...implement FIXME and minor restructure.
llvm-svn: 40713
2007-08-02 02:53:48 +00:00
Steve Naroff ade1649e57 Add a couple const modifiers.
llvm-svn: 40708
2007-08-02 00:19:14 +00:00
Steve Naroff b3deb2e112 Hack Expr::isConstantExpr() to allow for __builtin_types_compatible_p.
llvm-svn: 40705
2007-08-02 00:13:27 +00:00
Steve Naroff 788d864d6c - Finish hooking up support for __builtin_types_compatible_p().
- Fix type printing code for recently added TypeOfExpr/TypeOfType.

llvm-svn: 40700
2007-08-01 23:45:51 +00:00
Steve Naroff 7886467b35 Add AST/Sema support for __builtin_types_compatible_p (a GNU extension).
Todo...still need to call the action from the parser...

llvm-svn: 40693
2007-08-01 22:05:33 +00:00
Steve Naroff a773cd5d15 Add comments to getTypeOfExpr/getTypeOfType.
Also add instances of TypeOfExpr/TypeOfType to the Types vector (so we can keep track of them).

llvm-svn: 40677
2007-08-01 18:02:17 +00:00
Steve Naroff 236becbbc3 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.

llvm-svn: 40676
2007-08-01 17:20:42 +00:00
Chris Lattner 7b9f04eb19 update this to build with LLVM ToT
llvm-svn: 40665
2007-08-01 06:24:52 +00:00
Chris Lattner bf2f38693e Print floating point literal values better.
llvm-svn: 40659
2007-08-01 00:23:58 +00:00
Steve Naroff 872da803b2 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.

llvm-svn: 40656
2007-07-31 23:56:32 +00:00
Chris Lattner 0fd893e643 remove more explicit accesses to the canonical type pointer.
llvm-svn: 40653
2007-07-31 21:33:24 +00:00
Chris Lattner e5a6cbd457 simplify some type checking code, don't explicitly access
canonical types.

llvm-svn: 40652
2007-07-31 21:27:01 +00:00
Chris Lattner 0ddc7ba2e5 move trivial type predicates inline.
llvm-svn: 40651
2007-07-31 21:13:58 +00:00