Commit Graph

179 Commits

Author SHA1 Message Date
Joe Groff
093f803a95 IRGen: Remove now unneeded SILType::getSwiftType calls from GenTuple.
Swift SVN r5206
2013-05-17 18:12:24 +00:00
Joe Groff
b439e49625 IRGen: Use SILTypes in field projection functions.
Swift SVN r5154
2013-05-10 23:17:08 +00:00
John McCall
1fec73a8d2 Untested support for tuples with generically-sized elements.
Swift SVN r4926
2013-04-26 21:33:24 +00:00
John McCall
65fc2b74f8 Basics of dynamic struct layout.
Swift SVN r4902
2013-04-25 01:39:58 +00:00
Chris Lattner
85663f6df2 simplify Explosion by eliminating (now) copies of existing methods.
This removes addUnmanaged, ignoreAndDestroy, ignoreUnmanaged, claimUnmanagedNext,
claimUnmanaged, forwardNext, and forward


Swift SVN r4846
2013-04-21 06:29:50 +00:00
Chris Lattner
9ae0cf3bee inline Initialization::emitLocalAllocation into each of its callers and
eliminate the Initialization class and GenInit.h.  GenInit.cpp will stay
around, as it has some other random stuff in it.


Swift SVN r4845
2013-04-21 06:13:59 +00:00
Chris Lattner
0be7bbdddf remove ManagedValue.
Swift SVN r4843
2013-04-21 05:56:02 +00:00
Chris Lattner
abee79b26e remove some Expr stuff.
Swift SVN r4810
2013-04-18 22:32:37 +00:00
John McCall
38b34b7307 Pass #1 at localizing assumptions about fixed layout and
handling non-fixed layouts.

This uncovered a bug where we weren't rounding up the header
size to the element alignment when allocating an array of archetypes.

Writing up a detailed test case for *that* revealed that we were
never initializing the length field of heap arrays.  Fixing that
caused a bunch of tests to crash trying to release stuff.  So...
I've left this in a workaround state right now because I have to
catch a plane.

Swift SVN r4804
2013-04-18 07:58:21 +00:00
Chris Lattner
dc0454e1d2 remove GenArray.{h,cpp} as they are handled by SILGen. Remove getAddrOfLocalFunction.
Swift SVN r4796
2013-04-18 05:12:01 +00:00
Chris Lattner
47e508c24d remove LValue, PathComponent, and LValue.h as a whole.
Swift SVN r4792
2013-04-18 04:50:03 +00:00
Chris Lattner
ffe3388aa5 remove the dead logic form GenTuple, RValueInitEmitter, and some
erasure/protocol expr logic.


Swift SVN r4775
2013-04-17 06:34:27 +00:00
Chris Lattner
12a9c88ef1 zap GenLValue.h and supporting logic.
Swift SVN r4771
2013-04-17 05:38:57 +00:00
Chris Lattner
ade66c8b10 Remove the emitIgnored, emitLValue, and tryEmitAsAddress mechanics and
supporting logic.


Swift SVN r4770
2013-04-17 05:33:23 +00:00
Joe Groff
1459512901 IRGen: SIL tuple helper instructions.
Implement ElementAddrInst for lvalue tuples, and implement the AllocArray, IndexAddr, and IntegerValue insts used to lower variadic tuples. (Actually compiling code that uses variadic tuples still requires support for SpecializeInst and generic functions.)

Swift SVN r3781
2013-01-17 18:17:39 +00:00
Joe Groff
8320df8b9d IRGen: SIL branching and variable allocation.
Implement SIL-to-IR lowering for allocation, deallocation, load, store, and branching instructions so that local variables and branching control flow can be used. Add a Fibonacci loop test to exercise the new instructions.

Swift SVN r3767
2013-01-15 22:32:49 +00:00
Joe Groff
9259c0d912 IRGen: Get "hello world" to compile through SIL.
Add a path through IRGenModule to optionally codegen FuncDecls using their corresponding SIL Functions when constructed with a SILModule. Jury-rig an IRGenSILFunction subclass of IRGenFunction that does the bare minimum necessary to compile "hello world" from SIL. There are some impedance mismatches between irgen and SIL that need to be smoothed out, particularly the AST-dependent way irgen currently handles function calls. Nonetheless, `swift -sil-i hello.swift` works!

Swift SVN r3759
2013-01-14 02:57:11 +00:00
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +00:00
Chris Lattner
4494a988f4 implement support for default arguments and varargs in ScalarToTupleExpr lowering.
There is an apparent case where sema isn't computing the varargs injection function when it should (example 'd'), I'll look at that next.


Swift SVN r3028
2012-10-19 22:42:27 +00:00
Eli Friedman
dd299a35af Fix for LLVM TargetData -> DataLayout rename.
Swift SVN r2959
2012-10-09 23:18: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
Eli Friedman
d8b84d6cd0 Add ScalarToTupleExpr to represent an implicit conversion from a scalar to a tuple. Part of <rdar://problem/12337042>.
Swift SVN r2887
2012-09-21 00:45:33 +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
f1f67db652 Big cleanup for how we handle computing types for functions and semantic
analysis for patterns.

Major changes:
1. We no longer try to compute the types of functions in the parser.
2. The type of a function always matches the type of the argument patterns.
3. Every FuncDecl now has a corresponding FuncExpr; that FuncExpr might not
   have a body, though.
