Commit Graph

925 Commits

Author SHA1 Message Date
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
John McCall
20bfc9c1ec Initial, untested support for uniquing generic class metadata,
which is necessary to embed the value witnesses there.

Swift SVN r2671
2012-08-17 06:47:33 +00:00
John McCall
fc630c7f16 Inching towards a more useful idea of heap metadata.
In particular, prepare for storing real v-table-like information
in the heap metadata.  Give the metadata object proper linkage
and emit it as part of emitting the class.

Adjust the manglings of constructors and destructors while I'm
at it.

Swift SVN r2628
2012-08-14 06:51:17 +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
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +00:00
Chris Lattner
cd3f362faf revert r2364, which introduced the swift_allocClass entrypoint. The optimization that it was
trying to block has since been reverted, and I think there are other approachs that will work.


Swift SVN r2547
2012-08-03 23:27:15 +00:00
John McCall
011df45944 Fix the emission of member functions on generic types.
Swift SVN r2482
2012-07-27 18:37:09 +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
da8c01938e Reorg, monster comment.
Swift SVN r2391
2012-07-22 07:59:22 +00:00
John McCall
3950a6af41 Generic calls status code dump activate!
Swift SVN r2386
2012-07-20 21:59:14 +00:00
Eli Friedman
29b3994cca Add a new entry point for allocating classes. This API probably isn't really
right, but we need something in the meantime to make the optimizer understand
that there could be non-trivial destructors involved.



Swift SVN r2366
2012-07-17 23:25:02 +00:00
Eli Friedman
c9cb594eb3 IRGen for destructors. (This code is likely to change a lot once we design classes properly, but it should be a decent start.)
Swift SVN r2365
2012-07-17 22:41:23 +00:00
John McCall
b1d5c33e19 Support for trivial protocol compositon types.
Swift SVN r2362
2012-07-17 06:20:29 +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
Eli Friedman
2268f7155d Introduce UnresolvedNominalType to represent a generic type without an argument list, and add an argument list to NominalType to represent a generic type including an argument list.
Swift SVN r2299
2012-07-03 22:15:02 +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
85bdae402e Restructure code to permit protocols to be converted independently
of a ProtocolType.

Swift SVN r2242
2012-06-25 20:45:00 +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
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
Eli Friedman
6abcbcde33 Allow using LinkEntity for members of/witnesses for local types. As a simple test to start using them, get rid of getAddrOfLocalInjectionFunction.
Swift SVN r2084
2012-05-30 23:53:58 +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
John McCall
40d1591f89 Some minor tweaks to make our use of the allocation entrypoints
match the actual entrypoints vended by the runtime:
1) there is no swift_slowRawAlloc
2) swift_deallocObject takes two arguments
Also, make all calls to swift_allocObject go through a common
function so that we can easily use optimized entrypoints if the
runtime provides them.

Swift SVN r1993
2012-05-25 17:34:59 +00:00
John McCall
4b562e6b62 Use the actual raw-allocation APIs, including the optimized
allocation entrypoints.

Swift SVN r1976
2012-05-24 19:16:09 +00:00
John McCall
38bac7c706 Add Builtin.ObjCPointer with accompanying IR-gen support and
wrap it in an 'id' type in the standard library.

Also fix a bug noticed by inspection where initWithTake for
function types wasn't entering a cleanup for the taken value.
This probably doesn't matter for existing possibilities, but
it's potentially important under exceptions.

Swift SVN r1902
2012-05-18 23:40:17 +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
85acda32bb Implement basic functionality for protocol types, with the
exception of assign.

Swift SVN r1895
2012-05-18 10:01:46 +00:00
Eli Friedman
b788bad8e6 A couple missing pieces for classes. Also, a few fixes for local types.
Swift SVN r1873
2012-05-16 19:21:07 +00:00
John McCall
48cd78cfef Allow an opaque struct type to be specified as the struct
to perform struct-layout into.

