Commit Graph

75 Commits

Author SHA1 Message Date
Daniel Dunbar aec553bfdb Prefer llvm::Function::addFnAttr(...) to F->addAttribute(~0, ...).
llvm-svn: 56753
2008-09-27 07:16:42 +00:00
Devang Patel 597e70876e Now Attributes are divided in three groups
- return attributes - inreg, zext and sext
- parameter attributes
- function attributes - nounwind, readonly, readnone, noreturn

Return attributes use 0 as the index.
Function attributes use ~0U as the index.

llvm-svn: 56705
2008-09-26 22:53:57 +00:00
Devang Patel 322300d1c2 Large mechanical patch.
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

llvm-svn: 56623
2008-09-25 21:02:23 +00:00
Daniel Dunbar 7a95ca3197 Move FunctionType conversion into CGCall.cpp:
- Added CodeGenTypes::GetFunctionType, taking a CGFunctionInfo.
 - Updated Obj-C runtimes to use this instead of rolling the
   llvm::FunctionType by hand.
 - Killed CodeGenTypes::{ConvertReturnType, DecodeArgumentTypes}.

Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
 - Will move to target sometime soon.

llvm-svn: 56047
2008-09-10 04:01:49 +00:00
Daniel Dunbar c68897d2c3 Tweak CGCall functions again:
- 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
2008-09-10 00:41:16 +00:00
Daniel Dunbar 76c8eb75b1 Tweak CGCall functions:
- Move actual param attr list creation to
   CodeGenFunction::ConstructParamAttrList.
 - Make ReturnTypeUsesSret static.

llvm-svn: 56038
2008-09-10 00:32:18 +00:00
Daniel Dunbar 0beedc1684 Fix a number of issues w.r.t. emission of global for functions and
aliases.
 - Attributes specific to a definition are only set when the
   definition is seen.
 - Alias generation is delayed until the end of the module; necessary
   since the alias may reference forward.
 - Fixes: PR2743, <rdr://6140807&6094512>
 - Improves: <rdr://6095112> (added XFAIL)

Also, print module on verification failures.

llvm-svn: 55966
2008-09-08 23:44:31 +00:00
Daniel Dunbar 3d7c90b8ec Refactor parameter attribute handling:
- 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
2008-09-08 21:33:45 +00:00
Daniel Dunbar 2ffee610da Set sext/zext on function result.
- <rdar://problem/6156739>

llvm-svn: 55815
2008-09-05 00:57:45 +00:00
Daniel Dunbar 449a339ffd Set function attributes (sext, zext, etc.) on Objective-C methods.
llvm-svn: 55812
2008-09-04 23:41:35 +00:00
Daniel Dunbar f2cf6d16e6 Avoid superfluous errors regarding variable-length arrays (casts).
llvm-svn: 55759
2008-09-04 03:43:08 +00:00
Nuno Lopes f380a0de07 codegen constant data as such. add QualType::isConstant()
llvm-svn: 55603
2008-09-01 11:33:04 +00:00
Daniel Dunbar a799807dea Downgrade a number of FIXME asserts to ErrorUnsupported.
- Notably VLAs

llvm-svn: 55544
2008-08-29 17:28:43 +00:00
Daniel Dunbar 89654eef3a Objective-C @synthesize support.
- 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
2008-08-26 08:29:31 +00:00
Daniel Dunbar eb99810502 Use DenseMap on IdentifierInfo instead of StringMap.
llvm-svn: 55303
2008-08-25 06:18:57 +00:00
Daniel Dunbar d644ad61e9 NeXT: Clean up constant CFString handling.
- Use CodeGenModule::GetAddrOfConstantCFString

Some tweaks of CodeGenModule::GetAddrOfConstantCFString

llvm-svn: 55243
2008-08-23 18:37:06 +00:00
Daniel Dunbar a94ecd2a0b Add NeXT runtime support for generating methods.
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
2008-08-16 03:19:19 +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 fce4be843e Clean up CodeGenModule interface.
- Add CodeGenModule::EmitTopLevelDecl which uses switch on kind
   instead of ugly & slow dyn_cast chains.

 - Drop some simple forwarding methods into the ObjC runtime.

 - Privatize appropriate methods.

llvm-svn: 54827
2008-08-15 23:26:23 +00:00
Daniel Dunbar 9299250939 Change CGObjCRuntime methods to take appropriate clang Decls.
- This is in prep for implementation class support for the NeXT
   runtime, for which the existing methods don't provide enough
   information (and additionally make too many assumptions about how
   things should be emitted).

llvm-svn: 54824
2008-08-15 22:20:32 +00:00
Daniel Dunbar 2617a3abe6 Infinite loops considered harmful.
- Thanks Thomas

llvm-svn: 54818
2008-08-15 18:29:12 +00:00
Daniel Dunbar c4baa06d15 Add GetAddrOfConstantCString method
- Returns addr of constant for argument + '\0'.
 - I couldn't think of a better name.
 - Move appropriate users of GetAddrOfConstantString to this.

