Commit Graph

521 Commits

Author SHA1 Message Date
Chris Lattner
fc04d57bd0 Rework the assign instruction in two major ways:
1. Change assign to follow SILGen's model for a semantic assignment,
   which (in the case of unowned pointers) doesn't require the left
   and right hand sides to be the same.
2. Change assign to consume/take the refcount from the LHS, following
   SILGen's design (which I completely misunderstood before).



Swift SVN r7787
2013-08-30 17:59:56 +00:00
Joe Groff
55c8418a4e SIL.rst: Update is_nonnull description for John's change.
Swift SVN r7750
2013-08-29 22:05:18 +00:00
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
This was not likely an error-free change.  Where you see problems
please correct them.  This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.

Swift SVN r7631
2013-08-27 21:58:27 +00:00
Michael Gottesman
b8e7ccd3ff Updated SIL.rst in light of r7602.
Swift SVN r7607
2013-08-26 23:41:04 +00:00
Joe Groff
c74dc79610 SIL: Add instructions to implement address-only unions.
Because union layout may interleave tag bits with payload data, we need to be able to efficiently inject and remove tag bits from an address-only union in-place. To do this, we'll model address-only union initialization by projecting out the data address (union_data_addr) and storing to it, then overlaying the tag bits (inject_union_addr). To dispatch and project out the data, we'll use a destructive_switch_union_addr instruction that clears any tag bits in-place necessary to give a valid data address.

