Commit Graph

467 Commits

Author SHA1 Message Date
Devang Patel b3ae8d7dc2 Add assert to flag incomplete bit-field support.
llvm-svn: 44800
2007-12-10 18:52:06 +00:00
Devang Patel 3c31b54b47 Use getABITypeSizeInBits() instead of getTypeSizeInBits() during struct layout.
llvm-svn: 44799
2007-12-10 18:37:40 +00:00
Devang Patel bb5c0d8960 Use getABITypeSizeInBits() instead of getTypeSizeInBits() during struct layout.
llvm-svn: 44798
2007-12-10 18:25:34 +00:00
Chris Lattner cb04ac9599 abort when we lower an initializer to the wrong type, as we currently do for:
char text[] = "string";

llvm-svn: 44752
2007-12-10 00:05:55 +00:00
Chris Lattner 686628e052 extend or truncate the initializer for a string initializer to match its type.
llvm-svn: 44751
2007-12-10 00:00:56 +00:00
Chris Lattner c25c42f3ca Implement codegen support for:
char text[8] = "string";

Big fixme remains.

llvm-svn: 44750
2007-12-09 23:49:42 +00:00
Anders Carlsson 92c4e44da1 Address Chris's comments.
llvm-svn: 44749
2007-12-09 23:39:18 +00:00
Anders Carlsson 895af08562 Move target specific builtin IDs to TargetBuiltins.h so that they can be used by CGBuiltin.cpp
llvm-svn: 44748
2007-12-09 23:17:02 +00:00
Anders Carlsson 8e1d8cf241 Implement __builtin_ia32_mulps.
llvm-svn: 44745
2007-12-09 21:51:19 +00:00
Anders Carlsson a020c43034 Generate code for target specific intrinsics.
llvm-svn: 44744
2007-12-09 21:20:04 +00:00
Chris Lattner 283d094b75 implement support for functions that initialize globals.
llvm-svn: 44730
2007-12-09 00:36:01 +00:00
Devang Patel 65a2288eef More struct bitfields layout work. Now handle,
struct STestB1 {char a; char b:2; } stb1;
struct STestB2 {char a; char b:5; char c:4} stb2;

llvm-svn: 44664
2007-12-06 19:16:05 +00:00
Chris Lattner 6eed001371 fix some bogus code noticed by Kevin Andre
llvm-svn: 44615
2007-12-05 17:21:34 +00:00
Anders Carlsson a297e7a888 Implement CodeGen for vectors. Don't create unnecessary conversion instructions if the value to be converted is a constant.
llvm-svn: 44606
2007-12-05 07:36:10 +00:00
Anders Carlsson e8ee04c0bc Implement codegen for builtin infinity functions.
llvm-svn: 44604
2007-12-05 07:22:48 +00:00
Seo Sanghyeon 3d072bea09 Ignore typedefs in pointer arithmetic codegen.
llvm-svn: 44529
2007-12-03 06:23:43 +00:00
Anders Carlsson ef93b9d011 Implement __builtin_bswap32 and __builtin_bswap64.
llvm-svn: 44521
2007-12-02 21:58:10 +00:00
Chris Lattner 4e4186b2de fix logic for member expr codegen.
llvm-svn: 44520
2007-12-02 18:52:07 +00:00
Christopher Lamb 0cbd8723f3 Treat discarding array initializer elements as an extwarn (so -pedantic-errors flags it). Allow CodeGen to truncate the initializer if needed.
llvm-svn: 44518
2007-12-02 08:49:54 +00:00
Chris Lattner 0475c8178f globals can't be vla's
llvm-svn: 44512
2007-12-02 07:32:25 +00:00
Chris Lattner d8d18d561e add codegen support for global inits that require array decay.
llvm-svn: 44511
2007-12-02 07:30:13 +00:00
Chris Lattner d45aa2a03b warn about unhandled initializers instead of crashing on them.
llvm-svn: 44510
2007-12-02 07:19:18 +00:00
Chris Lattner 5bcdf24a50 Handle global variable definitions which change the type of a definition, such as:
extern int x[];
void foo() { x[0] = 1; }
int x[10];
void bar() { x[0] = 1; }

llvm-svn: 44509
2007-12-02 07:09:19 +00:00
Chris Lattner c48023bd5b remove the alloca insertion point inst, which is an internal helper.
llvm-svn: 44508
2007-12-02 06:32:24 +00:00
Chris Lattner 6d27513f6e merge the llvm global variable when there are multiple C decls.
llvm-svn: 44507
2007-12-02 06:30:46 +00:00
Chris Lattner 41af8182d8 implement codegen for functions whose function body type don't match
their prototype.

