Commit Graph

145 Commits

Author SHA1 Message Date
Doug Gregor
f05263d4fe Objective-C's -dealloc is a deallocating destructor, not a destroying destructor.
Because Objective-C doesn't have the notion of a destroying
destructor, this is a matter of cleanliness rather than
correctness. Still, it's better not to lie.


Swift SVN r12160
2014-01-10 23:08:42 +00:00
Doug Gregor
183a22b212 Add a deallocating destructor kind to SILDeclRef.
Swift SVN r12141
2014-01-10 22:32:50 +00:00
Doug Gregor
5f1b8618f4 Make the SILDeclRef for a destroying destructor store a DestructorDecl.
SILDeclRef was previously storing the ClassDecl for this case, because
semantic analysis didn't guarantee that a DestructorDecl was always
present. It is now, and this representation makes more sense.

Swift SVN r12122
2014-01-10 17:33:57 +00:00
John McCall
5da6defa1f Clean up the linkage model and the computation of linkage.
In general, this forces SILGen and IRGen code that's grabbing
a declaration to state whether it's doing so to define it.

Change SIL serialization to serialize the linkage of functions
and global variables, which means also serializing declarations.

Change the deserializer to use this stored linkage, even when
only deserializing a declaration, and to call a callback to
inform the client that it has deserialized a new entity.

Take advantage of that callback in the linking pass to alter
the deserialized linkage as appropriate for the fact that we
imported the declaration.  This computation should really take
advantage of the relationship between modules, but currently
it does not.

