In nongeneric contexts, or contexts where we only care about the indirectness of parameters or have already substituted the generic parameters for a function, the interface types are interchangeable, so just switch over.
Swift SVN r12044
Add an Archetype::substDependentType method that positionally substitutes dependent parameters and resolves dependent member types using the ArchetypeBuilder's archetypes, as in Array<$T.Foo>.Bar. We will want the same logic for IRGen's type converter when lowering generic signatures. NFC.
Swift SVN r12033
Split 'destructive_switch_enum_addr' into separate 'switch_enum_addr' and 'take_enum_data_addr' instructions. This should unblock some optimization work we would like to do with enums.
Swift SVN r12015
Emphasize the fact that this address is only intended for initialization. When we split destructive_switch_enum_addr, there will be another similar instruction for destructively taking the payload out of an already-initialized enum.
Swift SVN r12000
Introduce the SIL instruction peer_method, which references a method
in the given class or one of its superclasses (but not a subclass). It
IRGen's to objc_msgSendSuper[Stret] (vs. super_method IRGen'ing to
objc_msgSendSuper[Stret]2 for superclass lookup).
Use peer_method for initializer delegation to a foreign initializer
(i.e., an init-family method written in Objective-C) to close the
safety loophole introduced by initializer delegation in r11965. The
loophole still exists, but can only be triggered from Objective-C.
Teach definite initialization that peer_method really isn't a use of
self.
Swift SVN r11992
Treat the interface types of SILFunctionTypes as the canonical representation in the verifier. Do a bunch of supporting and annoyingly irreducible work to enable this:
- Stop trying to uncurry generic parameter lists during type lowering and preserve the structure of AST GenericParamLists. This makes mapping dependent types into contexts easier.
- Properly walk generic parameter lists at all depths when grooming substitution vectors for use with substGenericArgs interfaces.
- Reseat the generic parameter lists created for protocol_method results so that we don't expect the outer Self archetype to be unbound; it's provided by the extra data of the result.
- Hack SILFunctionType serialization never to use a decl reference when serializing its generic param list. When this happens, we get incorrect archetypes. This is a gross hack, but when we're able to jump all the way to interface types, it can go away.
Putting these ducks in a row nicely un-XFAILs TextFormatting.swift.
Swift SVN r11989
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
We need to be able to lower the substituted types against the interface types in the context of the SILFunctionType's generic signature.
Swift SVN r11936
TypeBase::isDependentType() is cheap now thanks to John's refactoring, so it's no longer necessary to cache it as a separate bit in TypeLowering's TypeKey. Also fix it so that the key is considered dependent if either the original abstraction pattern or the substituted type is dependent.
Swift SVN r11935
Factor the logic for turning a substitution vector into a TypeSubstitutionMap into a method on GenericSignature, and use it in GenericFunctionType and SILFunctionType to implement their substGenericArgs interfaces.
Swift SVN r11906
SIL instruction. Implement IR-gen support for same. Fix
the parsing of SIL string literals to properly unescape them.
SIL-gen still emits UTF8 literals unconditionally.
Swift SVN r11904
Currently SILType's method definitions are strewn in various files in
lib/SIL/*.cpp. This patch just adds a new file SILType.cpp that centralizes
many of those definitions.
*NOTE* Any method which uses declarations inside of a specific *.cpp file I left
alone (there were 3). If we want to, we can perhaps create a new header to share
the interface in between the two. I wanted this change to be as incremental as
possible so I left that undone.
Swift SVN r11890
Give TypeConverter methods to push and pop a generic context given a set of generic parameter types and requirements from a generic signature. Dependent types lowered in this context can then be lowered using an ArchetypeBuilder seeded with that signature. The TypeLowering objects created for dependent types are put in a special arena which we clear out when we pop the generic context. This sets the stage for allowing us to lower SILFunctionTypes using their interface types.
Swift SVN r11848
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
When we see an uncurried nested PolymorphicFunctionType, such as <T> Foo -> <U> Bar -> Bas, pull the deepest generic parameter list out into the lowered SIL function type, so that dependent archetypes at all levels get properly represented in the generic parameter list, and we can map them to dependent generic types.
Also, apparently deserialized generic param lists get different archetypes from the corresponding deserialized generic param decls. Weird, but hopefully this will all be over soon, so roll with it, man.
Swift SVN r11809
Originally there was a emitLoweredCopyValue method in TypeLowering, but it was
removed by Chris in r11353 since SILGen was no longer using it and it had bugs.
This method is useful for SILLowerAggregateInstrs, so I resurrected it, fixing
the bugs therein.
The bug was that emitLoweredCopyValue was not reforming aggregates correctly
since it was only considering non-trivial values. The new implementation passes
in all child values, but only recursively lowers the non-trivial children. This
does create an extra tuple_extract, struct_extract for trivial arguments, but
those are easily cleaned up by later dce.
Swift SVN r11753
The idea here is that the aggregate memory operation is lowered deep recursively
for all types except enums which recieve a shallow lowering. This prevents code
bloat due to the deep lowering of an enum requiring the creation of a bunch of
new basic blocks, code bloat which we do not want.
Another thing to note is that this method is actually not used anywhere else
currently, but in case this behavior was left in on purpose I decided to extend
it by adding the enum class flag rather than just changing the underlying
behavior (i.e. making deep not lower enum values).
Swift SVN r11748
with qualifiers on it, we have two distinct types:
- LValueType(T) aka @lvalue T, which is used for mutable values on the LHS of an
assignment in the typechecker.
- InOutType(T) aka @inout T, which is used for @inout arguments, and the implicit
@inout self argument of mutable methods on value types. This type is also used
at the SIL level for address types.
While I detangled a number of cases that were checking for LValueType (without checking
qualifiers) and only meant @inout or @lvalue, there is more to be done here. Notably,
getRValueType() still strips @inout, which is totally and unbearably wrong.
Swift SVN r11727
We should be able to cut out another layer of IRGen grime now.
This does XFAIL one test, test/Prototypes/TextFormatting.swift, which fails because of a weird archetype ordering in a nested substitution list. This should get sorted out by switching to interface types, so I'm going to let it go until then.
Swift SVN r11618
Lower the result type according to the original abstraction pattern the function is following, so that we represent metatype and function results properly.
Swift SVN r11617
The current implementation depends on the target basic block to record the number of argumens, but this is a bad idea because it makes it difficult to modify the argument list.
Swift SVN r11597
Given a destructor that is not implicit, one will have a decl that is not
autogenerated implying that this assert will always be hit.
I am going to submit an additional patch after this that changes
InlineLocation/MandatoryInlinedLocation/CleanupLocation that ensures that
the special flags on SILLocation are propagated appropriately (which they are
not right now).
Swift SVN r11595
These still can't ever take any extra polymorphic params without breaking the calling convention, so protocol_method still needs to produce a thin value in SIL, and we have to ensure we don't add any extra polymorphic params in the IR signature.
Swift SVN r11594
Lower metatype types as @thin or @thick based on whether the type is static and whether the abstraction pattern allows for a thin metatype. Add a '@thick' attribute and require SIL metatypes to always be annotated with either '@thin' or '@thick' to distinguish them from unlowered metatypes.
Swift SVN r11525