llvm-svn: 44506
2007-12-02 06:27:33 +00:00
Chris Lattner c5b3aab66b merge functions with multiple function decls if they have the same name.
llvm-svn: 44505
2007-12-02 05:56:05 +00:00
Chris Lattner f0780fae43 convert the rest of the stderr users in codegen to use diagnostics.
llvm-svn: 44503
2007-12-02 01:49:16 +00:00
Chris Lattner fc94434faf move unsupported warning into a centralized place.
llvm-svn: 44502
2007-12-02 01:43:38 +00:00
Chris Lattner c8dbe1e5d6 Warn about unsupported codegen with the diags machinery, giving us:
t.c:3322:5: warning: cannot codegen this yet
    __asm__ ("bswap   %0" : "+r" (_data));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

instead of:

Unimplemented stmt!
(AsmStmt 0x80eaa0 <t.c:3331:5, line:3334:28>)

llvm-svn: 44501
2007-12-02 01:40:18 +00:00
Oliver Hunt a96fe8d5c5 Add support for __builtin_expect which is needed for assert,
among other things.

Also change a codegen warning to dump to stderr so it doesn't
mess with -emit-llvm output

llvm-svn: 44497
2007-12-02 01:03:24 +00:00
Oliver Hunt aefc8fd415 Support initalisers for more than just int-typed static variables.
We now use the CodeGenModule logic for generating the constant 
initialiser expression, so happily further initialiser fixes should 
automatically work for statics as well.

llvm-svn: 44495
2007-12-02 00:11:25 +00:00
Christopher Lamb 7d303b2a20 Better match llvm-gcc's behavior for CodeGen naming of anonymous structs and unions.
llvm-svn: 44490
2007-12-01 09:20:34 +00:00
Christopher Lamb b0e6094a22 When generating the CodeGen type name of a struct, union, enum use the typedef
name if a tag type name is not available for the type. This matches how llvm-gcc 
chooses CodeGen type names.

This means that "typedef struct {...} foo" now results in a CodeGen name of 
"struct.foo" rather than "struct."

llvm-svn: 44489
2007-12-01 09:08:41 +00:00
Chris Lattner 9e137aad78 fix a couple switch codegen problems Oliver reported.
llvm-svn: 44484
2007-12-01 05:27:33 +00:00
Chris Lattner 1386de8757 fix a bug handling typedefs in member expr codegen. Patch
by Seo Sanghyeon

llvm-svn: 44455
2007-11-30 18:02:19 +00:00
Chris Lattner b6a7b582ee Fix a codegen crash on void ?: reported by Oliver
llvm-svn: 44454
2007-11-30 17:56:23 +00:00
Chris Lattner aa0b570dfb Support fully general case expressions, patch by Sanghyeon Seo!
llvm-svn: 44453
2007-11-30 17:44:57 +00:00
Chris Lattner fb30009465 Implement support for -fwritable-strings and make the code generator
merge string literals when it is not provided.

llvm-svn: 44394
2007-11-28 05:34:05 +00:00
Chris Lattner 1cfe02c38b update to match change in mainline llvm.
llvm-svn: 44367
2007-11-27 18:20:52 +00:00
Chris Lattner f04b69b26c take an initial stab at setting function linkage right. Handle
static and inline at least.

llvm-svn: 44355
2007-11-27 06:46:51 +00:00
Chris Lattner 2ab40a6207 Fix sema support for the gnu ?: expression with a
missing middle expression, and fix a codegen bug where
we didn't correctly promote the condition to the right 
result type.  This fixes PR1824.

llvm-svn: 44322
2007-11-26 01:40:58 +00:00
Chris Lattner 136449a6d7 improve codegen for global variable initializers, implementing
test/CodeGen/global-with-initialiser.c

Patch by Oliver Hunt!

llvm-svn: 44290
2007-11-23 22:07:55 +00:00
Anders Carlsson 4f8eb127e1 Add __builtin_abs
llvm-svn: 44254
2007-11-20 19:05:17 +00:00
Nate Begeman 4c18c23eb3 Implement codegen of CXX Bool
llvm-svn: 44160
2007-11-15 05:40:03 +00:00
Chris Lattner 034b49dca0 Clean up types, removing some casts. Patch contributed by
Cedric Venet.

llvm-svn: 44050
2007-11-13 18:16:41 +00:00
Devang Patel ec51171319 Add assert for the case that is not handled.
struct { char a; short b:2; };

