Commit Graph

292 Commits

Author SHA1 Message Date
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
Manman Ren
3a95cfc128 SILPrinter & SILParser: update both and testing cases to match SIL.rst.
For struct_extract and struct_element_addr, we now print %7 : $M, #M.member
instead of %7 : $M, #member

rdar://15810604


Swift SVN r14960
2014-03-12 18:07:48 +00:00
Manman Ren
b96ddf48d6 SILParser: parsing GenericParamList.
To parse GenericParamList in SILParser, we try to share code with TypeChecker.
We add handleSILGenericParams in Subsystems.h in order for SILParser to call
TypeChecker's handling of GenericParamList (this is motivated by the example of
SILParser calling performTypeLocChecking). handleSILGenericParams calls
checkGenericParamList and finalizeGenericParamList.

A Builder field (ArchetypeBuilder*) is added to GenericParamList so we can add
the same-type requirements to GenericSignature in getAsCanonicalGenericSignature
by checking SameTypeRequirements of the builder.

resolvePotentialArchetypeToType is moved from a static helper function in
TypeCheckGeneric.cpp to a public helper function in ArchetypeBuilder.cpp.
When constructing the same-type requirements in getAsCanonicalGenericSignature,
we will call it to convert from PotentialArchetype to a dependent type.

rdar://16238241


Swift SVN r14922
2014-03-11 18:01:01 +00:00
Manman Ren
37ea7f9d4b SILPrinter & SILParser: update both and testing cases to match SIL.rst.
For ref_element_addr, we now print
ref_element_addr %7 : $M, #M.member
instead of
ref_element_addr %7 : $M, #member

rdar://15810604


Swift SVN r14899
2014-03-11 00:25:51 +00:00
Joe Groff
945fbaf167 SIL: Add a linkage specifier to SILWitnessTables.
In the short term, we need to be able to emit shared symbols for SILWitnessTables corresponding to Clang-imported modules, and soon, the generic specializer will need to be able to reference *_external witness tables deserialized from library modules.

Swift SVN r14887
2014-03-10 23:14:16 +00:00
Doug Gregor
82c1ba2e29 Remove peer_method instruction; we're no longer using it.
Swift SVN r14599
2014-03-03 17:13:06 +00:00
Doug Gregor
5d8bd84dfa Introduce the SIL instruction alloc_ref_dynamic.
alloc_ref_dynamic allocates an instance of a class type based on the
value in its metatype operand. Start emitting these instructions for
the allocating constructor of a complete object initializer (not yet
tested) and for the allocating constructor synthesized for an imported
Objective-C init method.

Still missing:
  - IRGen still does the same thing as alloc_ref right now. That
  change will follow.
  - There are devirtualization opportunities when we know the value of
  the metatype that would turn an alloc_ref_dynamic into an alloc_ref;
  I'm not planning to do this optimization.



Swift SVN r14560
2014-03-01 21:55:50 +00:00
Joe Groff
67ca7ce1e9 SIL: Rename 'protocol_metatype' to 'existential_metatype'.
It's not forming the metatype for the protocol type (exists t: P. t).metatype, it's forming the existential of a metatype of a conforming type, exists t: P. (t.metatype).

Swift SVN r14520
2014-02-28 16:14:00 +00:00
Joe Groff
88b6efcc43 Rename ArchetypeMethodInst -> WitnessMethodInst more thoroughly.
Swift SVN r14501
2014-02-28 06:41:18 +00:00
Joe Groff
9424de6787 SIL: Rename 'archetype_metatype' to 'value_metatype'.
Since it can grab a metatype from any value now.

Swift SVN r14500
2014-02-28 06:33:05 +00:00
Joe Groff
545f173507 SIL: Fold 'archetype_metatype' and 'class_metatype'.
Having one instruction to get the dynamic metatype of a (non-existential) value makes more sense from a generic specialization standpoint and should stave off inevitable crashers when archetype_metatypes get specialized. protocol_metatype remains separate because metatype existentials are more interesting.

Swift SVN r14499
2014-02-28 06:32:58 +00:00
Joe Groff
59d2a169f6 SIL: Rename 'archetype_method' to 'witness_method'.
It has been generalized to get a witness out of an arbitrary protocol conformance, not just for archetypes.

Swift SVN r14497
2014-02-28 05:09:11 +00:00
Joe Groff
855ea99063 SIL: Combine 'archetype_ref_to_super' and 'upcast'.
We were wantonly applying 'upcast' to archetypes in some cases, and really, that's OK, since these instructions do the same thing (and generic specialization could turn archetype_ref_to_super into upcast). Make everyone's life easier by folding archetype_to_super into upcast. Fixes <rdar://problem/16192324>.

Swift SVN r14496
2014-02-28 04:33:18 +00:00
Doug Gregor
981f8f6509 Rename "destructor" -> "deinit" (as a keyword) and -> "deinitializer" (in diagnostics).
Swift SVN r14380
2014-02-26 05:51:45 +00:00
Joe Pamer
988a5877f2 Some updates:
- Respond to Doug's code review feedback
   - Stop hacking around with scopes and use "emplace" to work around RAII in the inactive config case
   - Limit use of StringRef on the front-end, in favor of std::string
   - Use ArrayRef rather than SmallVector within IfConfigDecl
   - Reorder new property declarations on BraceStmt to prevent unnecessary alignment issues
- Update ParseBraceItems to better capture top-level declarations, rather than using token lookahead

Swift SVN r14306
2014-02-24 18:16:49 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Michael Gottesman
b2abd4047b [sil-parse][sil-deserialize] Teach the SIL Parser/Deserializer to use the
lowered field type of a ref_element_addr's parent projection, rather than using
the unlowered siltype generated via creating a SILType from the field's
vardecl.

Swift SVN r14294
2014-02-24 04:01:45 +00:00