Commit Graph

1047 Commits

Author SHA1 Message Date
John McCall
e5434f80d9 Respond to a change in LLVM trunk.
Swift SVN r3568
2012-12-21 00:16:38 +00:00
Doug Gregor
96583a726b Introduce ArchetypeToSuperExpr for implicit archetype-to-superclass conversions.
The IR generation for this conversion is different from
derived-to-base conversions, because converting from an archetype to
its superclass type means projecting the buffer and then performing
the conversion.


Swift SVN r3462
2012-12-13 00:16:05 +00:00
Doug Gregor
b4ca0f1fef Rename llvm::AttrListPtr -> llvm::AttributeSet to sync with LLVM mainline.
Swift SVN r3430
2012-12-10 23:21:19 +00:00
John McCall
c6374093f6 Add support for messaging Objective-C classes.
Notably, there is still no support for +1 return values,
so we'll leak when doing alloc/init and so on;  but this gets
the fundamentals in place.  A lot of the extra stuff in here
is dealing with mapping between metatypes and class objects.

Swift SVN r3425
2012-12-10 08:18:03 +00:00
John McCall
65db19395d Make metatype layout compatible with struct objc_class.
The principal difficulty here is that we need accessing the
value witness table for a type to be an efficient operation,
but there (obviously) isn't a VWT field for ObjC classes.
Placing this field after the metatype would tend to bloat
metatypes by quite a bit.  Placing it before is best, but
it introduces an unfortunate difference between the address
point of a metatype and the address of the global symbol.
That, however, can be fixed with appropriate linker support.
Still, for now this is rather unfortunately over-subtle.

Swift SVN r3307
2012-11-30 02:47:01 +00:00
Chris Lattner
f5e4474c76 fix build with mainline llvm.
Swift SVN r3246
2012-11-26 20:44:27 +00:00
John McCall
1dd68ef331 Remove an unused field.
Swift SVN r3181
2012-11-14 08:45:20 +00:00
John McCall
ce7ddef710 Change value witnesses to take the metatype as 'self'.
The motivations here are that (1) the parametric types
that actually need the 'self' argument don't necessarily
all want to do what tuples do and put the VWT relative
to the metatype at some definable offset and (2)
recovering type parameters from the metatype is much
better defined than also hopping some relationship back.
Plus this allows VWTs to be shared across instances of
generic types.  Also, I'm going to need to add a VW
that takes a metatype, and consistency seems right here.

If keeping two values live is actually punishing, I
might have to reconsider this.  But the VWT is at least
always recoverable from the metatype, so....

I ended up abstracting the thing that GenHeap was doing
in order to save archetypes for arrays, because I
needed it to save metatypes instead of VWTs and because
it really needed abstractin'.

Swift SVN r3096
2012-10-31 08:09:33 +00:00
John McCall
2f8f05615e Rename TypeOfExpr / TypeOfInst to MetatypeExpr / MetatypeInst.
Introduce a '.metatype' form in the syntax and do some basic
type-checking that I probably haven't done right.  Change
IR-generation for that and GetMetatypeExpr to use code that
actually honors the dynamic type of an expression.

Swift SVN r3053
2012-10-24 07:54:23 +00:00
John McCall
8999ff03db Remember the metatype for This in a method on a generic
struct so that we can re-use it in the function body,
e.g. if we call another method on the type.

Swift SVN r3048
2012-10-23 23:30:25 +00:00
John McCall
0548cc7cff Cache local metadata in the scope in which we compute it,
to avoid some obvious redundancies.  This also gives us a
more general framework with which to exploit other ways
in which metadata is known.

Swift SVN r3047
2012-10-23 23:30:23 +00:00
John McCall
e8d5f08e94 Fix/suppress some warnings arising in newer clangs
as reported by Chris.

Swift SVN r3044
2012-10-23 08:12:08 +00:00
John McCall
85490080c2 Make protocol thunks expect a metatype pointer (for This) as
their last argument.  Pass it down correctly.

Swift SVN r3042
2012-10-23 07:59:35 +00:00
John McCall
3e0957af8f When emitting a polymorphic signature like <T,U> A<T,U>& -> (),
pass A<T,U>.metatype instead of breaking apart the type.
This is a WIP commit, because it breaks existentials quite
badly.

Swift SVN r3041
2012-10-23 07:59:30 +00:00
John McCall
36b4ebb9c6 Change the representation of existential types to always store
a type pointer;  in the case of protocol<>, this replaces the
mandatory trivial witness table, and in all other cases it simply
grows the representation by a pointer.  We've discussed shrinking
the representation by making the witness-table lookup a (cached)
lookup from the type metadata;  this needs more investigation.

