Commit Graph

186 Commits

Author SHA1 Message Date
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
Chris Lattner
63e2a60585 rename Module:: and Function::getContext to ::getASTContext()
This matches SILType and is more explicit about which context
we're talking about.


Swift SVN r5185
2013-05-16 20:14:13 +00:00
Chris Lattner
3facf741fa move SILFunction implementation goop out into SILFunction.cpp
and make the SILFunction ctor public since SIL is an optimization
IR, not just a transient by product of IRGen. :)


Swift SVN r5183
2013-05-16 19:59:01 +00:00
Joe Groff
d5784307d2 SILGen: Emit objc_msgSend-able thunks in SIL.
Emit thunks for [objc] class methods and properties as SILFunctions, using SILGen's OwnershipConventions. This will help kill some redundant ownership code in IRGen, and will allow msgSend thunks to handle string and block bridging. IRGen doesn't actually codegen the thunks yet; that will require teaching IRGenSILFunction how to be AbstractCC-aware, so for now, we just reemit the thunks using the old IRGen code.

Swift SVN r5168
2013-05-14 01:22:12 +00:00
Joe Groff
bcf510e30b SIL: Remove 'getPreLoweredType' from SILType.
We don't need this hole to bypass SIL TypeLowering anymore.

Swift SVN r5094
2013-05-08 18:26:38 +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
Joe Groff
8bdccdd418 IRGen: Clear up dtor special cases in SIL-IRGen.
Change the destroying destructor entry point ABI to take 'this' as the appropriate type instead of as %swift.refcounted. Emit the deallocating destructor in IRGen when we see the ClassDecl, not when we see the SILFunction for the destructor. This frees us from having to worry about whether a SILFunction came from a destructor decl. We won't be able to reconstruct that once SILFunctions are pre-mangled.

While we're here, repaint some bikesheds so it's clearer that SIL and SILGen work with the destroying destructor.

Swift SVN r4908
2013-04-25 19:50:58 +00:00
Joe Groff
ee9ca634a5 SIL: Add linkage and calling conv to SILFunctions.
Move AbstractCC into SILType and make it an attribute of SILTypes for functions. Add a ConvertCCInst to represent calling convention conversions. Give SILFunctions a linkage attribute. Add logic to SILGen to calculate these attributes for SILConstants based on their attached decls.

IRGen doesn't use these new attributes yet. I'll hook that up when I move mangling over.

Swift SVN r4886
2013-04-24 18:09:44 +00:00
Joe Groff
bcb49ce450 SIL: Key functions directly without SILConstant.
Replace 'constant_ref' with 'function_ref', which references a SILFunction directly, and 'global_addr', which references a global variable VarDecl. Get rid of the SILConstant-to-SILFunction mapping in SILModule and replace it with an ilist of SILFunctions. Allow SILFunctions to be 'external' by not having any blocks in their body. 

For now, SILFunctions still carry around their SILConstant "name", because name mangling and IRGen still rely on access to the original decl in order to recover IRGen information, which unfortunately leaves IRGen's CodeRefs in a gross, awkward intermediate state. Lifting mangling, AbstractCC, and other linkage attributes to SIL should clear up this up.

Swift SVN r4865
2013-04-23 23:29:04 +00:00
Chris Lattner
7588b99869 add a pre-mangled name to the top level function, some more minor
style changes to fit in 80 columns etc.  No useful behavior change.



Swift SVN r4748
2013-04-16 00:44:57 +00:00