Commit Graph

72 Commits

Author SHA1 Message Date
Mike Stump 8673657275 One step to fixing up codegen for a=b, where a is a volatile struct.
llvm-svn: 72315
2009-05-23 04:13:59 +00:00
Mike Stump a35af82429 Fix typo.
llvm-svn: 72308
2009-05-23 02:02:29 +00:00
Anders Carlsson c82b86dfaa Have AggExprEmitter::VisitCXXConstructExpr make new variables if necessary. Stub out VisitCXXExprWithTemporaries.
llvm-svn: 72103
2009-05-19 04:48:36 +00:00
Mike Stump 18bb9284ff Reflow some comments.
llvm-svn: 71937
2009-05-16 07:57:57 +00:00
Anders Carlsson 1619a5041c Make codegen for constructors work again.
llvm-svn: 70785
2009-05-03 17:47:16 +00:00
Chris Lattner a4185c543e fix PR4067: [Linux kernel] cannot aggregate codegen stmtexpr as lvalue
llvm-svn: 70067
2009-04-25 19:35:26 +00:00
Chris Lattner 2f343dd5c8 fix PR4026: Clang can't codegen __func__ without implicit cast
llvm-svn: 69747
2009-04-21 23:00:09 +00:00
Anders Carlsson b7f8f594f3 Implement basic code generation of constructor calls. We can now compile:
struct S {
S(int, int);
};

void f() {
S s(10, 10);
}

llvm-svn: 69330
2009-04-17 00:06:03 +00:00
Eli Friedman 20bb5e02a5 Minor work related to removing the assumption that value initialization
implies an all-zero bit pattern.

llvm-svn: 68994
2009-04-13 21:47:26 +00:00
Douglas Gregor bcced4ec31 Propagate the ASTContext to various AST traversal and lookup functions.
No functionality change (really).

llvm-svn: 68726
2009-04-09 21:40:53 +00:00
Eli Friedman 9127aa1caf Minor cleanup.
llvm-svn: 67896
2009-03-28 03:10:45 +00:00
Eli Friedman d6a7b72944 Remove dead code.
llvm-svn: 67477
2009-03-22 20:54:47 +00:00
Mike Stump bc7d67ce08 Add codegen support for aggregate BlockDeclRefExprs.
llvm-svn: 67207
2009-03-18 15:54:29 +00:00
Chris Lattner ca05dfef65 brain thinking memcpy, fingers thinking memset :)
llvm-svn: 65701
2009-02-28 18:31:01 +00:00
Chris Lattner 3ef668c27a after going around in circles a few times, finally cave and emit structure
copies with memcpy instead of memmove.  This matches what GCC does and if it
causes a problem with a particular libc we can always fix it with a target
hook.

llvm-svn: 65699
2009-02-28 18:18:58 +00:00
Chris Lattner d7cfc246f6 rip out __builtin_overload
llvm-svn: 64961
2009-02-18 22:14:55 +00:00
Daniel Dunbar e9fcadd2a6 Use EmitVAListRef instead of EmitLValue directly to handle array decay
case on x86_64.

llvm-svn: 64333
2009-02-11 22:25:55 +00:00
Douglas Gregor bf7207a11f Make CodeGen produce an error if we come across a non-constant initializer list that involves the GNU array-range designator extension
llvm-svn: 63327
2009-01-29 19:42:23 +00:00
Douglas Gregor 0202cb406e Introduce a new expression node, ImplicitValueInitExpr, that
represents an implicit value-initialization of a subobject of a
particular type. This replaces the (ab)use of CXXZeroValueInitExpr
within initializer lists for the "holes" that occur due to the use of
C99 designated initializers.

The new test case is currently XFAIL'd, because CodeGen's
ConstExprEmitter (in lib/CodeGen/CGExprConstant.cpp) needs to be
taught to value-initialize when it sees ImplicitValueInitExprs.

llvm-svn: 63317
2009-01-29 17:44:32 +00:00
Douglas Gregor 5169570e28 Clean up designated initialization of unions, so that CodeGen doesn't
have to try to guess which member is being initialized.

