Commit Graph

815 Commits

Author SHA1 Message Date
Joe Groff
ee9ca634a5 SIL: Add linkage and calling conv to SILFunctions.
Move AbstractCC into SILType and make it an attribute of SILTypes for functions. Add a ConvertCCInst to represent calling convention conversions. Give SILFunctions a linkage attribute. Add logic to SILGen to calculate these attributes for SILConstants based on their attached decls.

IRGen doesn't use these new attributes yet. I'll hook that up when I move mangling over.

Swift SVN r4886
2013-04-24 18:09:44 +00:00
Joe Groff
bcb49ce450 SIL: Key functions directly without SILConstant.
Replace 'constant_ref' with 'function_ref', which references a SILFunction directly, and 'global_addr', which references a global variable VarDecl. Get rid of the SILConstant-to-SILFunction mapping in SILModule and replace it with an ilist of SILFunctions. Allow SILFunctions to be 'external' by not having any blocks in their body. 

For now, SILFunctions still carry around their SILConstant "name", because name mangling and IRGen still rely on access to the original decl in order to recover IRGen information, which unfortunately leaves IRGen's CodeRefs in a gross, awkward intermediate state. Lifting mangling, AbstractCC, and other linkage attributes to SIL should clear up this up.

Swift SVN r4865
2013-04-23 23:29:04 +00:00
Joe Groff
b761bad088 SILGen: Lower some builtins to SIL.
The value semantics primitives load/move/assign/init/destroy lower trivially to SIL value semantics operators, and the bridge casting operations introduce r/r semantics that should be visible to the ARC optimizer, so move the lowering for these builtins up to SILGen. Add a BUILTIN_SIL_OPERATION metaprogramming macro to Builtins.def, and add a facility similar to IRGen's former SpecializedCallEmission so we can handle builtin call emissions as special cases.

This also sets up the framework for eventually reintroducing special-case handling of known functions like &&, ||, Bool.getLogicValue, Int.convertFromIntegerLiteral, etc. in SILGen.

Swift SVN r4862
2013-04-22 23:05:18 +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
2b6902b232 eliminate the "manage" operation on TypeInfo, which is now a (complicated!) noop.
Swift SVN r4850
2013-04-21 16:27:43 +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
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
d523932d85 remove InitializedObject.
Swift SVN r4844
2013-04-21 06:05:01 +00:00
Chris Lattner
0be7bbdddf remove ManagedValue.
Swift SVN r4843
2013-04-21 05:56:02 +00:00
Chris Lattner
510042f939 removed the registration logic from Initialization and Depth from Scope.
Swift SVN r4842
2013-04-21 05:39:35 +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
6e50329da3 remove the cleanups list from CallEmission and ManagedValue, along with the machinery for adding Cleanups.
Swift SVN r4840
2013-04-21 05:16:00 +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
519fa983ac remove some more little bits of stuff. Move the last
method remaining in GenLValue.cpp to GenType.cpp where
it belongs, and zap GenLValue.cpp


Swift SVN r4826
2013-04-19 04:19:18 +00:00
Chris Lattner
13b2af4f54 remove getAddrForParameter and some other dead logic.
Swift SVN r4824
2013-04-19 04:06:37 +00:00
Chris Lattner
a124da99eb remove the dead "Locals" map and supporting logic.
Swift SVN r4823
2013-04-19 04:01:59 +00:00
Chris Lattner
abee79b26e remove some Expr stuff.
Swift SVN r4810
2013-04-18 22:32:37 +00:00
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