llvm-svn: 43859
2007-11-08 00:32:12 +00:00
Devang Patel 7c7a07d949 Keep track of beginning offset for the bit field that does not start at byte boundry.
llvm-svn: 43857
2007-11-08 00:17:59 +00:00
Devang Patel ef2d838fef Stay within 80 columns.
llvm-svn: 43843
2007-11-07 21:04:59 +00:00
Devang Patel b1ecfc6e25 Start struct bit field laout work.
This is far from complete.

llvm-svn: 43801
2007-11-07 01:57:13 +00:00
Anders Carlsson bfd60eedd7 Generate code for member exprs.
llvm-svn: 43641
2007-11-02 16:59:10 +00:00
Devang Patel e11664a0ef Rename classes and collections that maintain record layout information.
Now, at AST level record info is maintained by ASTRecordLayout class.
Now, at code gen  level record info is maintained by CGRecordLayout class.

llvm-svn: 43619
2007-11-01 19:11:01 +00:00
Anders Carlsson 41b7c6b250 Put constant CFStrings in the __DATA,__cfstring section.
llvm-svn: 43593
2007-11-01 00:41:52 +00:00
Anders Carlsson 1e27f9b296 Stub out codegen for __builtin_constant_p. Remove any implicit cast exprs in the call to __builtin___CFStringMakeConstantString.
llvm-svn: 43592
2007-11-01 00:39:26 +00:00
Devang Patel 0b59b45870 Remove unnecessary method.
llvm-svn: 43591
2007-11-01 00:11:37 +00:00
Devang Patel ad175428c6 start adding pading fields.
llvm-svn: 43590
2007-11-01 00:07:12 +00:00
Anders Carlsson e89b84ab29 Fix a typo that prevented pointer-to-int conversions from working.
llvm-svn: 43588
2007-10-31 23:18:02 +00:00
Devang Patel f5fcb9870a Refactor code into a separate method.
llvm-svn: 43587
2007-10-31 23:17:19 +00:00
Anders Carlsson 0370eb2034 Handle function calls that return aggregate expressions.
llvm-svn: 43581
2007-10-31 22:04:46 +00:00
Devang Patel 6029cbf872 Check whether next slot meets field type's alignment requirements.
If it does not then assert at the moment.

llvm-svn: 43576
2007-10-31 21:01:37 +00:00
Devang Patel 1c8788bbd0 Keep track of field offsets during structure layout.
Take 2.

llvm-svn: 43573
2007-10-31 20:08:22 +00:00
Devang Patel 75ef2f0b45 Take 2.
Make target info available to clang code generator.  This is far from complete but this helps clang codegen module make progress.

At the moment target triplet and target description strings are hard coded in clang::TargetInfo

llvm-svn: 43572
2007-10-31 20:01:01 +00:00
Devang Patel 7abb7acafd Initialize MemCpyFn
llvm-svn: 43569
2007-10-31 19:54:57 +00:00
Chris Lattner 5087e267c2 temporarily revert devang's patch to link in the llvm codegen etc.
llvm-svn: 43544
2007-10-31 04:53:03 +00:00
Devang Patel df62bc067a Keep track of field offsets during structure layout.
llvm-svn: 43539
2007-10-31 01:23:10 +00:00
Devang Patel 46c7003052 Make target info available to clang code generator.
This is far from complete but this helps clang codegen module
make progress.

llvm-svn: 43536
2007-10-31 00:59:29 +00:00
Devang Patel 82ae5f255f Avoid unnecessary PATypeHolder copy.
llvm-svn: 43530
2007-10-30 23:22:14 +00:00
Chris Lattner 595db86c9d __real__ and __imag__ can be lvalues. Add support to ast and codegen for them.
llvm-svn: 43525
2007-10-30 22:53:42 +00:00
Devang Patel 73721a12ca Refactor code into a separate method.
llvm-svn: 43519
2007-10-30 21:27:20 +00:00
Devang Patel ffe1e218f2 Fix 80 col violations.
llvm-svn: 43516
2007-10-30 20:59:40 +00:00
Devang Patel f5bda316c5 Use
+  llvm::DenseMap<Type *, llvm::PATypeHolder> TypeHolderMap;
instead of
-  llvm::DenseMap<Type *, llvm::PATypeHolder *> TypeHolderMap;

llvm-svn: 43514
2007-10-30 20:46:47 +00:00
Devang Patel fa0cb1ef3a Remove commented out line.
llvm-svn: 43508
2007-10-30 18:31:12 +00:00
Devang Patel 134b3f4b55 Add RecordOrganizer::layoutUnionFields()
llvm-svn: 43472
2007-10-29 20:50:19 +00:00
Devang Patel d45e055f2c Insetead of assert() just emit an error message for
an unimplemented work  and continue.

