Commit Graph

745 Commits

Author SHA1 Message Date
Adrian Prantl
5325fd35e5 Debug info: Don't make byref types indirect.
Swift SVN r9160
2013-10-10 18:47:04 +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
Adrian Prantl
37bb48afb0 Debug info: Create debug type info for box-allocated types by using their
Decl. This should allow us to emit debug info for boxed generic types.

rdar://problem/15180622

Swift SVN r9071
2013-10-09 18:25:18 +00:00
Pete Cooper
f9c6bf0630 Initial framework for generating Axle metadata. This currently only supports the function level metadata. Argument and result metadata to come later
Swift SVN r9061
2013-10-09 16:54:28 +00:00
Adrian Prantl
627fec7f41 Debug info: fix scoping for boxed values that get promoted to stack
allocated values. Fixes rdar://problem/15035350

Swift SVN r9044
2013-10-09 01:01:32 +00:00
Stephen Lin
a6108dbd48 Rename FunctionRefInst::getFunction() and BuiltinFunctionRefInst::getFunction() to FunctionRefInst::getReferencedFunction() and BuiltinFunctionRefInst::getReferencedFunction() to avoid shadowing SILInstruction::getFunction().
Swift SVN r8929
2013-10-04 20:26:41 +00:00
Adrian Prantl
8808d48578 Debug info: emit captured variables in closures. rdar://problem/15035486
Swift SVN r8859
2013-10-02 22:46:03 +00:00
Adrian Prantl
0bd4357b1f Debug info: Emit shadow copies of boxed value's addresses in an alloca at
-O0 so the register allocator will not elide its DBG_VALUE.

Swift SVN r8798
2013-09-30 23:34:15 +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
Adrian Prantl
61b5d055ef Debug info: allow for boxed arguments. rdar://problem/15035486
Swift SVN r8713
2013-09-27 00:31:20 +00:00
Joe Groff
a2672e9313 SIL: Turn conditional checked casts into a branch instruction.
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
2013-09-26 18:24:44 +00:00
Joe Groff
cbfe3710f6 SIL: Rename the 'isObjC' SILDeclRef specifier to 'isForeign'.
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
2013-09-25 21:59:03 +00:00
Adrian Prantl
6009987432 Debug info: implement support for shadow-copied [byref] arguments.
This patch has a negative line balance -- those are my favorite!

Swift SVN r8655
2013-09-25 20:17:21 +00:00
Adrian Prantl
c4ece4ec9f Revisit scopes and locations in the light of SIL-based transparent inlining.
Swift SVN r8625
2013-09-25 16:14:47 +00:00
Doug Gregor
e6f47a6e2d IRGen for dynamic subscripting operations.
Swift SVN r8612
2013-09-24 22:28:36 +00:00
Joe Groff
9e54a69016 SIL: Allow RefToObjectPointer and ObjectPointerToRef to cast to/from Builtin.ObjCPointer.
Swift SVN r8558
2013-09-23 16:20:29 +00:00
Doug Gregor
903a4d2ea1 Implement SILGen/IRGen support for dynamic lookup that resolves to properties.
Swift SVN r8521
2013-09-20 22:15:03 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
John McCall
7954960797 Add 'copy_value' and 'destroy_value' operations to destroy
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
2013-09-19 22:14:55 +00:00
Doug Gregor
4a377575f8 IRGen support for dynamic method lookup of static methods.
Swift SVN r8301
2013-09-16 22:27:53 +00:00
Adrian Prantl
6fb78ed5e5 Debug info: Add initial support for boxed values on the heap.
Swift SVN r8221
2013-09-13 23:14:52 +00:00
Adrian Prantl
ba105c5705 Debug info: Emit byref parameter types as reference types.
Also scan store instructions for byref arguments.

Swift SVN r8209
2013-09-13 20:58:23 +00:00
Doug Gregor
c2c367b12a Pass the right selector to swift_objcRespondsToSelector().
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
2013-09-13 17:12:32 +00:00
Adrian Prantl
25f3bfe202 Debug info: Implement [byref] function arguments. rdar://problem/14949469
Swift SVN r8197
2013-09-13 16:03:45 +00:00
Chris Lattner
7c8ae9352a Add a new "mark_function_escape" instruction that will be used to mark the
escape point of function definitions that "close" over global variables.



