Commit Graph

1047 Commits

Author SHA1 Message Date
John McCall
7a9a8e92ea Another big drop of code to support protocol composition
types.  Mostly untested.  As part of this, I changed the
order in which we emit erasures:  now we evaluate the
operand in-place and only then write the protocols in.
This makes it slightly more likely that a generic
optimization will be able to devirtualize.

Swift SVN r2356
2012-07-14 06:51:01 +00:00
John McCall
b86d764397 Add some basic structures for protocol composition types.
Swift SVN r2355
2012-07-14 06:50:53 +00:00
Eli Friedman
6b4a248f04 Parsing and AST support for destructors on classes.
Swift SVN r2348
2012-07-12 01:26:02 +00:00
Doug Gregor
2da3c6c251 Virtualize TypeInfo::getSizeAndAlignment() and teach it to query the
value witness for archetypes. Builtin alignof/sizeof now work properly
for archetypes.


Swift SVN r2331
2012-07-10 19:08:14 +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
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
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
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
265292805e Introduce ExistentialSubscriptExpr, which describes subscript
operations into an existential type.


Swift SVN r2194
2012-06-18 17:45:57 +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
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
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
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
Eli Friedman
26bebcfd61 IRGen for break/continue.
Swift SVN r2089
2012-05-31 02:45:18 +00:00
Doug Gregor
3c2fb97bdf Introduce TypeBase::isExistentialType(), to determine whether a given
type is either a protocol type or a protocol composition type. The
long form of this query returns the minimal set of protocol
declarations required by that existential type.

Use the new isExistentialType() everywhere that we previously checked
just for ProtocolType, implementing the appropriate rules. Among other
things, this includes:
  - Type coercion
  - Subtyping relationship
  - Checking of explicit protocol conformance
  - Member name lookup

Note the FIXME for IR generation; we need to decide how we want to
encode the witnesses for the different protocols.

This is most of <rdar://problem/11548207>.


Swift SVN r2086
2012-05-31 00:26:13 +00:00
Chris Lattner
16cf77644f switch the frontend to generate swift_retain_noresult calls instead of
swift_retain calls.  The pertinent difference is that the former can be
marked nocapture, allowing general LLVM optimizations more flexibility.

With this change, early-cse is able to zap 9 more instructions, and 3
more functions are able to be marked nocapture by functionattrs in the
stdlib.


Swift SVN r2043
2012-05-28 20:20:07 +00:00
Chris Lattner
4f4636db31 adjust to mainline API change, and implement rdar://11542870 - @swift_release should be marked nocapture
Swift SVN r2031
2012-05-28 01:52:47 +00:00
John McCall
c9fdb3b224 Back this out, it's not really doing anything.
Revert "Hack the linkage and visibility of witnesses so that the REPL"

This reverts commit 3beb1278dfb6c306826eddd6c01fe79f4e94239e.

Swift SVN r1995
2012-05-25 18:31:00 +00:00
John McCall
28c7ba900b Hack the linkage and visibility of witnesses so that the REPL
doesn't die if the same witness is required on multiple lines.
The right solution here is to find some way to re-use the
previous functions.

Swift SVN r1994
2012-05-25 17:58:00 +00:00
John McCall
30244a2f0d Do all the dancing necessary to get method calls through
protocols working.

Swift SVN r1969
2012-05-24 12:16:51 +00:00
John McCall
6a16a5aae4 Prepare some abstractions for calling through an existential type.
Swift SVN r1968
2012-05-24 12:16:47 +00:00
John McCall
872cd45dae Stub out the less-important implementations of ExistentialMemberRefExpr.
Swift SVN r1967
2012-05-24 12:16:44 +00:00
John McCall
95a8c35a36 Implement IR-generation for instance method witnesses.
Swift SVN r1966
2012-05-24 12:16:40 +00:00
Doug Gregor
74436a3120 Introduce the implicit 'This' type into protocols, which refers to the
type T that conforms to the given protocol. 'This' is modeled simply
as an associated type.



Swift SVN r1953
2012-05-23 14:45:55 +00:00
John McCall
3d5380045a Allocate space for function witnesses.
Swift SVN r1917
2012-05-21 20:01:39 +00:00
John McCall
a8e511d429 Expound a bit about the decisions we need to come to about protocol
resilience.

Swift SVN r1916
2012-05-21 20:01:38 +00:00
John McCall
d1ce608f17 Implement conversion to super-protocols.
Swift SVN r1915
2012-05-21 20:01:37 +00:00
John McCall
e231868a84 Add witnesses for base protocols. For now, these are always
out-of-line rather than prefixed.

Swift SVN r1914
2012-05-21 20:01:36 +00:00
John McCall
e98d38bb3c Set up the basic framework for building witness-table layouts in
both the abstract and concrete cases.

Swift SVN r1913
2012-05-21 20:01:34 +00:00
John McCall
72ebeee76f Try to optimize assignment a bit more, and fix assignment
of protocol types to correctly handle self-assignment.
This ends up creating such a large amount of code that it's
worth extracting into its own helper function.  Fortunately,
this can be the same helper function for every protocol type.

Swift SVN r1905
2012-05-19 06:46:05 +00:00
John McCall
90939b19c0 Provide a base class for implementing a single retainable object
pointer TypeInfo more conveniently.  Have this class return true for
isSingleRetainablePointer().  Further specialize the implementations
of the value witnesses so that we no longer ever require type-specific
witnesses for reference types.

Swift SVN r1900
2012-05-18 10:02:04 +00:00
John McCall
d461d72e85 Implement ErasureExpr in IR-gen, at least as far as generating
value witnesses goes.

There are three major remaining things to do to support protocols:
  - laying out the actual protocol members
  - emitting witnesse for the actual protocol members
  - detecting uses of the actual protocol members and funnelling
    them through the witnesses as appropriate
All this work was just to let us treat protocol types as
first-class values.

Swift SVN r1899
2012-05-18 10:02:01 +00:00
John McCall
cf6a1fd284 Implement assignment on protocol types.
Swift SVN r1896
2012-05-18 10:01:50 +00:00
John McCall
85acda32bb Implement basic functionality for protocol types, with the
exception of assign.

Swift SVN r1895
2012-05-18 10:01:46 +00:00