Commit Graph

111 Commits

Author SHA1 Message Date
Jordan Rose
e05c03d5bc Standardize terminology for "computed", "stored", "variable", and "property".
These are the terms sent out in the proposal last week and described in
StoredAndComputedVariables.rst.

variable
  anything declared with 'var'
member variable
  a variable inside a nominal type (may be an instance variable or not)
property
  another term for "member variable"
computed variable
  a variable with a custom getter or setter
stored variable
  a variable with backing storage; any non-computed variable

These terms pre-exist in SIL and IRGen, so I only attempted to solidify
their definitions. Other than the use of "field" for "tuple element",
none of these should be exposed to users.

field
  a tuple element, or
  the underlying storage for a stored variable in a struct or class
physical
  describes an entity whose value can be accessed directly
logical
  describes an entity whose value must be accessed through some accessor

Swift SVN r8698
2013-09-26 18:50:44 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +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
Joe Groff
4851b89a3c IRGen: Handle argument bound generic abstraction differences for address-only unsubstituted types.
Handle the easy bound generic type abstraction difference case, where the original unsubstituted type is address-only, and we just need to emit a loadable substituted type to a temporary buffer or bitcast an already address-only substituted type.

Swift SVN r8265
2013-09-15 02:42:01 +00:00
Doug Gregor
7c84fd5926 Start detangling archetypes from the interface of generic functions.
This breaks the type-canonicalization link between a generic parameter
type and the archetype to which it maps. Generic type parameter types
are now separate entities (that can eventually be canonicalized) from
archetypes (rather than just being sugar).

Most of the front end still traffics in archetypes. As a step away
from this, allow us to type-check the generic parameter list's types
prior to wiring the generic type parameter declarations to archetypes,
using the new "dependent" member type to describe assocaited
types. The archetype builder understands dependent member types and
uses them to map down to associated types when building archetypes.

Once we have assigned archetypes, we revert the dependent identifier
types within the generic parameter list to an un-type-checked state
and do the type checking again in the presence of archetypes, so that
nothing beyond the generic-parameter-list checking code has to deal
with dependent types. We'll creep support out to other dependent types
elsewhere over time.



Swift SVN r7462
2013-08-22 18:07:40 +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
John McCall
eaa6228124 getFragileTypeInfo -> getTypeInfo
I didn't end up going the same way with fragility that I
thought I would at start, and this method name has become a
legacy.

Swift SVN r7340
2013-08-19 23:01:44 +00:00
John McCall
7ec0f84e33 Demote most of the Explosion routines on TypeInfo to
the new LoadableTypeInfo refinement interface.

This protects against bugs which would introduce unbalanced
allocations of temporary memory.

Swift SVN r7227
2013-08-14 07:19:52 +00:00
John McCall
e9b913fb5b Remove LocalStorageType, make it a kind of SILType.
Swift SVN r6968
2013-08-07 00:22:26 +00:00
John McCall
36aa6c2645 alloc_stack needs to return two values like alloc_box.
The current implementation of dealloc_stack in IR-gen is a
no-op, but that's very much wrong for types with non-trivial
local allocation requirements, e.g. archetypes.  So we need
to be able to do non-trivial code here.  However, that means
modeling both the buffer pointer and the allocated address
in SIL.

To make this more type-safe, introduce a SIL-specific
'[local_storage] T' type that represents the required
allocation for locally storing a T.  alloc_stack now returns
one of those in additon to a *T, and dealloc_stack expects
the former.

IR-gen still implements dealloc_stack as a no-op, but
that's now easy to fix.

Swift SVN r6937
2013-08-06 07:31:41 +00:00
John McCall
e3584068e8 Distinguish the allocation cases in IR-gen.
This gives us a more convenient type for allocateStack
and eliminates some unnecessary redundancy.

Swift SVN r6935
2013-08-06 07:31:36 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Joe Groff
f866e5af25 Revert "IRGen: Pass existentials as generic parameters by unwrapping the container."
This reverts commit r6350. We don't imminently need this and intend to do it right soon.

Swift SVN r6605
2013-07-25 18:38:14 +00:00
John McCall
69b64a09ce More canonical type preserving.
Swift SVN r6377
2013-07-19 07:08:38 +00:00
John McCall
4b4e7d0833 Eliminate SIL and IR-gen's TypeVisitor specializations in
favor of a new AST-level one, and exploit it.

Swift SVN r6376
2013-07-19 07:08:34 +00:00
Joe Groff
5fe164df07 IRGen: Pass existentials as generic parameters by unwrapping the container.
When an existential's contained type is used as a generic parameter, unwrap the existential container and save its metadata and witnesses to be used as polymorphic arguments.

Our AST representation can't quite express the distinction between a type parameter being satisfied by the existential type itself from being satisfied by the existential's contained yet. I use a goofy heuristic where I assume a protocol type bound to a type variable with no requirements is satisfied by the protocol type itself; this covers all of the existing <T> (Slice<T>, T) cases that come up in the library, while enabling the <T:Foo> (T) cases. This hopefully addresses <rdar://problem/14470097> well enough to unblock library work until we get a solid AST representation of this difference.

