Commit Graph

521 Commits

Author SHA1 Message Date
Roman Levenstein
f016754ef9 Add a new select_value instruction. This instruction should be the equivalent of select_enum, just for builtin int types. Such an instruction is needed e.g. to efficiently implement conversions of Int raw values to C-like enums.
rdar://18812325

Swift SVN r23036
2014-10-31 20:44:11 +00:00
Joe Groff
bf3ddb4c59 SIL.rst: Fix up some omissions in the calling convention section.
Explain how @cc(witness_method) is different from @cc(method), and fix a typo.

Swift SVN r23021
2014-10-30 22:04:24 +00:00
Joe Groff
7bbf6daf3d SIL.rst: Document instructions added for working with BridgeObject.
Swift SVN r23020
2014-10-30 21:50:03 +00:00
Joe Groff
3f23b82e6d SIL: Rename SILGlobalAddr to GlobalAddr.
All globals are SIL globals now.

Swift SVN r22827
2014-10-18 17:08:28 +00:00
Arnold Schwaighofer
329fa51d3f Reapply "Verifier: Cannonical SIL should have split critical edges for non cond_br
terminators"

This is an assumption that the SSAUpdater makes. Verify that we preserve this
property.

With changes to the test cases, SIL documentation and add a critical edge (non
cond_br only) splitting pass to the mandatory pipeline.

This reapplies commit 22775.

Swift SVN r22803
2014-10-16 21:16:24 +00:00
Joe Groff
ea65d1e60b SIL: Remove the builtin_function_ref instruction.
Swift SVN r22797
2014-10-16 16:18:40 +00:00
Joe Groff
bb46f4bbd9 SIL: Remove the global_addr instruction.
It's no longer needed now that we always lower to SIL globals.

Swift SVN r22693
2014-10-12 17:19:06 +00:00
Joe Groff
9205bf64cf SIL: Remove enum_is_tag.
Swift SVN r22616
2014-10-09 05:03:43 +00:00
Joe Groff
ca8b168188 SIL: Add select_enum and select_enum_addr insns.
Similar to LLVM's "select" instruction, the instruction picks one of its operands based on the case tag of an enum value.

Swift SVN r22578
2014-10-07 21:45:08 +00:00
Joe Groff
949e0b0741 Drop the @sil_self attribute.
We no longer need to abuse Self archetypes to represent values inside existential containers.

Swift SVN r22487
2014-10-03 03:09:45 +00:00
Joe Groff
782833f054 SIL: Remove the project_existential* instructions.
Swift SVN r22457
2014-10-02 04:06:10 +00:00
Joe Groff
3a606b9eb8 SIL: Drop the protocol_method instruction.
Swift SVN r22446
2014-10-01 23:35:41 +00:00
Joe Groff
be45322668 SIL: Drop the upcast_existential* instructions.
Swift SVN r22388
2014-09-30 16:11:54 +00:00
Joe Groff
152aa9e244 Revert "SIL: Drop the upcast_existential* instructions."
This reverts commit r22345.

Swift SVN r22353
2014-09-29 13:46:41 +00:00
Joe Groff
1e343fb430 SIL: Drop the upcast_existential* instructions.
Swift SVN r22345
2014-09-28 19:24:33 +00:00
Joe Groff
0518f2067f Revert "SIL: Drop the upcast_existential* instructions."
This reverts commit r22333.

Swift SVN r22337
2014-09-28 18:41:05 +00:00
Joe Groff
727c9b5ed7 SIL: Drop the upcast_existential* instructions.
Swift SVN r22333
2014-09-28 16:38:13 +00:00
Joe Groff
a3126706da SIL: Eliminate the dead 'alloc_array' insn.
Swift SVN r22292
2014-09-26 02:28:10 +00:00
Doug Gregor
c504086266 Revert r21707 "Remove the SIL is_nonnull instruction. It's no longer useful."
We want to be able to work around problems with non-failable
Objective-C initializers actually failing, which can happen when the
API audit data incorrectly marks an initializer as non-failable.



Swift SVN r21711
2014-09-04 17:26:34 +00:00
Doug Gregor
cdf94885ae Remove the SIL is_nonnull instruction. It's no longer useful.
Swift SVN r21707
2014-09-04 15:56:12 +00:00
Michael Gottesman
2b8edb80b7 [docs] Move some sections in SIL.rst to match SILNodes.def and add some stub docs/full docs for more instructions.
Specifically:

