summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Move EmitBranchOnBoolExpr and ConstantFoldsToSimpleInteger toChris Lattner2008-11-121-2/+12
| | | | | | | | | | 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
* Make emission of 'if' conditions much more sophisticated when weChris Lattner2008-11-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | have a condition that is an &&/||. Before we used to compile things like this: int test() { if (x && y) foo(); else bar(); } into: %0 = load i32* @x ; <i32> [#uses=1] %1 = icmp ne i32 %0, 0 ; <i1> [#uses=1] br i1 %1, label %land_rhs, label %land_cont land_rhs: ; preds = %entry %2 = load i32* @y ; <i32> [#uses=1] %3 = icmp ne i32 %2, 0 ; <i1> [#uses=1] br label %land_cont land_cont: ; preds = %land_rhs, %entry %4 = phi i1 [ false, %entry ], [ %3, %land_rhs ] ; <i1> [#uses=1] br i1 %4, label %ifthen, label %ifelse ifthen: ; preds = %land_cont %call = call i32 (...)* @foo() ; <i32> [#uses=0] br label %ifend ifelse: ; preds = %land_cont %call1 = call i32 (...)* @bar() ; <i32> [#uses=0] br label %ifend ifend: ; preds = %ifelse, %ifthen Now we turn it into the much more svelte code: %0 = load i32* @x ; <i32> [#uses=1] %1 = icmp ne i32 %0, 0 ; <i1> [#uses=1] br i1 %1, label %land_lhs_true, label %ifelse land_lhs_true: ; preds = %entry %2 = load i32* @y ; <i32> [#uses=1] %3 = icmp ne i32 %2, 0 ; <i1> [#uses=1] br i1 %3, label %ifthen, label %ifelse ifthen: ; preds = %land_lhs_true %call = call i32 (...)* @foo() ; <i32> [#uses=0] br label %ifend ifelse: ; preds = %land_lhs_true, %entry %call1 = call i32 (...)* @bar() ; <i32> [#uses=0] br label %ifend ifend: ; preds = %ifelse, %ifthen Note the lack of a phi node. This shrinks the -O0 .ll file for 176.gcc/expr.c from 43176 to 40267 lines. llvm-svn: 59111
* Disable generation of basic block names in NDEBUG mode.Daniel Dunbar2008-11-121-0/+4
| | | | | | | Revert to enabling generation of instruction names when not in NDEBUG mode. llvm-svn: 59094
* Rework IRgen invariant w.r.t. current insert point.Daniel Dunbar2008-11-111-10/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Change EmitBranch to always clear the insert point to clarify irgenDaniel Dunbar2008-11-111-0/+4
| | | | | | invariants. llvm-svn: 59085
* Add CodeGenFunction::EmitBranch.Daniel Dunbar2008-11-111-0/+5
| | | | | | | - Emits an unconditional branch, with extra logic to avoid generating spurious branches out of dummy blocks. llvm-svn: 59037
* short circuit && and || when possible. This substantially reducesChris Lattner2008-11-111-0/+6
| | | | | | | | the size of the -O0 output on some cases. For example, on expr.c from 176.gcc, it shrinks the .ll file from 43164 to 42835 lines, and removed references to two external symbols. llvm-svn: 59034
* Add CodeGenFunction::EmitDummyBlock for marking places where we makeDaniel Dunbar2008-11-111-0/+5
| | | | | | | "dummy" blocks (blocks just used to make sure we have a place to dump code to). llvm-svn: 59022
* Centralize basic block creation in CodeGenFunction::createBasicBlock.Daniel Dunbar2008-11-111-2/+8
| | | | | | - No functionality change. llvm-svn: 59017
* Add a new expression class, ObjCSuperExpr, to handle the Objective-C ↵Douglas Gregor2008-11-041-0/+1
| | | | | | 'super'. Remove ObjCThis from PredefinedExpr llvm-svn: 58698
* Implement lowering of va_arg in clang directly. (This is 32-bit X86 only for ↵Anders Carlsson2008-11-041-0/+6
| | | | | | now). llvm-svn: 58681
* Move IRBuilder type definition to common file.Daniel Dunbar2008-11-011-3/+3
| | | | | | - No functionality change. llvm-svn: 58546
* Debug info bug fix, function start wasn't getting generated correctlyDaniel Dunbar2008-10-181-1/+2
| | | | | | for Obj-C methods. llvm-svn: 57769
* Lift CodeGenFunction::EmitPredefinedFunctioName out of EmitPredefinedLValue.Daniel Dunbar2008-10-171-0/+1
| | | | | | | - Shouldn't assume predefined expr is a function printing one. - Uses CGM functionality to cache function names per module. llvm-svn: 57737
* Lift EmitTargetBuiltinExpr out of EmitBuiltinExpr.Daniel Dunbar2008-10-101-0/+4
| | | | llvm-svn: 57335
* Add infrastructure for proper @finally support.Daniel Dunbar2008-09-301-5/+35
| | | | | | | | | | | | - Provides a basic primitive to jump to an arbitrary basic block, through the finally code. - Only used for return statements and rethrow currently. Still need to handle break, continue and goto. - Code still needs to be shuffled around to live elsewhere. llvm-svn: 56827
* Add support for implicit rethrows in @catch blocks.Daniel Dunbar2008-09-281-1/+17
| | | | | | Comment exception-handling code generation strategy. llvm-svn: 56763
* Refactor some CodeGen functionality: Daniel Dunbar2008-09-241-1/+9
| | | | | | | | | | - Add CodeGenFunction::{EmitReturnOfRValue, EmitIvarOffset} - Factor EmitLValueForIvar out of EmitObjCIvarRefLValue. No non-error functionality change (some unsupported errors are degraded to asserts for the time being). llvm-svn: 56543
* Add support for ABIArgInfo::ExpandDaniel Dunbar2008-09-171-0/+16
| | | | | | - No functionality change. llvm-svn: 56269
* Make sure to store the exception in the catch parameter.Anders Carlsson2008-09-111-1/+3
| | | | llvm-svn: 56102
* Make sure to emit the catch parameter as well as the catch body.Anders Carlsson2008-09-111-0/+1
| | | | llvm-svn: 56101
* Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, ↵Argyrios Kyrtzidis2008-09-101-0/+3
| | | | | | which represents a 'condition' declaration, e.g: "if (int x=0) {...}". llvm-svn: 56045
* Tweak CGCall functions again:Daniel Dunbar2008-09-101-9/+0
| | | | | | | | - Realized these functions will eventually need access to more data, moved to CodeGenModule. Eventually they should probably live together in some other helper class. llvm-svn: 56039
* Tweak CGCall functions:Daniel Dunbar2008-09-101-1/+6
| | | | | | | | - Move actual param attr list creation to CodeGenFunction::ConstructParamAttrList. - Make ReturnTypeUsesSret static. llvm-svn: 56038
* Add CodeGenFunction::ReturnTypeUsesSretDaniel Dunbar2008-09-091-0/+4
| | | | | | - Hook so NeXT runtime doesn't depend on ABI. llvm-svn: 56034
* Move ABI specific code for functions / calls to CGCall.cpp:Daniel Dunbar2008-09-091-1/+12
| | | | | | - Factor out EmitFunction{Pro,Epi}log llvm-svn: 56031
* Factor CodeGenFunction::StartFunction out of GenerateCode andDaniel Dunbar2008-09-091-0/+3
| | | | | | StartObjCMethod. llvm-svn: 56030
* Use a unified return block.Daniel Dunbar2008-09-091-0/+6
| | | | | | | - For the time being this means our emitted code is somewhat worse, especially for aggregates. This will be fixed. llvm-svn: 56013
* Move EmitAggregate{Copy,Clear} into CodeGenFunction.Daniel Dunbar2008-09-091-0/+5
| | | | | | - No functionality change. llvm-svn: 56010
* Move handling of @try and @throw to the runtime class.Anders Carlsson2008-09-091-0/+2
| | | | llvm-svn: 55983
* Change CodeGen to emit calls using (RValue,Type) list:Daniel Dunbar2008-09-091-8/+6
| | | | | | | | | | | | | | - Add CodeGenFunction::EmitAnyExprToTemp o Like EmitAnyExpr, but emits aggregates to a temporary location if none is available. Seems like this should be simpler (even aside from using first class aggregates). - Killed CodeGenFunction::EmitCallArg (just append the pair) - Conversion of RValues to actual call arguments is now isolated in CodeGenFunction::EmitCall. llvm-svn: 55970
* Refactor parameter attribute handling:Daniel Dunbar2008-09-081-4/+1
| | | | | | | | | - Add CGCall.h for dealing with ABI issues related to calls. - Add CGFunctionInfo and CGCallInfo for capturing ABI relevant information about functions and calls. - Isolate LLVM parameter attribute handling inside CGCall.cpp llvm-svn: 55963
* Avoid superfluous errors regarding variable-length arrays (casts).Daniel Dunbar2008-09-041-1/+2
| | | | llvm-svn: 55759
* Implement codegen of aggregates as lvalues in binary expressions,Daniel Dunbar2008-09-041-0/+2
| | | | | | e.g. "(a = b).somefield". llvm-svn: 55758
* Stub out CodeGenFunction::EmitObjCForCollectionStmt.Anders Carlsson2008-08-301-0/+5
| | | | | | Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it. llvm-svn: 55573
* Add Objective-C property setter support.Daniel Dunbar2008-08-301-0/+18
| | | | | | | | | | | | | | | | | | | | | | - 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
* Refactor handling of calls:Daniel Dunbar2008-08-301-7/+6
| | | | | | | | | | | | | | | | - Added CodeGenFunction::EmitCall which just takes the callee, return type, and a list of (Value*,QualType) pairs. - Added CodeGenFunction::EmitCallArg which handles emitting code for a call argument and turning it into an appropriate (Value*,QualType) pair. - Changed Objective-C runtime interface so that the actual emission of arguments for message sends is (once again) done in the code to emit a message send. No intended functionality change, this is prep work for better ABI support and for Objective-C property setter support. llvm-svn: 55560
* Downgrade a number of FIXME asserts to ErrorUnsupported.Daniel Dunbar2008-08-291-1/+0
| | | | | | - Notably VLAs llvm-svn: 55544
* Add special "property reference" CodeGen::LValue type for emittingDaniel Dunbar2008-08-291-0/+4
| | | | | | | | Objective-C property references. - This handles property references "more correctly" but setters still don't work. llvm-svn: 55534
* Initial support for Obj-C dot-syntax for getters.Daniel Dunbar2008-08-271-0/+1
| | | | llvm-svn: 55410
* Objective-C @synthesize support.Daniel Dunbar2008-08-261-1/+13
| | | | | | | | | | | - Only supports simple assignment and atomic semantics are ignored. - Not quite usable yet because the methods do not actually get added to the class metadata. - Added ObjCPropertyDecl::getSetterKind (one of Assign, Copy, Retain). - Rearrange CodeGenFunction so synthesis can reuse function prolog / epilog code. llvm-svn: 55365
* Support __PRETTY_FUNCTION__ and friends in Obj-C methods.Daniel Dunbar2008-08-251-0/+6
| | | | | | | | | | | | Add CodeGenFunction::EmitUnsupportedLValue - Gives error and returns undef value. Swap some asserts() over to using EmitUnsupportedLValue - Rumor has it users (and even some developers) prefer carat diagnostics to backtraces. - Works better in Release-Asserts to boot. llvm-svn: 55328
* Implement Obj-C ivar references to aggregates.Daniel Dunbar2008-08-231-0/+2
| | | | | | | | | | | 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
* Trim CGObjCRuntime::GenerateMessageSend[Super]Daniel Dunbar2008-08-231-3/+10
| | | | | | | | | | | | | | | | | | - 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
* Move [LR]Value into CGValue.hDaniel Dunbar2008-08-231-182/+2
| | | | | | - No (intended) functional change. llvm-svn: 55221
* Add preliminary (and probably broken) codegen support for C++ static ↵Anders Carlsson2008-08-221-0/+4
| | | | | | initializers. llvm-svn: 55180
* Move all Obj-C runtime interaction into CodeGenFunction.Daniel Dunbar2008-08-201-1/+1
| | | | | | | - Drop duplicate (and broken) code for sending messages. - Add EmitObjCProtocolExpr to CodeGenFunction. llvm-svn: 55024
* Add NeXT runtime support for generating methods.Daniel Dunbar2008-08-161-1/+5
| | | | | | | | | | | | | Change CodeGenFunction::EmitParmDecl to take either a ParmVarDecl or an ImplicitParamDecl. Drop hasAggregateLLVMType from CodeGenModule.cpp (use version in CodeGenFunction). Change the Objective-C method generation to use EmitParmDecl for implicit parameters. llvm-svn: 54838
* Change WarnUnsupported to ErrorUnsupported (in name and in practice).Daniel Dunbar2008-08-161-2/+2
| | | | | | | - We are beyond the point where this shows up often and when it does generating miscompiled files is bad. llvm-svn: 54836
* More #include cleaningDaniel Dunbar2008-08-111-1/+5
| | | | | | | | - Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h - Moved Sema::getCurMethodDecl() out of line (dependent on ObjCMethodDecl via dyn_cast). llvm-svn: 54629
OpenPOWER on IntegriCloud