Rename getStringForStringLiteral to GetStringForStringLiteral.

Add GetAddrOfConstantStringFromLiteral
 - This combines GetAddrOfConstantString and
   GetStringForStringLiteral. This method can be, but is not yet, more
   efficient.

Change GetAddrOfConstantString to not add terminating '\0'
 - <rdar://problem/6140956>

llvm-svn: 54768
2008-08-13 23:20:05 +00:00
Daniel Dunbar 89da6ad1db Change ObjCRuntime GenerateProtocol[Ref] methods to take
ObjCProtocolDecl directly.

Implement CodeGen support for forward protocol decls (no-ops are so
    nice to implement).

Also moved CGObjCRuntime.h out of CodeGenModule.h

llvm-svn: 54709
2008-08-13 00:59:25 +00:00
Mike Stump 52f0260582 Fix compilation warning with help from David Chisnall.
llvm-svn: 54654
2008-08-11 23:16:18 +00:00
Daniel Dunbar 3ad53483fb Add LangOptions::NeXTRuntime.
- Wired to -fnext-runtime and -fgnu-runtime options.
 - Defaults to GNU, no autoselection for NeXT.

Emit NeXT OBJC_IMAGE_INFO marker.

llvm-svn: 54651
2008-08-11 21:35:06 +00:00
Daniel Dunbar 8d480594cf Change CodeGenModule to only create ObjC runtime for ObjC files
- Changed CodeGenModule::getObjCRuntime to return reference.
 - Added CodeGenModule::hasObjCRuntime predicate.

llvm-svn: 54645
2008-08-11 18:12:00 +00:00
Daniel Dunbar fb3043d627 Add -fexceptions to Driver
- Maps to LangOptions.Exceptions
 - Currently always off, should autoselect based on language.

Update CodeGen to set unwind attribute on functions definitions based
       on LangOptions.Exceptions.
 - Still need to set attributes appropriately on calls.

llvm-svn: 54643
2008-08-11 17:36:14 +00:00
Daniel Dunbar 56fdb6ae69 More #include cleaning
- Kill unnecessary #includes in .cpp files. This is an automatic
   sweep so some things removed are actually used, but happen to be
   included by a previous header. I tried to get rid of the obvious
   examples and this was the easiest way to trim the #includes in one
   fell swoop.
 - We now return to regularly scheduled development.

llvm-svn: 54632
2008-08-11 06:23:49 +00:00
Daniel Dunbar 6e8aa537f8 More #include cleaning
- 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
2008-08-11 05:35:13 +00:00
Daniel Dunbar 303e2c2f1f Add dummy Mac Objective-C runtime interface.
- Not currently accessible and completely non-functional.

llvm-svn: 54624
2008-08-11 02:45:11 +00:00
Daniel Dunbar 6dfdf8c97a Back out r54608 (inline string literals were getting an extra '\0')
temporarily, I assumed GetAddrForConstantString literal was being
  used consistently but it doesn't look like it is.

Factored out a CodeGenModule::getStringForStringLiteral which handles
  extracting a std::string for the bytes of a StringLiteral, padded to
  match the type.

Update EmitLValue to use getStringForStringLiteral, this was
  previously not padding strings correctly. Good thing we only emit
  strings in 4 different places!

llvm-svn: 54621
2008-08-10 20:25:57 +00:00
Daniel Dunbar 9a8d07321a Bug fix, inline string literals were getting an extra '\0'.
llvm-svn: 54608
2008-08-10 06:27:44 +00:00
Daniel Dunbar ffc29be83f Implement GNU asm-label extension support in CodeGen. This fixes
scimark2 on Darwin.

 - Added Sema support for asm-label on variables, which I forgot before.

 - Update CodeGen to use GlobalDeclMap to determine if static Decls
   require emission (instead of LLVM module name lookup). Important
   since the Decl name and the LLVM module name can differ.

 - <rdar://problem/6116729>

llvm-svn: 54388
2008-08-06 00:03:29 +00:00
Daniel Dunbar 829e988899 Change CodeGen of global decls to key off of the name (instead of
having multiple bindings from all the possible decls which
  conceptually map to the same global).

 - This eliminates CodeGen depending on the LLVM module for name
   lookup.

 - This also eliminates the need for ReplaceMapValuesWith (hurrah).

 - This handles lookups for FunctionDecls correctly in the presence of
   aliases, this was previously broken.

 - WIP: Can still clean up & unify variable and function emission.

