Commit Graph

12848 Commits

Author SHA1 Message Date
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
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
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
0bfcfbfb8a Change the type of ConstructorDecls to be of the form metatype<T> -> () -> (). Change a bunch of stuff to compensate. Get rid of ConstructorRefExpr, which is no longer used.
Swift SVN r2526
2012-08-03 03:58:44 +00:00
Eli Friedman
3d0d23b3ce Stop use OneOfElementDecls to represent constructors in structs.
Swift SVN r2518
2012-08-03 00:53:36 +00:00
Eli Friedman
519a683557 Shuffle around code to avoid a crash after IRGen errors.
Swift SVN r2510
2012-08-02 21:51:19 +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
76e6aa41b0 Change the computed type for OneOfElementDecls in OneOfs: for an Optional<T>, the OneOfElementDecl for Some now has type <T>(metatype<Optional<T>>) -> (T) -> Optional<T>, and the OneOfElementDecl for None has type <T>(metatype<Optional<T>>) -> Optional<T>.
The IRGen test is turned off because of another call-related IRGen crash (specifically, an indirect call of an indirect call crashes).



Swift SVN r2497
2012-07-30 23:31:23 +00:00
Ted Kremenek
4e121919d7 Remove redundant assignment. 'Changed' is unconditional set a few lines later.
Swift SVN r2490
2012-07-30 18:30:23 +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
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
f21d83aede Fix the standard library to use uitofp instead of sitofp
when turning integer constants into floating-point values.
Teach IR-gen to fold stdlib convertFromIntegerLiteral and
convertFromFloatLiteral calls.
Update a bunch of tests.

Swift SVN r2485
2012-07-27 21:03:17 +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
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
John McCall
6e5cdeadaa Fix a mangling ambiguity by ensuring that manglings never end
in a digit.  This penalizes the manglings of things using
builtin types but is kinder to the manglings of tuples.

Also, invent a not-unreasonable mangling for generic function
types and archtypes within them.

Swift SVN r2461
2012-07-26 07:03:17 +00:00
Eli Friedman
5419c62e9f Add missing Scope in logical &&/|| IRGen. <rdar://problem/11959537>.
Swift SVN r2459
2012-07-26 00:21:46 +00:00
John McCall
d076d5fc04 Mangling for BoundGenericType.
Swift SVN r2458
2012-07-25 22:54:15 +00:00
Eli Friedman
688138482d Complete the implementation of a basic Vector<T>.
Swift SVN r2457
2012-07-25 22:51:46 +00:00