Commit Graph

627 Commits

Author SHA1 Message Date
Joe Groff
56a4220eeb IRGen: Use superclass repr and refcount for superclass archetypes.
If an archetype has a superclass bound, we can assume the superclass's
retain semantics for the type. We can also use the superclass's storage pointer type to cut down on some bitcast IR noise when calling superclass methods on the archetype value.

Swift SVN r5642
2013-06-18 03:42:27 +00:00
Joe Groff
4ff8cd27dd IRGen: Abstract out an "unknown refcounted" concept.
In the implementation of class-bounded archetypes and existentials, instead of referring to ObjC pointer types and retain/release operations directly, use an 'UnknownRefCountedPtrTy' and 'emitUnknownRetain/Release' functions.

Swift SVN r5619
2013-06-17 18:31:49 +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
3d2cd72330 IRGen: Push SILTypes into emitClassAllocation.
Swift SVN r5188
2013-05-16 21:52:28 +00:00
Joe Groff
193e7c3b13 IRGen: Kill CanType version of projectPhysicalClassMemberAddress.
ObjC thunking was the last use of it.

Swift SVN r5181
2013-05-16 19:06:52 +00:00
Joe Groff
b439e49625 IRGen: Use SILTypes in field projection functions.
Swift SVN r5154
2013-05-10 23:17:08 +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
Joe Groff
2be26b31a5 Make the deallocating destructor actually deallocate.
Emit the deallocObject runtime call inside the deallocating destructor for a heap object, instead of inside swift_release. This will allow for heap objects with known size to directly call fast deallocator entry points and potentially custom deallocators in the future.

Swift SVN r5027
2013-05-02 20:37:12 +00:00
Joe Groff
24d44b051e Have destroying destructors return 'this' back to the deallocator.
This saves the deallocating destructor having to keep 'this' alive across the destructor call.

Swift SVN r5026
2013-05-02 16:36:50 +00:00
Joe Groff
ac1a7b3d0a IRGen: Walk local decls independent of SILFunctions
Find function bodies and emit their local type decls using the AST instead of relying on SILConstants to point the way back to the function bodies.

Swift SVN r4916
2013-04-26 00:32:22 +00:00
Joe Groff
8bdccdd418 IRGen: Clear up dtor special cases in SIL-IRGen.
Change the destroying destructor entry point ABI to take 'this' as the appropriate type instead of as %swift.refcounted. Emit the deallocating destructor in IRGen when we see the ClassDecl, not when we see the SILFunction for the destructor. This frees us from having to worry about whether a SILFunction came from a destructor decl. We won't be able to reconstruct that once SILFunctions are pre-mangled.

While we're here, repaint some bikesheds so it's clearer that SIL and SILGen work with the destroying destructor.

Swift SVN r4908
2013-04-25 19:50:58 +00:00
John McCall
65fc2b74f8 Basics of dynamic struct layout.
Swift SVN r4902
2013-04-25 01:39:58 +00:00
John McCall
a23349caa5 Add IGF::emitByteOffsetGEP to conveniently create a pointer
at a dynamic offset.

Swift SVN r4901
2013-04-25 01:39:52 +00:00
John McCall
80a82b6849 Abstract ElementLayout to work with non-fixed layouts.
Swift SVN r4899
2013-04-25 01:39:40 +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
9ae0cf3bee inline Initialization::emitLocalAllocation into each of its callers and
eliminate the Initialization class and GenInit.h.  GenInit.cpp will stay
around, as it has some other random stuff in it.


Swift SVN r4845
2013-04-21 06:13:59 +00:00
Chris Lattner
e3d6a489af remove the Cleanup subclasses.
Swift SVN r4839
2013-04-21 05:06:52 +00:00
Chris Lattner
abee79b26e remove some Expr stuff.
Swift SVN r4810
2013-04-18 22:32:37 +00:00
Chris Lattner
1abf1d0ebc remove RValueEmitter and some implementation logic for it, as well as
FullExpr.  Scope is kept alive by one dangling thread, rdar://13681467


