Commit Graph

113 Commits

Author SHA1 Message Date
Chris Lattner d7e7b8e411 first wave of fixes for @encode sema support. This is part of PR3648.
The big difference here is that (like string literal) @encode has 
array type, not pointer type.

llvm-svn: 65391
2009-02-24 22:18:39 +00:00
Mike Stump 624497c29a Cleanp code with some recent suggestions.
llvm-svn: 65285
2009-02-22 13:27:11 +00:00
Mike Stump cb2fbcb0c9 Add CodeGen support for the helper for BlockDeclRefExprs. The easier
stuff is mostly done.  Move BlockHasCopyDispose up.

llvm-svn: 65242
2009-02-21 20:00:35 +00:00
Mike Stump 5d2534ada7 More codegen for blocks. The type of block literals should be better.
The size calculation is improved.

llvm-svn: 64994
2009-02-19 01:01:04 +00:00
Chris Lattner d7cfc246f6 rip out __builtin_overload
llvm-svn: 64961
2009-02-18 22:14:55 +00:00
Mike Stump 2d5a2878d4 Generate the helper function for blocks. Now basic codegen is
starting to work for blocks.

llvm-svn: 64570
2009-02-14 22:16:35 +00:00
Chris Lattner cd7bc144f6 fix rdar://6586493, a bug in codegen of the GNU
missing-?:-true-value extension.

llvm-svn: 64505
2009-02-13 23:35:32 +00:00
Mike Stump 85284bacab Condense all the blocks code into CGBlocks.cpp.
llvm-svn: 64457
2009-02-13 16:19:19 +00:00
Mike Stump ab3afd8f2d Initial codegen for block literals. This is a work in progress. I've
tried to put FIXMEs on the most important things to fix up.  Lots left
to do including more codegen, more documentation and cleaning code and
style cleanups.

llvm-svn: 64390
2009-02-12 18:29:15 +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
Chris Lattner 746b21361f Fix rdar://6518463, increment of a bool is always true, due to
subtle and non-obvious promotion rules.  We already handle += 
and +1 correctly.

llvm-svn: 64296
2009-02-11 07:40:06 +00:00
Chris Lattner 60dcdc7062 finish off codegen support for sub of pointer to functions,
finishing off rdar://6520707

llvm-svn: 64295
2009-02-11 07:21:43 +00:00
Anders Carlsson 31f8649f83 Follow Eli's advice and store the VLA size with the native size_t type. Fixes PR3491.
llvm-svn: 63879
2009-02-05 19:43:10 +00:00
Anders Carlsson 221483dd4e Make sure to cast the VLA size of array to the type of size_t. Fixes PR3442.
llvm-svn: 63394
2009-01-30 16:41:04 +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 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 8549e5dcc8 Fix for PR2910: implement CodeGen for non-constant offsetof.
Note that there are still other issues in this area; see PR3396.

llvm-svn: 62942
2009-01-24 22:38:55 +00:00
Eli Friedman 2aa38fea35 Refactor sizeof handling to use constant folding logic for constant
sizeof expressions.

llvm-svn: 62941
2009-01-24 22:19:05 +00:00
Chris Lattner 04964bbebe remove a bunch of alignment handling code out of CGExprScalar, since
alignment must always be a constant.  Just let the constant folder 
do it.

llvm-svn: 62933
2009-01-24 21:09:45 +00:00
Daniel Dunbar 42a8cd37b2 Handle pointer arithmetic on function pointers.
- <rdar://problem/6518844> Clang-generated bitcode crashes LLVM while compiling function pointer addition expression

llvm-svn: 62857
2009-01-23 18:51:09 +00:00
Eli Friedman ddea0ade30 Slight cleanup, and fix for va_arg on architectures where va_list is a
struct.

llvm-svn: 62585
2009-01-20 17:46:04 +00:00
Nate Begeman b699c9bf57 Vector codegen improvements
llvm-svn: 62458
2009-01-18 06:42:49 +00:00
Fariborz Jahanian 55ca58ed61 Changed the API yet again.
llvm-svn: 62335
2009-01-16 19:02:53 +00:00
Fariborz Jahanian 195d36cb57 Used a more suitable api to get to the type of a record
in code gen.

llvm-svn: 62326
2009-01-16 17:41:13 +00:00
Fariborz Jahanian c5ece68d16 Implemented code gen for sizeof(objc class interface).
llvm-svn: 62289
2009-01-16 00:57:08 +00:00
Nuno Lopes a0abe62904 make ScalarExprEmitter::EmitCompare() emit the expression with the correct type instead of always zext it to an int
this fixes codegen of simple exprs in C++ like 'if (x != 0)'

llvm-svn: 62060
2009-01-11 23:22:37 +00:00
Daniel Dunbar 93215eca9b Emit more refined "unsupported" error for block expressions.
llvm-svn: 61993
2009-01-09 17:04:29 +00:00
Anders Carlsson 39def3adc8 Add codegen support for __null
llvm-svn: 61314
2008-12-21 22:39:40 +00:00
Anders Carlsson 3ebc7c4a0d Implement alignof for vla types.
llvm-svn: 61305
2008-12-21 03:48:05 +00:00
Anders Carlsson 76dbc0423e Make sure to emit the size expression for sizeof(type)
llvm-svn: 61301
2008-12-21 03:33:21 +00:00
Eli Friedman f4084708cd Make VLAs usable, and make basic usage work correctly. Also, add a
simple test that actually does VLA codegen.

