Commit Graph

6634 Commits

Author SHA1 Message Date
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
Stephen Lin
dfb4c976a0 s/Destructed/Destructured/g
Swift SVN r8348
2013-09-17 20:32:49 +00:00
Stephen Lin
2b509fc32c Use visitor to avoid O(N^2) behavior when getting destructured Swift argument types for computing partial apply result type
Swift SVN r8337
2013-09-17 17:16:14 +00:00
Dmitri Hrybenko
f1f189f4e0 Rename PipeClosureExpr -> ClosureExpr
Swift SVN r8321
2013-09-17 01:37:36 +00:00
Stephen Lin
694f56e2a1 Implement helper to compute partial apply return type; insert convert_function as necessary where this type does not match the needed type
Swift SVN r8315
2013-09-17 00:39:17 +00:00
Dmitri Hrybenko
b18c38a322 Rename ImplicitClosureExpr -> AutoClosureExpr
Swift SVN r8304
2013-09-16 23:03:50 +00:00
Dmitri Hrybenko
f2cc4cb303 Rename CapturingExpr -> AbstractClosureExpr
Swift SVN r8299
2013-09-16 21:58:44 +00:00
Dmitri Hrybenko
e7af4d6c72 Collapse ImplicitClosureExpr into its abstract base class, ClosureExpr
Swift SVN r8280
2013-09-16 18:31:05 +00:00
Stephen Lin
b0cdee2b9b Move SILBuilder::getTupleElementType and SILBuilder::getStructFieldType to SILBuilder.cpp
Swift SVN r8279
2013-09-16 18:19:14 +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
Anna Zaks
6775516a7c [SIL] Propagate [transparent] from decl to apply inst for constructor.
Swift SVN r8225
2013-09-13 23:21:40 +00:00
Anna Zaks
d5f826530b [SIL] Ensure we mark default argument generators as transparent.
We want the argument generator functions to be treated as transparent iff the "parent" function is transparent. There is no need to special case it in isTransparent because the SILDeclRef contains the :parent" Decl, and the first check will just work for us automatically.

Do make sure that the isTransparent is consulted when the apply instruction is created.

Swift SVN r8224
2013-09-13 23:21:39 +00:00
Joe Groff
c0317ec696 AST: Add Type::getStructOrBoundGenericStruct helper.
Swift SVN r8204
2013-09-13 17:10:21 +00:00
Anna Zaks
fe63b96109 [SIL] Provide a single source for determining a function transparency.
Makes sure the logic for determining if a function is transparent is shared
between the inliner and the SIL serializer.

Swift SVN r8173
2013-09-13 00:54:54 +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
Anna Zaks
9e887fc3c7 [SIL] Mark calls to implicitly generated union element constructors and default arg generators as transparent.
Swift SVN r8168
2013-09-12 22:45:18 +00:00
Chris Lattner
7c8ae9352a Add a new "mark_function_escape" instruction that will be used to mark the
escape point of function definitions that "close" over global variables.



Swift SVN r8152
2013-09-12 18:31:00 +00:00
Chris Lattner
3c0c9a5da7 introduce a new mark_uninitialized SIL instruction which will be used by
definitive initialization of top-level code.


Swift SVN r8144
2013-09-12 04:30:48 +00:00
Dmitri Hrybenko
e08eee270e Move some of SILGen for functions to use FuncDecl instead of FuncExpr
This changes most SILLocations to point to FuncDecls instead of FuncExprs,
thus SIL diagnostics had to be fixed up for this change.


Swift SVN r8132
2013-09-12 00:32:18 +00:00
Joe Groff
705102b544 SIL: Rename 'ClangThunk' specifier to 'Thunk'.
Lazily-generated currying thunks will require the same IR-level linkonce_odr linkage as clang thunks currently do, so generalize the name of the existing SIL-level linkage specifier 'clang_thunk'.

Swift SVN r8122
2013-09-11 23:47:15 +00:00
Anna Zaks
3997330530 [SIL] Remove the redundant secondary AST node.
We don’t use it for anything right now.