Swift SVN r4798
2013-04-18 05:24:50 +00:00
Chris Lattner
47e508c24d remove LValue, PathComponent, and LValue.h as a whole.
Swift SVN r4792
2013-04-18 04:50:03 +00:00
Chris Lattner
20a712a2fc remove emitAddressLValue and PhysicalPathComponent.
Swift SVN r4791
2013-04-18 04:46:41 +00:00
Joe Groff
5d66f94922 IRGen: Sever projectPhysicalClassMemberAddress from LValue.
Swift SVN r4785
2013-04-17 23:18:59 +00:00
Joe Groff
d0266e35c7 SILGen: Don't emit calls to objc super destructors
ObjC classes don't have a deallocating destructor, so we can't call up to it in a class derived from an ObjC class. Hack SILGen not to emit a call to the superclass destructor of a class inherited from an ObjC class. This is the wrong thing, but it looks like destructors don't get hooked up to ObjC dealloc methods anyway yet, so what the Swift destructor of an ObjC-derived class does is moot right now. This lets us remove the guards from IRGen that prevented ObjC destructors from being emitted.

Swift SVN r4784
2013-04-17 22:52:59 +00:00
Chris Lattner
477bdbd08a remove emitConstructorBody and GenConstructor.cpp now that Joe implemented
implicit struct constructors in r4776.


Swift SVN r4782
2013-04-17 22:38:38 +00:00
John McCall
8fe4246833 Hide StorageSize/Alignment behind accessors in preparation for moving
them to a subclass.

Swift SVN r4779
2013-04-17 21:55:41 +00:00
Joe Groff
b9bb84c58e SILGen: Emit implicit constructors.
Teach SILGen how to emit the implicit elementwise constructor for structs and the implicit default constructor for classes, and eliminate the now dead IRGen code for them. Add a StructInst SIL instruction to represent constructing a loadable struct value from elements, analogous to TupleInst for tuples.

Swift SVN r4778
2013-04-17 20:51:26 +00:00
Chris Lattner
ec6d194c5d remove the old IRGen path for statements.
Swift SVN r4767
2013-04-17 04:48:26 +00:00
Chris Lattner
a217fe69aa remove the old codepaths for emiting builtin and known calls.
SILGen needs to learn about "known" calls to remain competitive (13670729)


