Commit Graph

1069 Commits

Author SHA1 Message Date
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
fb6806abe5 Bridge 'self' for class methods.
The Objective-C entry point for a class method expects 'self' to be an
Objective-C metatype. Bridge it accordingly.


Swift SVN r14160
2014-02-20 19:10:55 +00:00
Doug Gregor
38cad0c284 Lower metatype and class_metatype to IR based on the requested representation.
Make IRGen just a little bit dumber: rather than inferring whether we
need the Swift or Objective-C metatype based on the uses of that
metatype, produce the metadata in the representation requested by the
'metatype' or 'class_metatype' instruction. SILGen will eventually
need to get smarter about asking for the representation it wants.


Swift SVN r14117
2014-02-20 00:31:24 +00:00
Doug Gregor
27ae27bf04 Start using objc_class* to describe Objective-C class metatypes in IRGen.
Swift SVN r14099
2014-02-19 21:24:00 +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
Joe Groff
bca066498f IRGen: Emit calls into blocks.
Add a 'Block' ExtraData kind, and teach IRGen how to pull the invocation pointer out of a block structure and pass the block object in the right place.

Swift SVN r13940
2014-02-15 08:17:09 +00:00
Chris Lattner
bd8323dff0 Add an irgen hack fix the rest of rdar://16006333 - observing properties don't work in @objc classes
This is a hack in that the bitcast it introduces shouldn't be needed, I've filed
rdar://16006333 to track a proper fix for this when Mark gets back.



Swift SVN r13931
2014-02-14 23:44:43 +00:00
Doug Gregor
cf5aaa2112 Properly extract the archetype type from open_existential[_ref] in IRGen.
Swift SVN r13897
2014-02-14 03:46:25 +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
Mark Lacey
112e5c1dc2 Remove obsolete comments.
Swift SVN r13865
2014-02-13 09:27:10 +00:00
Mark Lacey
df975185ac Handle padding arguments in C/ObjC entrypoints and calls.
Swift SVN r13864
2014-02-13 08:49:31 +00:00
Mark Lacey
8fd86aa79b Only coerce when necessary when lowering C/ObjC entrypoints.
This avoids storing and then loading arguments when the ABI type matches
the type used in the body of the function. This is important for types
like a boolean type represented as i1 where the storage type differs.

Fixes <rdar://problem/16040488>.

Swift SVN r13844
2014-02-12 23:37:04 +00:00
Chris Lattner
3f7d3877a4 Re-commit r13836 with more correctness this time:
Sink the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down to
AbstractStorageDecl.  NFC.



Swift SVN r13842
2014-02-12 22:49:47 +00:00
Mark Lacey
525c9323cc Revert "since the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down"
This reverts commit r13836, since it broke the build.

Swift SVN r13839
2014-02-12 20:59:24 +00:00
Chris Lattner
c23185d9ba since the getObjCGetterSelector/Setter methods from VarDecl/SubscriptDecl down
to AbstractStorageDecl, NFC.


Swift SVN r13836
2014-02-12 19:16:40 +00:00
Mark Lacey
70fa0dead0 Select ABI types for all arguments of a C/ObjC function together.
Updates to signature expansion, entrypoint lowering, and callsite
lowering so that each selects the ABI types for all arguments at once
rather than an argument at a time (as well as considering whether the
return value is returned indirectly). This is required to get the
correct behavior in cases where we run out of argument registers and
need to pass arguments as indirect byvals.

This is mostly just refactoring existing code to move loops inside inner
functions as well as dealing with return values at the same time as
arguments.

Swift SVN r13781
2014-02-11 06:45:53 +00:00
Doug Gregor
12c064d501 IR generation for DynamicSelf method invocations on existentials.
When projecting an existential into an opened archetype, bind the
archetype with metadata and witness tables extracted from the
existential. Tweak SILGen so that it doesn't destroy the opened
archetype value an extra two times.

Use an executable testcase to ensure end-to-end operation, because we
still don't have a parsable form existential projection to opened
archetype instructions.



Swift SVN r13755
2014-02-10 18:47:24 +00:00
Joe Groff
7275b2f34c IRGen: Pass in the debug DeclContext when building debug info for boxes.
So we don't crash when emitting debug info for a box of archetype type.