Swift SVN r8109
2013-09-11 20:54:33 +00:00
Anna Zaks
e7e3c10fec [SIL] Add appropriate SILLocations to the inlined code.
The inlined locations should point to the call site.

Swift SVN r8108
2013-09-11 20:54:31 +00:00
Adrian Prantl
46f616938c Debug info: Emit mangled name for bound generic structs and classes.
Implements rdar://problem/14802271

Swift SVN r8095
2013-09-11 17:58:54 +00:00
Joe Groff
cc37187c53 SIL: Remove 'UncurryDirection' and uncurry all methods right-to-left.
ObjC methods are already tagged with a special calling convention and have special IRGen handling to keep the _cmd argument abstracted away from SIL. We can use the CC to also abstract away the detail that Swift methods pass 'self' last but ObjC methods pass 'self' first. This eliminates a weird special case from SIL's perspective, and also means that 'partial_apply' can work on objc methods correctly without becoming significantly more complex.

Swift SVN r8091
2013-09-11 17:05:44 +00:00
Anna Zaks
39b7a43cc0 [SIL] Mark locations of implicit constructors/destructors as auto-generated.
(Also, renames getArtificialLocation -> getAutoGeneratedLocation).

Swift SVN r8085
2013-09-10 22:52:43 +00:00
Adrian Prantl
af562d1696 Debug info: name mangling for composite types containing Archetypes.
Among other things this enables mangled names for tuples.
This adds a pointer to the DeclContext to SILFunction and which is used
to provide the necessary context to the Mangler.
Fixes rdar://problem/14808764 and rdar://problem/14813658.

Swift SVN r8070
2013-09-10 17:04:33 +00:00
Doug Gregor
24f4706056 SIL: Introduce the dynamic_method_br instruction.
The dynamic_method_br instruction branches depending on whether a
particular object can accept a given message, as determined at
runtime. If the object can accept the message, it branches to the
first basic block, providing the uncurried method as the BB
argument. If the object cannot accept the message, it branches to the
second basic block. Either way, the result is packaged up into an
optional type and passed along to the continuation block, which
provides the optional result.

Note that this instruction is restricted to lookup of Objective-C
methods.

Documentation and IR generation (via -respondsToSelector) to
follow. Review greatly appreciated!



Swift SVN r8065
2013-09-09 23:46:10 +00:00
Anna Zaks
c06bd83358 [SIL] Remove the last few uses of SILLocation constructor.
This also removes the constructor itself, which forces future users of
SILLocation to construct a valid location.

Swift SVN r8056
2013-09-09 22:34:05 +00:00
Joe Groff
b960da9275 SIL: Fix logic bug in SILDeclRef::atUncurryLevel.
Swift SVN r8047
2013-09-09 18:40:30 +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
Doug Gregor
c5557a624c SIL: Introduce the 'dynamic_method' instruction for dynamic method dispatch.
The dynamic_method instruction handles method lookup on an existential
of type DynamicLookup based on the selector of an [objc] method of a
class or protocol. It is only introduced in the narrow case where we
are forcing a use of the method with '!', e.g.,

class X {
  func [objc] f() { println("Dynamic lookup") }
}

var x : DynamicLookup = X()
x.f!()



Swift SVN r8037
2013-09-09 16:12:50 +00:00
Doug Gregor
6e67e34b40 Rename DynamicMethodInst -> MethodInst.
Swift SVN r8031
2013-09-09 14:29:51 +00:00
Anna Zaks
cb43f56edb [SIL] Remove more dependancies on SILLocation(), specifically from debugging related code.
Swift SVN r8019
2013-09-06 23:57:30 +00:00
Anna Zaks
369a948248 [SIL] Minor auto-generated SILLocation API rename/refactor.
Swift SVN r8018
2013-09-06 23:57:27 +00:00
Anna Zaks
42f87d7725 [SIL] Represent module-level locations.
These are used for code that is usually associated with the enclosing decl such as epilog code and cleanups.

