Commit Graph

34741 Commits

Author SHA1 Message Date
Bill Wendling aec64c35f1 Submitted by: Bill Wendling
- Separate out the AST streamers from the clang.cpp file into their very
  own special files.

llvm-svn: 39676
2007-06-23 00:39:57 +00:00
Bill Wendling 26e1f8c05a Bug #:
Submitted by: Bill Wendling

- Convert std::cerr to using fprintf(stderr, ...) instead.

llvm-svn: 39675
2007-06-22 22:43:15 +00:00
Chris Lattner 54fb19efaa implement support for struct and complex returns.
llvm-svn: 39674
2007-06-22 22:02:34 +00:00
Chris Lattner e9a6453ded add some infrastructure for codegen'ing complex numbers. implement addition
of complex.  We now produce optimal code for:

void test(_Complex float *Y) {
  *Y = *Y + *Y;
}

$ clang -emit-llvm cg.c | llvm-as | opt -std-compile-opts | llc -march=x86-64
...
_test:
        movss (%rdi), %xmm0
        addss %xmm0, %xmm0
        movss 4(%rdi), %xmm1
        movss %xmm0, (%rdi)
        addss %xmm1, %xmm1
        movss %xmm1, 4(%rdi)
        ret

llvm-svn: 39673
2007-06-22 21:44:33 +00:00
Chris Lattner c6395936ae Split complex types out from being members of BuiltinType to being their own
types.

llvm-svn: 39672
2007-06-22 20:56:16 +00:00
Chris Lattner f033c147c9 remove location tracking for target info
llvm-svn: 39671
2007-06-22 19:05:19 +00:00
Chris Lattner 0fb8465981 Don't forget to set this
llvm-svn: 39670
2007-06-22 18:57:44 +00:00
Chris Lattner 09153c0a8c Build enough support for aggregates to be able to compile this:
void test(int A, _Complex float Y) {
  _Complex float X;
  X = X;

}

llvm-svn: 39669
2007-06-22 18:48:09 +00:00
Chris Lattner 3e3a1e9cda implement lowering of complex types
llvm-svn: 39668
2007-06-22 18:15:26 +00:00
Chris Lattner f39b03d98b fix naming of aggregate arguments.
llvm-svn: 39667
2007-06-22 18:15:16 +00:00
Chris Lattner 1fde0b345b implement codegen of the relational operations
One major FIXME though.

llvm-svn: 39666
2007-06-20 18:30:55 +00:00
Chris Lattner 273c63d450 Implement the equality operators for simple types
llvm-svn: 39665
2007-06-20 18:02:30 +00:00
Chris Lattner e1e93a5e5d assert, don't crash, on int[]
llvm-svn: 39664
2007-06-20 17:12:11 +00:00
Chris Lattner b6984c4854 Hook up global function and variable handling. We can now compile:
int X, bar(int,int,int);
short Y;

double foo() {
  return bar(X, Y, 3);
}

into:

@X = external global i32                ; <i32*> [#uses=1]
@Y = external global i16                ; <i16*> [#uses=1]

define double @foo() {
entry:
        %tmp = load i32* @X             ; <i32> [#uses=1]
        %tmp1 = load i16* @Y            ; <i16> [#uses=1]
        %promote = sext i16 %tmp1 to i32                ; <i32> [#uses=1]
        %call = tail call i32 @bar( i32 %tmp, i32 %promote, i32 3 )             ; <i32> [#uses=1]
        %conv = sitofp i32 %call to double              ; <double> [#uses=1]
        ret double %conv
}

declare i32 @bar(i32, i32, i32)

llvm-svn: 39663
2007-06-20 04:44:43 +00:00
Chris Lattner b3fef07a30 add new files to xcode project
llvm-svn: 39662
2007-06-16 00:17:33 +00:00
Chris Lattner 2ccb73bc8b Refactor CodeGenTypes out to CodeGenModule so it can be used for functions
and globals.

llvm-svn: 39661
2007-06-16 00:16:26 +00:00
Chris Lattner 2052bc8107 Split type analysis out to its own file, now the integer constant expr evaluation
is ready.

llvm-svn: 39660
2007-06-16 00:12:05 +00:00
Chris Lattner 23b7eb677d Finally bite the bullet and make the major change: split the clang namespace
out of the llvm namespace.  This makes the clang namespace be a sibling of
llvm instead of being a child.

The good thing about this is that it makes many things unambiguous.  The
bad things is that many things in the llvm namespace (notably data structures
like smallvector) now require an llvm:: qualifier.  IMO, libsystem and libsupport
should be split out of llvm into their own namespace in the future, which will fix
this issue.

llvm-svn: 39659
2007-06-15 23:05:46 +00:00
Chris Lattner 2b228c95aa implement codegen of calls. We can now compile:
double foo( int (*FP)(int, int, int)) {
  return FP(1, 2, 3);
}

to:

define double @foo(i32 (i32, i32, i32)* %FP) {
entry:
        %call = tail call i32 %FP( i32 1, i32 2, i32 3 )
        %conv = sitofp i32 %call to double
        ret double %conv
}

llvm-svn: 39658
2007-06-15 21:34:29 +00:00
Bill Wendling 52d85bdd2b Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Refactor some code from main() and ProcessInputFile() so that it helps to
  decouple the initialization of the Preprocessor object from the
  diagnostic client.

llvm-svn: 39657
2007-06-15 21:20:00 +00:00
Chris Lattner d760e468aa Don't generate code for prototypes
llvm-svn: 39656
2007-06-15 21:16:23 +00:00
Chris Lattner b48238188e Fix a nasty bug which caused infinite recursion
llvm-svn: 39655
2007-06-15 21:04:38 +00:00
Steve Naroff 75c1723b3c Bug #:
Submitted by:
Reviewed by:
Fix CheckRelationalOperands/CheckEqualityOperands to deal with null pointer
constants. The new logic also deals (more) correctly for non-pointer/integer
operands.

llvm-svn: 39654
2007-06-13 21:41:08 +00:00
Chris Lattner cf98efa73b Implement implicit conversions in return stmts.
llvm-svn: 39653
2007-06-13 20:50:31 +00:00
Chris Lattner 53621a535d Implement support for formal arguments. We can now compile this:
int test(int X, short Y, float Z) {
  return (int)(X*Y+Z);
}

to:

define i32 @test(i32 %X, i16 %Y, float %Z) {
entry:
        %promote = sext i16 %Y to i32           ; <i32> [#uses=1]
        %mul = mul i32 %promote, %X             ; <i32> [#uses=1]
        %promote3 = sitofp i32 %mul to float            ; <float> [#uses=1]
        %add = add float %promote3, %Z          ; <float> [#uses=1]
        %conv = fptosi float %add to i32                ; <i32> [#uses=1]
        ret i32 %conv
}

with:

$ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis

llvm-svn: 39652
2007-06-13 20:44:40 +00:00
Chris Lattner 23cff88741 Update the xcode project for bill
llvm-svn: 39651
2007-06-13 20:14:12 +00:00
Bill Wendling 478b88638f Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Created a base class (TextDiagnostics) for all text diagnostic classes.
  Moved the "IgnoreDiagnostic" method up there, and created a method that
  will format the diagnostic string, replacing %# with the appropriate
  string. This is in preparation for adding a text diagnostic checker.

llvm-svn: 39650
2007-06-13 17:45:37 +00:00
Steve Naroff d6fbee81df Bug #:
Submitted by:
Reviewed by:
Fixed typechecking bugs wrt UsualUnaryConversions. Includes two distinct fixes:

#1: Call UsualUnaryConversions in CheckRelationalOperands/CheckEqualityOperands.
#2: UsualArithmeticConversions arguments are now output parameters. This insures
the implicit conversion is seen by clients (and fixes bugs in CheckAdditionOperands
and CheckSubtractionOperands when doing pointer arithmetic).
~

llvm-svn: 39649
2007-06-13 15:42:33 +00:00
Chris Lattner c0a38dd38f Pretty print if/else/elseif chains nicer, like this:
void printutf8(unsigned int X) {
  if (X <= 127)
    printf("%c", (char)X);
  else if (X <= 2047)
    printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
  else if (X <= 65535)
    printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
  else
    printf("UNKNOWN %d\n", X);

instead of:

  if (X <= 127)
    printf("%c", (char)X);
  else
    if (X <= 2047)
      printf("%d %d ", 128 + 64 + (X >> 6), 128 + (X & ((1 << 6) - 1)));
    else
      if (X <= 65535)
        printf("%c%c%c", 128 + 64 + 32 + (X >> 12), 128 + ((X >> 6) & 63), 128 + (X & 63));
      else
        printf("UNKNOWN %d\n", X);

llvm-svn: 39648
2007-06-11 22:26:23 +00:00
Chris Lattner d4a20ad752 Wording fix for a diagnostic, suggested by bill
llvm-svn: 39647
2007-06-11 20:54:56 +00:00
Chris Lattner f99b3f5ec2 Emit codegen of enum literals.
llvm-svn: 39646
2007-06-11 03:52:52 +00:00
Chris Lattner 9fba02845b Enums are integer constant exprs, return their values.
llvm-svn: 39645
2007-06-11 03:47:05 +00:00
Chris Lattner 4ef40013d7 Implement capturing of enum values and chaining of enums together.
llvm-svn: 39644
2007-06-11 01:28:17 +00:00
Steve Naroff a8fd973aa0 Bug #:
Submitted by:
Reviewed by:
Implement semantic analysis for vector_size attribute!
We now produce the following diagnostics...

[administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang vector.c
vector.c:2:29: error: attribute requires precisely 1 argument
typedef int __attribute__(( vector_size )) tVecp;
                            ^
vector.c:7:32: error: attribute requires precisely 1 argument
extern int foo __attribute__(( vector_size ));
                               ^
vector.c:8:34: error: attribute requires precisely 1 argument
extern float bar __attribute__(( vector_size(16,18) ));
                                 ^
vector.c:11:34: error: vector_size requires integer constant (attribute ignored)
extern char foo2 __attribute__(( vector_size(16.2) ));
                                 ^           ~~~~
vector.c:21:47: error: invalid vector type 'struct s'
struct s { int a; } structVar __attribute__(( vector_size(16) ));

llvm-svn: 39643
2007-06-11 00:35:03 +00:00
Chris Lattner 843c592e28 GCC accepts code like this as an extension:
static int seminal(from, to)
{
}

llvm-svn: 39642
2007-06-10 23:40:34 +00:00
Bill Wendling 314ae547a1 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Added a method "IgnoreDiagnostic" so that the diagnostic client can
  tell the diagnostic object that it doesn't want to handle a particular
  diagnostic message. In which case, it won't be counted as either a
  diagnostic or error.

llvm-svn: 39641
2007-06-10 04:13:42 +00:00
Steve Naroff 0f05a7ae7a Bug #:
Submitted by:
Reviewed by:
Changed the name of DeclSpec.AddAttribute and Declarator.AddAttribute to
AddAttributes(). Also added some (much needed) comments. While documenting,
realized I could simplify & tighten up Declarator.AddAttributes...

llvm-svn: 39640
2007-06-09 23:38:17 +00:00
Steve Naroff 5b6afadf81 Bug #:
Submitted by:
Reviewed by:
Add initialization and memory management for AttributeList.
Added a big FIXME comment for handling expressions (which are currently leaked).

llvm-svn: 39639
2007-06-09 14:13:39 +00:00
Chris Lattner 3f4b6e3623 Fix lexing octal escapes like:
void foo() {
"\0";
}

llvm-svn: 39638
2007-06-09 06:20:47 +00:00
Chris Lattner b2dd241b15 fix a crash parsing spass
llvm-svn: 39637
2007-06-09 06:16:32 +00:00
Chris Lattner ff591e24eb Don't warn about escaped newlines in // comments if the next line is also
a // comment, this reduces noise in the llvm testsuite.

llvm-svn: 39636
2007-06-09 06:07:22 +00:00
Chris Lattner 736ed5dfb8 accept __extension__, update todo list.
llvm-svn: 39635
2007-06-09 05:59:07 +00:00
Chris Lattner 6d9b49ae64 add another example
llvm-svn: 39634
2007-06-09 05:56:19 +00:00
Chris Lattner 0c7e82de07 Accept horrible code like this:
2005-10-18-VariableSizedElementCrash.c:5:41: warning: expected ';' at end of declaration list
  struct bar {foo f1; int f2:3; int f3:4} *p = (struct bar *) pi;
                                        ^

llvm-svn: 39633
2007-06-09 05:54:40 +00:00
Chris Lattner 36e46a219b Add support for a little extension. ISO C does not allow extra ;'s in structs,
e.g.:

struct A {
  ;
  int X;;
  const;
};

llvm-svn: 39632
2007-06-09 05:49:55 +00:00
Steve Naroff 9507c79698 Bug #:
Submitted by:
Reviewed by:
Incorporate some feedback from Chris.
Fixed a crasher, added an assert.

llvm-svn: 39631
2007-06-09 05:31:51 +00:00
Steve Naroff 6d26a892d4 Bug #:
Submitted by:
Reviewed by:
Move Attr.h to the correct group in the Xcode project file...

llvm-svn: 39630
2007-06-09 03:59:22 +00:00
Steve Naroff 06f0f8c414 Bug #:
Submitted by:
Reviewed by:
Lot's of attribute scaffolding.
Modernized ParseArraySubscriptExpr...call DefaultFunctionArrayConversion (which
simplified the logic considerably) and upgrade Diags to use the range support.

llvm-svn: 39629
2007-06-09 03:47:54 +00:00
Steve Naroff b309644a35 Bug #:
Submitted by:
Reviewed by:
Lot's of attribute scaffolding.
Modernized ParseArraySubscriptExpr...call DefaultFunctionArrayConversion (which
simplified the logic considerably) and upgrade Diags to use the range support.

llvm-svn: 39628
2007-06-09 03:47:53 +00:00
Steve Naroff 29ca72ae02 Bug #:
Submitted by:
Reviewed by:
Add new file AttributeList.h

llvm-svn: 39627
2007-06-09 03:40:25 +00:00