Swift SVN r8152
2013-09-12 18:31:00 +00:00
Joe Groff
59b3ecc3a2 IRGen: Bind the destination BB argument for dynamic_lookup_br.
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
2013-09-12 17:52:01 +00:00
Chris Lattner
3c0c9a5da7 introduce a new mark_uninitialized SIL instruction which will be used by
definitive initialization of top-level code.


Swift SVN r8144
2013-09-12 04:30:48 +00:00
Joe Groff
4a4c70ab36 IRGen: Implement partial_apply lowering for objc dynamic method values.
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
2013-09-11 21:07:28 +00:00
Joe Groff
cc37187c53 SIL: Remove 'UncurryDirection' and uncurry all methods right-to-left.
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
2013-09-11 17:05:44 +00:00
Doug Gregor
0e3aa19313 Factor the selector-loading logic into its own routine.
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
2013-09-10 22:42:45 +00:00
Doug Gregor
5917038895 Untested IR generation for dynamic_method_br.
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
2013-09-10 22:27:14 +00:00
Joe Groff
b86203f021 IRGen: Emit partial applications of indirect function calls.
Add support to partial_apply lowering to handle partial applications of indirect functions, including ones that already have context.

Swift SVN r8074
2013-09-10 18:59:08 +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
Doug Gregor
24f4706056 SIL: Introduce the dynamic_method_br instruction.
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
2013-09-09 23:46:10 +00:00
Anna Zaks
e36839ca8a [IRGen] Eliminate calls to SILLocation() from IRGen.
Here, the location information does not have to always be available. Use Optional instead of creating an empty location.

Swift SVN r8055
2013-09-09 22:34:01 +00:00
Doug Gregor
c5557a624c SIL: Introduce the 'dynamic_method' instruction for dynamic method dispatch.
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
2013-09-09 16:12:50 +00:00
Anna Zaks
cb43f56edb [SIL] Remove more dependancies on SILLocation(), specifically from debugging related code.
Swift SVN r8019
2013-09-06 23:57:30 +00:00
Joe Groff
915ed36c8d IRGen: Lower SIL destructive_switch_union_addr instruction.
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
2013-08-31 04:30:54 +00:00
Joe Groff
65a53dfd9d IRGen: Implement SIL union_data_addr and inject_union_addr insns.
This allows constructors for address-only unions to be emitted.

Swift SVN r7751
2013-08-29 22:05:28 +00:00
Dmitri Hrybenko
69cfa73640 More 'this' -> 'self' replacements
Swift SVN r7657
2013-08-28 02:57:21 +00:00
Anna Zaks
440631f86a [SIL] Add the SILLocation hierarchy.
Now we should be ready to start using these.

Swift SVN r7632
2013-08-27 22:16:18 +00:00
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
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
2013-08-27 21:58:27 +00:00
Michael Gottesman
d41b871b3a At Joe's suggestion added the prefix strong to instructions Retain,Release,RetainAutoreleased,RetainUnowned to prevent confusion in between RetainUnowned and UnownedRetain.
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
2013-08-26 23:32:16 +00:00
Joe Groff
c74dc79610 SIL: Add instructions to implement address-only unions.
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
2013-08-26 20:50:31 +00:00
Joe Groff
bb8b42260b SILGen/IRGen: Move union constructor generation to SILGen.
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
2013-08-25 18:31:07 +00:00
Joe Groff
fe1ad586e7 SIL: Add a 'union' instruction to construct unions.
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
2013-08-24 18:33:24 +00:00
John McCall
55926f3f16 Don't crash in IR-gen if the SIL basic blocks aren't
dominance-sorted.

Swift SVN r7546
2013-08-24 00:03:22 +00:00
Joe Groff
74d1196401 IRGen: Start implementing the projection half of switch_union.
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
2013-08-20 01:18:29 +00:00
John McCall
1a8e5740cb Rename load -> loadAsCopy and fix a test case that
was accidentally causing a double retain (in a suspicious
case, but still).

Swift SVN r7350
2013-08-20 00:55:08 +00:00
John McCall
2ffcef1670 Make a couple minor interfaces traffic in Address instead
of OwnedAddress.

Swift SVN r7349
2013-08-20 00:55:04 +00:00