Swift SVN r3018
2012-10-18 06:08:06 +00:00
Chris Lattner
e475986dbc adapt to mainline llvm API changes.
Swift SVN r3006
2012-10-16 17:54:16 +00:00
John McCall
2353465f3f Add an API for reemitting as a substituted type and change
protocol witnesses over to the new API.  There's some badness
that we're papering over here involving generic types, but
this is a necessary first step.

Swift SVN r3003
2012-10-14 07:36:22 +00:00
Dave Zarzycki
89bf1a0fc9 Fix unused variable warnings with asserts disabled
Swift SVN r2996
2012-10-12 21:52:09 +00:00
John McCall
f4dd62dee7 Metatypes for class types have non-trivial representation.
Swift SVN r2971
2012-10-11 00:36:05 +00:00
Chris Lattner
4135441203 update to build with mainline API changes.
Swift SVN r2968
2012-10-10 22:22:06 +00:00
John McCall
ae978371ac Make calls to non-static methods on classes use virtual
dispatch.  Currently there is no possibility of override.

This was really not as difficult as I managed to make it
the first time through.

Swift SVN r2960
2012-10-10 01:31:47 +00:00
John McCall
6e9a2aab8b Fix a conceptual bug in class metadata: the parent pointer
of a class is part of the class members section and is not
global to the entire class metadata.  This is crucial for
correct operation of functions expecting a base-class
metadata object.

That gives us the correct foundation to implement an
optimization under which generic arguments that can be
inferred from the 'this' pointer need not actually be
separately passed.  This has the important result of
making all class member functions with the same signature
up to abstraction actually have the same physical
signature.

Swift SVN r2936
2012-10-04 23:44:31 +00:00
John McCall
526e2d7c54 Flesh out some code to decide when we can avoid passing
metadata and witness tables separately to polymorphic
functions.

Swift SVN r2935
2012-10-04 23:44:24 +00:00
John McCall
1f5b775bc7 Use metatype pointers as generic type arguments. Movements
towards optimizing generic calls to derive things from the
'this' pointer, which is actually crucial for virtual
dispatch (to get all methods to agree about how the
implicit arguments are passed).  Fix a number of assorted
bugs in metadata emission.  Lots of assorted enhancements.

This was proving surprisingly difficult to actually tease
apart into smaller patches.

Swift SVN r2927
2012-10-03 08:57:40 +00:00
John McCall
179e260ea3 Add an abstraction to encapsulate a Decl + explosion level +
uncurrying level, which is something I find myself passing around
quite a bit.  Make sure that it can propagate getter/setter
references in the same way.

Swift SVN r2902
2012-09-28 05:21:24 +00:00
John McCall
ee012c0903 Make IR-gen use canonical types as the basic type currency.
This is kindof a pain in a few places where the type system
doesn't propagate canonicality.  Also, member initializations
are always direct-initializations and so are allowed to use
explicit constructors, which is a hole in our canonicality
tracking.  But overall I like the idea of always working
with canonical types.

Swift SVN r2893
2012-09-21 07:53:08 +00:00
John McCall
2c21ee7796 Add the compiler infrastructure for emitting references to tuple and
function metadata.

Swift SVN r2864
2012-09-18 07:23:51 +00:00
John McCall
8499117b59 The value witnesses for size/alignment/stride can just be size_t's.
This requires us to potentially copy the value witness tables for
generic struct types as part of computing layout, but that's not
the end of the world (although it will rely on a future patch
to split value witnesses out from protocol witness tables).

Oh, and add a value witness for stride, changing Builtin.strideof
to use that.

Swift SVN r2829
2012-09-06 08:23:14 +00:00
Eli Friedman
eb1689710f Delete isa, cast, and dyn_cast on Type. Hopefully, this will lead to fewer stupid mistakes.
Swift SVN r2691
2012-08-20 22:15:10 +00:00
Eli Friedman
77623b42be Fix IRGen of value witness tables for generic types.
Swift SVN r2656
2012-08-16 21:58:44 +00:00
Eli Friedman
2970604619 Switch the swift standard library over to the generic UnsafePointer. Fix an IRGen bug that showed up when I did that.
Swift SVN r2642
2012-08-15 23:28:51 +00:00
John McCall
baecef724d Work out a different way to meet access-control restrictions
on the archetype wtable mapping.  Amp up the asserts, too.