Note that despite the fact that the alloca isn't in the entry block, it 
should dominate all uses; this is guaranteed by the restrictions on goto 
into VLA scope in C99.

llvm-svn: 61291
2008-12-20 23:11:59 +00:00
Chris Lattner e69336c22d disable Anders' recent VLA patch, this fixes PR3209.
llvm-svn: 60989
2008-12-13 18:58:59 +00:00
Anders Carlsson 30032889ae Implement allocation and sizeof VLAs. This is very basic for now.
llvm-svn: 60943
2008-12-12 07:38:43 +00:00
Eli Friedman e918435f94 Fix for PR3150: obvious copy-paste bug in
ScalarExprEmitter::VisitBinLOr.

llvm-svn: 60415
2008-12-02 16:02:46 +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
Daniel Dunbar 7689f6be47 Add spec ref to comment.
llvm-svn: 59622
2008-11-19 11:54:05 +00:00
Daniel Dunbar 9b1335eca8 Fix redundant load of bit-fields on assignment (to get the updated
value).
 - Use extra argument to EmitStoreThroughLValue to provide place to
   write update bit-field value if caller requires it.
 - This fixes several FIXMEs.

llvm-svn: 59615
2008-11-19 09:36:46 +00:00
Chris Lattner 9ce8a533cd daniel prefers completed thoughts.
llvm-svn: 59404
2008-11-16 06:16:27 +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 d2a53a7b77 Rename ?: operator blocks to cond.true and cond.false (I don't know
what "cond.?" means, and this avoids quoting).

llvm-svn: 59128
2008-11-12 10:13:37 +00:00
Chris Lattner 3fd91f83fd Lower ?: into select when the selected values are cheap and side-effect-free.
This cuts another 200 lines off expr.ll, forming 23 selects.

llvm-svn: 59124
2008-11-12 08:55:54 +00:00
Chris Lattner 35710d18fe emit better codegen for ||/&&, shrinking expr.ll by another 240 lines.
This happens for stuff like this:

x = cond1 || cond2 || cond3 || cond4;

llvm-svn: 59123
2008-11-12 08:38:24 +00:00
Chris Lattner 8b0845822d use ConstantFoldsToSimpleInteger instead of code emission to do
constant folding.

llvm-svn: 59121
2008-11-12 08:26:50 +00:00
Chris Lattner 51e7118c30 Use EmitBranchOnBoolExpr in VisitConditionalOperator. This
shrinks code yet again by a bit.

llvm-svn: 59114
2008-11-12 08:08:13 +00:00
Chris Lattner cd439299b0 Move EmitBranchOnBoolExpr and ConstantFoldsToSimpleInteger to
CodeGenFunction.cpp.  Change VisitConditionalOperator to use
constant fold instead of codegen'ing a constant conditional.

Change ForStmt to use EmitBranchOnBoolExpr, this shrinks
expr.c very slightly to 40239 lines.

llvm-svn: 59113
2008-11-12 08:04:58 +00:00
Chris Lattner 4ad31fcc43 Clean up some code to use isZero instead of calling getZExtValue.
llvm-svn: 59103
2008-11-12 04:54:14 +00:00
Daniel Dunbar 8307290f35 Use createBasicBlock here too.
llvm-svn: 59095
2008-11-12 00:02:07 +00:00
Daniel Dunbar 5c7e3935f1 Rework IRgen invariant w.r.t. current insert point.
- EmitStmt is no longer required to finish with a current insertion
   point defined (i.e. it does not need to make dummy
   blocks). Instead, it can clear the insertion point in the builder
   which indicates that the current insertion point is unreachable.
 - CodeGenFunction provides HaveInsertPoint and EnsureInsertPoint
   which respectively test if there is an insert point and ensure an
   insertion point exists (by making a dummy block).
 - Clearly mark functions in CodeGenFunction which can be called with
   no insertion point defined. Currently this is a limited set, and
   EmitStmt simply EnsureInsertPoint()s before emitting subsequent IR.

Remove EmitDummyBlock, which is no longer needed. Clients who haven't
already cleared the insertion point (typically via EmitBranch) can do
so by hand.

Remove isDummyBlock, which has effectively been renamed to
HaveInsertPoint.

The main thrust of this change is that we no longer have create dummy
blocks just to destroy them a short time later in EmitBlock in the
common case that there is no unreachable code following something like
a goto. 

Additionally, this means that we are not using the hokey condition in
isDummyBlock that a block without a name is a dummy block. Guess how
well that works when we never emit block names!

llvm-svn: 59089
2008-11-11 23:11:34 +00:00
Chris Lattner d53e23328e Try to not emit the dead side of ?: if the condition is a constant.
llvm-svn: 59061
2008-11-11 18:56:45 +00:00