Swift SVN r8017
2013-09-06 23:57:25 +00:00
Anna Zaks
04b4901b79 [SIL] Split emitBlock() into 2 to remove dependency on construction of a NULL SILLocation.
Swift SVN r8015
2013-09-06 23:57:19 +00:00
Anna Zaks
1ba2554fb2 [SIL] Ensure that all loop branches have valid locations.
Also, change the location of "looping back to head" branch to point to the closing brace of the body, which is a more natural source location than the beginning of the enclosing loop statement.

Swift SVN r7989
2013-09-06 17:46:15 +00:00
Anna Zaks
4d7de376bb [SIL] Refactor splitBasicBlock() into splitBasicBlock and splitBasicBlockAndBranch
This API is more explicit and avoids relying on passing around empty SILLocation.
(No functional change.)

Swift SVN r7988
2013-09-06 17:46:12 +00:00
Michael Gottesman
c001e3e82b Added SILInstructionMemoryBehavior::MayRead/MayReadWrite and mayRead()/mayWrite() methods on SILInstruction.
Swift SVN r7963
2013-09-05 22:28:54 +00:00
Michael Gottesman
6988171ee6 As per my discussions with Anna, removed MayWriteAndHaveSideEffects.
The reason we decided to do this is that MayHaveSideEffects implies that a write
can occur, making MayWriteAndHaveSideEffects redundent.

Swift SVN r7943
2013-09-05 06:57:25 +00:00
John McCall
b9dea7f458 Remove the emitSemantic* methods from TypeLowering and
move the corresponding functionality into SILGen.

I've switched around 'assign' so that it's no longer a
semantic assignment --- that is, so that it expects a properly
lowered value as its operand, not an r-value of the semantic
type.  This actually simplifies quite a lot of code and removes
some ugly special-casing from MemoryPromotion.

Swift SVN r7942
2013-09-05 06:44:50 +00:00
Chris Lattner
a864b8ea00 enhance the union retain/release implementations to split the block when
inserting a diamond into the middle of an existing block.  This fixes a
problem that manifests in memory promotion when lowering an assign.


Swift SVN r7917
2013-09-04 22:02:50 +00:00
Anna Zaks
2ea48d3d52 [SIL] Assign SIL location info for tuple initialization code.
Swift SVN r7915
2013-09-04 21:57:50 +00:00
Chris Lattner
5065699eb3 Enhance SILBuilder::emitBlock to emit new blocks after the current insertion
point's block, if it has one, instead of always at the end of the function.

No functionality change for current use cases.


Swift SVN r7907
2013-09-04 18:30:20 +00:00
Manman Ren
ad318b0cee SIL Serialiation: add Transparent to SILFunction so we can decide which
functions should be serialized.

Transparent is added as a 1-bit field. In SILGen, we set SILFunction's
transparent attribute according to the attribute of the ValueDecl.


Swift SVN r7882
2013-09-04 00:16:34 +00:00
Anna Zaks
781ee9bdab [SIL Loc] Allow CleanupLocations that point to the beginning of the AST node.
Swift SVN r7817
2013-08-30 23:41:36 +00:00
Anna Zaks
fbcf5d458f [SIL Loc] Use a separate bit to represent auto-generated code
Auto generated location should not be a separate location kind since
we might have different kinds of auto generated locations (ex: cleanup,
return). Even though the kind info might not be necessary for diagnostics or
debug info, it allows us to better use type system, for example, only pass
CleanupLocation where expected.

Swift SVN r7816
2013-08-30 23:41:33 +00:00
Joe Groff
c1eddbe484 Update SILInstruction VALUE_RANGE in SILNodes.def.
Swift SVN r7793
2013-08-30 19:12:38 +00:00
Chris Lattner
fc04d57bd0 Rework the assign instruction in two major ways:
1. Change assign to follow SILGen's model for a semantic assignment,
   which (in the case of unowned pointers) doesn't require the left
   and right hand sides to be the same.
2. Change assign to consume/take the refcount from the LHS, following
   SILGen's design (which I completely misunderstood before).



Swift SVN r7787
2013-08-30 17:59:56 +00:00
Michael Gottesman
5679974328 Fixed comment typo.
Swift SVN r7777
2013-08-30 04:47:58 +00:00