Swift SVN r2627
2012-08-14 00:34:15 +00:00
John McCall
cfaedbf6c4 More miscellaneous fixes towards getting slice_test to work.
Sadly, it doesn't yet --- some sort of unbound archetype.

Swift SVN r2622
2012-08-13 09:04:13 +00:00
John McCall
17027b8d8e Basic support for members of generic types.
Swift SVN r2619
2012-08-13 09:03:40 +00:00
Eli Friedman
1d5921105a Fix thunk emission for witnesses for protocol members returning an archetype.
Swift SVN r2557
2012-08-04 04:27:58 +00:00
Eli Friedman
0ab188aa20 Get generic min with the "<" operator working.
Swift SVN r2556
2012-08-04 02:00:59 +00:00
Eli Friedman
742f51f5b0 Some random fixes to avoid crashing on unimplemented IRGen codepaths.
Swift SVN r2554
2012-08-04 01:14:52 +00:00
John McCall
9106aa6254 Rewrite the function-call infrastructure. This gets us
a lot closer to successfully emitting the polymorphic-min-over-ranges
example;  the main blocker right now seems to be that the witness
for a static member function is not, in fact, a static member
function at al, but a freestanding function.  That's legitimate,
but it probably needs some shepherding through the witness
system.

Swift SVN r2532
2012-08-03 08:10:47 +00:00
Eli Friedman
a87d83b7b8 Work-in-progress towards getting generic new array expressions working.
Swift SVN r2509
2012-08-02 21:36:33 +00:00
Eli Friedman
84e858da4e Fix static member functions so a member of type T has type "metatype<T> -> () -> ()" instead of "() -> ()".
This is much more convenient for IRGen, and gives us a reasonable representation for a static
polymorphic function on a polymorphic type.

I had to hack up irgen::emitArrayInjectionCall a bit to make the rest of this patch work; John, please
revert those bits once emitCallee is fixed.



Swift SVN r2488
2012-07-28 06:47:25 +00:00
Eli Friedman
cfa9f4c101 Fix thunk generation for abstract return types in witness tables.
Swift SVN r2465
2012-07-26 21:28:45 +00:00
Doug Gregor
9e8633ac41 Encode and pass all of the archetypes, including derived archetypes,
in SpecializeExpr, so that we have complete substitution and
protocol-conformance information. On the IR generation side, pass
witness tables for all of the archetypes (again, including derived
archetypes) into generic functions, so that we have witness tables for
all of the associated types.

There are at least two major issues:

  (1) This is a terribly inefficient way to pass witness tables for
  associated types. The witness tables for associated types should be
  accessible via the witness tables of their parent. However, we need
  more information in the ASTs here, because there may be additional
  witness tables that will need to be passed for requirements that are
  placed on the associated type by the generic function itself.

  (2) Something about my test triggers a void/non-void verification failure
  in the witness build for an instance function whose abstracted form
  returns an associated type archetype and whose concrete form returns
  an empty struct. See the FIXME in the test.



Swift SVN r2464
2012-07-26 17:52:04 +00:00
Eli Friedman
83a29c9cff Fix a small FIXME related to static methods in witness tables.
Swift SVN r2451
2012-07-25 21:27:59 +00:00
Doug Gregor
64130a82ad When checking protocol conformance for an operator requirement,
perform global operator lookup and match those operators. We can now
type-check a proper 'min' function that uses '<'.


Swift SVN r2449
2012-07-25 21:10:48 +00:00
John McCall
ed38caaa04 Support generic return types, as long as they don't differ
by abstraction from the concrete return type.

This basically gets generic calls working totally as long
as there's no remapping required.

Swift SVN r2402
2012-07-23 07:06:28 +00:00
John McCall
3950a6af41 Generic calls status code dump activate!
Swift SVN r2386
2012-07-20 21:59:14 +00:00
Eli Friedman
d6a4ba90dd Move TypeLocs to a design where a TypeLoc is a struct containing a type plus
location info for that type.  Propagate TypeLocs a bit more through the AST.



Swift SVN r2383
2012-07-20 21:00:30 +00:00
John McCall
3b30fbfc36 Support multiple protocols on a generic parameter.
Swift SVN r2363
2012-07-17 06:20:38 +00:00
John McCall
b1d5c33e19 Support for trivial protocol compositon types.
Swift SVN r2362
2012-07-17 06:20:29 +00:00
John McCall
7d8231e22a Test basic functionality for protocol composition types.
Swift SVN r2357
2012-07-14 06:51:07 +00:00