Commit Graph

280 Commits

Author SHA1 Message Date
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +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
John McCall
3c053a7b98 In preparation for shifting the metadata layout, widen
the metadata kind field to a full word.

Swift SVN r3183
2012-11-14 08:45:29 +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
07482e6de1 If the root class in a hierarchy is marked with [objc], we
have to use objc_retain/release.

Swift SVN r3089
2012-10-30 00:20:40 +00:00
John McCall
84f3b7f884 Unify the ObjC and Swift heap pointer TypeInfos.
Swift SVN r3088
2012-10-30 00:19:33 +00:00
Chris Lattner
e475986dbc adapt to mainline llvm API changes.
Swift SVN r3006
2012-10-16 17:54:16 +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
2d03d842f5 Move class metadata emission into GenMeta.cpp. The main
motivation for this is to re-use code involving generic nominal
types.

Swift SVN r2891
2012-09-21 07:52:58 +00:00
John McCall
a695354dc1 Make heap metadata use the metadata scheme.
Swift SVN r2871
2012-09-19 06:33:41 +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
26f07eca36 Throw the switch to start using generic slices everywhere. Out with the old,
in with the new!

Random notes:
1. I had to XFAIL 4 IRGen tests; I'll file radars on them.
2. I preserved SliceStringByte and renamed it StringByteData because
   it has some String-specific functionality.
3. There's a small IRGen patch included which fixes a couple of runtime
   failures involving generic array new.



Swift SVN r2644
2012-08-16 02:04:20 +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
bd6ff42df2 A couple misc fixes for a testcase John and I were looking at (array new over a generic type). Not committing the testcase because it's still broken.
Swift SVN r2487
2012-07-27 22:20:36 +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
24a84132ca More CC-related changes.
Swift SVN r2150
2012-06-05 04:51:04 +00:00
Eli Friedman
26bebcfd61 IRGen for break/continue.
Swift SVN r2089
2012-05-31 02:45:18 +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
06992eec7a Introduce helper templates to make it easier to define
type infos that can be efficiently scalarized.

Swift SVN r1904
2012-05-19 03:16:08 +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
Eli Friedman
33f20a14e0 Add NewReferenceExpr, for allocating class objects.
Swift SVN r1867
2012-05-16 01:36:03 +00:00
John McCall
be2bfa9eb7 Don't emit the begin/end pointers in an array destructor if
the element type is trivial, and test that we correctly emit
loops when the element type is not trivial.

Swift SVN r1653
2012-04-26 08:07:35 +00:00
John McCall
ee61610563 Implement IR generation for NewArrayExpr.
Swift SVN r1651
2012-04-26 07:34:04 +00:00
John McCall
b3b71178a5 Fix a pair of bugs with partial updates of logical l-values:
first, we weren't registering the cleanup for the temporary
if it needed materialization, and second, we were potentially
double-consuming cleanups associated with the l-value, e.g.
subscript indices.

Swift SVN r1631
2012-04-25 09:39:22 +00:00
John McCall
bc32a8aedb Fix a bug with returning value that need to be refcounted:
we want to do a take-load out of the return address slot
instead of a normal load, or else we'll end up +1'ing an
already +1 value.

Swift SVN r1564
2012-04-23 17:47:07 +00:00
John McCall
50899952e3 Fix a consistency error: just because a value doesn't
require reference counting doesn't mean we shouldn't
add it to the explosion when "retaining" it.

Swift SVN r1500
2012-04-19 21:05:26 +00:00
John McCall
0146f895a0 Merge GenRefCount.cpp into GenHeap.cpp.
Swift SVN r1387
2012-04-11 03:44:47 +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