Swift SVN r4766
2013-04-17 04:35:04 +00:00
Chris Lattner
22321ffe7f next pass deleting now-dead code. Default ctors are keeping a bunch of
stuff alive (tracked by rdar://13670607)


Swift SVN r4763
2013-04-17 04:01:37 +00:00
Chris Lattner
ea4eca3a95 now that SILGen is on all the time, start removing dead code.
Swift SVN r4762
2013-04-17 03:49:38 +00:00
Joe Groff
6df319ab8e Update PointerIntPairs to use enum class members.
LLVM r179073 fixed PointerIntPair to work with an enum class as the IntType member, so we can kill some boilerplate in a few type implementations that were explicitly casting to unsigned to work around PointerIntPair's limitations.

Swift SVN r4652
2013-04-10 15:30:41 +00:00
Joe Groff
aeeda4ee12 Parser: Parse operator decls.
At the top level, if 'operator' is followed by 'infix', 'prefix', or 'postfix', consider it a contextual keyword, and parse an operator decl following it that looks like:

  operator {infix|postfix|prefix} <+> {
    attributes…
  }

Prefix and postfix operator decls currently admit no attributes. Infix operators have 'associativity {left|right|none}' and 'precedence <int>' attributes.

This patch implements parsing for operator declarations but does not yet attach the declared attributes to func decls for the operators.

Swift SVN r4596
2013-04-03 23:30:50 +00:00
Joe Groff
a1eaeb751f IRGen: Disable SIL destructors for ObjC classes.
They don't do the right thing yet.

Swift SVN r4554
2013-03-30 19:25:45 +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
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
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
8392d212ec IRGen: Update ObjC mangling not to depend on attr.
Oops, missed a spot where it was referring to 'DeclAttributes::ObjC' directly instead of going through the accessor. This should make removing [objc] from the examples work.

Swift SVN r4100
2013-02-20 02:16:17 +00:00
Joe Groff
74589d788e Make ObjC-ness implicit to ObjC-inherited classes.
Add 'isObjC' as a property of ValueDecl, and set it during type checking if a class is either explicitly annotated with an [objc] attribute or inherits from an isObjC class, or if a func is a method of an isObjC class. Tweak the ClangImporter and other places that summon magic ValueDecl nodes to set up the decls they synthesize as isObjC. Replace logic in typechecking and IRGen that branched on the 'isObjC' attribute to now branch on the 'isObjC' property of ValueDecls.

Swift SVN r4078
2013-02-19 02:11:09 +00:00
Jordan Rose
b68b1b27f9 Emit [ibaction] methods as if they were [objc].
Conversely, /call/ [ibaction] methods as Swift methods, at least for now,
and ignore [iboutlet] altogether.

Swift SVN r4018
2013-02-12 01:31:50 +00:00
Doug Gregor
a9a90fd56a Track the Clang macros that were used to generate Swift constants.
Swift SVN r3960
2013-02-06 00:57:03 +00:00
Joe Groff
be09b16f93 Sema: Allow returns from constructors/destructors.
In the StmtChecker, consider a ConstructorDecl or DestructorDecl context to be a function context that returns (). In IRGen for constructors and destructors, set up proper return blocks so that 'return' does the right thing, and in constructors, pretend that the body has no return value even though the underlying constructor mechanism totally returns a value. Fixes <rdar://problem/12950817>.

Swift SVN r3915
2013-01-31 22:30:12 +00:00
Joe Groff
cf0d186bf8 IRGen: Undo r3904.
It fixed a symptom, not a problem. The actual problem is fixed in r3905.

Swift SVN r3908
2013-01-30 21:47:20 +00:00
Joe Groff
ac2d549b08 IRGen: Forward wtables from alloc to init ctor.
We can't naively assume that the allocating constructor's metatype is the very last argument. If there are protocol constraints on the class's generic parameters, those witness tables will get passed in afterward. Add some hacky logic to emitClassAllocatingConstructor to gather witness tables and forward them to the initializing constructor. The added test cases are broken because of <rdar://problem/12965934>.

Swift SVN r3906
2013-01-30 20:52:02 +00:00
Joe Groff
8b8396fa58 IRGen: Fix logic inversion in building objc ivars.
Swift SVN r3891
2013-01-29 01:59:31 +00:00
Joe Groff
0bf66dae4b IRGen: Separate allocating and initializing ctors.
Emit separate entry points for the allocating and initializing constructors. 'super.constructor' now works for the small subset of cases for which I've implemented sema support.

Swift SVN r3864
2013-01-25 17:50:55 +00:00
Joe Groff
7a7e14a9c5 IRGen: Emit SIL destructors.
Emit the SIL destructor as a destroying destructor, then emit a deallocating destructor shim that calls into it and then returns the heap size. (The actual deallocation still happens in swift_release--I talked to John about that and I'll fix it later.) This gets the broken SIL/IRGen class tests passing again.

Swift SVN r3838
2013-01-22 23:36:37 +00:00
Joe Groff
5852448152 IRGen: Generate SIL ctor and property decls.
Remove the filter that only irgenned SIL functions for FuncDecls so that we emit functions for all SIL decls, and disable the old paths for properties, constructors, and destructors when a SIL module is present. Unfortunately this breaks class constructors because SIL and IRGen don't agree on how initializing constructors should work. I need to sync with John to figure out how to fix that.

Swift SVN r3827
2013-01-22 02:45:27 +00:00
Joe Groff
ae396e3905 IRGen: SIL AllocRefInst.
Implement AllocRefInst so that SIL-emitted constructors can be irgenned. Factor the code for allocating a class instance from GenClass's emitClassConstructor function.

Swift SVN r3826
2013-01-22 02:45:25 +00:00