Commit Graph

797 Commits

Author SHA1 Message Date
Chris Lattner
6315bb233f remove a few random remnants.
Swift SVN r4808
2013-04-18 22:25:20 +00:00
Chris Lattner
fa168e15a9 remove emitRValueAsUnsubstituted and some related logic. Once I get this deep, it
seems that this is not a good idea, because it seems statically live from the SIL
SuperToArchetypeInst.  However, apparently nothing in the testsuite exercises
this code, so I'll need to discuss and a testcase to know how much logic needs
to be ressurrected from SVN.  rdar://13681541



Swift SVN r4800
2013-04-18 05:41:20 +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
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
a8ed1a187f remove CallSite and emitRValueForFunction
Swift SVN r4795
2013-04-18 05:09:38 +00:00
Chris Lattner
9459ee19e1 remove CalleeSource, SpecializedCallEmission, and derived classes.
Swift SVN r4794
2013-04-18 05:01:58 +00:00
Chris Lattner
03394a29ea remove prepareCall and some various array handling logic now handled by SILGen.
Swift SVN r4793
2013-04-18 04:57:27 +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
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
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
Chris Lattner
ade66c8b10 Remove the emitIgnored, emitLValue, and tryEmitAsAddress mechanics and
supporting logic.


Swift SVN r4770
2013-04-17 05:33:23 +00:00
Chris Lattner
0701489691 remove Condition.
Swift SVN r4768
2013-04-17 05:01:03 +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
e3e2c12c18 remove CurriedData, which is now dead.
Swift SVN r4764
2013-04-17 04:06:53 +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
Joe Groff
a90338bddb IRGen: Compile builtin calls from SIL.
When lowering SIL builtin ConstantRefs, just stash away the FuncDecl, and pass that decl on to a tweaked version of emitBuiltinCall when the constant is applied.

Swift SVN r4736
2013-04-15 21:04:36 +00:00
Joe Groff
eae9dd9214 IRGen: Fix PartialApply forwarder w/empty context.
Partial application forwarders don't take an ExtraData argument if the context layout is empty.

Swift SVN r4716
2013-04-12 21:04:49 +00:00
Joe Groff
18655c76a0 stdlib: Fix unary - for floats.
+0.0 - ±0.0 == ±0.0, so the correct definition of '-x' is '-0.0 - x'. However, this would be infinitely recursive, so I added an 'fneg' builtin that lowers directly to 'fsub -0.0, %x', and redefined the unary - operators for floats in terms of it.

Swift SVN r4634
2013-04-08 16:38:04 +00:00
Joe Groff
bb1f516555 IRGen: Lower SIL SpecializeInsts.
Collect the substitutions from SpecializeInsts and use them when emitting an ApplyInst to pass archetype parameters and to reexplode arguments at the right abstraction level for the generic callee. Unfortunately, ArchetypeTypeInfo::allocate() is broken, so alloc_box $T for an archetype type T doesn't yet work.

Swift SVN r4597
2013-04-04 22:39:35 +00:00
Chris Lattner
65cd2b2d25 rename swift::Function to swift::SILFunction to be more explicit.
Swift SVN r4590
2013-04-03 18:36:15 +00:00
Chris Lattner
05fbef4a86 give SIL Function a mangled name field, which is currently unused.
Swift SVN r4586
2013-04-03 16:49:10 +00:00
Joe Groff
ef6d33039e Mark fallthroughs with [[clang::fallthrough]].
Use [[clang::fallthrough]] instead of informal /*fallthrough*/ comments.

Swift SVN r4574
2013-04-02 20:51:38 +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
98f58675d5 IRGen: Handle function values from SIL correctly.
As values, IRGen expects functions to be i8*, so bitcast function values to i8* and bitcast them back when they're actually called.

Swift SVN r4471
2013-03-21 23:44:03 +00:00
Joe Groff
ac73865dd7 IRGen: Update lowering of SIL applications.
We no longer need the PartialCall hackery in IRGen to uncurry calls, because SILGen does it for us.

