Commit Graph

6634 Commits

Author SHA1 Message Date
Joe Groff
583ad139b6 SILGen: Remove AllocTmp, add AllocVar stack attr
Remove the AllocTmp instruction and represent MaterializeExpr allocations using 'alloc_var stack'/'dealloc_var stack' instructions. Rename Dealloc to DeallocVar, and add an AllocKind attribute to AllocVar and DeallocVar. Update MaterializeExpr SILGen to generate an AllocVar with a DeallocVar cleanup instead of AllocTmp. Tweak SILPrinter's presentation of AllocVar and DeallocVar to be in line with what SIL.rst claims.

Swift SVN r3311
2012-11-30 18:45:57 +00:00
Joe Groff
3d273367f4 SIL: rename TupleElementInst -> ExtractInst
Now that it's being used on both tuples and structs, the current name doesn't make much sense. SIL.rst specifies a unified set of extract/insert/gep instructions that operate on either tuples or nominal fragile structs.

Swift SVN r3303
2012-11-30 01:49:57 +00:00
Joe Groff
f8a2de9d61 Sync up with today's earlier SIL insn changes.
Swift SVN r3268
2012-11-27 22:44:44 +00:00
Joe Groff
253e953a98 SIL: Release arguments and retain stores to boxes.
Build some infrastructure for handling retain/release/copy/destroy of values. Use this to retain values when storing them into boxes and to clean up reference type arguments on function exit. Right now this just stupidly assumes "value type is trivial, reference type is retained/released", but it eventually needs to handle address-only types using the indirect copy_addr/destroy_addr instructions and to handle loadable value types with reference members by retaining the proper members. Passing arguments to function calls, reassignment, and cleanup of full expression temporaries all still need implementation.

Swift SVN r3267
2012-11-27 22:20:49 +00:00
Joe Groff
abc1724204 SILBuilder: use SILLocation in createR/R methods
Update createRetain, createRelease, etc. to use SILLocation instead of Expr * arguments to be in line with Chris's update in r3249.

Swift SVN r3263
2012-11-27 22:20:42 +00:00
Chris Lattner
6d8d9daee8 rename DestroyInst -> DestroyAddr to conform to SIL.rst. The non-addr form of destroy will be added later.
Swift SVN r3257
2012-11-27 18:35:57 +00:00
Chris Lattner
9750e36943 rename Copy -> CopyAddr to follow SIL.rst
Swift SVN r3256
2012-11-27 18:34:40 +00:00
Chris Lattner
0e264aeb98 prune some forward decls.
Swift SVN r3253
2012-11-27 02:06:43 +00:00
Chris Lattner
2c009210a4 rework a bunch of instructions to have a single constructor (and builder) form
that takes a generic SILLocation... instead of having duplicated constructors.


Swift SVN r3251
2012-11-27 01:28:23 +00:00
Joe Groff
a5157cac07 SILGen: generate alloc_box/release for PatternDecl
Update codegen for local variables and arguments to use the new alloc_box instruction to allocate retainable storage for the variables and to release the boxes when the variables go out of scope. Update tests to check for alloc_box and release sequences instead of alloc_var.

Swift SVN r3242
2012-11-26 17:48:37 +00:00
Chris Lattner
a9abb47cf0 rip out the 'is initialization' bit from StoreInst per SIL.rst. The AssignStmt
lowering code needs to emit the retain/release dance, but I'll leave that to
Joe :)


Swift SVN r3234
2012-11-17 01:56:57 +00:00
Joe Groff
39e1ba0e44 SIL: get IntLiteral/FloatLiteral values from AST
It would be better in the long term to copy the getText() from the AST into the instructions so they can stand independent of any AST node, but this is convenient for now.

Swift SVN r3233
2012-11-17 01:53:08 +00:00
Chris Lattner
aad1b3c904 remove the 'take' flag from LoadInst
Swift SVN r3232
2012-11-17 01:47:55 +00:00
Chris Lattner
2ddc716bba rename TypeConversion to Convert to follow SIL.rst
Swift SVN r3231
2012-11-17 01:38:41 +00:00
Joe Groff
6d58ee281d SIL: rip out redundant CharacterLiteralInst
Swift SVN r3230
2012-11-17 01:32:16 +00:00
Chris Lattner
8c0513f9cc rename index_lvalue instruction to index_addr to follow SIL.rst.
Swift SVN r3226
2012-11-17 01:22:19 +00:00
Chris Lattner
8ad5ba2428 introduce an alloc_box instruction. Also, normalize alloc_array to follow
the syntax in SIL.rst.


