Commit Graph

6634 Commits

Author SHA1 Message Date
John McCall
9f6820fadc SILGenModule::getConstantLinkage -> SILDeclRef::getLinkage
Swift SVN r14247
2014-02-22 01:45:40 +00:00
John McCall
3d5d8fdc03 Resilience expansion is really an aspect of a SILDeclRef.
We should also remove it from IRGen's Explosion API; IRGen
should always use maximal explosion, and SILGen will tell us
whether or not we need to put that in memory somewhere.
But that can be a later commit.

Swift SVN r14242
2014-02-21 23:28:43 +00:00
Doug Gregor
50a7d66112 SILBuilder: peephole 'metatype' instruction used only by a thick/ObjC conversion instruction.
The 'metatype' instruction can produce either a thick or Objective-C
metatype value for a class. Sometimes SILGen picks the "wrong" one,
and ends up converting the value directly, which is sub-optimal. Clean
this up in SILBuilder.

I didn't add a corresponding SILCombine optimization, nor did I add
this for class_metatype, because it seems unlikely that those will
occur in practice.


Swift SVN r14183
2014-02-20 23:39:44 +00:00
Doug Gregor
3182cd3910 Introduce thick/Objective-C metatype conversion instructions.
Introduce the SIL instructions thick_to_objc_metatype and
objc_to_thick_metatype to convert between the 'thick' and
'Objective-C' representations of a metatype. Most of this code is
trivial support code for these conversions: printing, parsing,
(de-)serialization, etc., for which testing will come online in
subsequent patches or is incidental in other tests.

Lower Objective-C metatype values down to objc_class* at the IR level
and implement IRGen support for these SIL instructions. SIL-only test
case at the moment because SILGen never creates these instructions.



Swift SVN r14087
2014-02-19 18:20:21 +00:00
Mark Lacey
09d892798a Update a comment to use a style consistent with surrounding comments.
Swift SVN r14046
2014-02-18 17:49:09 +00:00
Michael Gottesman
6570c169c0 Teach SILArgument how to determine if it is a function argument or not.
A SILArgument is a function argument if the argument's parent BB is the entry BB
of the function containing the argument.

This is an interesting distinction since function arguments have special
aliasing properties with respect to indirect arguments which normal basic block
arguments do not.

Swift SVN r14012
2014-02-17 23:24:06 +00:00
Jordan Rose
0b2541b58f Rename the standard library to "Swift" (instead of "swift")
This is more in line with all other modules currently on our system.
If/when we get our final name for the language, we're at least now set
up to rename the library without /too/ much trouble. (This is mostly just
a lot of searching for "import swift", "swift.", "'swift'", and '"swift"'.
The compiler itself is pretty much just using STDLIB_NAME consistently now,
per r13758.)

<rdar://problem/15972383>

Swift SVN r14001
2014-02-17 19:30:47 +00:00
Joe Groff
df356b475b SIL: Set the context generic params of reabstraction thunks less greedily.
Don't try to set the generic params of a reabstraction thunk until we've established it hasn't already been defined, fixing an issue where the same generic reabstraction pattern occurred in different contexts and we ended up clobbering the archetypes of a thunk that was already defined in terms of other archetypes.

Swift SVN r13964
2014-02-16 16:56:43 +00:00
Doug Gregor
9c6c270771 Teach SILCloner to clone the opened existential archetype as well.
Swift SVN r13943
2014-02-15 22:05:34 +00:00
Chris Lattner
d88852e457 remove SILDeclRef::Getter/Setter and supporting code. NFC, but I think
the previous patches have defined away a few obscure bugs handling subscript 
accessors (from inspection).


Swift SVN r13885
2014-02-14 01:12:56 +00:00
Doug Gregor
2134072285 Split open_existential[_ref] out as their own instructions.
Riding off of project_existential[_ref] was convenient, but the
resuls are used quite differently. Note that open_existential[_ref]
still don't print/parse reasonably yet.



Swift SVN r13878
2014-02-13 23:42:23 +00:00
Chris Lattner
12196c17ba Now that we always have funcdecls for getters and setters, we don't need
SILDeclRef::Getter/Setter and the complexity therein.  Switch the world
to make SILDeclRef::Func's instead of them.  NFC.


Swift SVN r13875
2014-02-13 23:11:29 +00:00
Michael Gottesman
3ba6b7c663 [sil-combine] Make output of (extract (load)) -> (load (element_addr)) deterministic by not using pointer address as a sorting criteria for vardecls.
Instead for vardecls, we use the index of the field in the structdecl itself as
a stable ordering of vardecls.

I validated that the indeterminism was gone by running the failing test 1000
times in a row. Doug and I were hitting the indeterminism with well less than
100 iterations before, so I feel the number of iterations is sufficient.