llvm-svn: 54382
2008-08-05 23:31:02 +00:00
Ted Kremenek 2c674f6dbb Refactored driver logic for CodeGen into LLVMCodeGenWriter. This ASTConsumer layers on top of LLVMCodeGen (another existing ASTConsumer) to emit bitcode files to disk. This layering takes this logic out of clang.cpp and puts it directly into the ASTConsumer interface. The benefit is that now --emit-llvm works with both serialized ASTs and regular source files.
llvm-svn: 54364
2008-08-05 18:50:11 +00:00
Chris Lattner 7adf076088 Finally fix PR2189. This makes a fairly invasive but important change to
move getAsArrayType into ASTContext instead of being a method on type.
This is required because getAsArrayType(const AT), where AT is a typedef
for "int[10]" needs to return ArrayType(const int, 10).

Fixing this greatly simplifies getArrayDecayedType, which is a good sign.

llvm-svn: 54317
2008-08-04 07:31:14 +00:00
Daniel Dunbar 74aa7e1eae Support constructor and destructor attributes in CodeGen
- There is an miscompilation issue remaining due to a poor
   interaction between the delayed emission of static functions and
   the emission of constructors, but that already existed prior to
   this change.

llvm-svn: 54258
2008-08-01 00:01:51 +00:00
Daniel Dunbar e49df9b58f Change CodeGenModule GlobalDeclMap to directly reference globals
instead of mapping the decl to a bitcast of the global to the correct
type.
 
 - GetAddrOf{Function,GlobalVar} introduce the bitcast on every use now.

 - This solves a problem where a dangling pointer could be introduced
   by the RAUW done when replacing a forward or tentative
   definition. See testcase for more details.

 - Fixes <rdar://problem/6108358>

llvm-svn: 54211
2008-07-30 16:32:24 +00:00
Daniel Dunbar 9c426524f8 Rework codegen emission of globals
- No (intended) functionality change.

 - Primary purpose is to clearly separate (lazy) construction of
   globals that are a forward declaration or tentative definition from
   those that are the final definition.

 - Lazy construction is now encapsulated in
   GetAddrOf{Function,GlobalVar} while final definitions are
   constructed in EmitGlobal{Function,Var}Definition.
 
 - External interface for dealing with globals is now limited to
   EmitGlobal and GetAddrOf{Function,GlobalVar}.

 - Also updated helper functions dealing with statics, annotations,
   and ctors to be private.

llvm-svn: 54179
2008-07-29 23:18:29 +00:00
Daniel Dunbar 837fd272f8 Fix codegen of chained declarations
- Killed useless CodeGenModule::EmitGlobalVarDeclarator, instead just
   recurse on any ScopedDecl.
 - Fix for <rdar://problem/6093838>

llvm-svn: 54162
2008-07-29 17:47:36 +00:00
Chris Lattner 390d39ac7e move two more lists of protocols over to use ObjCList<ObjCProtocolDecl>,
simplifying code along the way and fixing a problem and memory leak or two.

llvm-svn: 53876
2008-07-21 21:32:27 +00:00
Chris Lattner d004505b74 introduce a new ObjCList templated class and start moving
various objc lists over to it.  First up, the protocol list 
on ObjCInterfaceDecl.

llvm-svn: 53856
2008-07-21 18:19:38 +00:00
Chris Lattner bf231a61fd refactor more objc codegen interfaces to pass around selectors so
we don't push strings into LLVM IR and then have to read them back out.

llvm-svn: 52765
2008-06-26 05:08:00 +00:00
Chris Lattner 882034dd99 indenting and other minor things.
llvm-svn: 52764
2008-06-26 04:52:29 +00:00
Chris Lattner 87ab27d42f give CreateObjCRuntime a full CGM so it can get whatever state it needs,
instead of passing in just a couple random things it currently 
happens to use.

llvm-svn: 52756
2008-06-26 04:19:03 +00:00
Nuno Lopes b6f7953818 implement the alias attirbute (in both Sema and Codegen)
llvm-svn: 52092
2008-06-08 15:45:52 +00:00
Sanjiv Gupta 158143ad54 Emit debug information for global and static variables when -g is specified.
llvm-svn: 51993
2008-06-05 08:59:10 +00:00
Eli Friedman 2425cd8158 For setting attributes, don't assume there are ParamVarDecls available,
because trying to access non-existent ParamVarDecls can crash. 
Testcase from the original source for PR2414.

llvm-svn: 51960
2008-06-04 19:41:28 +00:00
Eli Friedman f6b091f73a First cut at setting attributes for functions and calls; this puts us
much closer to passing the gcc struct layout tests.

It might be possible to refactor this a bit, but I'm not sure there's 
actually enough common code for that to be useful.

To get the calling convention completely correct, a bit of 
platform-specific code is necessary even for x86-Linux. On x86-Linux, the
alignment of function parameters is extremely strange; as far as I can tell,
it's always 4 except for SSE vectors or structs containing SSE vectors.  I'm 
continuing to investigate this.

llvm-svn: 51839
2008-06-01 15:54:49 +00:00
Anton Korobeynikov 1200aca763 Support for code generation of Objective-C top-level language constructs.
Implemented by David Chisnall!

llvm-svn: 51835
2008-06-01 14:13:53 +00:00