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
Replace the existing suite of checked cast instructions with:
- unconditional_checked_cast, which performs an unconditional cast that aborts on failure (like the former downcast unconditional); and
- checked_cast_br, which performs a conditional pass and branches on whether the cast succeeds, passing the result to the true branch as an argument.
Both instructions take a CheckedCastKind that discriminates the different casting modes formerly discriminated by instruction type. This eliminates a source of null references in SIL and eliminates null SIL addresses completely.
Swift SVN r8696
Doug pointed out that 'isObjC' incorrectly excludes C functions, for which we'll also need to be able to independently reference Swift and foreign entries.
Swift SVN r8669
entire aggregates at once.
This has three worth effects:
- It significantly decreases the amount of SIL required
for these operations.
- It makes it far easier for IR-gen to choose efficient
patterns of destruction, e.g. calling a single entrypoint
or recognizing that it can just use the runtime 'release'
entrypoints.
- It makes it easier to recognize and optimize aggregate
copy/destroy operations.
It does make SROA-like tasks a bit more challenging. The
intent is to give TypeLowering a way to expand these into
their primitive behavior.
Swift SVN r8465
With this, we're correctly lowering the dynamic_method_br instruction
to IR, which allows us to query the existence of an instance method on
a value of type DynamicLookup and, if it's there, call it via the
closure stored in the optional. Part of <rdar://problem/14397505>.
Swift SVN r8205
This is kind of gross because we want the BB argument to be lowered to an ObjCMethod abstraction rather than a concrete explosion of PHI nodes. For now, assume that there won't be other predecessors to a dynamic_method_br's destinations and clobber the BB argument's PHI node lowering, replacing it with an ObjCMethod. This is hacky but unblocks Doug's dynamic lookup work, and avoids having to create an ObjCMethod-to-explosion thunk in the (currently 100%, probably always 99.99%) case where the branches have single predecessors.
Swift SVN r8150
To do this right, we need to emit the objc_msgSend on the 'self' argument inside the forwarding stub, so handle them in a different code path in IRGenSIL::visitPartialApplyInst.
Swift SVN r8112
ObjC methods are already tagged with a special calling convention and have special IRGen handling to keep the _cmd argument abstracted away from SIL. We can use the CC to also abstract away the detail that Swift methods pass 'self' last but ObjC methods pass 'self' first. This eliminates a weird special case from SIL's perspective, and also means that 'partial_apply' can work on objc methods correctly without becoming significantly more complex.
Swift SVN r8091
When loading a selector in the JIT, we need to call
sel_registerName(). This was manually coded in two places and missed
in a third, so factor it appropriately.
Swift SVN r8082
The dynamic method branch queries for the ability of an object to
respond to a particular selector (with -respondsToSelector:) and
branches on the result.
Note that we can't actually check the resulting IR here until we
handle partial application on Objective-C methods
(<rdar://problem/14958980>).
Swift SVN r8081
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
The dynamic_method_br instruction branches depending on whether a
particular object can accept a given message, as determined at
runtime. If the object can accept the message, it branches to the
first basic block, providing the uncurried method as the BB
argument. If the object cannot accept the message, it branches to the
second basic block. Either way, the result is packaged up into an
optional type and passed along to the continuation block, which
provides the optional result.
Note that this instruction is restricted to lookup of Objective-C
methods.
Documentation and IR generation (via -respondsToSelector) to
follow. Review greatly appreciated!
Swift SVN r8065
The dynamic_method instruction handles method lookup on an existential
of type DynamicLookup based on the selector of an [objc] method of a
class or protocol. It is only introduced in the narrow case where we
are forcing a use of the method with '!', e.g.,
class X {
func [objc] f() { println("Dynamic lookup") }
}
var x : DynamicLookup = X()
x.f!()
Swift SVN r8037
Implement the destructive-project logic for all of the union implementation strategies so that we can lower switches on address-only unions.
Swift SVN r7828
This was not likely an error-free change. Where you see problems
please correct them. This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.
Swift SVN r7631
This is was a very mechanical patch where I basically first renamed SILNodes.def
and then just kept fixing things until everything compiled, so even though it is
large patch I feel ok(ish) with committing it.
If anyone has any concerns/etc, please email me and I will revert in 1 second.
Swift SVN r7604
Because union layout may interleave tag bits with payload data, we need to be able to efficiently inject and remove tag bits from an address-only union in-place. To do this, we'll model address-only union initialization by projecting out the data address (union_data_addr) and storing to it, then overlaying the tag bits (inject_union_addr). To dispatch and project out the data, we'll use a destructive_switch_union_addr instruction that clears any tag bits in-place necessary to give a valid data address.
Swift SVN r7589
Generate union constructors as SIL functions using the new 'union' instruction. Change UnionTypeInfo::emitInjectionFunctionBody into UnionTypeInfo::emitInjection, which emits the union value to an explosion rather than emitting the scalar return directly, and use it to implement IRGen lowering of the 'union' instruction.
This breaks a few serialization tests because of mangler bugs handling generic unions, which I'll fix next.
Swift SVN r7559
The instruction represents constructing a loadable union given a case and the data for that case, which will let us emit union constructor functions in SIL instead of IRGen (rdar://problem/14773182).
Swift SVN r7558
For each switch_union case that branches to a BB with a SIL argument, set up an intermediate LLVM BB into which we can emit the projection to that union case and hang the result off of the SIL argument's PHI nodes. This is a bit goofy since most switch_union destinations only have a single predecessor, but the "SILArgument == llvm::PHINode" assumption in IRGenSIL runs a bit deeper than I want to fight with. Implement projection for the easy cases of no-payload, single-case, and single-payload unions.
Swift SVN r7352