llvm-svn: 63315
2009-01-29 16:53:55 +00:00
Douglas Gregor 17bd094a6b Improvements to code-generation and semantic analysis of designated
initializers.

  - We now initialize unions properly when a member other than the
    first is named by a designated initializer.
  - We now provide proper semantic analysis and code generation for
    GNU array-range designators *except* that side effects will occur
    more than once. We warn about this.

llvm-svn: 63253
2009-01-28 23:36:17 +00:00
Douglas Gregor 347f7eabb9 Code generation support for C99 designated initializers.
The approach I've taken in this patch is relatively straightforward,
although the code itself is non-trivial. Essentially, as we process
an initializer list we build up a fully-explicit representation of the
initializer list, where each of the subobject initializations occurs
in order. Designators serve to "fill in" subobject initializations in
a non-linear way. The fully-explicit representation makes initializer
lists (both with and without designators) easy to grok for codegen and
later semantic analyses. We keep the syntactic form of the initializer
list linked into the AST for those clients interested in exactly what
the user wrote.

Known limitations:
  - Designating a member of a union that isn't the first member may
    result in bogus initialization (we warn about this)
  - GNU array-range designators are not supported (we warn about this)

llvm-svn: 63242
2009-01-28 21:54:33 +00:00
Eli Friedman 3f66b84c86 Support CodeGen for __extension__ operator on aggregates.
llvm-svn: 63101
2009-01-27 09:03:41 +00:00
Eli Friedman 7139af42ce Rename Expr::isConstantExpr to Expr::isConstantInitializer; this more
accurately states what the function is trying to do and how it is 
different from Expr::isEvaluatable.  Also get rid of a parameter that is both 
unused and inaccurate.

llvm-svn: 62951
2009-01-25 02:32:41 +00:00
Nuno Lopes 7ffcf93b24 add codegen support to union casts
init of static vars still not working. I'll get back to it tomorrow or so

llvm-svn: 62278
2009-01-15 20:14:33 +00:00
Sebastian Redl 020cddcfee Prevent a segfault for vaarg expressions on unsupported architectures.
llvm-svn: 62008
2009-01-09 21:09:38 +00:00
Douglas Gregor 91f84216f7 Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).

llvm-svn: 60878
2008-12-11 16:49:14 +00:00
Eli Friedman f5d08c9ee4 Disabling this code due to regression on test/CodeGen/bitfield.c. See
PR3152.

llvm-svn: 60389
2008-12-02 01:17:45 +00:00
Eli Friedman c59bb48e80 Fix for PR2969: generate a memcpy from a constant for constant
initializers.  llvm-gcc appears to be more aggressive, but incorrect, 
for constructs like "const int a[] = {1,2,3};"; that said, current 
optimizers will do the appropriate optimizations when safe.

llvm-svn: 60270
2008-11-30 02:11:09 +00:00
Fariborz Jahanian 9ac535162b Implemented ir-gen for 'implicit' properties using the new AST nodes.
llvm-svn: 59886
2008-11-22 22:30:21 +00:00
Fariborz Jahanian 8a1810f06b New AST node to access "implicit" setter/getter using property dor syntax.
Issuing diagnostics when assigning to read-only properties.
This is work in progress.

llvm-svn: 59874
2008-11-22 18:39:36 +00:00
Chris Lattner 0f137df0aa reapply the (corrected) patch to use the new llvm intrinsics for memcpy/memmove etc.
llvm-svn: 59824
2008-11-21 16:43:15 +00:00
Chris Lattner b7f4ce3de7 temporarily revert Sangiv's patch.
llvm-svn: 59821
2008-11-21 16:26:37 +00:00
Sanjiv Gupta 371298488b mem[cpy,set,move] intrinsics are now overloaded.
llvm-svn: 59806
2008-11-21 07:57:42 +00:00
Daniel Dunbar a612e79be4 Normalize many BasicBlock names.
- Use dotted notation for blocks related to a particular statement
   type.
 - Use .end for landing pads.

No functionality change in NDEBUG mode. :)

llvm-svn: 59210
2008-11-13 01:38:36 +00:00
Daniel Dunbar c56e67644f Add CodeGenFunction::EmitBranch.
- Emits an unconditional branch, with extra logic to avoid generating
   spurious branches out of dummy blocks.

