Commit Graph

308 Commits

Author SHA1 Message Date
John McCall
05b51f4fa7 Add some utilities for parsing verbatim identifiers and AST types.
Swift SVN r18933
2014-06-16 17:35:42 +00:00
John McCall
1fed3121ad Allow arbitrary keywords to be used in SIL identifiers.
Swift SVN r18932
2014-06-16 17:35:41 +00:00
Doug Gregor
5bb6969af3 Type checker support for dictionary downcasting.
This is the semantic-analysis portion of <rdar://problem/16847470>.


Swift SVN r18900
2014-06-14 18:27:38 +00:00
Nadav Rotem
bb0438f27b [Early Binding of Virtual Calls] Add a new kind of unconditional_checked_cast: Identical cast. This cast checks that the class that we inspect is exactly the type we expect, and not a subclass of that type.
Swift SVN r18859
2014-06-13 06:15:14 +00:00
Bob Wilson
2df66cf8c4 Implement inline scopes for the performance inliner.
Mandatory-inlined (aka transparent functions) are still treated as if they
had the location and scope of the call site. <rdar://problem/14845844>
Support inline scopes once we have an optimizing SIL-based inliner

Patch by Adrian Prantl.

Swift SVN r18835
2014-06-12 19:48:43 +00:00
Joe Groff
1f1c00cf9e SIL: Add instructions to convert metatypes to object references.
Add objc_metatype_to_object and objc_existential_metatype_to_object to convert metatypes to AnyObject, and objc_protocol to get a reference to an @objc protocol descriptor as a Protocol class instance.

Swift SVN r18824
2014-06-12 05:34:03 +00:00
Manman Ren
4847208815 [SILParser] correctly handles protocol_method on a getter.
Before this commit, SILParser will assert with message
"Can't find a member with the right type".


Swift SVN r18792
2014-06-10 23:43:34 +00:00
John McCall
f5749cc037 Track the consumption behavior of the new indirect-cast
instructions.

Swift SVN r18785
2014-06-10 22:27:56 +00:00
John McCall
0f0874bb4b Add variants of the checked-cast instructions that
put the result in a different place.

WIP: no IRGen support yet.

This will eventually be the required form when casting
to an address-only type; the existing instructions will
have only scalar outputs.

Swift SVN r18780
2014-06-10 07:43:22 +00:00
Manman Ren
06ed1162c0 [SILParser] parse apply substitutions with conformances.
SILPrinter does not print the conformances in the substitution, instead in
SILParser we try to construct the conformances by looking them
up from replacement type.

rdar://16375832


Swift SVN r18440
2014-05-20 00:16:17 +00:00
Michael Gottesman
66e35bb191 [sil-parser] Call default Substitution Constructor so we initialize an ArrayRef<Conformance> correctly.
Swift SVN r18235
2014-05-17 03:48:36 +00:00
Manman Ren
9b2aee5b14 [SILParser] parse inherited protocol conformance in sil_witness_table.
We currently do not emit inherited protocol conformance in sil_witness_table,
when building swift.

rdar://15722175


Swift SVN r18127
2014-05-15 21:17:53 +00:00
Manman Ren
8685b295c4 [SILParser] parse specialized protocol conformance in sil_witness_table.
Also parsing generic param list in protocol conformance.

rdar://15722175


Swift SVN r18122
2014-05-15 19:53:21 +00:00
Manman Ren
866f306e62 [SILParser] refactor handleSILGenericParams to prepare patches for parsing.
No functionality change.
Change signature of handleSILGenericParams to get ready for patches on parsing
specialized protocol conformance in sil_witness_table.

rdar://15722175