4. We now use a new class "ExprHandle" so that both a pattern and a type
   can hold a reference to the same expression.

Hopefully this will be a more reasonable foundation for further changes to
how we compute the types of FuncDecls in generics and for the implementation
of type location information.



Swift SVN r2370
2012-07-19 02:09:04 +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
Eli Friedman
1341f19da8 IRGen for varargs tuples.
Swift SVN r1883
2012-05-17 03:22:49 +00:00
Eli Friedman
6e69e27975 Kill ScalarToTupleExpr, which is no longer in use.
Swift SVN r1881
2012-05-17 01:50:48 +00:00
John McCall
8617d1733d Change the IR translation of struct types to just require a single
level of IR struct type.  At first we were emitting two layers
because structs were secretly tuples, and then more recently
we were emitting two layers to avoid having to adjust a bunch
of tests.  Just bite the bullet now;  it makes the IR a lot
cleaner, and it's never going to be easier.

Swift SVN r1824
2012-05-12 07:19:48 +00:00
Eli Friedman
01a18f6c7a Use VarDecls to represent struct members, and MemberRefExprs to represent member access in structs. Eliminate the horrible hack which was LookThroughOneOfExpr.
Swift SVN r1808
2012-05-11 03:08:15 +00:00
John McCall
875d914c77 Extract the layout logic out of GenTuple.cpp into a template header.
It does seem silly for this to all be templated, but I couldn't
really see a very elegant solution given how I wanted things to
be genericized.

...interestingly, a ?t.t[] type would have done nicely for some
of this.

Swift SVN r1807
2012-05-11 01:34:56 +00:00
Eli Friedman
f75e305a20 Add ScalarToTupleExpr to represent an implicit conversion from a scalar to a tuple, with or without default arguments. Make Sema and IRGen work with them.
I'm not completely sure this is the representation we want, but it isn't much code to rip out if we decide to represent it some other way.

While I'm in the area, also fix a case where tuple->tuple conversion wasn't working.



Swift SVN r1748
2012-05-05 00:50:06 +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
ab44ee7921 Don't force PathComponent subclasses to propagate their size
upwards;  this is very error-prone.

Swift SVN r1626
2012-04-25 08:36:21 +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
Eli Friedman
372ecb3b6b Fix Ted's latest fractal testcase. <rdar://problem/11278118>. (There were two issues: an assertion failure in tryEmitTupleElementAsAddress, and a strange runtime failure caused by incorrect refcounting.)
Swift SVN r1524
2012-04-20 04:14:22 +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
Ted Kremenek
352453a53b Revert "Fix a bunch of "has virtual functions but non-virtual destructor" warnings"
Swift SVN r1376
2012-04-11 00:02:16 +00:00
Ted Kremenek
8a61ea1fd0 Fix a bunch of "has virtual functions but non-virtual destructor" warnings
Swift SVN r1373
2012-04-10 23:53:46 +00:00
John McCall
0cd849b19c Complete the pattern-matching IR emission logic,
at least for exhaustive patterns.

Swift SVN r1359
2012-04-10 08:28:31 +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
John McCall
ca9f85d694 Add code for associating cleanups with intermediate
evaluation results and then claiming or forwarding the
ownership of such results.

Swift SVN r1337
2012-04-06 07:07:28 +00:00
John McCall
edad637ddb In preparation for Explosion storing some sort of cleanup pointer,
add some APIs for working with non-cleaned-up entities.

Swift SVN r1336
2012-04-06 07:07:22 +00:00
Eli Friedman
debd0361ee Fix a couple crashers for tuples with default values.
Swift SVN r1289
2012-03-29 02:54:02 +00:00
John McCall
173d750a02 Switch IR-generation to use ASTVisitor, or more precisely, to
use irgen::ASTVisitor, which is a subclass of the AST version
that always looks through some expressions and asserts that
others (the unchecked/error ones) can't happen.  The main
obstacle to that is access control, because it's quite nice to
have the visitor be a non-local class for nesting purposes,
but that makes it impossible to use private methods anymore.
It's nice to give all the type-specific emitters private
interfaces anyway, though;  that ends up being most of the
patch.

I futzed with GenClosure.cpp while I was in there, but
separating it would have been obnoxious.

Swift SVN r1267
2012-03-26 06:08:19 +00:00
John McCall
df7ebcd9e8 Introduce the concept of an 'owned address', i.e. an address with
an owner attached.  Use this to implement [byref(heap)].  Force
locals to the heap if they've been referenced in a way that requires
this.

Swift SVN r1265
2012-03-26 03:26:21 +00:00
John McCall
52598e0e91 Kill more unnecessary 'Exploded's from method names, and do
a minor reorganization with CallPlan.

Swift SVN r1223
2012-03-17 00:44:58 +00:00
John McCall
e020724c3d Distinguish between assignment and initialization, and fix
some problems with the data pointer of function types.

Swift SVN r1220
2012-03-16 19:02:25 +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
d76aaea2b6 Remove the outdated RValue concept; no functionality change.
Swift SVN r1216
2012-03-16 09:26:39 +00:00
John McCall
9038a38ce8 We will need a DiverseStack<T> for cleanups, but a stack is really
the wrong structure for an l-value.  Use a list instead (that is,
something which allows efficient iteration forward through the
collection).

Swift SVN r1117
2012-02-16 06:11:30 +00:00