Commit Graph

152 Commits

Author SHA1 Message Date
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
22240080b1 move SILFunction::dump out of line, so that LLDB can find it.
Swift SVN r10544
2013-11-18 17:53:39 +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
Joe Groff
003709d51f SIL: Add a backreference from SILModule to its originating Swift Module.
Ideally this wouldn't be necessary, but the type substitution APIs required by generic specialization and SIL verification currently require a Module* pointer, and it's obnoxious to have to pass it down separately everywhere it's needed. Longer-term the reliance on Modules for type substitution might be able to go away.

Swift SVN r9866
2013-11-01 00:46:21 +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
Jordan Rose
25deab5f31 Misc. cleanup related to use of TranslationUnit.
Swift SVN r9164
2013-10-10 19:49:32 +00:00
John McCall
b880e60100 Remove SILFunctionTypeInfo in favor of SILFunctionType.
We still don't actually use this as a type, however.

Swift SVN r9091
2013-10-09 20:55:55 +00:00
John Garvin
a1badb1777 Add kernel/shader data to SILFunction.
Swift SVN r9047
2013-10-09 01:11:20 +00:00
Stephen Lin
3f5c0dbf0e Update SILArgument::getModule(), SILBasicBlock::getModule() and SILInstruction::getModule() signatures to match SILFunction::getModule(), for consistency; standardize usage of SILFunction::getParent() to SILFunction::getModule().
Swift SVN r8932
2013-10-04 21:12:20 +00:00
Joe Groff
82a18333ed SIL: Purge SpecializeInst.
Make ApplyInst and PartialApplyInst directly take substitutions for generic functions instead of trying to stage out substitutions separately. The legacy reasons for doing this are gone.

Swift SVN r8747
2013-09-28 00:15:45 +00:00
Anna Zaks
30039a59f1 Emit Swift declarations when printing SIL.
Only print function member declarations and skip the bodies since the bodies are already represented in SIL and ASTPrinter is not good enough to print arbitrary expressions.

In order to have valid output, make sure that ASTPrinter does not print references to DynamicLookup protocol.

Swift SVN r8627
2013-09-25 17:08:42 +00:00
Manman Ren
6ff9cee5e5 "transparent" attribute on SILFunction
Update SILPrinter, SILParser, SILSerializer and SILDeserializer to handle
the attribute.


Swift SVN r8597
2013-09-24 19:06:05 +00:00
Manman Ren
be3a4101ed SIL Serialization: perform SIL linking right after SILGen.
Add a SILLinkage mode "Deserialized" to make sure IRGen will emit
hidden symbols for deserialized SILFunction.

Inside SIL linker, set Linkage to external if we only have a declaration for
a callee function.

Both sil block and decl block in a module can emit an array of substitutions.
To share the serialization between SILSerializer and Serializer, we modify
the interface to pass in the abbreviation codes to write functions and to
pass in a cursor to read functions.

We now correctly handle the serialization of Substitutions in SpecializeInst.

For a deserialized SILFunction, we now temporarily set its SILLocation and 
DebugScope to an empty FileLocation. Once mandatory inliner sets the SILLocation
to the location of ApplyInst, a null SILLocation and a null DebugScope
may work for a deserialized SILFunction.

Update testing cases to reflect that we are now inlining transparent functions
from modules, or to disable SILDeserializer for now (I am not sure how to update
those testing cases).


Swift SVN r8582
2013-09-24 00:44:54 +00:00
Chris Lattner
cac7969c33 split dump() into two functions, LLDB doesn't know about default arguments.
Swift SVN r8551
2013-09-22 00:38:00 +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
Anna Zaks
fe63b96109 [SIL] Provide a single source for determining a function transparency.
Makes sure the logic for determining if a function is transparent is shared
between the inliner and the SIL serializer.

Swift SVN r8173
2013-09-13 00:54:54 +00:00
Joe Groff
705102b544 SIL: Rename 'ClangThunk' specifier to 'Thunk'.
Lazily-generated currying thunks will require the same IR-level linkonce_odr linkage as clang thunks currently do, so generalize the name of the existing SIL-level linkage specifier 'clang_thunk'.

Swift SVN r8122
2013-09-11 23:47:15 +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
Anna Zaks
2ea48d3d52 [SIL] Assign SIL location info for tuple initialization code.
Swift SVN r7915
2013-09-04 21:57:50 +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
Anna Zaks
aaa4b2c332 [SIL Printer] Add optional source location printing.
Added a -v(verbose) option to swift that will trigger verbose printing in SIL
Printer. SIL Printer will print the location info only in the verbose mode.

