Commit Graph

144 Commits

Author SHA1 Message Date
Joe Groff
801efc55e7 SIL.rst: ReST typo.
Swift SVN r8577
2013-09-24 00:17:56 +00:00
Joe Groff
014f270516 SIL: Have project_existential_ref project to a protocol Self archetype.
This mirrors the behavior of project_existential and simplifies some special cases in SILGen. It unfortunately makes dynamic_lookup sequences a bit noisier because of the need to explicitly cast the projection from DynamicLookup.Self to Builtin.ObjCPointer, but I think this modeling is more solid and will fit better with my planned redesign of archetype_method/protocol_method.

Swift SVN r8572
2013-09-23 21:57:12 +00:00
Joe Groff
14f1b9da42 SIL.rst: Update for 'This' -> 'Self' sea change.
Swift SVN r8571
2013-09-23 21:57:05 +00:00
Joe Groff
9e54a69016 SIL: Allow RefToObjectPointer and ObjectPointerToRef to cast to/from Builtin.ObjCPointer.
Swift SVN r8558
2013-09-23 16:20:29 +00:00
Joe Groff
26125d050b Update 'union' references in other docs.
Swift SVN r8483
2013-09-20 04:41:49 +00:00
John McCall
7954960797 Add 'copy_value' and 'destroy_value' operations to destroy
entire aggregates at once.

This has three worth effects:
  - It significantly decreases the amount of SIL required
    for these operations.
  - It makes it far easier for IR-gen to choose efficient
    patterns of destruction, e.g. calling a single entrypoint
    or recognizing that it can just use the runtime 'release'
    entrypoints.
  - It makes it easier to recognize and optimize aggregate
    copy/destroy operations.
It does make SROA-like tasks a bit more challenging.  The
intent is to give TypeLowering a way to expand these into
their primitive behavior.

Swift SVN r8465
2013-09-19 22:14:55 +00:00
Joe Groff
04b9685d84 SIL.rst: Remove currently irrelevant and potentially confusing caveat.
Swift SVN r8219
2013-09-13 22:25:18 +00:00
Joe Groff
7b37f2d445 SIL.rst: Clarify class subtyping rules wrt generic instances.
Swift SVN r8216
2013-09-13 22:12:07 +00:00
Joe Groff
6e56a4206c SIL.rst: Describe aliasing rules for heap object references.
Clarify that, unlike SIL addresses, class values and other heap object references can alias and be captured. Class value aliasing is controlled by the type system.

Swift SVN r8210
2013-09-13 21:01:58 +00:00
Chris Lattner
7c8ae9352a Add a new "mark_function_escape" instruction that will be used to mark the
escape point of function definitions that "close" over global variables.



Swift SVN r8152
2013-09-12 18:31:00 +00:00
Chris Lattner
3c0c9a5da7 introduce a new mark_uninitialized SIL instruction which will be used by
definitive initialization of top-level code.


Swift SVN r8144
2013-09-12 04:30:48 +00:00
Joe Groff
f58d65a903 SIL.rst: Update description of 'thunk' linkage for its broader role.
Swift SVN r8124
2013-09-11 23:51:16 +00:00
Joe Groff
705102b544 SIL: Rename 'ClangThunk' specifier to 'Thunk'.
Lazily-generated currying thunks will require the same IR-level linkonce_odr linkage as clang thunks currently do, so generalize the name of the existing SIL-level linkage specifier 'clang_thunk'.

Swift SVN r8122
2013-09-11 23:47:15 +00:00
Joe Groff
4a4c70ab36 IRGen: Implement partial_apply lowering for objc dynamic method values.
To do this right, we need to emit the objc_msgSend on the 'self' argument inside the forwarding stub, so handle them in a different code path in IRGenSIL::visitPartialApplyInst.

Swift SVN r8112
2013-09-11 21:07:28 +00:00
Joe Groff
7eb02647f5 Update SIL.rst discussion of objc calling convention.
Swift SVN r8111
2013-09-11 21:07:22 +00:00
Doug Gregor
ad9a958e2d Document SIL dynamic_method_br instruction
Swift SVN r8086
2013-09-10 22:58:53 +00:00
Anna Zaks
89fff39153 [SIL.rst] Update the guaranteed passes section.
Swift SVN r8058
2013-09-09 22:37:10 +00:00
Joe Groff
387946298e Describe calling convention for [byref] arguments in SIL.rst.
Swift SVN r8052
2013-09-09 20:17:37 +00:00
Doug Gregor
c5557a624c SIL: Introduce the 'dynamic_method' instruction for dynamic method dispatch.
The dynamic_method instruction handles method lookup on an existential
of type DynamicLookup based on the selector of an [objc] method of a
class or protocol. It is only introduced in the narrow case where we
are forcing a use of the method with '!', e.g.,

class X {
  func [objc] f() { println("Dynamic lookup") }
}

var x : DynamicLookup = X()
x.f!()



Swift SVN r8037
2013-09-09 16:12:50 +00:00
Joe Groff
d10491ae18 SIL.rst: Add a note that 'apply' currently consumes thick callees.
Swift SVN r7995
2013-09-06 20:33:32 +00:00
John McCall
7a909b64c2 Update the description of 'assign'.
I also removed a restriction about the form of the operand that
doesn't seem to be enforced by SIL-gen at all.

Swift SVN r7951
2013-09-05 18:08:11 +00:00
Michael Gottesman
743e99fb96 Fixed typo in SIL documentation.
Swift SVN r7944
2013-09-05 07:03:44 +00:00
John McCall
6aba15bc63 Document unowned_to_ref and ref_to_unowned, and discuss some
of the philosophy behind preserving this information in the type.

Swift SVN r7791
2013-08-30 18:31:31 +00:00
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