Swift SVN r12090
2014-01-09 08:58:07 +00:00
John McCall
8d68478c77 Move the SILDeclRef mangler to the SIL library. NFC.
Swift SVN r11894
2014-01-04 09:11:14 +00:00
Michael Gottesman
f257340f5a Refactor most of the definitions of SILType methods into SILType.cpp.
Currently SILType's method definitions are strewn in various files in
lib/SIL/*.cpp. This patch just adds a new file SILType.cpp that centralizes
many of those definitions.

*NOTE* Any method which uses declarations inside of a specific *.cpp file I left
alone (there were 3). If we want to, we can perhaps create a new header to share
the interface in between the two. I wanted this change to be as incremental as
possible so I left that undone.

Swift SVN r11890
2014-01-04 05:52:05 +00:00
Doug Gregor
1ee513e7e8 Use Builtin.Word for array lengths, string literal lengths, etc.
This eliminates a number of 64-bit integer/64-bit pointer assumptions
in the type checker and SILGen.


Swift SVN r11863
2014-01-03 18:53:01 +00:00
Nadav Rotem
8d75365b10 Add an assertion
Swift SVN r11622
2013-12-24 21:16:35 +00:00
Chris Lattner
a42debfb69 fix a few places that missed marking 'self' as an implicit decl.
Swift SVN r10961
2013-12-07 01:11:16 +00:00
Michael Gottesman
90f7847e58 Change ValueBase::replaceAllUsesWith to only go over the use list once.
Swift SVN r10771
2013-12-04 01:49:49 +00:00
Michael Gottesman
301a42f140 Move SILInstruction::replaceAllUsesWith -> SILValue::replaceAllUsesWith.
This commit corrects, as Jim likes to put it, a "thinko".

Swift SVN r10760
2013-12-03 22:37:10 +00:00
Chris Lattner
07ce5306f3 add a SILType::isTrivial helper function.
Swift SVN r10610
2013-11-20 22:53:49 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Joe Groff
88ff3dc7f7 SIL: Suppress uninitialized variable warning.
SILDeclRef's loc can only be a ValueDecl or an AbstractClosureExpr; any other case is unreachable.

Swift SVN r10064
2013-11-09 01:39:58 +00:00
Joe Groff
9c0e07fe35 SIL: Capture generic parameters through nested closures.
We were failing to capture generic parameters from closure contexts that themselves capture generic parameters from context. This fixes <rdar://problem/15417783>. While we're here, eliminate some unnecessary splitting of 'ClosureExpr' and 'AutoClosureExpr' in the SILDeclRef::Loc PointerUnion; we can just use their base class AbstractClosureExpr in the PointerUnion.

Swift SVN r10031
2013-11-07 23:39:37 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Chris Lattner
ef93c81ffb Introduce a new SIL-level "undef" value, useful for SIL transformations.
IRGen support is missing, Joe volenteers to implement it.


Swift SVN r9776
2013-10-30 00:58:09 +00:00
Joe Groff
3a5267c020 SILGen: Build a thunk in SILGen instead of using convert_cc instruction.
We already know how to call external functions in SILGen, why reimplement all that in IRGen? Instead of representing the thunk operation as a SIL instruction, let's just emit the thunk using existing SILGen machinery. Fixes <rdar://problem/14097136>.

Swift SVN r9576
2013-10-22 03:16:15 +00:00
Anna Zaks
3e5c1f81d2 Support transparent attributes on struct and enum extensions.
Attribute [transparent] on extensions should apply to all members(functions, properties) of that extension.

Addresses radar://15035271.

Swift SVN r8735
2013-09-27 20:29:31 +00:00
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
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
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
Anna Zaks
ba3298e6b8 Add support for [transparent] attribute on property getters and setters
Addresses radar://14738227

Swift SVN r8405
2013-09-18 17:30:52 +00:00
Doug Gregor
f7a2d5eed0 Emit Objective-C thunks for [objc] initializing constructors.
Now that all [objc] constructors have a suitable "init" selector, emit
an Objective-C thunk for the initializing constructor (not the
allocating constructor!) with that selector, and make sure it shows up
in the Objective-C metadata. 

With this, we can write a Swift constructor "constructor()" to
override "-init"; see the change to ListMaker that exercises this.

Joe or John: I'd love a review of these.



Swift SVN r8373
2013-09-18 00:30:54 +00:00
Dmitri Hrybenko
f1f189f4e0 Rename PipeClosureExpr -> ClosureExpr
Swift SVN r8321
2013-09-17 01:37:36 +00:00
Dmitri Hrybenko
64cb7058e4 Add AnyFunctionRef::getArgParamPatterns()
... and simplify getFuncNaturalUncurryLevel() with it


Swift SVN r8317
2013-09-17 01:13:42 +00:00
Dmitri Hrybenko
b18c38a322 Rename ImplicitClosureExpr -> AutoClosureExpr
Swift SVN r8304
2013-09-16 23:03:50 +00:00
Dmitri Hrybenko
e7af4d6c72 Collapse ImplicitClosureExpr into its abstract base class, ClosureExpr
Swift SVN r8280
2013-09-16 18:31:05 +00:00
Dmitri Hrybenko
536ed954ad Remove FuncExpr. Add CaptureInfo to FuncDecl. Introduce AnyFunctionRef.
AnyFunctionRef is a universal function reference that can wrap all AST nodes
that represent functions and exposes a common interface to them.  Use it in two
places in SIL where CapturingExpr was used previously.

AnyFunctionRef allows further simplifications in other places, but these will
be done separately.


Swift SVN r8239
2013-09-14 02:15:48 +00:00
Dmitri Hrybenko
5ac875e5dc Add CaptureInfo class that manages capture lists
Swift SVN r8234
2013-09-14 00:22:44 +00:00
Dmitri Hrybenko
fb227e6da6 Remove CapturingExpr::getParamPatterns()
Swift SVN r8218
2013-09-13 22:19:20 +00:00
Dmitri Hrybenko
7da84fd13d Make FuncExpr, PipeClosureExpr and ClosureExpr DeclContexts on their own.
This is a first step to detach them from CapturingExpr and eventually move them
in the AST class hierarchy.


Swift SVN r8171
2013-09-12 23:58:06 +00:00
Dmitri Hrybenko
1e23c936e0 Rename FuncDecl::getBody() to FuncDecl::getFuncExpr()
ConstructorDecl::getBody() and DestructorDecl::getBody() return 'BraceStmt *'.
After changing the AST representation for functions, FuncDecl::getBody() will
return 'BraceStmt *' and FuncDecl::getFuncExpr() will be gone.


Swift SVN r8050
2013-09-09 19:57:27 +00:00
Chris Lattner
e48b3a4702 Rework how capture lists work in CaptureExpr: now we record
global variables used by functions in the capture list as well.

SILGen and other things that don't care about these (i.e., all 
current current clients) filter the list to get what they want.

This is needed for future definite init improvements, and unblocked
by Doug's patch in r8039 (thanks! :)

No functionality change.



Swift SVN r8045
2013-09-09 18:15:07 +00:00
Joe Groff
2cdbec48ae SILGen: Currying thunks always have Freestanding CC.
Thunks above the natural uncurry level of a function should always be emitted with standalone function CC instead of method or foreign CC. Partially addresses <rdar://problem/14687373>, but we still don't emit thunks for struct instance methods.

Swift SVN r8043
2013-09-09 17:44:11 +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
Anna Zaks
b073815e7d [SIL] Remove ValueBase::replaceAllUses, which should never have been added.
I’ve added it without understanding the full consequences. If a variant of this is added, it
should take a list of values as the argument. Currently, there is no use for it, so just remove it.

Swift SVN r7238
2013-08-14 22:01:58 +00:00
Anna Zaks
342dff1c80 [SIL CCP] Add the early constant propagation pass skeleton.
The pass folds a single operation: int_sadd_with_overflow and issues an
error on detectable overflow.

Swift SVN r7204
2013-08-13 17:36:35 +00:00
John McCall
b0084f7204 Prepare SILType for more than just isAddress.
Swift SVN r6946
2013-08-06 20:23:12 +00:00
Joe Groff
4316239f5d Kill Builtin.OpaquePointer.
It's not needed by SIL anymore.

Swift SVN r6873
2013-08-03 01:56:06 +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
398cbba5be Rename SILConstant to SILDeclRef.
"SILConstant" doesn't really describe its role in SIL anymore, which is to provide a reference to a Swift declaration in a SIL instruction, such as a method or nominal type field.

Swift SVN r6559
2013-07-24 21:21:31 +00:00
Dmitri Hrybenko
aa46064432 Pass a const ASTContext and const DeclContext whenever possible. This makes it
possible to use lookupVisibleDecls() with a const DeclContext.


Swift SVN r6274
2013-07-15 23:39:00 +00:00
Doug Gregor
a12d30d9b1 Emit entrypoints for the default argument generator functions.
In the resilience model for default arguments, the presence of a
default argument is API, but its specific value is not. Thus, the
actual default argument values can evolve over time. To implement
this, for each default argument, we emit a function that
takes no arguments and produces the default value for that
argument. The caller will then call that function to form the default
argument.

This commit emits these functions for each default argument, even
though they are not currently being called. This is part of
<rdar://problem/11561185>.

We'll probably want a different calling convention for these functions
that preserves all registers, since they will often end up being very
trivial functions. 




Swift SVN r6260
2013-07-15 17:34:22 +00:00
Ted Kremenek
05508d147c Add FIXME.
Swift SVN r5567
2013-06-11 00:17:05 +00:00
Ted Kremenek
ee9925495a Add llvm_unreachable() to silence uninitialized variable warning from the analyzer.
In this case "naturalUncurryLevel" *might* be uninitialized.  I'd prefer
that this code be structured with a switch to prove that all cases
are covered, but that might not be the cleanest solution.  I'll
leave that for Joe to decide.

Swift SVN r5565
2013-06-11 00:11:20 +00:00
Joe Groff
2ce2d33a64 SIL: Add instructions for class-bound archetype/existential operations.
Add class-bound versions of archetype conversion and existential creation/projection/conversion instructions. Since class-bound generics aren't address-only these instruction variants don't need to indirect through addresses.

Swift SVN r5554
2013-06-09 18:12:43 +00:00
Chris Lattner
3db9fff98f implement SILValue::replaceAllUsesWith, fix a linked list manipulation
bug in removeFromCurrent.  Clearly I would fail an interview manipulating
linked lists :-)


Swift SVN r5341
2013-05-25 18:39:37 +00:00
Chris Lattner
1f971f88dd Remove the IsLoadable flag from SILType, and the isInvalid() state for SILType.
This frees up an extra bit in SILType, which we can expose to LLVM through
PointerLikeTypeTraits.  Use this bit in a PointerUnion, which allows simplifying
ValueBase, which happened to be the last use of the isInvalid() state.



Swift SVN r5218
2013-05-18 00:21:46 +00:00
Chris Lattner
fa9adc72ed merge SILBase into SILModule, the only class that derives from it.
Swift SVN r5197
2013-05-17 04:22:00 +00:00