Commit Graph

12816 Commits

Author SHA1 Message Date
John McCall
14489d4cad Fix test.
Swift SVN r2865
2012-09-18 07:23:54 +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
5b10c5df32 Move emitClassMetadataRef to GenMeta.cpp and make it work for
an arbitrary metadata type.

Swift SVN r2862
2012-09-18 07:23:44 +00:00
John McCall
c4c8c5cbe7 Expose an API to fetch a class metadata pointer.
Swift SVN r2861
2012-09-18 07:23:40 +00:00
John McCall
77ac36ce66 This hack is no longer necessary. Thanks, Doug!
Swift SVN r2860
2012-09-18 07:23:36 +00:00
John McCall
1529e0ddd4 Arrange for general mangling of type metadata.
Swift SVN r2853
2012-09-13 21:26:07 +00:00
John McCall
d84d024f52 Fix an uninitialized-memory bug.
Swift SVN r2852
2012-09-13 21:26:05 +00:00
John McCall
ab8677cf7f Change the mangling of metadata objects to be more consistent.
Swift SVN r2850
2012-09-13 21:26:02 +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
Chris Lattner
7055cfe43a move DiverseList and DiverseStack to swift/Basic, out of IRGen.
Swift SVN r2784
2012-08-26 20:10:10 +00:00
Chris Lattner
2a8a6b04d8 microoptimize IRGen's emitCondition a bit: instead of emitting a xor to
invert a condition, just output an inverted conditional branch (swap the 
true/false dests).


Swift SVN r2778
2012-08-26 17:20:23 +00:00
Ted Kremenek
a5ec0af7e8 Rename 'BraceStmt::elements()' to 'getElements()' to match Swift
naming style for accessors.

Swift SVN r2742
2012-08-24 14:17:28 +00:00
John McCall
e7b9ae47fa Defer to the value witness when moving an archetype. This
is really a deficiency in TypeInfo::initializeWithTake, which
is now virtual and not implemented in TypeInfo anymore.  This
fixes rdar://problem/12153619.

While I'm at it, fix an inefficiency in how we were handling
ignored results of generic calls, and add 4 new builtins:
  Builtin.strideof is like sizeof, but guarantees that it
  returns a multiple of the alignment (i.e., like C sizeof,
  it is the appropriate allocation size for members of an
  array).
  Builtin.destroy destroys something "in place";  previously
  this was being simulated by moving and ignoring the result.
  Builtin.allocRaw allocates raw, uninitialized memory, given
  a size and alignment.
  Builtin.deallocRaw deallocates a pointer allocated with
  Builtin.allocRaw;  it must be given the allocated size.

Swift SVN r2720
2012-08-23 05:21:31 +00:00
Eli Friedman
ae7c99020b Fix use of uninitialized member.
Swift SVN r2715
2012-08-22 22:50:03 +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
John McCall
8e735aec52 Bind generic parameter witnesses when emitting a generic
class destructor.

Swift SVN r2672
2012-08-17 07:45:09 +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
e74432a7b9 More incremenetal progress on metadata layout.
Swift SVN r2670
2012-08-17 06:47:29 +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
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
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
Eli Friedman
30b74f45d4 Fix the type of main(); make it return 0. <rdar://problem/11986212>
Swift SVN r2639
2012-08-15 21:21:55 +00:00
John McCall
1324d50299 Good switch hygiene.
Swift SVN r2629
2012-08-14 06:57:51 +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
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
b82165019c Fix access-control bug in a slightly different way.
Swift SVN r2626
2012-08-14 00:34:09 +00:00
Doug Gregor
0d7afbe5e0 Introduce an almost completely untested implementation of constraint
generation from an expression that has not been type-checked. One can
see the constraints introduced by an expression by using

  :dump_constraints <expression>

within the REPL. We're still missing several major pieces of
constraint generation:
  - We don't yet "open up" references to polymorphic types
  - We don't print out the child constraint systems in the dump, so
  it's not at all obvious what happens within overloading (and I'm not
  convinced I like my representation anyway)
  - There are no tests whatsoever
  - Member constraints are still very, very weird