llvm-svn: 43449
2007-10-29 16:56:27 +00:00
Anders Carlsson d849982e84 Add (partial) support for @encode.
llvm-svn: 43439
2007-10-29 05:01:08 +00:00
Anders Carlsson ceced4ca73 Generate code for __builtin_classify_type.
llvm-svn: 43429
2007-10-29 02:59:40 +00:00
Devang Patel ed93c3c3b3 Codegen union member references.
llvm-svn: 43390
2007-10-26 19:42:18 +00:00
Devang Patel 7718d7a2eb Handle non LValue base expressions.
llvm-svn: 43387
2007-10-26 18:15:21 +00:00
Devang Patel ffdb07c939 Code gen static initializer.
llvm-svn: 43386
2007-10-26 17:50:58 +00:00
Devang Patel 8717417b3b Codegen array initializers.
llvm-svn: 43385
2007-10-26 17:44:44 +00:00
Devang Patel 19c2b9a66f Codegen global array initializers.
llvm-svn: 43383
2007-10-26 16:31:40 +00:00
Devang Patel b989c9e65c Fix "strbuf += stufflen;" crash.
llvm-svn: 43365
2007-10-25 22:19:13 +00:00
Devang Patel 5ea6d7f1be Document ConvertNewType() method and make it a private method.
llvm-svn: 43363
2007-10-25 21:40:12 +00:00
Devang Patel 29e3824453 Cache llvm::Type through PATypeHolder.
llvm-svn: 43355
2007-10-25 18:32:36 +00:00
Chris Lattner 35e564ed09 Add a new ChooseExpr::isConditionTrue method to unify
some code.

llvm-svn: 43322
2007-10-25 00:29:32 +00:00
Devang Patel e85285b9f3 Remove unused #includes
llvm-svn: 43317
2007-10-24 23:42:18 +00:00
Devang Patel d68df20620 Handle
foo()->a = 42;

llvm-svn: 43315
2007-10-24 22:26:28 +00:00
Devang Patel bc50aab635 Move RecordOrganizer into CodeGenTypes.cpp
llvm-svn: 43310
2007-10-24 20:38:06 +00:00
Devang Patel b67e596d86 Handle non-constant initializers.
llvm-svn: 43301
2007-10-24 18:05:48 +00:00
Devang Patel 43fc86d0f2 Visit CompoundLiteralExpr and InitListExpr
llvm-svn: 43300
2007-10-24 17:18:43 +00:00
Devang Patel ea37aa7d64 Constify methods and reuse RecordOrganizer object.
llvm-svn: 43284
2007-10-24 00:56:23 +00:00
Devang Patel 790afb0444 check base type.
llvm-svn: 43283
2007-10-24 00:54:17 +00:00
Devang Patel f2423473b1 Add notes.
llvm-svn: 43282
2007-10-24 00:32:16 +00:00
Devang Patel e531ae687a Use isUnionType() predicate.
llvm-svn: 43281
2007-10-24 00:28:49 +00:00
Devang Patel c4e224e59c untabify
llvm-svn: 43280
2007-10-24 00:26:24 +00:00
Hartmut Kaiser 5277af121a Fixed a strange construct, please review.
llvm-svn: 43278
2007-10-24 00:07:36 +00:00
Devang Patel 65c4afb940 Handle nested structs.
typdef struct A { int i; struct A *next; } A

llvm-svn: 43268
2007-10-23 23:26:46 +00:00
Devang Patel 30efa2eec9 Handle simple struct member expr.
llvm-svn: 43258
2007-10-23 20:28:39 +00:00
Devang Patel 3e11ccea96 Begin struct layout work.
llvm-svn: 43236
2007-10-23 02:10:49 +00:00
Hartmut Kaiser 7078da8e58 Updated VC++ build system.
Silenced some VC++ warnings.
Had to rephrase a partial specialization of the IntrospectionTrait struct in SerializationTest.cpp, please review.
Added a compiler specific workaround in IdentifierTable.h. Is that the way to fix this kind of issues?

llvm-svn: 43074
2007-10-17 15:00:17 +00:00
Anders Carlsson f94cd1ffe6 Generate code for static variables that don't have initializers. Also, report an error if a static initializer is not constant.
llvm-svn: 43058
2007-10-17 00:52:43 +00:00
Steve Naroff 32e44c0032 Move type compatibility predicates from Type to ASTContext. In addition, the predicates are now instance methods (they were previously static class methods on Type).
This allowed me to fix the following hack from this weekend...