Swift SVN r13859
2014-02-13 04:57:54 +00:00
Joe Groff
96e4713415 SIL: Simplify TypeLowering generic context APIs to work only with GenericSignature.
Remove the pushGenericContext/popGenericContext entrypoints that took an ArrayRef pair instead of a GenericSignature.

Swift SVN r13810
2014-02-12 04:22:52 +00:00
Joe Groff
68db63b45d AST: Have GenericFunctionType use GenericSignature.
Change GenericFunctionType to reference a GenericSignature instead of containing its generic parameters and requirements in-line, and clean up some interface type APIs that awkwardly returned ArrayRef pairs to instead return GenericSignatures instead.

Swift SVN r13807
2014-02-12 03:44:28 +00:00
Chris Lattner
bc005219d1 Implement most of support for properties in function scope, part of rdar://15922884.
Most of the complexity here is teaching SILGen how to handle closed-over direct 
accesses to observing properties, since all of the getter/setter/willSet/didSet
members of the property are actually full closures when in a function body.

We generate correct but really terrible code here, since the setter captures the
willset/didset members themselves.  I'm not worrying about the performance of 
this construct though, functionality is what matters.


Swift SVN r13778
2014-02-11 06:23:14 +00:00
Joe Groff
05c1594441 SILGen: Derive protocol witness context generic params independent of type.
We still glue the generic params of the requirement to the generic params of the conformance, but now we do it without relying on TypeLowering.

Swift SVN r13771
2014-02-11 02:05:00 +00:00
Michael Gottesman
de48699d49 [sil-aa] Teach SILAA how to prove that two GEPs from the same base pointer with the same projections must alias.
Swift SVN r13768
2014-02-11 00:55:09 +00:00
Michael Gottesman
3a1d46d145 [sil-code-motion] Refactor out the address projection path computation from findExtractPathBetweenValues to a new function findAddressProjectionPathBetweenValues and wire up the old method to use the results of the refactored method.
This is in preparation for using the refactored functionality in Alias
Analysis's address projection disambiguation code.

Swift SVN r13765
2014-02-11 00:09:15 +00:00
Joe Groff
5e1d7d6ef2 SIL: Lower the context generic params for a SILDeclRef independent of its type.
Instead of relying on type lowering to produce a contextualized SILFunctionType from which we can borrow context generic params, add a getConstantContextGenericParams that grabs the generic param list for a SILDeclRef independent of the function type, severing another dependency on SILFunctionType's context params.

Swift SVN r13743
2014-02-10 06:51:42 +00:00
Michael Gottesman
5b3423308d Refactor out the class Projection class into its own header swift/SIL/Projection.h.
This class allows you to deal with tuple and nominal projections in a way that
is agnostic of either of them.

Expect some incoming utilities based off of this for dealing with what I call
'aggregate type trees'.

Swift SVN r13735
2014-02-10 05:07:36 +00:00
Joe Groff
481fbb7b91 Drop the non-interface types from SILFunctionType.
There are some straggling references to the context generic param list, but nothing uses the non-interface param or result types anymore!

Swift SVN r13725
2014-02-09 22:39:01 +00:00
Michael Gottesman
d01ddfdb25 Change the indentation in SILNodes.def of LiteralInst, AllocationInst, and DeallocationInst to match the rest of the ABSTRACT_VALUEs in SILNodes.def.
Swift SVN r13723
2014-02-09 22:30:40 +00:00
Joe Groff
42677b21d1 IRGenDebugInfo: Stub out debug info for dependent types.
Build debug info for function types using the interface types of their lowered SILFunctionTypes. We can't use the archetype path to declare dependent parameter types of a generic function, since the function type can't be tied to any specific decl context, so stub them out as an UnspecifiedType for now.

Swift SVN r13722
2014-02-09 22:25:58 +00:00
Michael Gottesman
5327c3b089 Print out the result number of the SILValue when you print it out.
Swift SVN r13613
2014-02-07 00:50:19 +00:00
Michael Gottesman
9a297333f9 Enable printing of AliasAnalysis::AliasResult and SILValues.
Swift SVN r13577
2014-02-06 10:06:20 +00:00
Michael Gottesman
ccdb0eb352 Change AllocationInsts, DeallocationInsts, LiteralInsts to have the correct parent class.
Swift SVN r13518
2014-02-05 23:18:40 +00:00
Michael Gottesman
cdeb7f78d8 Remove trailing whitespace. NFC.
Swift SVN r13517
2014-02-05 23:03:00 +00:00
Michael Gottesman
8281c9855b Create abstract SILInstruction DeallocationInst as a parent class of Dealloc{Stack,Box,Ref} so that one can check if an instruction is a deallocation instruction by calling isa<DeallocationInst>(I).
Swift SVN r13516
2014-02-05 23:02:59 +00:00
Michael Gottesman
2bf56c0dee Add in abstract SILInstruction AllocationInst so we can query if we have an Alloc{Stack,Box,Ref,Array} by just doing isa<AllocationInst>.
Swift SVN r13515
2014-02-05 23:02:58 +00:00
Joe Groff
484468fd96 Push deprecations of SILConstantInfo non-interface types out a bit. NFC.
Swift SVN r13502
2014-02-05 20:23:35 +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
2d63a4dc42 Add RefElementAddrInst::getClassDecl to return the class decl associated with the GEP operatiion.
Swift SVN r13450
2014-02-04 22:41:53 +00:00
Michael Gottesman
2afa5075fd Add SILValue::stripIndexingInsts() which strips of index_addr, index_raw_pointer from SILValues.
Swift SVN r13444
2014-02-04 20:25:48 +00:00
Michael Gottesman
8fd89a4fdc Change SILType::isAddressOnly to perform its query analogously to isTrivial by calling TypeLowering::isAddressOnly().
This is going to be useful so we can use a TypeLowering cache on SILType to ensure that both SILType::isTrivial and SILType::isAddressOnly do not have to perform the lookup of their TypeLowering which is slow. This will be coming later in the week.