Swift SVN r13721
2014-02-09 22:25:57 +00:00
Joe Groff
05daca8e79 IRGen: Use interface types to implement the PolymorphicConvention.
Refactor the base PolymorphicConvention implementation to work using generic signatures and dependent types instead of GenericParamLists and archetypes, using an ArchetypeBuilder to produce representative archetypes as a convenience when we need to consider all of the requirements attached to a dependent type. In EmitPolymorphicParameters, map the dependent types into context to resolve the archetypes that should be bound in the body of the function.

Swift SVN r13685
2014-02-08 21:04:15 +00:00
Mark Lacey
660bb20909 Select correct IR types for direct arguments to C/@objc functions.
Reapply r13532 fixes for dealing with arguments that should be exploded
for C/Obj-C functions.

This gets us a bit closer to properly generating the correct types for
arguments. The remaining piece is generating all the argument types at
once rather than one at a time, which also requires being able to always
generate Clang types for the Swift types we see in the signatures of
these functions.

Swift SVN r13638
2014-02-07 18:04:45 +00:00
Adrian Prantl
bacd2d3c04 Debug info: Fix the locations for branches in case statements.
<rdar://problem/15899195> Step from a case the middle of a switch goes to the beginning of the containing function

Swift SVN r13623
2014-02-07 02:37:36 +00:00
Chris Lattner
827acad533 Various inout improvements:
- purge @inout from comments in the compiler except for places talking about
   the SIL argument convention.
 - change diagnostics to not refer to @inout
 - Change the astprinter to print InoutType without the @, so it doesn't show
   up in diagnostics or in closure argument types in code completion.
 - Implement type parsing support for the new inout syntax (before we just 
   handled patterns).
 - Switch the last couple of uses in the stdlib (in types) to inout.
 - Various testcase updates (more to come).



Swift SVN r13564
2014-02-06 06:22:27 +00:00
Mark Lacey
d335817783 Revert "Generate arguments with the correct ABI types for C/Obj-C functions."
This reverts commit r13532 which broke the build.

Swift SVN r13547
2014-02-06 02:07:17 +00:00
Mark Lacey
fd8e10fa68 Generate arguments with the correct ABI types for C/Obj-C functions.
This gets us a bit closer to properly generating the correct types for
arguments. The remaining piece is generating all the argument types at
once rather than one at a time.

That part cannot happen until we can always generate Clang types for
the Swift types we see in the signatures of these functions.

Swift SVN r13532
2014-02-06 01:06:32 +00:00
Mark Lacey
0d62463ce3 Revert "Refactor argument emission for apply. NFC."
This was r13282, and it turned out to be unnecessary.

Swift SVN r13490
2014-02-05 18:44:35 +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
Mark Lacey
03d5cb233f Refactor argument emission for apply. NFC.
Split out argument emission into a function that handles calling into
Swift calling convention functions and a function that handles
foreign ("external") calling conventions.

The emission for foreign calling conventions simply falls back on the
one for Swift calling conventions at the moment, i.e. there is no change
in behavior yet.

Swift SVN r13282
2014-02-01 02:36:38 +00:00
Mark Lacey
52ae907e5d Remove unused SILValue.
Swift SVN r13209
2014-01-31 09:41:07 +00:00
Joe Groff
53ed008acb IRGen: Add an "unimplemented" error when trying to call ObjC blocks.
Beats crashing.

Swift SVN r13083
2014-01-29 01:32:29 +00:00
Adrian Prantl
0b40f0bda3 Debug info: Use a small dense map to keep track of argument numbers.
Swift SVN r12872
2014-01-23 19:46:33 +00:00
Adrian Prantl
7468054191 Debug info: Emit O0 shadow copies more consistently for (most) debuggable
values.

Swift SVN r12803
2014-01-22 22:42:07 +00:00
Adrian Prantl
69c58421ec Debug info: emit alloca shadow copies for DebugValues at -O0.
<rdar://problem/15849532> iteration variables in "for X in Y" statements don't have debug information