Swift SVN r6352
2013-07-18 19:09:19 +00:00
John McCall
18a9290cbe Add ReferenceStorageType.
The idea for now is that this is a SIL-only type used for
representing the storage of a weak or unowned reference.
Having it be its own type is pretty vital for reasonable
behavior in SIL and IR-generation, and it's likely that
this will surface into runtime metadata as well (hence
the mangling).

I've implemented a bunch of things that technically I don't
think are necessary if this stays out of the typechecker,
but it's easier to implement half-a-dozen "recurse into
the child type" methods now that it would be to find them
all later if we change our minds.

Swift SVN r6091
2013-07-09 08:37:40 +00:00
Joe Groff
f072c48e45 Refactor cast representation in AST and SIL, and implement 'is'.
Improve our representations of casts in the AST and SIL so that 'as!' and 'is' (and eventually 'as?') can share almost all of the same type-checking, SILGen, and IRGen code.

In the AST, we now represent 'as!' and 'is' as UnconditionalCheckedCastExpr and IsaExpr, respectively, with the semantic variations of cast (downcast, super-to-archetype, archetype-to-concrete, etc.) discriminated by an enum field. This keeps the user-visible syntactic and type behavior differences of the two forms cleanly separated for AST consumers.

At the SIL level, we transpose the representation so that the different cast semantics get their own instructions and the conditional/unconditional cast behavior is indicated by an enum, making it easy for IRGen to discriminate the different code paths for the different semantics. We also add an 'IsNonnull' instruction to cover the conditional-cast-result-to-boolean conversion common to all the forms of 'is'.

The upshot of all this is that 'x is T' now works for all the new archetype and existential cast forms supported by 'as!'.

Swift SVN r5737
2013-06-21 05:54:03 +00:00
Joe Groff
a55f246946 Remove the controversial "bounded" from "class-bounded".
Just refer to "class archetypes" and "class protocols". Change 'isClassBounded' methods to 'requiresClass', which is a character shorter.

Swift SVN r5674
2013-06-19 03:58:11 +00:00
Joe Groff
56a4220eeb IRGen: Use superclass repr and refcount for superclass archetypes.
If an archetype has a superclass bound, we can assume the superclass's
retain semantics for the type. We can also use the superclass's storage pointer type to cut down on some bitcast IR noise when calling superclass methods on the archetype value.

Swift SVN r5642
2013-06-18 03:42:27 +00:00
Joe Groff
ff5f41b5f0 Archetypes with superclass bounds are class-bounded.
Treat archetypes with a superclass bound as class-bounded. Change SILGen and IRGen to use the new SuperToArchetypeRef and ArchetypeRefToSuper cast instructions, and drop the old SuperToArchetype and ArchetypeToSuper instructions, which are unneeded because any archetype with a superclass will be class-bounded.

Note that this patch doesn't implement representation optimization for archetypes with superclass bounds--they're still always represented with a worst-case UnknownRefCountedPtrTy.

Swift SVN r5629
2013-06-17 21:54:01 +00:00
Joe Groff
087803f5b0 IRGen: Implement type info for class-bounded archetypes.
Split ArchetypeTypeInfo into ClassBoundedArchetypeTypeInfo, for class-bounded archetypes, and OpaqueArchetypeTypeInfo, for fully generalized archetypes (the existing case). ClassBoundedArchetypeTypeInfo is represented using a single refcounted ObjCPointer. Implement abstraction remapping from class instances to class-bounded archetypes and back, and from class-bounded archetypes to non-class-bounded and back.

Witness tables are still generated only for opaque archetypes, so method calls on class-bounded archetypes won't work just yet.

Swift SVN r5569
2013-06-11 00:19:34 +00:00
Joe Groff
285031cc8c IRGen: Use SILTypes for utility functions used by conversion insns.
Push SILTypes down into the helper functions used to emit SuperToArchetype, Downcast, and BridgeToBlock instructions.

Swift SVN r5189
2013-05-16 22:31:46 +00:00
Jordan Rose
ca498e04ef More -Wdocumentation cleanup.
Swift SVN r5167
2013-05-13 21:41:28 +00:00
Chris Lattner
d2a8cffd9c remove an unneeded #include and some llvm:: qualifiers
Swift SVN r4966
2013-04-28 16:07:19 +00:00
Joe Groff
0566088bf2 Move name mangling into SIL.
Sever the last load-bearing link between SILFunction and SILConstant by naming SILFunctions with their mangled symbol names. Move the core of the mangler up to SIL, and teach SILGen how to use it to mangle a SILConstant.