Swift SVN r2624
2012-08-13 22:59:41 +00:00
Doug Gregor
0a30594524 Access control fix for those using a bleeding-edge Clang.
Swift SVN r2623
2012-08-13 17:53:16 +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
286a1a14dd Assert early when something tries to add null to an explosion.
Swift SVN r2621
2012-08-13 09:04:04 +00:00
John McCall
e64342b29a Bugfixes with properties of generic types.
Swift SVN r2620
2012-08-13 09:03:51 +00:00
John McCall
17027b8d8e Basic support for members of generic types.
Swift SVN r2619
2012-08-13 09:03:40 +00:00
John McCall
26ae1648c2 More restructuring in support of emitting getter/setter
calls on different base types.

Swift SVN r2618
2012-08-13 09:03:32 +00:00
John McCall
fbafe28ffb Progress towards making GetterSetterComponent more abstractable.
Swift SVN r2617
2012-08-13 09:03:24 +00:00
John McCall
88e03293cc Change the formal type of subscript declarations to always
pass the index as a separate argument.  This makes it much
easier to work with these things generically.

Swift SVN r2616
2012-08-13 09:02:37 +00:00
Eli Friedman
6781f56cfd Start of support for class inheritance.
Swift SVN r2598
2012-08-09 21:56:05 +00:00
Ted Kremenek
479077e354 Remove individual element setters from BraceStmt, and just use MutableArrayRef and ArrayRef to access its elements.
Swift SVN r2586
2012-08-08 05:06:33 +00:00
Eli Friedman
95cb2d6af2 Add builtins to convert between arbitrary retainable pointers,
Builtin.ObjectPointer, and Builtin.RawPointer.  I don't really like the way
these builtins are defined (specifically, the part where messing up
gives a mysterious IRGen error), but it's workable. <rdar://problem/11976323>.



Swift SVN r2585
2012-08-08 00:40:07 +00:00
Doug Gregor
1b510128c7 Factor the mangling of generic parameter lists (i.e., their
archetypes) into a single place, and cope with outer parameter
lists. Incrementally stepping toward IRgen support for nested generics.


Swift SVN r2570
2012-08-06 23:16:34 +00:00
Doug Gregor
531583e2d1 Implement support for nested generics in the AST and type
checker. There are a few related sets of changes here:

  - Generic parameter lists have a link  to their "outer" generic
  parameter lists, so its easy to establish the full generic context
  of an entity.
  - Bound and unbound generic types now carry a parent type, so that
  we distinguish between, e.g., X<Int>.Inner<Int> and
  X<Double>.Inner<Int>. Deduction, substitution, canonicalization,
  etc. cope with the parent type.
  - Opening of polymorphic types now handles multiple levels of
  generic parameters when needed (e.g., when we're substituting into
  the base).

Note that the generics module implied by this representation restricts
what one can do with requirements clauses in nested generics. For
example, one cannot add requirements to outer generic parameters or
their associated types, e.g., this is ill-formed:

  struct X<T : Range> {
    func f<U requires T.Element : Range>() {}
  }

The restriction has some precedent (e.g., in C#), but could be
loosened by rearchitecting how we handle archetypes in nested
generics. The current approach is more straightforward.


Swift SVN r2568
2012-08-06 19:02:06 +00:00
Chris Lattner
1f8c05dc75 teach the destructor analysis to ignore stores to 'this' object, allowing us to delete
trivial dtors like:

class File {
  var x : Int
  destructor { x = 4 }
}



Swift SVN r2565
2012-08-06 15:55:01 +00:00
Chris Lattner
4b05e121c9 teach the destructor analysis code to ignore retains and releases of
'this'.  This allows us to zap the default class dtor when it is
empty, e.g.:

class File {
}

func test() {
  var f : File = new File()
}



Swift SVN r2564
2012-08-06 15:50:00 +00:00
Chris Lattner
946b142b33 rename DTorFn to DtorFn to be more consistent with other names.
Teach the optimizer that readonly/readnone functions obviously
have no side effect, so we don't even need to look at their bodies.


Swift SVN r2562
2012-08-05 23:53:56 +00:00
Chris Lattner
3139f3dcc5 Reenable the "store only object elimination" optimization, with a *very* simple
metric to decide whether a dtor is side-effect free.  This will be improved later
(to make it more aggressive), but is enough to get us to optimize away maxtest
from rdar://11542743 again, thus resolving rdar://11939216



Swift SVN r2559
2012-08-05 17:50:31 +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
996d891b53 Make the mangler handle a couple of constructs which show up in slice_test.
Swift SVN r2555
2012-08-04 01:30:02 +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
Eli Friedman
c9c542b2b9 Fix the computed type of getters/setters on generic types in IRGen.
Swift SVN r2553
2012-08-04 00:16:33 +00:00
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +00:00