Swift SVN r13374
2014-02-03 22:05:48 +00:00
Chris Lattner
7532213f4a simplify the SIL string_literal instruction to only produce a single value,
which is the address of the string data.  Have SILGen compute and produce the
isASCII bit as an integer literal, and remove the logic from IRGen.

This overall approach is simpler and enables better SIL-level optimizations.


Swift SVN r13363
2014-02-03 19:10:37 +00:00
Nadav Rotem
d5bc89c85b Remove the API for setting destination blocks directly. It is incorrect to change the branch instructions without the blocks.
Swift SVN r13274
2014-02-01 01:30:40 +00:00
Nadav Rotem
42c3b8b00b Add a builder API for creating cond_br from OperandValueArrayRefs
Swift SVN r13273
2014-02-01 01:29:59 +00:00
Joe Groff
71379f5bad SILGen: Explicitly mark uninitialized locals with mark_uninitialized, and have DI only consider mark_uninitialized storage.
Have SILGen mark all variables bound from pattern bindings without initializers (and *only* ones without initializers) with mark_uninitialized [var] pseudo instructions. On the DI end, *only* consider mark_uninitialized instructions for DI analysis. This has many benefits:

- DI doesn't waste time analyzing locals that are trivially initialized in the original source code.
- DI doesn't try to mangle canonical SIL that has been inlined from transparent functions, which may have been optimized into a form DI isn't written to understand.

While we're here, fix an issue with DCE where it would try to kill unused MarkUninitialized instructions. Although MarkUninitialized has no side effects, it still is semantically important to raw SIL, and can't be killed.

Chris did most of the work here; I just finished updating tests and fixing bugs.

Swift SVN r13247
2014-01-31 22:50:21 +00:00
Nadav Rotem
bcb13736f3 Add block setters to the branch instructions.
Swift SVN r13241
2014-01-31 19:35:56 +00:00
Nadav Rotem
cbd1eac034 Add a helper function.
Swift SVN r13092
2014-01-29 06:12:03 +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
3b0159f376 SILGen: Process reabstraction thunks using interface types.
The expected and original types of reabstracted functions are nongeneric and thus don't depend on generic context.

Swift SVN r13060
2014-01-28 17:43:07 +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
Michael Gottesman
35d1f4aa1c Rename SILValue::stripObjectProjections() => SILValue::stripAggregateProjections.
Swift SVN r12931
2014-01-24 19:48:02 +00:00
Michael Gottesman
bbc1093efd Add SILValue::stripObjectProjections().
This method looks recursively through the operand chain of the given SILValue
until it finds a non-object projection instruction. It then returns that value.

An object projection instruction is one of:

1. struct_extract.
2. tuple_extract.

Swift SVN r12918
2014-01-24 18:20:10 +00:00
Michael Gottesman
8db21be9e5 Fix typo from last night.
Swift SVN r12917
2014-01-24 18:12:13 +00:00
Michael Gottesman
6fd616c95b Add SILValue::stripPointerProjections().
An address projection instruction is one of the following instructions:

1. struct_element_addr.
2. tuple_element_addr.
3. ref_element_addr.

This method takes in the given SILValue and continually searches up its
operand chain until it finds a non address projection, non-cast
value (where cast is defined as in SILValue::stripCasts()). The found
SILValue is then returned.

Swift SVN r12909
2014-01-24 07:30:34 +00:00
Michael Gottesman
15e087bb90 Added SILValue::stripCasts().
This method takes in a SILValue and returns the SILValue created by continually
moving up the operand chain of the SILValue until a non-cast instruction is hit.
The non-cast instruction is then returned.

Swift SVN r12906
2014-01-24 07:01:52 +00:00
Michael Gottesman
82a912cc45 Added SILInstruction::mayReadOrWriteMemory().
Swift SVN r12905
2014-01-24 06:13:56 +00:00