I Moved ref_to_unowned and unowned_to_ref to conversion inst section so
we match SILNodes.def.

I added full docs for:

  1. unchecked_trivial_bit_cast
  2. unchecked_ref_bit_cast

and stub docs for:

  1. objc_protocol.
  2. autorelease_value.
  3. init_block_storage_header
  4. project_block_header

Swift SVN r21671
2014-09-03 08:50:52 +00:00
Michael Gottesman
d7af8fc6e4 Swift SVN r21670 2014-09-03 06:52:05 +00:00
Chris Lattner
0275a37935 enhance the SIL is_nonnull instruction to work with values of function type. This
isn't used yet.


Swift SVN r21636
2014-09-02 01:06:07 +00:00
Chris Lattner
dc7c565af8 further generalize dynamic_method and dynamic_method_br: instead of having them force
the subject to "Builtin.UnknownObject", just traffic in the protocol type directly.


Swift SVN r21516
2014-08-28 05:41:35 +00:00
Dave Abrahams
c3e1f98891 Fix RestructuredText error
Swift SVN r20895
2014-08-01 16:26:45 +00:00
Pete Cooper
6802c2d81c Document the enum_is_tag instruction. Thanks Michael for pointing out that i'd missed this
Swift SVN r20894
2014-08-01 16:24:08 +00:00
Jordan Rose
b6818046a8 Eliminate optimization levels 0-3 in favor of -Onone/-O/-Ofast.
We were already effectively doing this everywhere /except/ when building
the standard library (which used -O2), so just use the model we want going
forward.

Swift SVN r20455
2014-07-24 01:12:59 +00:00
Nadav Rotem
73e07f3616 Add a link to the high-level optimizations document.
Swift SVN r19677
2014-07-08 04:11:09 +00:00
John McCall
e1456005ca Update SIL.rst for the change to the checked_cast instructions.
I still owe an update for the checked_cast_addr instructions.

Swift SVN r19057
2014-06-20 22:51:22 +00:00
Michael Gottesman
c20c41c8a9 Fix two typos in SIL.rst I noticed upon visual inspection.
Swift SVN r19032
2014-06-20 04:45:18 +00:00
Chris Lattner
2fb6a4494e update the SIL dox to reflect that load_weak and store_weak now traffic in optionals
directly instead of them taking non-nullable types that sometimes had a nil bit pattern.


Swift SVN r18314
2014-05-18 04:56:42 +00:00
Ted Kremenek
050fd53af7 Rename UncheckedOptional to ImplicitlyUnwrappedOptional.
Swift SVN r17232
2014-05-02 06:13:57 +00:00
Manman Ren
480b41c824 [SIL Vtable emission] use the least derived method in sil_vtable.
Given base class A and dervied class B, both with member functions f(),
to look for A.f in B's vtable, we should return SILFunction for B.f.

Before this commit, B's vtable will have entry for B.f, A's vtable will
have entry for A.f. When looking for A.f in B's vtable, it returns null.
And devirtualizer will look for A.f in A's vtable and resolve it to
SILFunction for A.f.

When replacing a class_method %1 : $A, #A.f!1 with a function ref to B.f,
we will have type checking issues for the apply instructions. So devirtualizer
will replace the argument of the apply instructions when necessary.

rdar://16681983


Swift SVN r16854
2014-04-25 23:42:12 +00:00
Joe Groff
4ea0a2839b SIL.rst: Document unchecked_addr_cast.
Swift SVN r16744
2014-04-24 04:59:56 +00:00
Joe Groff
68f942117a SIL: Squash 'ref_to_native_object' and 'native_object_to_ref' into one 'unchecked_ref_cast' insn.
An unsafe cast from a base to a derived class isn't really all that different from one from Builtin.NativeObject to an arbitrary class, so relax this pair of instructions to allow an arbitrary bitcast. This only combines the instructions; it doesn't attempt to simplify any codegen that was emitting round-trip casts before yet.

Swift SVN r16736
2014-04-24 03:10:53 +00:00
Joe Groff
fe47ddb540 SIL.rst: Note that unchecked_take_enum_data_addr will not actually destroy the enum when applied to the first payloaded case.
At least not in 1.0.