Swift SVN r3224
2012-11-17 01:09:42 +00:00
Chris Lattner
fadda48e26 Switch the alloc_array instruction to return two results instead of a tuple.
Where before we had:

  %8 = alloc_array element type=Int, %7
  %9 = tupleelement %8, 1
  %10 = tupleelement %8, 0
  %11 = type_conversion %9 -> Builtin.RawPointer
..
  %17 = apply %16(%11, %10, %7)

we now have:

  %8 = alloc_array element type=Int, %7
  %9 = type_conversion %8#1 -> Builtin.RawPointer
..
  %15 = apply %14(%9, %8#0, %7)



Swift SVN r3220
2012-11-17 00:12:18 +00:00
Chris Lattner
d92ccc0747 remove the incorrect V->getType() method, forcing clients to specify a result#
they want (e.g. V->getType(0)), or, better yet, to use V.getType() which includes
the result # implicitly.


Swift SVN r3218
2012-11-16 23:58:28 +00:00
Chris Lattner
a2d60a1fe1 switch V->getType() uses (which are unsafe if V points to something with multiple results) to
V.getType() which returns the type of the value being referenced.


Swift SVN r3217
2012-11-16 23:57:11 +00:00
Chris Lattner
6ab2a17518 make ValueBase::getType() take a result number, right now default it to zero in the
base class, which is wrong.  Add shadowing versions that do allow no argument in 
derived classes where it is right.


Swift SVN r3216
2012-11-16 23:52:05 +00:00
Chris Lattner
09a0566d34 start getting crazy: store and control flow instructions now have no result.
Swift SVN r3210
2012-11-16 22:32:49 +00:00
Chris Lattner
06ead2d5cb just some comment fixes.
Swift SVN r3208
2012-11-16 22:24:02 +00:00
Chris Lattner
d87f65f1a3 Land a pretty big conceptual/API change to pave the way for multiple
return values.  Now the base class of the value hierarchy is "ValueBase"
instead of "Value", and "Value" is now a PointerIntPair indicating the
ValueBase (e.g. an instruction) being referenced along with what result
value is being referenced.

By default, any place you used "Value*" before, you should now use "Value".


Swift SVN r3207
2012-11-16 22:21:47 +00:00
Chris Lattner
4e1893236c switch the storage representation of Value::Type to be a PointerUnion<Type,TypeList*> handling
the 0/1/N cases of types.  Still only form the "1" case though.


Swift SVN r3206
2012-11-16 21:09:53 +00:00
Chris Lattner
4643edc850 initial support for uniquing SIL type lists, not used yet.
Swift SVN r3204
2012-11-16 19:45:51 +00:00
Joe Groff
73f87996c3 SIL: add instruction types for ARC and lvalues
Add RetainInst, ReleaseInst, DeallocInst for managing object lifetimes, and CopyInst and DestroyInst for indirectly managing resilient types and other non-materializable types.

Swift SVN r3159
2012-11-12 18:00:16 +00:00
Chris Lattner
091bf35360 rename SIL.h -> Function.h
Swift SVN r3135
2012-11-07 01:39:05 +00:00
Chris Lattner
6cadce0ab1 rename the CFG type to "Function", since it is the SIL Function concept,
which is separable from the SIL library.


Swift SVN r3134
2012-11-07 01:37:49 +00:00
Chris Lattner
57eea530a9 more random changes CFG -> SIL
Swift SVN r3133
2012-11-07 01:31:27 +00:00
Chris Lattner
8eec098ffd rename more references to CFGs to SIL.
Swift SVN r3132
2012-11-07 01:13:31 +00:00
Chris Lattner
eab0962c5f rename many references to CFG to SIL.
Swift SVN r3130
2012-11-07 01:06:19 +00:00
Chris Lattner
93ae03891d rename the SIL/CFG*.h headers to SIL/SIL*.h
Swift SVN r3128
2012-11-07 00:56:21 +00:00
Chris Lattner
3a559b4318 rename include/swift/CFG -> include/swift/SIL.
Swift SVN r3127
2012-11-07 00:52:51 +00:00