llvm-svn: 59037
2008-11-11 09:41:28 +00:00
Daniel Dunbar 75283ff38a Centralize basic block creation in CodeGenFunction::createBasicBlock.
- No functionality change.

llvm-svn: 59017
2008-11-11 02:29:29 +00:00
Anders Carlsson 13abd7e98b Implement lowering of va_arg in clang directly. (This is 32-bit X86 only for now).
llvm-svn: 58681
2008-11-04 05:30:00 +00:00
Daniel Dunbar cb4638599c Move IRBuilder type definition to common file.
- No functionality change.

llvm-svn: 58546
2008-11-01 01:53:16 +00:00
Chris Lattner 084bc32e0d make codegen reject initializes with designators, like this:
t.c:1:13: error: cannot codegen this designators yet
int a[10] = {2, 4, [8]=9, 10};
            ^~~~~~~~~~~~~~~~~

llvm-svn: 58220
2008-10-26 23:53:12 +00:00
Daniel Dunbar 0bc8e86d6e Move EmitAggregate{Copy,Clear} into CodeGenFunction.
- No functionality change.

llvm-svn: 56010
2008-09-09 20:49:46 +00:00
Anders Carlsson 2e744e8aa6 Stub out CodeGenFunction::EmitObjCForCollectionStmt.
Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it.

llvm-svn: 55573
2008-08-30 19:51:14 +00:00
Anders Carlsson 7e1e57103e Simplify some calls to Builder.CreateCall
llvm-svn: 55567
2008-08-30 16:17:45 +00:00
Daniel Dunbar 4b8c6db927 Add Objective-C property setter support.
- Change Obj-C runtime message API, drop the ObjCMessageExpr arg in
   favor of just result type and selector. Necessary so it can be
   reused in situations where we don't want to cons up an
   ObjCMessageExpr.
 - Update aggregate binary assignment to know about special property
   ref lvalues.
 - Add CodeGenFunction::EmitCallArg overload which takes an already
   emitted rvalue.

Add CodeGenFunction::StoreComplexIntoAddr.

Disabled logic in Sema for parsing Objective-C dot-syntax that
accesses methods. This code does not search in the correct order and
the AST node has no way of properly representing its results.

Updated StmtDumper to print a bit more information about
ObjCPropertyRefExprs.

llvm-svn: 55561
2008-08-30 05:35:15 +00:00
Daniel Dunbar 55310df79c Initial support for Obj-C dot-syntax for getters.
llvm-svn: 55410
2008-08-27 06:57:25 +00:00
Daniel Dunbar 28ff072b70 Drop a dead call to isConstantExpr()
llvm-svn: 55244
2008-08-23 18:44:10 +00:00
Daniel Dunbar c8317a44cf Implement Obj-C ivar references to aggregates.
Implement Obj-C lvalue message sends (aggregate returns).

Update several places to emit more precise ErrorUnsupported warnings
  for currently unimplemented Obj-C features (main missing chunks are
  property references, Obj-C exception handling, and the for ... in
  syntax).

llvm-svn: 55234
2008-08-23 10:51:21 +00:00
Daniel Dunbar 97db84ce6d Trim CGObjCRuntime::GenerateMessageSend[Super]
- Returns an RValue.
 - Reduced to only taking the CodeGenFunction, Expr, and Receiver.
 - Becomes responsible for emitting the arguments.

Add CodeGenFunction::EmitCallExprExt
 - Takes optional extra arguments to insert at the head of the call.
 - This allows the Obj-C runtimes to call into this and isolates the
   argument and call instruction generation code to one place. Upshot
   is that we now pass structures (more) correctly.

Also, fix one aspect of generating methods which take structure
arguments (for NeXT). This probably needs to be merged with the
SetFunctionAttributes code in CodeGenModule.cpp

llvm-svn: 55223
2008-08-23 03:46:30 +00:00
Daniel Dunbar a7c8cf6200 Change WarnUnsupported to ErrorUnsupported (in name and in practice).
- We are beyond the point where this shows up often and when it does
   generating miscompiled files is bad.

llvm-svn: 54836
2008-08-16 00:56:44 +00:00
Daniel Dunbar ad319a73f2 More #include cleaning
- Remove internal uses of AST.h

llvm-svn: 54628
2008-08-11 05:00:27 +00:00