Swift SVN r4964
2013-04-28 03:32:41 +00:00
John McCall
24c55531ea Promote emitTypeMetadataRef to being "top-level" IGF API.
Swift SVN r4920
2013-04-26 18:48:33 +00:00
Chris Lattner
2b6902b232 eliminate the "manage" operation on TypeInfo, which is now a (complicated!) noop.
Swift SVN r4850
2013-04-21 16:27:43 +00:00
Chris Lattner
85663f6df2 simplify Explosion by eliminating (now) copies of existing methods.
This removes addUnmanaged, ignoreAndDestroy, ignoreUnmanaged, claimUnmanagedNext,
claimUnmanaged, forwardNext, and forward


Swift SVN r4846
2013-04-21 06:29:50 +00:00
Chris Lattner
9ae0cf3bee inline Initialization::emitLocalAllocation into each of its callers and
eliminate the Initialization class and GenInit.h.  GenInit.cpp will stay
around, as it has some other random stuff in it.


Swift SVN r4845
2013-04-21 06:13:59 +00:00
Chris Lattner
d523932d85 remove InitializedObject.
Swift SVN r4844
2013-04-21 06:05:01 +00:00
Chris Lattner
0be7bbdddf remove ManagedValue.
Swift SVN r4843
2013-04-21 05:56:02 +00:00
Chris Lattner
510042f939 removed the registration logic from Initialization and Depth from Scope.
Swift SVN r4842
2013-04-21 05:39:35 +00:00
Chris Lattner
e8686c9560 remove Cleanups from IGF, simplify Initialization a bit.
Swift SVN r4841
2013-04-21 05:28:04 +00:00
Chris Lattner
6e50329da3 remove the cleanups list from CallEmission and ManagedValue, along with the machinery for adding Cleanups.
Swift SVN r4840
2013-04-21 05:16:00 +00:00
Chris Lattner
abee79b26e remove some Expr stuff.
Swift SVN r4810
2013-04-18 22:32:37 +00:00
Joe Groff
d1a04c92a7 IRGen: Kill dead emitSupertoArchetype overload.
Swift SVN r4805
2013-04-18 15:28:13 +00:00
Chris Lattner
fa168e15a9 remove emitRValueAsUnsubstituted and some related logic. Once I get this deep, it
seems that this is not a good idea, because it seems statically live from the SIL
SuperToArchetypeInst.  However, apparently nothing in the testsuite exercises
this code, so I'll need to discuss and a testcase to know how much logic needs
to be ressurrected from SVN.  rdar://13681541



Swift SVN r4800
2013-04-18 05:41:20 +00:00
Chris Lattner
a7748f61ae remove emitRValue, which is dead, at least dynamically according to our testsuite.
Swift SVN r4799
2013-04-18 05:33:40 +00:00
Chris Lattner
1abf1d0ebc remove RValueEmitter and some implementation logic for it, as well as
FullExpr.  Scope is kept alive by one dangling thread, rdar://13681467


Swift SVN r4798
2013-04-18 05:24:50 +00:00
John McCall
8fe4246833 Hide StorageSize/Alignment behind accessors in preparation for moving
them to a subclass.

Swift SVN r4779
2013-04-17 21:55:41 +00:00
Joe Groff
7dde07cfd3 IRGen: Lower SIL ArchetypeToSuper (and v.v.).
Swift SVN r4747
2013-04-15 23:32:46 +00:00
Joe Groff
328b788a92 IRGen: Fix ReemitAsUnsubstituted for leaf types.
Values should go from 'In' to 'Out', not the other way.

Swift SVN r4609
2013-04-05 18:03:39 +00:00
Joe Groff
3f81dfef15 IRGen: Implement 'x is T' for archetype T.
<rdar://problem/13530695> blocks this from actually working yet.

Swift SVN r4523
2013-03-28 22:18:17 +00:00
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +00:00
Doug Gregor
662861fd66 Implement runtime checking for super-to-archetype casts, finishing <rdar://problem/12768631>.
Introduce a new swift_dynamicCast pair that take in a general metatype
pointer, rather than the more specific class-metatype pointer used for
class downcasts, and grab the class out of that general metatype
pointer, which may actually be an Objective-C wrapper. This is
slightly slower, but it works for the super-to-archetype cases like
T(an_NSObject), where T can have either kind of metadata.

NSTypedArray<T> is actually run-time type checked now, yay!


Swift SVN r3564
2012-12-20 18:47:39 +00:00
John McCall
d01b272531 Untested infrastructure for emitting non-constant field accesses.
Swift SVN r3542
2012-12-19 08:45:47 +00:00
John McCall
2353465f3f Add an API for reemitting as a substituted type and change
protocol witnesses over to the new API.  There's some badness
that we're papering over here involving generic types, but
this is a necessary first step.

Swift SVN r3003
2012-10-14 07:36:22 +00:00
John McCall
261731a8aa Make a function for reemitting an unsubstituted explosion
as a substituted one, which is critical for thunk emission.

Swift SVN r2976
2012-10-11 04:29:32 +00:00
John McCall
64c8346afc Promote reemitUnderSubstitutions to API and give it a better
name that makes the direction of substitution clear.

Swift SVN r2975
2012-10-11 04:29:29 +00:00