Swift SVN r7589
2013-08-26 20:50:31 +00:00
Joe Groff
fe1ad586e7 SIL: Add a 'union' instruction to construct unions.
The instruction represents constructing a loadable union given a case and the data for that case, which will let us emit union constructor functions in SIL instead of IRGen (rdar://problem/14773182).

Swift SVN r7558
2013-08-24 18:33:24 +00:00
Chris Lattner
d4a0c16baa revert my r7505 patch to 'assign'. It turns out that changing
assign in this way doesn't actually make things simpler, and the
former model for assign is simpler to work with.


Swift SVN r7537
2013-08-23 22:40:56 +00:00
Chris Lattner
f6a5c78df2 Per John's advice (a few weeks ago), rework the 'assign' instruction
to being a semantic assign.  The functional difference here is only
for unowned pointers, where now the conversion from strong to unowned 
is implicit in the assign.

The logic behind this is that 'assign' is really part of SILGen, that
is only moved later to make it easier to make it be flow sensitive.
Since it is part of SILGen and will be using some of the type lowering
functionality used by SILGen, we should play by its rules.

No functionality change.


Swift SVN r7507
2013-08-23 18:15:21 +00:00
Joe Groff
fcbefd0c38 SIL: Don't allow switch_union to work with address-only unions.
In designing the runtime model for generic unions with John, we decided we're going to need very different SIL semantics for destructuring address-only unions, so I don't think trying to stretch switch_union to cover all unions makes any sense anymore.

Swift SVN r7225
2013-08-14 02:56:05 +00:00
John McCall
6794921f1d Describe operations on [weak] and [unowned] values.
Swift SVN r7221
2013-08-14 00:56:16 +00:00
John McCall
ab7d9e024a Describe local-storage types and the changes to alloc_stack.
Swift SVN r7220
2013-08-14 00:56:14 +00:00
Chris Lattner
c8f01a0bf3 Introduce a new SIL "assign" instruction to represent assignments in SIL when
SILGen doesn't know whether they are initializations or stores.


Swift SVN r7146
2013-08-12 14:24:52 +00:00
John McCall
268a947044 Update the SIL docs for dealloc_box.
Swift SVN r6932
2013-08-06 01:31:21 +00:00
Joe Groff
5a2128bc77 SIL: Model project_existential using an address.
Have project_existential return $*This instead of $Builtin.OpaquePointer, and have protocol_method do the same for methods of opaque protocols. This makes it easier for passes to reason about the semantics of the projected address, since it's restricted by the semantics of SIL addresses.

Swift SVN r6872
2013-08-03 01:48:15 +00:00
Joe Groff
ba774364f1 SIL: Have SILModules track their SILStage.
Modules can be in either 'Raw' or 'Canonical' form, with different invariants on each. We don't actually distinguish those invariants yet, but this patch adds the field to SILModule and adds a "sil_stage" declaration to SIL printer/parser syntax.

Swift SVN r6793
2013-08-01 00:58:31 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Joe Groff
26c00fd429 SIL: Add a switch_int instruction.
This will help represent cleanup blocks in the grown-up Clang way instead of the childish SILGen way, e.g.:

  retain %x
  retain %y
  ...
break_branch:
  %1 = int_literal 1 : $Builtin.Int64
  br cleanup(%1)
return_branch:
  %2 = int_literal 2 : $Builtin.Int64
  br cleanup(%2)
cleanup(%dest : $Builtin.Int64):
  release %z
  release %y
  switch %dest, case 1: break_dest, case 2: return_dest

Swift SVN r6753
2013-07-30 21:32:23 +00:00
Anna Zaks
fd52b193ec [SIL.rst] Minor edit to the Intro.
Swift SVN r6712
2013-07-29 21:55:04 +00:00
Joe Groff
3e6092db80 SIL.rst: Fill in details about how function context is consumed.
Swift SVN r6678
2013-07-27 17:03:15 +00:00
Joe Groff
24dc1cfad7 SIL: Remove the redundant associated_metatype instruction.
Its behavior was exactly the same in IRGen as 'metatype' on the associated type. Managing type metadata should be IRGen's job.

Swift SVN r6677
2013-07-27 04:13:59 +00:00
Joe Groff
1300efb8fb SIL: Represent float_literal values with bitwise representations.
This way we don't need to deal with the inaccuracy of decimal float literals. While we're here, modify the in-memory representation of IntegerLiteralInst and FloatLiteralInst to save the word array of the APInt instead of round-tripping through plain text.

Swift SVN r6676
2013-07-27 03:57:14 +00:00
Anna Zaks
abf9c1f99a [SIL.rst] Document an extra check we now perform on noreturn.
Swift SVN r6668
2013-07-27 00:30:11 +00:00
Joe Groff
60d440e124 SIL.rst: Give an example of uncurried decl refs.
Swift SVN r6653
2013-07-26 21:25:43 +00:00
Dave Abrahams
c8f46ae9ea SIL.rst: ReST syntax fixup
Swift SVN r6646
2013-07-26 17:12:36 +00:00
Dave Abrahams
628937e68e SIL.rst: stop using ReST line-block directives for grammar rules
Swift SVN r6644
2013-07-26 17:08:17 +00:00
Dave Abrahams
d20039bb2e SIL.rst: At Joe's request, change "class reference" to "class value" everywhere
...except one place where "reference" became "type"

Swift SVN r6643
2013-07-26 16:54:08 +00:00
Dave Abrahams
ea24dbd9db SIL.rst: Fix mis-merge
Swift SVN r6634
2013-07-26 00:34:58 +00:00
Dave Abrahams
aaa2295717 SIL.rst: Editorial fixes, part I
Swift SVN r6633
2013-07-26 00:33:02 +00:00
Joe Groff
553b445c8c SIL.rst: Clarify the syntax of apply instructions.
Swift SVN r6624
2013-07-25 23:39:38 +00:00
Joe Groff
8056358348 SIL.rst: Clarify UB semantics of project_existential insns.
Avoid the SSA watch word "use". The projected address or class reference from an existential can be spilled, phi-ed, or GVNed, but it's UB if it's passed to a protocol method from another existential, or if the address is dereferenced after the existential has been modified.

Swift SVN r6621
2013-07-25 23:02:24 +00:00
Joe Groff
f43aa1face SIL.rst: Remove needless reference to type canonicalization.
Swift SVN r6620
2013-07-25 22:46:51 +00:00
Joe Groff
91f8bc5b2a SIL.rst: Briefly discuss the cdecl and objc conventions.
C types are always trivial and C function signatures don't get mangled by the platform ABI at the SIL level. ObjC methods uncurry left-to-right, "_cmd" is magicked away, and they follow ARC's ownership rules for reference counting.

Swift SVN r6619
2013-07-25 22:28:31 +00:00
Joe Groff
f3d943f111 SIL.rst: Elaborate on how exactly function types get transformed.
Swift SVN r6618
2013-07-25 22:08:53 +00:00
Joe Groff
ac50a32428 SIL.rst: Remove absurd grammar example.
None of the instructions I used to demonstrate the operand syntax actually use it. That's dumb.

Also refactor the grammar to fix an inaccurate use of 'sil-value'. We allow the '#n' value index even in places we don't require a type, but not for instruction or bb argument defs.

Swift SVN r6615
2013-07-25 21:46:02 +00:00
Joe Groff
cbd8fc1665 SIL.rst: Make more explicit that 'coerce' has no runtime effect.
Swift SVN r6611
2013-07-25 21:00:12 +00:00
Joe Groff
e673b0cf55 SIL.rst: Update in response to DaveA comments.
Avoid overspecifying optimization/diagnostic passes because those aren't nailed down yet. Don't use "shared" to refer to boxed variables; it's meaningless in this context.

Swift SVN r6610
2013-07-25 21:00:10 +00:00
Joe Groff
258d4fd3c2 SIL.rst: Rename values in an example to avoid confusion.
Swift SVN r6606
2013-07-25 18:38:17 +00:00
Joe Groff
9fc4047d6c SIL.rst: Terminators never produce values.
Swift SVN r6604
2013-07-25 17:39:35 +00:00
Joe Groff
16d68f6115 SIL.rst: Update with feedback from ChrisL and Fariborz.
Swift SVN r6603
2013-07-25 17:37:05 +00:00
Chris Lattner
9d093f32af updates: increase some of the description of compiler flow, change some minor wording
and fix some syntactic issues.


Swift SVN r6590
2013-07-25 07:06:56 +00:00
Joe Groff
b85ba363a8 SIL.rst: Update SIL comment syntax.
Swift SVN r6575
2013-07-25 00:29:35 +00:00
Joe Groff
a6ff8a4479 SIL.rst: Update the calling convention section.
Swift SVN r6574
2013-07-25 00:25:54 +00:00
Joe Groff
213f2e8592 SIL.rst: Cleanups.
Swift SVN r6572
2013-07-24 23:32:37 +00:00
Joe Groff
e98dfb5ff4 SIL.rst: Call things out as UB instead of being vague.
Swift SVN r6571
2013-07-24 23:32:35 +00:00
Joe Groff
b1500945c2 SIL.rst: More words about addresses and generic function types.
Swift SVN r6570
2013-07-24 23:32:32 +00:00
Joe Groff
af2ffca8a2 SIL.rst: Elaborate on the restrictions on SIL address types.
Swift SVN r6565
2013-07-24 22:27:57 +00:00
Joe Groff
6850f6698e SIL.rst: Missing grammar rule.
Swift SVN r6564
2013-07-24 22:12:54 +00:00
Joe Groff
668f38732d SIL.rst: Cleanups.
Swift SVN r6562
2013-07-24 22:10:50 +00:00
Joe Groff
872e781093 SIL.rst: Document sil function linkage specifiers.
Swift SVN r6561
2013-07-24 22:10:48 +00:00
Joe Groff
777c1fd4e9 SIL.rst: Fix section reference.
Swift SVN r6560
2013-07-24 21:21:34 +00:00