Swift SVN r1823
2012-05-12 07:19:43 +00:00
Eli Friedman
77fa49ec2b Introduce StructDecl and StructType; use them for structs instead of OneOfDecl/OneOfType. To keep this patch small, I'm leaving in LookThroughOneOf etc. for the moment, but that's next on the agenda.
Swift SVN r1780
2012-05-09 00:27:44 +00:00
Eli Friedman
d9f8ab5084 Get rid of unused functions.
Swift SVN r1776
2012-05-08 21:14:07 +00:00
Eli Friedman
4ca443d0f5 Add OneOfDecl; use it as a DeclContext for OneOfElementDecls instead of OneOfType, and get rid of the implicit TypeAliasDecl. Add TypeDecl as a base class for OneOfDecl and TypeAliasDecl (and StructDecl, once we have it). Adjust a whole bunch of stuff to this new scheme.
Swift SVN r1774
2012-05-08 21:09:42 +00:00
Eli Friedman
c2868d6d0a Make local oneofs not crash in IRGen. <rdar://problem/11292678>.
Swift SVN r1743
2012-05-04 18:20:51 +00:00
Chris Lattner
774a557e5c Merge NamedDecl into ValueDecl, rdar://11379147.
Swift SVN r1737
2012-05-04 04:50:53 +00:00
John McCall
6cdecc020c Make all the subscripting getters/setters go down the same path.
This intentionally changes the mangling of variable getters and
setters so that we can have a reproducible mangling that doesn't
depend on things like the variables names, which is important
for resilience.  It's not currently important for subscripting,
although equally I see no reason to mangle in the subscript
pattern name.

Swift SVN r1590
2012-04-24 09:04:54 +00:00
John McCall
85fecab3b1 Reorganize the emission of a call site so that it's abstracted over
exactly how the arguments are emitted.  Introduce a new code path
which emits arguments from existing Explosions (possibly of the wrong
resilience level).  Use that code path to implement getter/setter
code for MemberRefExpr l-values.  This is just a checkpoint for the
latter two parts, but the ApplyExpr path is working correctly in the
new framework, which is worth a commit.

Swift SVN r1589
2012-04-24 08:16:51 +00:00
Eli Friedman
dc213bca76 Implement basic REPL under swift -repl. Known demo-blockers: need error recovery, need better brace/paren handling, need to implement the "print" part of REPL.
Swift SVN r1452
2012-04-18 00:52:11 +00:00
John McCall
5ad3782b01 Rework the IR-generation of initialization and teach the
compiler to enter properly-scoped cleanups to destroy local
variables.

Swift SVN r1385
2012-04-11 03:00:08 +00:00
John McCall
f3e27d90ff Change IR-generation so that it emits metadata objects for the
heap allocations it makes, and switch swift_alloc over to pass
that pointer in as well as the alignment.  Also, compute
whether a type is POD during its generation and cache that in
the object, and introduce a method on TypeInfo to destroy an
object in memory.

Swift SVN r1356
2012-04-10 06:28:22 +00:00
Chris Lattner
fbfb76a515 rename 'plus' methods to 'static' methods, resolving:
<rdar://problem/10718220> Need a better name than 'plus' for "static" functions



Swift SVN r1340
2012-04-06 17:50:43 +00:00
Eli Friedman
29f3fca950 First iteration of CaptureAnalysis.
Swift SVN r1284
2012-03-29 00:24:03 +00:00
John McCall
aafaae22bc Properly include the heap header when laying out structures
for the heap.

Swift SVN r1275
2012-03-27 23:54:10 +00:00
John McCall
99a6c4ccf1 Cache %refcounted* null. This will be particularly important
for heap l-values.

Swift SVN r1245
2012-03-20 19:42:00 +00:00
John McCall
d6b05b38a6 Document the various cached bits of IR on IRGenModule.
Swift SVN r1243
2012-03-20 19:41:54 +00:00
John McCall
53de72a7f1 Pull an unnecessary 'Explosion' out of some names.
Swift SVN r1217
2012-03-16 19:02:22 +00:00
John McCall
8831d35de1 The data pointer is also reference-counted.
Swift SVN r1215
2012-03-16 09:26:36 +00:00
John McCall
1f118dbda6 Basic support for Builtin.ObjectPointer as a completely
opaque type.  Also some rudimentary support for retain/release.

Swift SVN r1214
2012-03-16 09:26:32 +00:00
John McCall
2b65cf22d1 Make 'this' implicitly [byref] when the container type does
not have reference semantics.  Deciding whether the container
type has reference semantics requires us to perform
some amount of limited name-binding and type-checking first,
which introduces a few complexities.

Also, fix a bug in uncurried call emission.

Methods work now.



Swift SVN r1112
2012-02-11 07:37:57 +00:00