Swift SVN r18117
2014-05-15 18:27:50 +00:00
Doug Gregor
c41f0e01ce Make # a real punctuator.
Swift SVN r17980
2014-05-13 00:03:01 +00:00
Joe Pamer
1e5b9116d4 More array casting work:
- Continue adding support for checked downcasts of array types (rdar://problem/16535104)
- Fix non-bridged array conversions post-r17868
- Fix rdar://problem/16773693
- Add tests for NSArray coercions to and from Array<T>

Swift SVN r17957
2014-05-12 20:49:42 +00:00
Chris Lattner
d83289cb49 the 'destructor' keyword got renamed to 'deinit' a long time ago, remove
parsing and fixit support for 'destructor'.


Swift SVN r17361
2014-05-04 04:28:25 +00:00
Joe Groff
3b4a9d2ba5 Add a 'conditionallyUnreachable' builtin.
This builtin only becomes unreachable when assert_configuration calls have been folded, allowing library-level checks to become unreachable based on the assert level.

Swift SVN r17322
2014-05-03 19:41:40 +00:00
Manman Ren
7140f46889 [SILParser] teach SILParser to handle multiple results when looking up a member of an enum.
When enum is defined inside a class, looking up a member of the enum can return
multiple results, one of them is the enum itself. Teach SILParser to find
the correct result.

rdar://16764223


Swift SVN r17292
2014-05-03 00:07:35 +00:00
Joe Groff
7d274e28a7 SIL: Add an unchecked_addr_cast instruction.
Cast an address to another address type without the silly address_to_pointer/pointer_to_address round trip.

Swift SVN r16743
2014-04-24 04:14:48 +00:00
Joe Groff
68f942117a SIL: Squash 'ref_to_native_object' and 'native_object_to_ref' into one 'unchecked_ref_cast' insn.
An unsafe cast from a base to a derived class isn't really all that different from one from Builtin.NativeObject to an arbitrary class, so relax this pair of instructions to allow an arbitrary bitcast. This only combines the instructions; it doesn't attempt to simplify any codegen that was emitting round-trip casts before yet.

Swift SVN r16736
2014-04-24 03:10:53 +00:00
Joe Groff
285ec1e2dd SIL: Add an unchecked_enum_data instruction.
This allows the payload for a loadable enum to be unsafely projected without branching, enabling more enum optimizations when switch branches can be culled or when indirect enum code can be promoted.

Swift SVN r16729
2014-04-24 00:41:08 +00:00
Joe Groff
55f6b925de SIL: Rename 'take_enum_data_addr' to 'unchecked_take_enum_data_addr'.
In preparation for adding an 'unchecked_enum_data' equivalent for loadable enums.

Swift SVN r16728
2014-04-24 00:40:47 +00:00
John McCall
b38a63950d Implement @unowned(unsafe).
This was part of the original weak design that
there was never any particular reason to rush the
implementation for.  It's convenient to do this now
so that we can use it to implement Unmanaged<T> for
importing CF types.

Swift SVN r16693
2014-04-23 08:51:23 +00:00
Andrew Trick
f58ebbc251 Add a global_init attribute to SILFunction.
The implied semantics are:
- side-effects can occur any time before the first invocation.
- all calls to the same global_init function have the same side-effects.
- any operation that may observe the initializer's side-effects must be
  preceded by a call to the initializer.

This is currently true if the function is an addressor that was lazily
generated from a global variable access. Note that the initialization
function itself does not need this attribute. It is private and only
called within the addressor.

Swift SVN r16683
2014-04-23 01:09:47 +00:00
John McCall
8681963bcb A couple of long-overdue renames.
Builtin.ObjectPointer -> Builtin.NativeObject
Builtin.ObjCPointer -> Builtin.UnknownObject

Swift SVN r16634
2014-04-22 00:17:08 +00:00
Joe Groff
dcad7fb248 SIL: Add an autorelease_value instruction.
Give us a way to formally represent autoreleases in SIL separate from autoreleased returns, allowing us to lifetime-extend inner pointer parameters the lazy way and hopefully clean up some asmname hacks in the stdlib implementation too.

Swift SVN r16632
2014-04-21 23:11:38 +00:00
Joe Groff
eaa6088102 SIL: Remove the now-obsolete bridge_to_block instruction.
Swift SVN r16487
2014-04-18 02:26:10 +00:00
Manman Ren
1b8087cf5d [SILParser] Handle overloaded members for protocol_method and dynamic_method.
We print the AST type for the member when printing SILDeclRef for
protocol_method and dynamic_method. The AST type can be polymorphic, so parsing
of PolymorphicFunctionType is added to the Parser. Also add parsing "inout"
right before an identifier type. "inout" was parsed only in parseTypeTupleBody.

rdar://15763213


Swift SVN r16460
2014-04-17 17:56:57 +00:00
Joe Groff
2312d1fea4 SIL: Parse @block_storage attribute positionally.
We want to model block invoke functions as taking the address of their @block_storage directly, so resolve @block_storage as part of type repr resolution, allowing it to appear as a parameter of a SIL function type.

Swift SVN r16370
2014-04-15 15:16:08 +00:00
Joe Groff
acdc425dfb SIL: Add instructions to initialize and project block storage.
Add project_block_storage, to project the capture storage from within a block_storage, and init_block_storage_header, to represent filling out the block header.

Swift SVN r16358
2014-04-15 04:48:34 +00:00
Joe Groff
f7cf592777 Add a SIL-only '@block_storage T' type to represent on-stack storage for blocks.
Blocks need to be born on the stack, so we need a way to represent that on-stack storage. @block_storage T will represent the layout of a block that contains storage for a capture of type T.

Swift SVN r16355
2014-04-15 03:56:09 +00:00
Manman Ren
7e31d0c0ad SILParser: use '"' around operator name when printing SILDeclRef.
This enables parsing SILDeclRef with an operator name.
One example is #AnyProtocol."<~>"!1, we will drop the double quotes when
parsing the dotted path.


Swift SVN r16082
2014-04-08 23:50:59 +00:00
Joe Groff
fd9a9b5881 SIL: Add a CopyBlockInst instruction.
This maps down to a _Block_copy call that gives us the result, which may be different from the original object, back.

Swift SVN r16042
2014-04-08 02:43:17 +00:00
Manman Ren
9ce381f1fc SILParser: a decl in witness table can be from other modules.
Also fix operator as part of a SILDeclRef e.g "Equatable.==!".

rdar://16503632


Swift SVN r15951
2014-04-04 20:04:49 +00:00
Chris Lattner
afea47b621 rename "destroy_value" to "release_value", part of rdar://15889208.
Swift SVN r15777
2014-04-02 05:33:52 +00:00
Chris Lattner
a0a65c0ea2 change the sil parser/printer to use retain_value instead of copy_value.
Swift SVN r15776
2014-04-02 05:22:41 +00:00
Chris Lattner
6540423613 rename CopyValueInst -> RetainValueInst. The .sil syntax
isn't changed yet.


Swift SVN r15775
2014-04-02 05:11:31 +00:00
Joe Groff
afd59130f0 SIL: Add a FixLifetime instruction.
This will be a signal to ARC optimization, RVO, and other lifetime-affecting optimizations that they should not shorten the lifetime of a value past a certain point. We need this for C pointer bridging. This adds the instruction, but does not add any knowledge of it to the ARC optimizers.

Swift SVN r15601
2014-03-29 02:50:34 +00:00
Manman Ren
ea319984fd SILParser: handle overloaded members for super_method.
rdar://15763213


Swift SVN r15469
2014-03-25 22:35:02 +00:00
Manman Ren
91a2eef1d3 SILParser: parsing generic code.
We parse the substitution of [Partial]ApplyInst as AST type to fix type
mismatch issues between SILFunctionType and FunctionType.

With this commit, we can parse the sil file generated from
"-emit-silgen optional.swift".

rdar://14443287


Swift SVN r15246
2014-03-19 20:35:05 +00:00
Manman Ren
8e64b2a170 SILParser: parsing generic code.
Do not print '.Archetype' property of Substitution in SILPrinter.
Update testing cases accordingly.

We assume the order of substitions matchs the order of AllArchetypes for
the generic param list.

rdar://14443287


Swift SVN r15090
2014-03-14 23:13:55 +00:00
Chris Lattner
bc19a383b5 move recordDecl lower in the file, and turn a check for !->hasName() into ->isAccessor(),
fixing a FIXME.  NFC.


Swift SVN r15039
2014-03-14 06:03:40 +00:00
John McCall
3dab4a7be0 Add missing include for SWIFT_FALLTHROUGH.
Swift SVN r15036
2014-03-14 05:59:41 +00:00
Ted Kremenek
c87ac8167a Use SWIFT_FALLTHROUGH instead of [[clang::fallthrough]].
Swift SVN r15028
2014-03-14 05:15:05 +00:00
Ted Kremenek
39a368f0ec Add [[clang::fallthrough]] in obvious cases to satisfy -Wimplicit-fallthrough.
Swift SVN r15018
2014-03-14 00:34:25 +00:00
Manman Ren
7afc067819 SILParser: parsing generic code.
The '.Archetype' property of Substitution is not used and SILPrinter
prints a different name for Substitution and for the generic param list.

The fix is to ignore the '.Archetype' property in SILParser and instead
to match up Substitution with the archetype by ordering alone.

The silgen output from generic_closures.swift can now be parsed with SILParser
with changes:
  typealias Int = Int64 to typealias Int = Builtin.Int64
  typealias Char = Int32 to typealias Char = Builtin.Int32
Without the changes, SILParser will complain about mismatching Int64
with Builtin.Int64.

The next step is for SILPrinter to not print '.Archetype' property of
Substitution. The majority of work is updating testing cases.

rdar://14443287


Swift SVN r15014
2014-03-14 00:20:14 +00:00
Michael Gottesman
5b88963e78 [SIL] Implement external SIL Witness Table declarations.
This will help with ensuring that we do not create multiple witness
table "definitions" one of which is null. That situtation yields an
IRGen assertion to be hit since the external declaration (in the guise
of a definition) has a different type from the actual deserialized
definition.

Swift SVN r14999
2014-03-13 19:52:59 +00:00
Manman Ren
58b0d61bbb SILParser: use a Scope for generic parameters.
This will fix the scoping issue for generic paremeters in SILType.
We use a Generics scope when parsing generic paremters of a SILType, after
we are done parsing the type, we delete the Generics scope.

Testing case will be added when SILParser can correctly handle generic code.

rdar://14443287


Swift SVN r14998
2014-03-13 19:34:04 +00:00
Manman Ren
e716023bc3 SILParser: handle overloaded members in SILDeclRef.
The problem is that SILDeclRef::print does not print enough information
for SILParser to find the correct Decl when there are overloading members.

This commit handles the case for class_method. We print type information for
the SILDeclRef together with the SILFunctionType separated by a comma.

SILParser then use the type information to disambiguate the overloaded
methods.

rdar://15763213


Swift SVN r14994
2014-03-13 17:52:47 +00:00