Swift SVN r12675
2014-01-21 23:58:37 +00:00
Joe Groff
2af8cf2343 IRGen: Use interface types to lower ApplyInst args and returns, and SILFunction parameters and returns.
Swift SVN r12626
2014-01-21 00:23:07 +00:00
Joe Groff
0ad29a86dd IRGen: Emit unconditional casts as bitcasts when runtime checks are disabled.
Swift SVN r12602
2014-01-20 18:47:12 +00:00
John McCall
11bd9bbbd9 Prune unnecessary #includes.
Swift SVN r12429
2014-01-16 22:32:36 +00:00
Doug Gregor
3a6db8292e Revert "Introduce the self_downcast SIL instruction to downcast the result of super.init."
We need to model the difference between Objective-C- and Swift-rooted
class hierarchies in SIL. IRGen is too late to handle nil returns.

This reverts commit 549db981ea0136a67aee3029aefe18a05d3c8833.

Swift SVN r12400
2014-01-16 06:01:21 +00:00
Doug Gregor
d59cf64dbf Revert "self_downcast never deals in address-only types."
This reverts commit a877f20420b14a7f053d6496d43b20689631ac4b.

Swift SVN r12399
2014-01-16 06:01:19 +00:00
Doug Gregor
8647c3c295 Revert "For Swift-rooted class hierarchies, emit self_downcast as a bitcast."
This reverts commit fb1ed53c039a46aa501734948e417a4dfbc86f69.

Swift SVN r12398
2014-01-16 06:01:18 +00:00
Doug Gregor
a6148459ef Revert "Simplify the emission of self_downcast. NFC"
This reverts commit d674023b0d5e4e7e058cc8b6275d2bad569fbf80.

Swift SVN r12397
2014-01-16 06:01:17 +00:00
Doug Gregor
9dfa5171a9 Simplify the emission of self_downcast. NFC
Swift SVN r12396
2014-01-16 06:01:13 +00:00
Doug Gregor
0c554b77da For Swift-rooted class hierarchies, emit self_downcast as a bitcast.
Swift-rooted class hierarchies don't permit the replacement of "self",
so it's guaranteed that the 'self' returned from a 'super.init'
invocation is identical to the previous self. Elide the unconditional
checked downcast (that manifests as a call to
swift_dynamicCastClassUnconditional in the runtime) by simply putting
a bitcast in its place.

For Objective-C-rooted hierarchies, 'self' can be replaced so memory
safety dictates that we keep the
swift_dynamicCastClassUnconditional(). Note that this path is still
unsafe against nil returns.

Swift SVN r12384
2014-01-16 04:24:59 +00:00
Doug Gregor
4abc10f2f4 self_downcast never deals in address-only types.
Swift SVN r12383
2014-01-16 04:24:59 +00:00
Doug Gregor
d19065048b Introduce the self_downcast SIL instruction to downcast the result of super.init.
No functional difference from the unconditional checked downcast we
had before, but this gives IRGen the chance to specialize the
implementation.

Swift SVN r12382
2014-01-16 04:24:56 +00:00
John McCall
a1b469ed2f ExplosionKind -> ResilienceExpansion. NFC.
Swift SVN r12364
2014-01-16 00:25:29 +00:00
Joe Groff
677576cffb IRGen: Use a shared bb for condfail instructions and kill the runtime call.
Swift SVN r12339
2014-01-15 19:33:01 +00:00
Adrian Prantl
7f28907cae Reapply r12201 and r12289 with a workaround that does not crash when
the location of a DebugValueInst is not a Decl.
FIXME: This should probably not happen <rdar://problem/15825786>.


This reverts commit 12323 + bugfix.

Swift SVN r12332
2014-01-15 18:05:51 +00:00
Joe Groff
56128aca65 IRGen: Don't emit a trap for SIL 'unreachable'.
Missing return diagnostics are mature now, so a SIL 'unreachable' that makes it to IRGen should be legitimately unreachable now.

Swift SVN r12329
2014-01-15 17:42:03 +00:00
Greg Parker
a9697b308e Revert r12201 and r12289 because they crash in the stdlib -O0 build.
Swift SVN r12323
2014-01-15 07:41:04 +00:00
Adrian Prantl
bc084d7962 Debug info: Implement IRGen support for debug_value_addr.
rdar://problem/15785053.s

Swift SVN r12289
2014-01-14 18:21:39 +00:00
Doug Gregor
68e416bb21 SIL: Zap the unused "coerce" instruction.
The coercion doesn't represent anything interesting for SIL.


Swift SVN r12261
2014-01-13 23:50:12 +00:00