// FIXME: Devise a way to do this without using strcmp.
// Would like to say..."return getAsStructureType() == IdStructType;", but
// we don't have a pointer to ASTContext.
bool Type::isObjcIdType() const {
  if (const RecordType *RT = getAsStructureType())
    return !strcmp(RT->getDecl()->getName(), "objc_object");
  return false;
}

...which is now...

bool isObjcIdType(QualType T) const {
  return T->getAsStructureType() == IdStructType;
}

Side notes:

- I had to remove a convenience function from the TypesCompatibleExpr class.

int typesAreCompatible() const {return Type::typesAreCompatible(Type1,Type2);}

Which required a couple clients get a little more verbose...

-    Result = TCE->typesAreCompatible();
+    Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2());

Overall, I think this change also makes sense for a couple reasons...

1) Since ASTContext vends types, it makes sense for the type compatibility API to be there.
2) This allows the type compatibility predeciates to refer to data not strictly present in the AST (which I have found problematic on several occasions).

llvm-svn: 43009
2007-10-15 20:41:53 +00:00
Anders Carlsson 7e13ab88a2 Add code generation and sema checking for __builtin_va_arg.
llvm-svn: 43006
2007-10-15 20:28:48 +00:00
Anders Carlsson d5f857f2e5 Fix an incorrect assertion.
llvm-svn: 42951
2007-10-13 05:52:34 +00:00
Anders Carlsson 24ebce6fca Generate code for va_start and va_end.
llvm-svn: 42939
2007-10-12 23:56:29 +00:00
Devang Patel 152f18f671 Recognize while(1) and avoid extra blocks.
llvm-svn: 42811
2007-10-09 20:51:27 +00:00
Devang Patel c1380400d5 Recognize "do {} while (0)" idiom and avoid extra basic blocks.
llvm-svn: 42808
2007-10-09 20:33:39 +00:00
Devang Patel 7ad0c2f1f9 Use LLVMFoldingBuilder
llvm-svn: 42807
2007-10-09 19:49:58 +00:00
Devang Patel eac5948348 Use const& for RHS.
Use copy for LHS, because it is incremented using ++ operator.

llvm-svn: 42792
2007-10-09 17:10:59 +00:00
Devang Patel 49a44f3b52 Fix comment. Describe what it is, instead of how it is used.
llvm-svn: 42791
2007-10-09 17:08:50 +00:00
Fariborz Jahanian da6c012ee7 Added a new class for Interfaces qualified by protocol list.
Protocols are now sorted and made unique in the list.
Enhanced pretty printer for @interface (So, I can see the protocol list).

llvm-svn: 42776
2007-10-08 23:06:41 +00:00
Chris Lattner ba9dddb01e Rename FileVariable -> FileVar for consistency with its class name,
likewise block and param.  Reorder the layout of the Decl kind enum
so that the inheritance tree is reflected in the ordering.  This allows
trivial range comparisons to determine whether something is an instance
of some abstract class, making classof faster.

llvm-svn: 42772
2007-10-08 21:37:32 +00:00
Devang Patel 1166312e8b Code gen case statement ranges.
llvm-svn: 42766
2007-10-08 20:57:48 +00:00
Chris Lattner ef6b136781 move IdentifierTable.h from liblex to libbasic.
llvm-svn: 42730
2007-10-07 08:58:51 +00:00
Devang Patel 64a9ca7c58 Support case statement ranges.
llvm-svn: 42648
2007-10-05 20:54:07 +00:00
Devang Patel da5d6bbc40 switch statement code gen.
llvm-svn: 42616
2007-10-04 23:45:31 +00:00
Devang Patel 8ec4f837fa Do not codegen dummy block.
Dummy block is an empty block with no predecessors.

llvm-svn: 42451
2007-09-28 21:49:18 +00:00
Chris Lattner 2dd003e807 further apfloat'ize the front-end, allowing codegen to pass
APFloat straight through to LLVM now.

llvm-svn: 42236
2007-09-22 18:47:25 +00:00
Chris Lattner 793d10ca38 fix some warnings, patch by Justin Handville
llvm-svn: 42010
2007-09-16 19:23:47 +00:00
Steve Naroff a23cc79654 Move Decl::NextDeclarator (w/ setters/getters) down to ScopedDecl/FieldDecl.
Decl is now svelte:-)

llvm-svn: 41935
2007-09-13 23:52:58 +00:00
Steve Naroff 9def2b15c1 Phase 2 of making the Decl class more lightweight...
Move Identifier/Loc instance variables (and associated getters/setters) down from Decl to ScopedDecl/FieldDecl.

