Commit Graph

12848 Commits

Author SHA1 Message Date
Eli Friedman
66907893d3 Allow destructuring assignments (assignment to a tuple expression). <rdar://problem/11719247>.
Swift SVN r2285
2012-07-02 21:39:52 +00:00
Doug Gregor
6083420a0c IRBuilder.h has moved in top-of-tree LLVM. Update our includes appropriately.
Swift SVN r2283
2012-07-02 21:04:14 +00:00
Eli Friedman
5bb6c36104 Support for calling member operators with operands of generic type.
Swift SVN r2279
2012-06-29 21:37:06 +00:00
John McCall
2d998f315d Implement method calls on archetype values.
Swift SVN r2275
2012-06-28 20:56:25 +00:00
John McCall
e53aed65d7 Initial support for IR-genning generic function bodies.
Mangling is still a hack, pending a better type AST.  Fixed
a bug where arguments passed indirectly were not being destroyed
by the callee (when passed by value).  Changed some of the protocol
signatures to use the generic opaque pointer type, making the
types a bit more self-documenting in the IR.

Swift SVN r2274
2012-06-28 08:50:06 +00:00
Eli Friedman
01e7041600 Misc fixes on top of John's PolymorphicFunctionType patch.
Swift SVN r2256
2012-06-27 02:23:38 +00:00
John McCall
668f674bfa Split off a PolymorphicFunctionType from FunctionType. I am
*positive* that the behavior here is blatantly wrong in a lot
of places, but I'm going to leave it to Doug to clean up after me. :)

Swift SVN r2255
2012-06-27 00:22:15 +00:00
John McCall
b35ab5e4df Make the opaque type be a named IR type.
Swift SVN r2248
2012-06-25 20:45:06 +00:00
John McCall
4d4073cafa Provide a dinky little interface for associating a wtable with an
archetype within a context.

Swift SVN r2247
2012-06-25 20:45:06 +00:00
John McCall
de61d2796e Switch the translation of an archetype type to be the opaque struct
type, not the fixed-buffer type.

Swift SVN r2246
2012-06-25 20:45:05 +00:00
John McCall
6c821ddc1b Support allocating local objects of archetype type, at least in
theory.

Swift SVN r2245
2012-06-25 20:45:04 +00:00
John McCall
8203b795ef Trivial refactor in preparation for making Initialization part
of the TypeInfo API.

Swift SVN r2244
2012-06-25 20:45:03 +00:00
John McCall
e3ea138183 Pack of changes leading towards a more-correct implementation
of archetypes.

Swift SVN r2243
2012-06-25 20:45:01 +00:00
John McCall
85bdae402e Restructure code to permit protocols to be converted independently
of a ProtocolType.

Swift SVN r2242
2012-06-25 20:45:00 +00:00
John McCall
770ce0fde7 Refactor to make it easier to keep common information in
the type converter.

Swift SVN r2241
2012-06-25 20:44:59 +00:00
John McCall
e2440ff94c Split TypeInfo into its own header.
Swift SVN r2240
2012-06-25 20:44:51 +00:00
Doug Gregor
bcbbe7e9d4 Introduce SpecializeExpr, an implicit conversion that will be used to
specialize a generic function with a given set of substitutions to
produce a new, concrete type. This node is not yet used.


Swift SVN r2226
2012-06-22 18:58:21 +00:00
Eli Friedman
2b163c2afa Get rid of a broken optimization in the cleanup generation code. Fixes <rdar://problem/11720621>.
Swift SVN r2225
2012-06-22 01:55:07 +00:00
Doug Gregor
31d1f40cb8 The type of the 'this' parameter for a protocol method is [byref]
This, not [byref] ProtocolType. Fix this in semantic analysis, and
update IR generation accordingly.


Swift SVN r2217
2012-06-20 20:47:03 +00:00
Doug Gregor
cf4a05f66d Eliminate SuperConversionExpr. This expression node was only really
used in the very narrow case where we were converting from one
protocol type to another (super) protocol type. However, ErasureExpr
now handles this case via its null conformance entries (for the
"trivial" cases), and can cope with general existential types where
some conversions are trivial and others are not.

The IR generation side of this is basically just a hack to inline the
existing super-conversion code into the erasure code. This whole
routine will eventually need to be reworked anyway to deal with
destination types that are protocol-conformance types and with source
types that are archetypes (for generic/existential interactions).



