Commit Graph

90 Commits

Author SHA1 Message Date
Nadav Rotem
1b650dcdf6 Add helper functions to SILBlock and SILFunction.
Swift SVN r18858
2014-06-13 06:10:07 +00:00
Andrew Trick
f58ebbc251 Add a global_init attribute to SILFunction.
The implied semantics are:
- side-effects can occur any time before the first invocation.
- all calls to the same global_init function have the same side-effects.
- any operation that may observe the initializer's side-effects must be
  preceded by a call to the initializer.

This is currently true if the function is an addressor that was lazily
generated from a global variable access. Note that the initialization
function itself does not need this attribute. It is private and only
called within the addressor.

Swift SVN r16683
2014-04-23 01:09:47 +00:00
Michael Gottesman
0bc4f9c936 Call SILFunction destructor when we cleanup functions so that if the function contains a function_ref, the function referenced by the function_ref has its refcount properly decrement.
Otherwise a function_ref which was supposed to be deallocated would keep
functions alive.

rdar://16287331

Swift SVN r16192
2014-04-11 01:44:38 +00:00
Joe Groff
0c0d30d5eb SIL: Make ContextGenericParams a constructor parameter of SILFunction.
Edge SILFunction one step closer to independence from SILFunctionType context by taking the generic param list as a separate constructor parameter, and serializing those params alongside the function record. For now we still pass in the context params from the SILFunctionType in most cases, because the logic for finding the generic params tends to be entangled in type lowering, but this pushes the problem up a step.

Thanks Jordan for helping work out the serialization changes needed.

Compared to r13036, this version of the patch includes the decls_block RecordKind enumerators for the GENERIC_PARAM_LIST layouts in the sil_block RecordKind enumerator, as Jordan had suggested before. r13036 caused buildbot failures when building for iOS, but I am unable to reproduce those failures locally now.

Swift SVN r13485
2014-02-05 16:52:02 +00:00
Michael Gottesman
800ea37c34 Revert r13036 as per Joe's request.
Swift SVN r13063
2014-01-28 21:36:06 +00:00
Joe Groff
5d58f10e48 SIL: Make ContextGenericParams a constructor parameter of SILFunction.
Edge SILFunction one step closer to independence from SILFunctionType context by taking the generic param list as a separate constructor parameter, and serializing those params alongside the function record. For now we still pass in the context params from the SILFunctionType in most cases, because the logic for finding the generic params tends to be entangled in type lowering, but this pushes the problem up a step.

Thanks Jordan for helping work out the serialization changes needed.

Swift SVN r13036
2014-01-28 02:17:46 +00:00
Joe Groff
0776c4b6b8 SIL: Reorient function type lowering toward interface types.
Lower types for SILDeclRefs from the interface types of their referents, dragging the old type along for the ride so we can still offer the context to clients that haven't been weaned off of it. Make SILFunctionType's interface types and generic signature independent arguments of its  Derive the context types of SILFunctionType from the interface types, instead of the other way around. Do a bunch of annoying inseparable work in the AST and IRGen to accommodate the switchover.

Swift SVN r12536
2014-01-18 19:42:02 +00:00
Joe Groff
3b20645274 Factor out a DependentMemberType::substBaseType method and use it in ArchetypeBuilder::mapTypeInContext.
This lets mapTypeInContext do the right thing with dependent member types for which the base is not a simple archetype.

Swift SVN r12512
2014-01-17 23:09:14 +00:00
John McCall
5da6defa1f Clean up the linkage model and the computation of linkage.
In general, this forces SILGen and IRGen code that's grabbing
a declaration to state whether it's doing so to define it.

Change SIL serialization to serialize the linkage of functions
and global variables, which means also serializing declarations.

Change the deserializer to use this stored linkage, even when
only deserializing a declaration, and to call a callback to
inform the client that it has deserialized a new entity.

Take advantage of that callback in the linking pass to alter
the deserialized linkage as appropriate for the fact that we
imported the declaration.  This computation should really take
advantage of the relationship between modules, but currently
it does not.

Swift SVN r12090
2014-01-09 08:58:07 +00:00
Joe Groff
4a8edecc8c SIL: Positionally build archetypes in dependent member types when lowering.
A DependentMemberType may have a complex base type, such as Array<$T_0_0>.IndexType, in which case it resolves not to an archetype but to a conformance of the archetype-substituted contextual base type Array<T>. When we visit a DependentMemberType during TypeLowering, fall back to a positional substitution if the fast path of resolving an archetype with ArchetypeBuilder fails.

Swift SVN r11987
2014-01-07 06:50:17 +00:00
John McCall
e507341c1b SILModule lookup: now with that magic O(1) flavor.
Swift SVN r11978
2014-01-07 01:21:10 +00:00
John McCall
bb63d2312b Hide the constructors of SILFunction/SILGlobalVariable
behind factory methods.

Swift SVN r11967
2014-01-07 00:22:15 +00:00
Joe Groff
cdc2b34a80 SIL: Give SILFunction context generic params and a mapTypeInContext method.
For now, steal the context generic params from the SILFunctionType, and borrow ArchetypeBuilder's implementation of mapTypeInContext for AST decl contexts. This should eventually be an independent property.

Swift SVN r11811
2014-01-02 05:47:39 +00:00
Joe Groff
fd7b61ac71 SIL: Add a lookup cache StringMap to SILModule.
Because doing linear lookup all the time is dumb. NFC.

Swift SVN r11575
2013-12-22 22:37:55 +00:00
Adrian Prantl
c610ac94ef Add an IsBare attribute to SILFunction for functions that do not have an
AST.

