Commit Graph

421 Commits

Author SHA1 Message Date
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Joe Groff
398cbba5be Rename SILConstant to SILDeclRef.
"SILConstant" doesn't really describe its role in SIL anymore, which is to provide a reference to a Swift declaration in a SIL instruction, such as a method or nominal type field.

Swift SVN r6559
2013-07-24 21:21:31 +00:00
John McCall
69b64a09ce More canonical type preserving.
Swift SVN r6377
2013-07-19 07:08:38 +00:00
John McCall
4b4e7d0833 Eliminate SIL and IR-gen's TypeVisitor specializations in
favor of a new AST-level one, and exploit it.

Swift SVN r6376
2013-07-19 07:08:34 +00:00
John McCall
16063866ed Preserve type canonicality with isa/cast/dyn_cast.
Swift SVN r6362
2013-07-18 23:28:53 +00:00
John McCall
075539b0f5 Generate runtime functions from an xmacro database.
Swift SVN r6266
2013-07-15 18:33:45 +00:00
Joe Groff
f678700dce IRGen: Implement class-bounded existential containers.
Provide TypeInfo for class-bounded existentials, which represents them as an explosion comprising one witness table per subscribed protocol and then the class instance pointer as an ObjC-refcounted pointer. Provide lowerings for the SIL instructions that manipulate class-bounded existentials (except for existential-to-existential erasures, which aren't critical to getting basic operations working and will need some abstraction remapping to deal with class-bounded-to-opaque upcasts aside from the representation change).

Swift SVN r5579
2013-06-14 14:52:47 +00:00
Joe Groff
66d4e683da Disable ObjC property thunks for function-type properties.
We can't autorelease a Swift function value to conform to the ObjC convention, we don't urgently need to expose function properties to ObjC, and the ultimate right thing to do is to convert between a Swift function value and an ObjC block value, so for now, we can just drop the property thunks.

Swift SVN r5373
2013-05-29 16:27:11 +00:00
Joe Groff
72e53052dc IRGen: Build method/property encodings based on bridged type.
This gives [objc] properties or property-ish methods of String type encodings as their NSString counterparts in the ObjC world.

Swift SVN r5365
2013-05-28 21:05:14 +00:00
Joe Groff
5e2779b51e SIL: Uncurry function types within the Swift type system.
Remove uncurry level as a property of SILType/SILFunctionTypeInfo. During SIL type lowering, map a (Type, UncurryLevel) pair to a Swift CanType with the uncurried arguments as a Swift tuple. For example, T -> (U, V) -> W at uncurry level 1 becomes ((U, V), T) -> W--in reverse order to match the low-level calling convention. Update SILGen and IRGen all over the place for this representation change.

SILFunctionTypeInfo is still used in the SILType representation, but it's no longer load-bearing. Everything remaining in it can be derived from a Swift type.

This is an ABI break. Be sure to rebuild clean!

Swift SVN r5296
2013-05-24 01:51:07 +00:00
Joe Groff
8993ed707e Split 'C' and 'ObjCMethod' calling conventions.
This cleans up some wishy-washy control flow that relied on the uncurryLevel of a type to distinguish ObjC methods from freestanding C functions. While we're here, clean up all the places we use ad-hoc comparison logic on the AbstractCC enum to use switches that properly cover the enum.

Swift SVN r5251
2013-05-21 15:19:37 +00:00
Joe Groff
b7f16016c1 IRGen: Remove calling convention special-case in GenObjC call emission.
The isObjC bit on SILConstant now gets SILGen to consistently give ObjC class_method dispatches the right SILType.

Swift SVN r5208
2013-05-17 18:12:30 +00:00
Joe Groff
a8a7e16cf9 IRGen: requiresExternal{ByvalArgument,IndirectResult} can use SILType now.
These functions are now used in places where we're emitting ObjC calls and have a SILType.

Swift SVN r5187
2013-05-16 21:44:43 +00:00
Joe Groff
ea85e8ff5f IRGen: Remove ObjCMethodSignature.
Most of what it does is now handled by getFunctionType.

Swift SVN r5186
2013-05-16 21:35:38 +00:00
Joe Groff
8303addde0 IRGen: Get ObjC thunks from SIL.
Use the SIL-generated ObjC thunk symbols instead of generating them in IRGen. Kill all the now-dead IRGen OwnershipConventions stuff. Teach IRGenSILFunction how to emit a C-calling-convention function, and getFunctionType how to map a C-calling-convention function type. Fix a bug in SILGen where ObjC thunks for methods and properties from extensions weren't getting emitted.

Swift SVN r5180
2013-05-16 19:03:37 +00:00
Joe Groff
667ef5d651 IRGen: Look up metatypes and class methods using SIL types.
Swift SVN r5150
2013-05-10 21:20:11 +00:00
Joe Groff
197c3e6d02 IRGen: Strip unneeded parameters from IRGenFunction constructor.
Swift SVN r5146
2013-05-10 18:18:14 +00:00
Joe Groff
223d0251bd IRGen: Add getFragileTypeInfo and getFunctionType for SIL types.
Add overloads of getFragileTypeInfo and getFunctionType that take a SILType instead of a Swift CanType, and use them where it's easy to do so. Right now they just forward to the CanType versions, but we'll want to do SILType-specific type conversion soon. Clean up some IRGenSILFunction interfaces now that SILFunction carries most of the information IRGen needs intrinsically. No functionality change.

Swift SVN r5141
2013-05-10 16:28:25 +00:00
John McCall
d8cdb0160f Switch IR-generation to generally traffic in alignment
masks rather than raw alignments.

Swift SVN r5136
2013-05-10 06:16:28 +00:00
John McCall
1fec73a8d2 Untested support for tuples with generically-sized elements.
Swift SVN r4926
2013-04-26 21:33:24 +00:00
Joe Groff
2b99cb98fc Fix crash calling a super.method on an ObjC class.
Swift SVN r4859
2013-04-22 01:41:00 +00:00
Chris Lattner
d420672353 use early exits to reduce indentation, no functionality change.
Swift SVN r4853
2013-04-21 17:02:26 +00:00
Chris Lattner
43bd01689b Tidy up IGF a bit, changing some ivars to be arguments to emitProlog, removing
dead methods, and moving emitInvoke to CallInvocation.

An interesting semantic change of this is that we're now calling getResultType
on the function type every time IGF is constructed, which exposed some latent
bugs.  Specifically two places in GenObjC are trying to extra curry level two 
from function types like "SomeObject -> (value : SomeObject) -> ()" which
doesn't make sense.  I switched them to get curry level 1, but this definitely
needs some close review.



Swift SVN r4852
2013-04-21 17:00:33 +00:00
Chris Lattner
5664431c9a remove Cleanup.h and references to the Cleanup class, along with
some dead logic in IRGenFunction.



Swift SVN r4847
2013-04-21 06:36:22 +00:00
Chris Lattner
85663f6df2 simplify Explosion by eliminating (now) copies of existing methods.
This removes addUnmanaged, ignoreAndDestroy, ignoreUnmanaged, claimUnmanagedNext,
claimUnmanaged, forwardNext, and forward


Swift SVN r4846
2013-04-21 06:29:50 +00:00
Chris Lattner
0be7bbdddf remove ManagedValue.
Swift SVN r4843
2013-04-21 05:56:02 +00:00
Chris Lattner
e8686c9560 remove Cleanups from IGF, simplify Initialization a bit.
Swift SVN r4841
2013-04-21 05:28:04 +00:00
Chris Lattner
e3d6a489af remove the Cleanup subclasses.
Swift SVN r4839
2013-04-21 05:06:52 +00:00
Joe Groff
e5068920bb SILGen: Handle ObjC ownership conventions of calls
Port IRGen's calculation of consumed arguments and return value semantics to SILGen, and use it to handle the ownership semantics of calls. Refactor the handling of properties and other clients of emitApply so they can properly hand ownership semantics down to it.

This should let all the moribund cleanup management code in IRGen die. Unfortunately Scope appears to be tied into scoped calculated metadata caching so it's not quite ready to die.

Swift SVN r4834
2013-04-20 23:13:42 +00:00
Chris Lattner
6a6601ec04 remove the Expr version of prepareObjCMethodCall and the code that is keeps alive.
Swift SVN r4807
2013-04-18 18:05:45 +00:00
John McCall
38b34b7307 Pass #1 at localizing assumptions about fixed layout and
handling non-fixed layouts.

This uncovered a bug where we weren't rounding up the header
size to the element alignment when allocating an array of archetypes.

Writing up a detailed test case for *that* revealed that we were
never initializing the length field of heap arrays.  Fixing that
caused a bunch of tests to crash trying to release stuff.  So...
I've left this in a workaround state right now because I have to
catch a plane.

Swift SVN r4804
2013-04-18 07:58:21 +00:00
Chris Lattner
a7748f61ae remove emitRValue, which is dead, at least dynamically according to our testsuite.
Swift SVN r4799
2013-04-18 05:33:40 +00:00
Joe Groff
c724d1f6a1 IRGen: Emit SIL class metatypes as Swift or ObjC.
Look at the uses of a SIL MetatypeInst to determine whether it is being used as a Swift metatype and/or ObjC class and emit the needed values. This avoids a costly trip wrapping and unwrapping ObjC Classes in a Swift metatype when they're just used to invoke class methods.

Swift SVN r4562
2013-04-01 22:10:12 +00:00
Joe Groff
0034475514 IRGen: Map SIL metatypes back to ObjC classes.
For ObjC class method calls, map a metatype value back to an objc Class before emitting the ObjC call. This is dumb because we already map the original Class to a Swift metatype when we map the metatype instruction, but it gets ObjC class method calls working. Now that SIL keeps use chains, we could be easily smarter about this.

Swift SVN r4558
2013-03-30 23:40:35 +00:00
Joe Groff
02de4d8007 IRGen: Handle ownership conventions from SIL apply
Introduce cleanups onto arguments to SIL apply instructions, and let CallEmission consume the cleanups corresponding to the values consumed by the called function, so that releases will be emitted as needed to make a foreign call conform to Swift ownership conventions.

Swift SVN r4556
2013-03-30 22:48:16 +00:00
Joe Groff
0e4c0a568d IRGen: Start adding ObjC call support through SIL.
Represent class_method and super_method SIL values using an ObjCMethod variant of LoweredValue that holds the necessary information to emit an objc_msgSend* call when the value is apply-ed. You can't really use ObjC objects from SIL IRGen yet because SILGen doesn't yet visit external definitions from the Clang importer.

Swift SVN r4550
2013-03-30 00:06:41 +00:00
Joe Groff
10438902dd Remove GetMetatypeExpr.
Now that we don't allow static methods to be invoked from instances we no longer need an AST node to represent an implicit instance-to-metatype conversion. MetatypeExpr encodes the explicit '.metatype' operation.

Swift SVN r4472
2013-03-22 00:28:21 +00:00
Joe Groff
0132f279a7 IRGen: ObjC super dispatch for super.constructor.
Implement super.constructor for ObjC superclasses by dispatching the superclass init message with objc_msgSendSuper2. Fixes <rdar://problem/13107128>.

Swift SVN r4288
2013-03-05 21:39:42 +00:00
Joe Groff
f78b090829 IRGen: Fix for llvm::Attributes API change.
CallInst::addAttribute takes an AttrKind now instead of an Attribute.

Swift SVN r4264
2013-03-02 17:17:41 +00:00
Joe Groff
470ad60d60 IRGen: Emit properties for ivars of ObjC classes.
If a class has ObjC interop, synthesize property accessors for its ivars so that things like IBOutlets and bindings work correctly.

Swift SVN r4240
2013-02-28 20:24:43 +00:00
Joe Groff
54bf40ee49 IRGen: Fix crashing objc_subclass test.
Swift SVN r4208
2013-02-26 23:05:14 +00:00
Joe Groff
be3f4ae1ec IRGen: Emit ObjC methods for properties.
Emit getter and setter ObjC methods and selectors for Swift properties declared in ObjC classes or extensions. If the type of the property is an ObjC class, also emit special-cased ObjC formal property metadata for the property as if it were declared @property (nonatomic, {readonly,strong}) in ObjC.

Swift SVN r4207
2013-02-26 22:57:45 +00:00
Joe Groff
4bac3168c9 IRGen: Retain value type elts in objc stub.
We were just shuttling value types from the objc entry point to the native one at +0 without bringing them up to +1 like the Swift native entry point expects, so things like Slices or closures that got passed through an ObjC interface were getting overfreed.

Swift SVN r4160
2013-02-23 01:22:23 +00:00
Joe Groff
827cbfe0b0 IRGen: Dynamic init for repl ObjC extensions.
When running in immediate mode, generate a global initializer when an extension is defined for an ObjC class that uses the class_replaceMethod runtime function to dynamically add the extension methods to the ObjC class.

Swift SVN r4153
2013-02-22 21:08:39 +00:00
Joe Groff
a9f747ec1f IRGen: Emit categories for ObjC class extensions.
Emit ObjC stubs and categories for methods defined in extensions of ObjC-compatible classes. This makes extensions of ObjC classes available to ObjC in statically compiled code. For immediate-mode code we'll still need to dynamically register extension methods using the ObjC runtime.

Swift SVN r4149
2013-02-22 05:40:09 +00:00
Joe Groff
4792c60d2d IRGen: Implement super method calls.
For Objective-C super calls, build an objc_super struct value containing the receiver and class/metaclass object and pass it to objc_msgSendSuper2. For Swift super calls, emit a direct call to the super implementation.

Swift SVN r4023
2013-02-13 02:41:20 +00:00
Joe Groff
45e5909911 IRGen: Export objc methods w/ NSRect return/args.
Fix up the thunk generator so it knows how to turn byval C arguments back into Swift explosions, so that methods that take NSRects as arguments or give NSRect as their return value can be exported as objc methods.

Swift SVN r4010
2013-02-10 17:24:27 +00:00
Joe Groff
9c022d5d65 IRGen: Fudge passing large ObjC structs as byvals.
Push LLVM attribute generation from expandAbstractCC into getFunctionSignature and CallEmission so that they can generate sret and/or byval attributes per-argument according to the calling convention. Copy our bogus rule for emitting sret returns (more than three elements in the explosion) and reuse it to pass large struct values as byvals rather than as explosions. This should be good enough to get both 'NSRect' and
'NSRange', 'NSSize' etc. to pass correctly to ObjC methods. Next step is to set the AbstractCC correctly for imported func decls so that standalone C functions follow the same bogus rule.

Swift SVN r3993
2013-02-08 21:50:08 +00:00
Jordan Rose
b44f38ef44 Emit ObjC method types for getters that return (class) objects.
This is needed for KVC.

Swift SVN r3987
2013-02-08 00:19:53 +00:00
Jordan Rose
7654aad18b llvm::Twine can only be used as a temporary.
Fixes r3839.

Swift SVN r3842
2013-01-23 19:41:12 +00:00