Swift SVN r2213
2012-06-20 16:26:48 +00:00
Eli Friedman
d85f426693 Initial implementation of static functions on protocols. <rdar://problem/11448251>.
There are currently two places where you can use a static function defined on a protocol:
on an object with the type of the protocol (discarding the base), and on an archetype in a generic function.  The AST for the protocol object case is probably okay;
the AST for the generic case is almost certainly wrong, but that whole area isn't really stable at the moment anyway.  The proposal in rdar://problem/11448251 will
add a third way: operators on protocols will be found by overload resolution.  (Having static functions on protocols opens up the possibility of metaprotocols,
but I don't think I need to worry about that for the moment.)



Swift SVN r2211
2012-06-20 02:49:54 +00:00
Doug Gregor
0741dcec2b Introduce ArchetypeSubscriptExpr to model subscripting of a value of
archetype type.


Swift SVN r2209
2012-06-20 00:27:28 +00:00
Doug Gregor
f847fe4a22 Introduce basic support for type-checking the definitions of generic
functions. This involves a few steps:

  - When assigning archetypes to type parameters, also walk all of the
  protocols to which the type parameter conforms and assign archetypes
  to each of the associated types.
  - When performing name lookup into an archetype, look into all of
  the protocols to which it conforms. If we find something, it can be
  referenced via the new ArchetypeMemberRefExpr.
  - When type-checking ArchetypeMemberRefExpr, substitute the values
  of the various associated types into the type of the member, so the
  resulting expression involves the archetypes for the enclosing
  generic method.

The rest of the type checking essentially follows from the fact that
archetypes are unique types which (therefore) have no behavior beyond
what is provided via the protocols they conform to. However, there is
still much work to do to ensure that we get the archetypes set up
correctly.



Swift SVN r2201
2012-06-19 21:16:14 +00:00
Doug Gregor
265292805e Introduce ExistentialSubscriptExpr, which describes subscript
operations into an existential type.


Swift SVN r2194
2012-06-18 17:45:57 +00:00
Chris Lattner
b23f4eb4f8 switch from SmallMap to SmallDenseMap.
Swift SVN r2189
2012-06-17 21:22:13 +00:00
Chris Lattner
56886268dd implement irgen support for do/while statements, wrapping up rdar://11576294
Swift SVN r2188
2012-06-17 04:16:55 +00:00
Eli Friedman
338aadad57 IRGen for logical lvalues with a base of class type. <rdar://problem/11466574>
Swift SVN r2177
2012-06-08 22:38:36 +00:00
Doug Gregor
dd55aedbba Fix comment in new file
Swift SVN r2174
2012-06-08 17:20:52 +00:00
Eli Friedman
032d9d3538 Default construction for classes. <rdar://problem/11619111>.
Swift SVN r2172
2012-06-08 00:31:29 +00:00
Eli Friedman
45f1fa1f6c Fix some comments; remove unused ErrorStmt.
Swift SVN r2169
2012-06-07 22:14:17 +00:00
Eli Friedman
9d21e367eb Switch strings over to new constructor syntax. Fix a few constructor bugs I found along the way.
Swift SVN r2166
2012-06-07 20:26:16 +00:00
Eli Friedman
e5b4b924a1 More work on constructors. Basic testcases with "constructor" declarations appear to be working, although there's probably more work to be done. (Both old-style and new-style constructors work for the moment.)
Swift SVN r2163
2012-06-07 01:57:57 +00:00
Eli Friedman
f1ffa870a3 A few adjustments to AST/Sema for ConstructorDecls, and starting IRGen.
Swift SVN r2160
2012-06-06 00:53:44 +00:00
Eli Friedman
75907029f1 Add parsing and semantic analysis for a basic ConstructorDecl. Still missing: no IRGen, and semantic analysis to actually call them.
Swift SVN r2159
2012-06-05 23:51:19 +00:00
Eli Friedman
cd8632c685 Compute heap layout for classes lazily, so we don't get infinite recursion. <rdar://problem/11588882>.
Swift SVN r2155
2012-06-05 20:17:23 +00:00
John McCall
53646ccfc8 Better support for mangling, emitting, and using local
functions.

Swift SVN r2152
2012-06-05 04:51:21 +00:00
John McCall
b5381edb88 Some overlooked uses of std::vector that are unnecessary
now that SmallVector is move-only-compatible.

Swift SVN r2151
2012-06-05 04:51:12 +00:00
John McCall
24a84132ca More CC-related changes.
Swift SVN r2150
2012-06-05 04:51:04 +00:00
John McCall
5064f39024 Refactor towards the goal of using different CCs when
passing this pointers or data arguments.

Swift SVN r2149
2012-06-05 04:50:58 +00:00
John McCall
6758b45136 Kill FixedPadding::Realign; it is not address-invariant, which
is a property that we'd prefer to maintain.

Swift SVN r2148
2012-06-05 04:50:49 +00:00
John McCall
3dd77943df Change the size of a prototype type to 3 pointers rather than
a fixed size of 16 bytes.  3 pointers is the magic value in
swift:  many, many things are better if we can handle three
pointers efficiently.

Swift SVN r2147
2012-06-05 04:50:42 +00:00
Chris Lattner
fe24ea3c8f delete some pointless objc_retain/objc_release pairs, which show up in String -> NSString conversions.
Finishes off rdar://11583269


Swift SVN r2127
2012-06-03 04:41:00 +00:00
Chris Lattner
5074859478 teach the optimizer about objc_retain and objc_release, allowing us to zap a objc_release(null)
from the String->NSString conversion routine (rdar://11583269)


Swift SVN r2126
2012-06-03 04:33:21 +00:00
Chris Lattner
83cee744d1 sinking retains pushed them after insertelement instructions in a return sequence,
which defeated the optimization which formed "retainThree" tail calls.  Restructure
and generalize this optimization to handle the new and old forms.  Through
the combination of the two, we now form 19 of them on the stdlib.  Before I broke
things, we only formed 14 of them.


Swift SVN r2124
2012-06-03 03:50:07 +00:00
Chris Lattner
540b7b92e6 implement trivial retain motion, pushing retains past operations that obviously cannot release an object (unless we get to a matching retain of course).
This allows us to optimize away 43 (instead of 31) retain/release pairs from the stdlib.  This resolves rdar://11571612.


Swift SVN r2123
2012-06-03 00:53:18 +00:00
Chris Lattner
32f529f1db Split arc-optimizer into two passes: arc-optimize and arc-expand.
This makes the two phases independently testable, but is also the
right thing to do: previously we'd form swift_retain early enough
that inlining would inline them from previously optimized callees
into callers, and this would block some mid-level optimizations
from doing nice things (because swift_retain isn't no-escape).

It's a small thing, but doing this allows us to eliminate a few 
more "and x, 9223372036854775807"'s from the stdlib.  We also
end up doing a lot less optimizations because we do them early
instead of only having the optimizations exposed after inlining
deeply.



Swift SVN r2114
2012-06-02 16:43:51 +00:00
Chris Lattner
fac11ffe56 Introduce a swift-specific alias analysis pass that knows that retain/release/alloc
don't mod/ref any state to swift code.  This allows the general LLVM optimizer to be
*much* more aggressive.  For example, on swift.swift, GVN deletes 15% more instructions,
jump threading folds 2.4X more terminators, SCCP removes 3.3X more instructions, and 2
more retain/release pairs are removed by the ARC optimizer.


Swift SVN r2113
2012-06-02 02:39:27 +00:00
Eli Friedman
ae86d64644 Rename Decl::getLocStart() to Decl::getStartLoc(). Add Decl::getLoc(), which is essentially the location which should be used for diagnostics.
Swift SVN r2105
2012-05-31 23:56:30 +00:00
Chris Lattner
a7f2593b51 make sure to set the tail marker on the generated calls.
Swift SVN r2103
2012-05-31 23:21:47 +00:00
Chris Lattner
91a80673b7 Enhance the swift_retainAndReturnThree optimizer to be able to handle the case
when swift_retainAndReturnThree is inlined from a previously optimized function.

The upshot of this is that we compile:

var a : String
func f() -> String {
  return a
}

into:

__T1t3fooFT_NSs6String:
	pushq	%rax
	movq	__T1t1xNSs6String+16(%rip), %rcx
	movq	__T1t1xNSs6String+8(%rip), %rdx
	movq	__T1t1xNSs6String(%rip), %rsi
	movq	%rcx, %rdi
	callq	_swift_retainAndReturnThree
	popq	%rsi
	ret

instead of:

__T1t3fooFT_NSs6String:
	pushq	%r14
	pushq	%rbx
	pushq	%rax
	movq	__T1t1aNSs6String+8(%rip), %r14
	movq	__T1t1aNSs6String(%rip), %rbx
	movq	__T1t1aNSs6String+16(%rip), %rdi
	callq	_swift_retain
	movq	%rax, %rcx
	movq	%rbx, %rax
	movq	%r14, %rdx
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	ret



Swift SVN r2102
2012-05-31 22:57:10 +00:00