Swift SVN r4451
2013-03-20 00:02:49 +00:00
Joe Groff
8da204e3a2 IRGenSIL: Improve Explosion handling.
Instead of embedding Explosions in IRGenSIL's LoweredValues and trying to use them directly, store an unmanaged vector of llvm::Value*s, and create Explosions as needed. This allows Explosion APIs to behave normally (consuming values out of the explosion) without potentially messing up SIL value-to-LLVM value mappings.

Swift SVN r4309
2013-03-06 22:11:13 +00:00
Joe Groff
c9c0d7e2cc Sema: Set an 'isSuper' flag on ApplyExprs.
SIL or IRGen need to consider the 'super'-ness of an apply when determining its dispatch semantics.

Swift SVN r4307
2013-03-06 19:36:30 +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
f489f2a6fd Clean up AST representation of 'super'.
Replace the more specific Super*RefExpr nodes with a single SuperRefExpr that resolves members of 'this' relative to its superclass. Add an OtherConstructorDeclRefExpr for referring to a constructor as called from another constructor, and use it to represent resolved 'super.constructor' expressions. (It should also be able to represent delegating constructors for free, if we decide we want to add syntax for that.)

Swift SVN r4286
2013-03-05 02:13:49 +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
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
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
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
aa75885266 IRGen: Fix C funcs with big struct return and arg.
Should have tested both together. Oops.

Swift SVN r3998
2013-02-09 01:39:22 +00:00
Joe Groff
7ad898b404 IRGen: Fudged big struct support for C functions.
Extend the NSRect kludge to freestanding functions by giving imported decls the C calling convention.

Swift SVN r3995
2013-02-08 23:20:55 +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
13bbc9ac76 [objc] Fix closure->block conversion to handle closures with context.
Previously, we were relying on objc_retain to retain the closure, but
closure contexts aren't actually id-compatible. Now we use a C++ RAII
object for Swift to manage the closure context retain count.

In the process, Joe and I discovered that the closure context was being
passed to the conversion shim at +0; that has now been fixed to be +1.

Swift SVN r3948
2013-02-05 19:52:57 +00:00
Joe Groff
f946737515 IRGen: Collect/emit nested generic substitutions.
Alter CalleeSource and Callee to keep their own internal vector of substitutions and concatentate multiple SpecializationExpr substitutions. Update EmitPolymorphicArguments::emit to emit arguments out of the substitution list based on the generic parameters of the current function type instead of assuming that the substitution list and generic parameter list match up.

Swift SVN r3937
2013-02-02 22:00:15 +00:00
Joe Groff
ef1395dcc6 IRGen: Add an 'addressof' builtin.
Returns the address of an lvalue as a RawPointer. The address is only valid at statement scope for logical lvalues.

Swift SVN r3928
2013-02-01 21:13:57 +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
Jordan Rose
f1d7337880 Update for LLVM changes to make llvm::AttributeSet an opaque type.
Swift SVN r3909
2013-01-30 22:30:00 +00:00
Joe Groff
6cca08826a IRGen: Hack in calls to block converter funcs.
Add a mangling for 'block converter' functions and for [objc_block] function types. [objc_block] types also need their own HeapTypeInfo representation that uses ObjC retain/release. When we see a BridgeToBlockExpr, feed the function pointer and context from the Swift closure to the external conversion function and hope we get a block back.

Swift SVN r3899
2013-01-30 01:01:34 +00:00
Joe Groff
e822b95861 IRGen: Lowering for SIL UpcastInst.
Swift SVN r3873
2013-01-26 00:49:49 +00:00
Joe Groff
5dee8a5dbc Missed a spot.
Swift SVN r3866
2013-01-25 17:56:28 +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
f40dfce918 IRGen: Implement SuperConstructorRefCallExprs.
Recognize super.constructor calls in IRGen and generate them as calls to the superclass initializing constructor. Note that super.constructor code still won't execute just yet because classic IRGen doesn't generate initializing constructors.

Swift SVN r3859
2013-01-24 21:58:36 +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
19d65fede5 IRGen: Visit all SIL Functions in a SILModule.
Make the SIL visitor path a bit less hacky by more cleanly separating the AST walk to find types to codegen from the SIL module walk to find functions to codegen. This way, local functions and other such entry points from SIL actually get generated, and the closures test works.

Swift SVN r3820
2013-01-21 20:17:05 +00:00