Objc AST's can now inherit from Decl without getting instance variables and types that are C specific. For now, I am keeping NextDeclarator, since I believe it may be useful to ObjC. If not, it can be moved later.

llvm-svn: 41934
2007-09-13 21:41:19 +00:00
Chris Lattner d3d8aca074 update to match llvm mainline api
llvm-svn: 41926
2007-09-13 06:19:18 +00:00
Chris Lattner 6fb276d433 adjust to a change in the LLVM APIs, this is still very hackish until
the front-end adopts APFloat though.  This fixes test/CodeGen/mandel.c

llvm-svn: 41908
2007-09-13 01:26:11 +00:00
Chris Lattner 69de3f4af6 When dumping out errors about unsupported stuff, emit loc info.
llvm-svn: 41907
2007-09-13 01:17:29 +00:00
Hartmut Kaiser ec7531c9f6 Fixed compilation on Windows.
Silenced a couple of warnings.
Added *.vcproj file for new clangAnalysis library.
Renamed Basic to clangBasic projects.

llvm-svn: 41767
2007-09-07 14:34:20 +00:00
Ted Kremenek c81587d240 Updated calls to CreateGEP to new interface in LLVM mainline.
llvm-svn: 41704
2007-09-04 17:20:08 +00:00
Chris Lattner fb2eb6941a eliminate some VC++ warnings, patch contributed by Hartmut Kaiser
llvm-svn: 41692
2007-09-04 02:34:27 +00:00
Chris Lattner 49e3bfa8a4 add stmtexpr support for aggregates
llvm-svn: 41662
2007-08-31 22:54:14 +00:00
Chris Lattner 1c3ad19714 add support for complex stmtexpr's
llvm-svn: 41661
2007-08-31 22:51:38 +00:00
Chris Lattner 4647a21825 Generalize RValue to handle complex better, generalize EmitCompoundStmt to
support any sort of expr, add a new EmitAnyExpr routine.

llvm-svn: 41660
2007-08-31 22:49:20 +00:00
Chris Lattner 04a913b958 implement code generation for scalar stmt expressions.
llvm-svn: 41656
2007-08-31 22:09:40 +00:00
Chris Lattner 9e47ead594 Implement codegen support for lowering "library builtins" like __builtin_isinf
to their corresponding library routines (e.g. isinf).  This allows us to handle
all the stuff in macos math.h, and other stuff as it's added to *Builtins.def.

llvm-svn: 41634
2007-08-31 04:44:06 +00:00
Chris Lattner 1eec6601d9 add the ability to get the llvm function corresponding to a library builtin.
llvm-svn: 41633
2007-08-31 04:31:45 +00:00
Steve Naroff 5c13180a27 Fix the following redefinition errors submitted by Keith Bauer...
[dylan:~/llvm/tools/clang] admin% cat tentative_decls.c 
// incorrectly generates redefinition error
extern int array[3];
int array[3];

// incorrectly generates a redefinition error
extern void nup(int a[3]);
void nup(int a[3]) {}

It turns out that this exposed a fairly major flaw in the type system,
array types were never getting uniqued! This is because all array types
contained an expression, which aren't unique.

To solve this, we now have 2 array types, ConstantArrayType and
VariableArrayType. ConstantArrayType's are unique, VAT's aren't.

This is a fairly extensive set of fundamental changes. Fortunately,
all the tests pass. Nevertheless, there may be some collateral damage:-)
If so, let me know!

llvm-svn: 41592
2007-08-30 01:06:46 +00:00
Chris Lattner fb38f274ff remove some ugly code now that implicit defs are being generated in this case, thanks Steve!
llvm-svn: 41560
2007-08-29 06:38:44 +00:00
Chris Lattner 1c1f932433 Change EnumDecl to store its corresponding integer type
directly in it.  Remove TargetInfo::getEnumPolicy, as there is only
one policy that we support right now.