Here is the example of the format - only the line and colon are displayed for
brevity:

%24 = apply %13(%22) : $[cc(method), thin] ((), [byref] Bool) -> Builtin.Int1 // user: %26 line:46:10

(This will be used to test the validity of SILLocation info.)

Swift SVN r6991
2013-08-07 18:39:48 +00:00
John McCall
fcd998a48b PrettyStackTrace enhancements for SIL constructs.
Swift SVN r6966
2013-08-07 00:10:57 +00:00
Joe Groff
06f0eb3240 SIL: Remove stale leading name from doc comment.
Swift SVN r6509
2013-07-23 21:17:54 +00:00
Joe Groff
1984cf41e0 SIL: Rename SILFunction::getMangledName to SILFunction::getName.
Swift SVN r6430
2013-07-21 18:39:51 +00:00
Chris Lattner
c7373c563b add regular convenience methods to SIL IR objects for getting parent containers.
Add a getOperand(n) method to SILInstruction.


Swift SVN r6425
2013-07-21 06:12:29 +00:00
Chris Lattner
496446ce64 Make all SIL objects that are print()-able, also raw_ostream insertable
with <<.  Use this to implement a DEBUG() dump in MemoryPromotion.cpp


Swift SVN r6412
2013-07-20 02:43:26 +00:00
Anna Zaks
c315b357af Add SILLocation to the SILFunction and to the UnreachableInst, which represents falling off the end of the function.
Both of these are needed to produce user-friendly diagnostics from SIL.

Swift SVN r6152
2013-07-11 17:12:12 +00:00
Chris Lattner
b13c50157e implement proper name binding and resolution of global sil function names, including
diagnosing redefinitions, use of undefined values, handling forward references, etc.



Swift SVN r5908
2013-06-30 19:31:19 +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
Joe Groff
0dc5c66cd2 SIL: Move SILFunctionTypeInfo into a side table.
Generate and cache SILFunctionTypeInfo from Swift types on the fly, and simplify the SILType representation down to a CanType and isAddress bit.

Swift SVN r5298
2013-05-24 16:33:52 +00:00
Joe Groff
e3269a3b95 Pick one name for 'getAbstractCC'.
getCC, getFunctionCC, getConvention...consolidate them all under one name.

Swift SVN r5297
2013-05-24 03:08:40 +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
a4ce448280 Move cc attribute from SILType to AnyFunctionType.
We decided we're going to want to surface fine-grained representational control of functions to the user, so move AbstractCC and the calling convention attributes into the Swift type system. Like the [thin] attribute, we don't set this in the type-checker or importer at all yet, and let SILGen set the attribute where it wants it for now.

Swift SVN r5222
2013-05-20 17:55:51 +00:00
Chris Lattner
611a3a97db Parse sil linkage types, and actually create the SILFunction parsed.
This gets us prototypes parsing and printing, though types aren't
correct at all yet.



Swift SVN r5192
2013-05-16 22:48:07 +00:00
Chris Lattner
4b8f53ef42 allow random clients to 'new' SILFunctions.
Swift SVN r5190
2013-05-16 22:36:22 +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
Chris Lattner
d2a8cffd9c remove an unneeded #include and some llvm:: qualifiers
Swift SVN r4966
2013-04-28 16:07:19 +00:00
Joe Groff
0566088bf2 Move name mangling into SIL.
Sever the last load-bearing link between SILFunction and SILConstant by naming SILFunctions with their mangled symbol names. Move the core of the mangler up to SIL, and teach SILGen how to use it to mangle a SILConstant.

Swift SVN r4964
2013-04-28 03:32:41 +00:00
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
John McCall
dd4f26c6dc It does seem to make non-generic assumptions about the node
type, though;  I had to define a WriteAsOperand function and
add a front() method to SILFunction to get this to work.
Rip out my dominators implementation and replace it with
LLVM's.  I'd forgotten that LLVM's was actually generic.

Swift SVN r4717
2013-04-12 21:24:27 +00:00
Chris Lattner
a71bc3a78e rename Value -> SILValue, BasicBlock -> SILBasicBlock, BBArgument -> SILArgument.
Swift SVN r4594
2013-04-03 21:05:42 +00:00
Chris Lattner
1beebda868 move Instruction/BasicBlock/BBArgument files to have SIL prefixes.
Swift SVN r4591
2013-04-03 18:43:54 +00:00