Swift SVN r16735
2014-04-24 02:36:39 +00:00
Joe Groff
5db5acc8fc SIL.rst: Fix up and extend discussion of layout compatible types.
Got the sense of 'layout compatible' reversed for enum payloads, and mixed up "commutative" and "transitive". Add rules to cover RawPointer <-> Word, heap object references, and single-field structs.

Swift SVN r16734
2014-04-24 02:36:37 +00:00
Joe Groff
7bc9bf95cf SIL.rst: Add a note about layout compatibility.
Start trying to formalize when reinterpretCast can actually mean something for the optimizer.

Swift SVN r16731
2014-04-24 01:07:34 +00:00
Joe Groff
285ec1e2dd SIL: Add an unchecked_enum_data instruction.
This allows the payload for a loadable enum to be unsafely projected without branching, enabling more enum optimizations when switch branches can be culled or when indirect enum code can be promoted.

Swift SVN r16729
2014-04-24 00:41:08 +00:00
Joe Groff
55f6b925de SIL: Rename 'take_enum_data_addr' to 'unchecked_take_enum_data_addr'.
In preparation for adding an 'unchecked_enum_data' equivalent for loadable enums.

Swift SVN r16728
2014-04-24 00:40:47 +00:00
Joe Groff
eaa6088102 SIL: Remove the now-obsolete bridge_to_block instruction.
Swift SVN r16487
2014-04-18 02:26:10 +00:00
Arnold Schwaighofer
989d554a45 Add support for an assert_configuration builtin function
This patch adds support for a builtin function assert_configuration that is
replaced by constant progpagation by an appropriate value dependent on a compile
time setting. This replacement can also be disabled when serializing sil for a
library.

Using this mechanism we implement assertions that can  be disabled (or whose
behavior changes) depending on compile time build settings (Debug, Release,
DisableReplacement).

In the standard library we can now write one assert function that uses this
builtin function to provide different compile time selectable runtime behavior.

Example

Assert.swift:

@transparent
func assert<T : LogicValue>(
  condition: @auto_closure () -> T, message: StaticString = StaticString(),

  // Do not supply these parameters explicitly; they will be filled in
  // by the compiler and aren't even present when asserts are disabled
  file: StaticString = __FILE__, line: UWord = __LINE__
) {
  // Only in debug mode.
  if _isDebug() {
    assert(condition().getLogicValue(), message, file, line)
  }
}

AssertCommon.swift:

@transparent
func _isDebug() -> Bool {
  return Int32(Builtin.assert_configuration()) == 0;
}

rdar://16458612

Swift SVN r16472
2014-04-17 22:05:42 +00:00
Michael Gottesman
7f7e256f73 [SIL.rst] Begin filling out the section in SIL.rst describing the general optimization passes.
Swift SVN r16196
2014-04-11 02:59:38 +00:00
Joe Groff
e9d2e122ee SIL.rst: Document copy_block.
Swift SVN r16087
2014-04-09 00:37:24 +00:00
Chris Lattner
afea47b621 rename "destroy_value" to "release_value", part of rdar://15889208.
Swift SVN r15777
2014-04-02 05:33:52 +00:00
Chris Lattner
6540423613 rename CopyValueInst -> RetainValueInst. The .sil syntax
isn't changed yet.


Swift SVN r15775
2014-04-02 05:11:31 +00:00
Joe Groff
584009d27e SIL: Remove copy_value's result.
We won't have any types where copying has an effect on the bit pattern (except for blocks, which need special handling anyway), and copy_value having a result makes optimizations more complex, so remove it.

Swift SVN r15640
2014-03-30 03:40:45 +00:00
Joe Groff
afd59130f0 SIL: Add a FixLifetime instruction.
This will be a signal to ARC optimization, RVO, and other lifetime-affecting optimizations that they should not shorten the lifetime of a value past a certain point. We need this for C pointer bridging. This adds the instruction, but does not add any knowledge of it to the ARC optimizers.

Swift SVN r15601
2014-03-29 02:50:34 +00:00
Mark Lacey
cae8562ff7 Reformat for 80 columns.
Swift SVN r15515
2014-03-26 19:28:02 +00:00
Mark Lacey
78931ea27b Fix typo: addres -> address
Swift SVN r15514
2014-03-26 19:28:02 +00:00