llvm-svn: 41548
2007-08-28 18:24:31 +00:00
Chris Lattner 304ff47b1a teach codegen to lay out enum types.
llvm-svn: 41501
2007-08-27 17:44:34 +00:00
Chris Lattner bda69f80bc move EmitAggregateCopy into AggExprEmitter
llvm-svn: 41472
2007-08-26 23:13:56 +00:00
Chris Lattner c1045b1a69 remove dead code
llvm-svn: 41470
2007-08-26 23:02:57 +00:00
Chris Lattner 1916b88723 remove dead protos
llvm-svn: 41469
2007-08-26 23:01:23 +00:00
Chris Lattner 6c555f96e8 eliminate EmitAnyExpr, inlining it and simplifying it into its only caller.
llvm-svn: 41468
2007-08-26 22:58:05 +00:00
Chris Lattner a811da5fcd eliminate use of EmitAnyExpr.
llvm-svn: 41467
2007-08-26 22:55:13 +00:00
Chris Lattner a8d8b71680 implement a fixme
llvm-svn: 41466
2007-08-26 22:47:40 +00:00
Chris Lattner e56d3e1a23 Implement compound assignment operators whose LHS is scalar but RHS is complex.
llvm-svn: 41464
2007-08-26 22:37:40 +00:00
Chris Lattner 624e6d0c68 implement codegen of compound assignment operators for complex.
llvm-svn: 41463
2007-08-26 22:09:01 +00:00
Chris Lattner b633469e02 compound assignment operators are of type CompoundAssignOperator
llvm-svn: 41460
2007-08-26 21:41:21 +00:00
Chris Lattner 2c666fa40d update fixme's
llvm-svn: 41458
2007-08-26 21:27:07 +00:00
Chris Lattner 6f672c150c implement complex division
llvm-svn: 41457
2007-08-26 21:24:19 +00:00
Chris Lattner 2e928885b2 fix a typo noticed by Gordon Henriksen
llvm-svn: 41451
2007-08-26 17:25:57 +00:00
Chris Lattner c3b3707536 llvmgcc is right :)
llvm-svn: 41450
2007-08-26 16:54:05 +00:00
Chris Lattner 183c231cf9 compound assignmetns work for scalars.
llvm-svn: 41449
2007-08-26 16:52:57 +00:00
Chris Lattner c141c1b390 implement conversions of complex to bool.
llvm-svn: 41448
2007-08-26 16:52:28 +00:00
Chris Lattner 268fcce4f0 remove ConvertScalarValueToBool.
llvm-svn: 41447
2007-08-26 16:46:58 +00:00
Chris Lattner e004438f4a reimplement ConvertScalarValueToBool in CGExprScalar.cpp
llvm-svn: 41446
2007-08-26 16:42:57 +00:00
Chris Lattner 42e6b8150a refactor some code to expose compex->scalar conversion to CGF
llvm-svn: 41445
2007-08-26 16:34:22 +00:00
Chris Lattner b84bb95b44 be slightly more volatile correct
llvm-svn: 41444
2007-08-26 16:22:13 +00:00
Chris Lattner f6dcc9df7e these fixme's are easy :)
llvm-svn: 41442
2007-08-26 07:30:49 +00:00
Chris Lattner b753f66339 implement a fixme, add a couple more :)
llvm-svn: 41441
2007-08-26 07:29:23 +00:00
Chris Lattner 5de3b174c8 there are no conversions from aggregates to scalars.
llvm-svn: 41440
2007-08-26 07:26:12 +00:00
Chris Lattner 08c611e4dc implement conversions from complex to scalar types.
llvm-svn: 41439
2007-08-26 07:21:11 +00:00
Chris Lattner 46c7161311 Omit EmitConversion
llvm-svn: 41438
2007-08-26 07:16:41 +00:00
Chris Lattner 45067906ad Fix return of aggregate and return of complex.
llvm-svn: 41437
2007-08-26 07:14:44 +00:00
Chris Lattner 44d3e74e22 these implicit conversions are now explicit :)
llvm-svn: 41436
2007-08-26 07:09:42 +00:00
Chris Lattner cf3da8495a remove uses of EmitConversion
llvm-svn: 41435
2007-08-26 07:08:39 +00:00
Chris Lattner 798da7033f implicit casts take care of this code, remove it now.
llvm-svn: 41434
2007-08-26 07:06:24 +00:00
Chris Lattner 3474c202ab refactor scalar conversions out into CGExprScalar.cpp
llvm-svn: 41433
2007-08-26 06:48:56 +00:00
Chris Lattner 7460f9620c Implement casts from scalar -> complex and complex->complex.
llvm-svn: 41429
2007-08-26 05:57:57 +00:00
Chris Lattner b5e1262437 implement codegen of __imag of a scalar. Our impl doesn't suffer from
GCC bug PR33192.