Swift SVN r11236
2013-12-13 04:48:37 +00:00
Nadav Rotem
ccf3a127f2 Add a simple generic specialization pass.
Swift SVN r10885
2013-12-05 22:20:05 +00:00
Adrian Prantl
6e075ae220 Add the missing debug scopes to functions cloned by the capture promotion
pass.

Swift SVN r10618
2013-11-21 00:50:53 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
Stephen Lin
4ebdf9c80f Capture Promotion: have new closures inserted before their original versions
Swift SVN r10554
2013-11-19 03:29:00 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Chris Lattner
2127da6a91 Enhance the function_ref instruction to maintain a refcount on the
SILFunction that it references.  Use this in the mandatory inlining
pass to remove deserialized transparent functions, to clean up the
-emit-sil output of the compiler (and presumably speed up compile 
time).  This implements rdar://15272652



Swift SVN r9699
2013-10-27 22:00:54 +00:00
John Garvin
a1badb1777 Add kernel/shader data to SILFunction.
Swift SVN r9047
2013-10-09 01:11:20 +00:00
Dmitri Hrybenko
b18c38a322 Rename ImplicitClosureExpr -> AutoClosureExpr
Swift SVN r8304
2013-09-16 23:03:50 +00:00
Dmitri Hrybenko
e7af4d6c72 Collapse ImplicitClosureExpr into its abstract base class, ClosureExpr
Swift SVN r8280
2013-09-16 18:31:05 +00:00
Dmitri Hrybenko
536ed954ad Remove FuncExpr. Add CaptureInfo to FuncDecl. Introduce AnyFunctionRef.
AnyFunctionRef is a universal function reference that can wrap all AST nodes
that represent functions and exposes a common interface to them.  Use it in two
places in SIL where CapturingExpr was used previously.

AnyFunctionRef allows further simplifications in other places, but these will
be done separately.


Swift SVN r8239
2013-09-14 02:15:48 +00:00
Dmitri Hrybenko
0d6d9a0ffb Move the DeclContext base class from FuncExpr to FuncDecl
FuncDecl still has a FuncExpr because capture list is stored in FuncExpr
(which is a CapturingExpr).


Swift SVN r8179
2013-09-13 01:40:41 +00:00
Dmitri Hrybenko
7da84fd13d Make FuncExpr, PipeClosureExpr and ClosureExpr DeclContexts on their own.
This is a first step to detach them from CapturingExpr and eventually move them
in the AST class hierarchy.


Swift SVN r8171
2013-09-12 23:58:06 +00:00
Adrian Prantl
da57c68c62 Just code cleanup.
Swift SVN r8118
2013-09-11 23:07:00 +00:00
Adrian Prantl
b9ac293046 Revert "more code cleanup." Accidentally committed too much.
This reverts commit 4e476a57689da4acf3e3dd5d5e385b18b57d571c.

Swift SVN r8117
2013-09-11 22:57:50 +00:00
Adrian Prantl
b287c3417e more code cleanup.
Swift SVN r8116
2013-09-11 22:49:08 +00:00
Adrian Prantl
46f616938c Debug info: Emit mangled name for bound generic structs and classes.
Implements rdar://problem/14802271

Swift SVN r8095
2013-09-11 17:58:54 +00:00
Adrian Prantl
af562d1696 Debug info: name mangling for composite types containing Archetypes.
Among other things this enables mangled names for tuples.
This adds a pointer to the DeclContext to SILFunction and which is used
to provide the necessary context to the Mangler.
Fixes rdar://problem/14808764 and rdar://problem/14813658.

Swift SVN r8070
2013-09-10 17:04:33 +00:00
Anna Zaks
c06bd83358 [SIL] Remove the last few uses of SILLocation constructor.
This also removes the constructor itself, which forces future users of
SILLocation to construct a valid location.

Swift SVN r8056
2013-09-09 22:34:05 +00:00
Manman Ren
ad318b0cee SIL Serialiation: add Transparent to SILFunction so we can decide which
functions should be serialized.

Transparent is added as a 1-bit field. In SILGen, we set SILFunction's
transparent attribute according to the attribute of the ValueDecl.


Swift SVN r7882
2013-09-04 00:16:34 +00:00
Joe Groff
1984cf41e0 SIL: Rename SILFunction::getMangledName to SILFunction::getName.
Swift SVN r6430
2013-07-21 18:39:51 +00:00
Adrian Prantl
de32b201d0 Debug Info: Add support for subprograms.
This means that single-stepping in lldb actually works now!

Swift SVN r5828
2013-06-27 00:46:30 +00:00
Chris Lattner
e4ccec4cfc rename SILBAse.h -> SILAllocated.h and SILBase.cpp -> SILModule.cpp to
reflect their contents.


Swift SVN r5198
2013-05-17 04:25:49 +00:00
Chris Lattner
63e2a60585 rename Module:: and Function::getContext to ::getASTContext()
This matches SILType and is more explicit about which context
we're talking about.


Swift SVN r5185
2013-05-16 20:14:13 +00:00
Chris Lattner
21a3b9d246 remove two helper forwarding methods from SILFunction
one is dead, the other isn't helpful enough to persist.


Swift SVN r5184
2013-05-16 20:07:53 +00:00
Chris Lattner
3facf741fa move SILFunction implementation goop out into SILFunction.cpp
and make the SILFunction ctor public since SIL is an optimization
IR, not just a transient by product of IRGen. :)


Swift SVN r5183
2013-05-16 19:59:01 +00:00