llvm-svn: 41427
2007-08-26 05:29:21 +00:00
Chris Lattner 9de9527ad6 Make initialization of complex vars work.
llvm-svn: 41426
2007-08-26 05:13:54 +00:00
Chris Lattner a01d898ff5 fix codegen of pre/post inc/dec of a pointer.
llvm-svn: 41425
2007-08-26 05:10:16 +00:00
Chris Lattner c7f06ca780 tolerate unimplemented codegen better
llvm-svn: 41424
2007-08-26 05:06:40 +00:00
Chris Lattner e7a160b37d int X[] isn't a VLA. This improves support for stdio.h on darwin.
llvm-svn: 41423
2007-08-26 05:02:07 +00:00
Chris Lattner 57c269b5d3 implement rudimentary union layout support.
llvm-svn: 41421
2007-08-26 04:50:19 +00:00
Chris Lattner 881440f5d2 Don't make unknown builtins fatal errors yet.
llvm-svn: 41419
2007-08-26 04:17:05 +00:00
Chris Lattner c5221650b3 remove a bunch of dead code
llvm-svn: 41418
2007-08-26 04:13:58 +00:00
Chris Lattner 0fffcb5b28 implement codegen for complex literals.
llvm-svn: 41414
2007-08-26 03:51:12 +00:00
Chris Lattner 27f00282e9 The new correct compound assignment operators exposed a bug in codegen.
llvm-svn: 41405
2007-08-25 21:56:20 +00:00
Chris Lattner 9f0ad96b3e implement codegen for real/imag. TODO: imag of non-complex.
llvm-svn: 41376
2007-08-24 21:20:17 +00:00
Chris Lattner 3d966d6556 Teach emit-llvm for scalars to properly handle compound assignment
operators in all their glory :)

llvm-svn: 41373
2007-08-24 21:00:35 +00:00
Chris Lattner 100198f3f7 print the computation type for compound assignment operators in dumps.
llvm-svn: 41361
2007-08-24 16:24:49 +00:00
Chris Lattner 2da04b3322 completely refactor codegen of scalar expressions out into its own CGExprScalar.cpp file.
This patch temporarily breaks compound assignment operators, but greatly simplifies many
things.

llvm-svn: 41355
2007-08-24 05:35:26 +00:00
Chris Lattner 11e0de5193 rename two files.
llvm-svn: 41350
2007-08-24 02:22:53 +00:00
Chris Lattner db0d60d5b5 implement codegen of builtin_choose_expr for complex.
llvm-svn: 41349
2007-08-24 02:18:47 +00:00
Chris Lattner 8ad56707ea stub out complex -> bool conversion.
llvm-svn: 41347
2007-08-24 00:01:20 +00:00
Chris Lattner 0b984995b7 implement complex subtraction
llvm-svn: 41345
2007-08-23 23:46:33 +00:00
Chris Lattner 08b15df766 implement passing of complex and aggregates through call args.
llvm-svn: 41344
2007-08-23 23:43:33 +00:00
Chris Lattner 1aaab49a3e add support for codegen of calls returning complex.
llvm-svn: 41336
2007-08-23 21:38:16 +00:00
Chris Lattner cb1ffbc12e add some fixme's, implement complex struct members.
llvm-svn: 41256
2007-08-21 22:33:41 +00:00
Chris Lattner d34c999b67 implement codegen for --/++
llvm-svn: 41255
2007-08-21 22:25:29 +00:00
Chris Lattner 875a519ca6 implement __extension__ and unary~ for complex.
llvm-svn: 41249
2007-08-21 20:41:44 +00:00
Chris Lattner ad4569eacb implement codegen for complex unary +/-
llvm-svn: 41247
2007-08-21 20:08:23 +00:00
Chris Lattner d614e7a553 minor nicities.
llvm-svn: 41244
2007-08-21 18:51:13 +00:00
Chris Lattner a0733a777b implement support for complex subscripts.
llvm-svn: 41240
2007-08-21 18:03:58 +00:00
Chris Lattner e0e54120b2 allow support for volatile lvalues even though it's still not right.
llvm-svn: 41239
2007-08-21 18:02:02 +00:00
Anders Carlsson 76f4a902d7 Implement parsing and code generation of Objective-C string literals.
llvm-svn: 41238
2007-08-21 17:43:55 +00:00
Chris Lattner 2dc2af3515 add a new builder ivar.
llvm-svn: 41237
2007-08-21 17:39:38 +00:00
Chris Lattner 4b0e7873f6 move EmitLoadOfComplex/EmitStoreOfComplex into ComplexExprEmitter.
llvm-svn: 41236
2007-08-21 17:28:34 +00:00
Chris Lattner 3cf417b369 implement comma for complex.
llvm-svn: 41235
2007-08-21 17:15:50 +00:00
Chris Lattner 64be48fede and/or/xor are invalid for complex, even integer complex apparently.
llvm-svn: 41234
2007-08-21 17:12:50 +00:00
Chris Lattner bf1bd0dcc7 simplify code slightly
llvm-svn: 41233
2007-08-21 17:03:38 +00:00