Skip to content

Commit ed623d7

Browse files
committed
[NFC] Shortened SIL [init] flag.
Instead of writing out [initalization] for some instructions, use [init] everywhere.
1 parent b0de482 commit ed623d7

File tree

247 files changed

+1527
-1527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+1527
-1527
lines changed

docs/DifferentiableProgrammingImplementation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ sil hidden [ossa] @$s4main7genericyxxlF : $@convention(thin) <T> (@in_guaranteed
885885
// %1 // users: %3, %2
886886
bb0(%0 : $*T, %1 : $*T):
887887
debug_value_addr %1 : $*T, let, name "x", argno 1 // id: %2
888-
copy_addr %1 to [initialization] %0 : $*T // id: %3
888+
copy_addr %1 to [init] %0 : $*T // id: %3
889889
%4 = tuple () // user: %5
890890
return %4 : $() // id: %5
891891
} // end sil function '$s4main7genericyxxlF'

docs/SIL.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4169,7 +4169,7 @@ assign_by_wrapper
41694169

41704170
sil-instruction ::= 'assign_by_wrapper' sil-operand 'to' mode? sil-operand ',' 'init' sil-operand ',' 'set' sil-operand
41714171

4172-
mode ::= '[initialization]' | '[assign]' | '[assign_wrapped_value]'
4172+
mode ::= '[init]' | '[assign]' | '[assign_wrapped_value]'
41734173

41744174
assign_by_wrapper %0 : $S to %1 : $*T, init %2 : $F, set %3 : $G
41754175
// $S can be a value or address type
@@ -4286,9 +4286,9 @@ copy_addr
42864286
::
42874287

42884288
sil-instruction ::= 'copy_addr' '[take]'? sil-value
4289-
'to' '[initialization]'? sil-operand
4289+
'to' '[init]'? sil-operand
42904290

4291-
copy_addr [take] %0 to [initialization] %1 : $*T
4291+
copy_addr [take] %0 to [init] %1 : $*T
42924292
// %0 and %1 must be of the same $*T address type
42934293

42944294
Loads the value at address ``%0`` from memory and assigns a copy of it back into
@@ -4307,11 +4307,11 @@ is equivalent to::
43074307

43084308
except that ``copy_addr`` may be used even if ``%0`` is of an address-only
43094309
type. The ``copy_addr`` may be given one or both of the ``[take]`` or
4310-
``[initialization]`` attributes:
4310+
``[init]`` attributes:
43114311

43124312
* ``[take]`` destroys the value at the source address in the course of the
43134313
copy.
4314-
* ``[initialization]`` indicates that the destination address is uninitialized.
4314+
* ``[init]`` indicates that the destination address is uninitialized.
43154315
Without the attribute, the destination address is treated as already
43164316
initialized, and the existing value will be destroyed before the new value
43174317
is stored.
@@ -4329,15 +4329,15 @@ operations::
43294329
store %new to %1 : $*T
43304330

43314331
// copy-initialization
4332-
copy_addr %0 to [initialization] %1 : $*T
4332+
copy_addr %0 to [init] %1 : $*T
43334333
// is equivalent to:
43344334
%new = load %0 : $*T
43354335
strong_retain %new : $T
43364336
// no load/release of %old!
43374337
store %new to %1 : $*T
43384338

43394339
// take-initialization
4340-
copy_addr [take] %0 to [initialization] %1 : $*T
4340+
copy_addr [take] %0 to [init] %1 : $*T
43414341
// is equivalent to:
43424342
%new = load %0 : $*T
43434343
// no retain of %new!
@@ -4355,9 +4355,9 @@ explicit_copy_addr
43554355
::
43564356

43574357
sil-instruction ::= 'explicit_copy_addr' '[take]'? sil-value
4358-
'to' '[initialization]'? sil-operand
4358+
'to' '[init]'? sil-operand
43594359

4360-
explicit_copy_addr [take] %0 to [initialization] %1 : $*T
4360+
explicit_copy_addr [take] %0 to [init] %1 : $*T
43614361
// %0 and %1 must be of the same $*T address type
43624362

43634363
This instruction is exactly the same as `copy_addr`_ except that it has special
@@ -4789,14 +4789,14 @@ store_weak
47894789

47904790
::
47914791

4792-
sil-instruction ::= 'store_weak' sil-value 'to' '[initialization]'? sil-operand
4792+
sil-instruction ::= 'store_weak' sil-value 'to' '[init]'? sil-operand
47934793

4794-
store_weak %0 to [initialization] %1 : $*@sil_weak Optional<T>
4794+
store_weak %0 to [init] %1 : $*@sil_weak Optional<T>
47954795
// $T must be an optional wrapping a reference type
47964796

47974797
Initializes or reassigns a weak reference. The operand may be ``nil``.
47984798

4799-
If ``[initialization]`` is given, the weak reference must currently either be
4799+
If ``[init]`` is given, the weak reference must currently either be
48004800
uninitialized or destroyed. If it is not given, the weak reference must
48014801
currently be initialized. After the evaluation:
48024802

@@ -6019,7 +6019,7 @@ an `inject_enum_addr`_ instruction::
60196019
entry(%0 : $*AddressOnlyEnum, %1 : $*AddressOnlyType):
60206020
// Store the data argument for the case.
60216021
%2 = init_enum_data_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData!enumelt
6022-
copy_addr [take] %2 to [initialization] %1 : $*AddressOnlyType
6022+
copy_addr [take] %2 to [init] %1 : $*AddressOnlyType
60236023
// Inject the tag.
60246024
inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData!enumelt
60256025
return

docs/proposals/InoutCOWOptimization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ To work with opaque types, ``copy_addr`` must also be able to perform an
202202
an original value. This can be an additional attribute on the source, mutually
203203
exclusive with ``[take]``::
204204

205-
copy_addr [inout] %a to [initialization] %b
205+
copy_addr [inout] %a to [init] %b
206206

207207
This implies that value witness tables will need witnesses for
208208
inout-initialization and inout-reassignment.

lib/SIL/IR/SILPrinter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
17061706
case AssignByWrapperInst::Unknown:
17071707
break;
17081708
case AssignByWrapperInst::Initialization:
1709-
*this << "[initialization] ";
1709+
*this << "[init] ";
17101710
break;
17111711
case AssignByWrapperInst::Assign:
17121712
*this << "[assign] ";
@@ -1771,7 +1771,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
17711771
void visitStore##Name##Inst(Store##Name##Inst *SI) { \
17721772
*this << Ctx.getID(SI->getSrc()) << " to "; \
17731773
if (SI->isInitializationOfDest()) \
1774-
*this << "[initialization] "; \
1774+
*this << "[init] "; \
17751775
*this << getIDAndType(SI->getDest()); \
17761776
}
17771777
#include "swift/AST/ReferenceStorage.def"
@@ -1781,7 +1781,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
17811781
*this << "[take] ";
17821782
*this << Ctx.getID(CI->getSrc()) << " to ";
17831783
if (CI->isInitializationOfDest())
1784-
*this << "[initialization] ";
1784+
*this << "[init] ";
17851785
*this << getIDAndType(CI->getDest());
17861786
}
17871787

@@ -1790,7 +1790,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
17901790
*this << "[take] ";
17911791
*this << Ctx.getID(CI->getSrc()) << " to ";
17921792
if (CI->isInitializationOfDest())
1793-
*this << "[initialization] ";
1793+
*this << "[init] ";
17941794
*this << getIDAndType(CI->getDest());
17951795
}
17961796

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,7 @@ static bool parseAssignByWrapperMode(AssignByWrapperInst::Mode &Result,
22412241
// Then try to parse one of our other initialization kinds. We do not support
22422242
// parsing unknown here so we use that as our fail value.
22432243
auto Tmp = llvm::StringSwitch<AssignByWrapperInst::Mode>(Str)
2244-
.Case("initialization", AssignByWrapperInst::Initialization)
2244+
.Case("init", AssignByWrapperInst::Initialization)
22452245
.Case("assign", AssignByWrapperInst::Assign)
22462246
.Case("assign_wrapped_value", AssignByWrapperInst::AssignWrappedValue)
22472247
.Default(AssignByWrapperInst::Unknown);
@@ -4403,7 +4403,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
44034403
if (parseValueName(from) ||
44044404
parseSILIdentifier(toToken, toLoc, diag::expected_tok_in_sil_instr,
44054405
"to") ||
4406-
(isRefStorage && parseSILOptional(isInit, *this, "initialization")) ||
4406+
(isRefStorage && parseSILOptional(isInit, *this, "init")) ||
44074407
parseTypedValueRef(addrVal, addrLoc, B) ||
44084408
parseSILDebugLocation(InstLoc, B))
44094409
return true;
@@ -5011,7 +5011,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
50115011
if (parseSILOptional(IsTake, *this, "take") || parseValueName(SrcLName) ||
50125012
parseSILIdentifier(ToToken, ToLoc, diag::expected_tok_in_sil_instr,
50135013
"to") ||
5014-
parseSILOptional(IsInit, *this, "initialization") ||
5014+
parseSILOptional(IsInit, *this, "init") ||
50155015
parseTypedValueRef(DestLVal, DestLoc, B) ||
50165016
parseSILDebugLocation(InstLoc, B))
50175017
return true;
@@ -5041,7 +5041,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
50415041
if (parseSILOptional(IsTake, *this, "take") || parseValueName(SrcLName) ||
50425042
parseSILIdentifier(ToToken, ToLoc, diag::expected_tok_in_sil_instr,
50435043
"to") ||
5044-
parseSILOptional(IsInit, *this, "initialization") ||
5044+
parseSILOptional(IsInit, *this, "init") ||
50455045
parseTypedValueRef(DestLVal, DestLoc, B) ||
50465046
parseSILDebugLocation(InstLoc, B))
50475047
return true;

lib/SILOptimizer/Differentiation/PullbackCloner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,7 @@ void PullbackCloner::Implementation::accumulateAdjointForOptional(
22892289
// #Optional.some!enumelt
22902290
auto *enumAddr = builder.createInitEnumDataAddr(
22912291
pbLoc, optArgBuf, someEltDecl, wrappedTanType.getAddressType());
2292-
// copy_addr %wrappedAdjoint to [initialization] %enumAddr
2292+
// copy_addr %wrappedAdjoint to [init] %enumAddr
22932293
builder.createCopyAddr(pbLoc, wrappedAdjoint, enumAddr, IsNotTake,
22942294
IsInitialization);
22952295
// inject_enum_addr %optArgBuf : $*Optional<T.TangentVector>,

lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void ExistentialSpecializerCloner::cloneArguments(
198198
/// bb0(%0 : $*T):
199199
/// %3 = alloc_stack $P
200200
/// %4 = init_existential_addr %3 : $*P, $T
201-
/// copy_addr [take] %0 to [initialization] %4 : $*T
201+
/// copy_addr [take] %0 to [init] %4 : $*T
202202
/// %7 = open_existential_addr immutable_access %3 : $*P to
203203
/// $*@opened P
204204
auto *ASI =

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,9 +1581,9 @@ namespace {
15811581
// br bb3(val0, val1)
15821582
// bb2:
15831583
// temp = alloc_stack
1584-
// copy_addr [take] addr0 to [initialization] temp
1585-
// copy_addr [take] addr1 to [initialization] addr0
1586-
// copy_addr [take] temp to [initialization] addr1
1584+
// copy_addr [take] addr0 to [init] temp
1585+
// copy_addr [take] addr1 to [init] addr0
1586+
// copy_addr [take] temp to [init] addr1
15871587
// dealloc_stack temp
15881588
// br bb3(val1, val1)
15891589
// bb3(phi0, phi1):

lib/SILOptimizer/Transforms/CopyForwarding.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Useless copies of address-only types look like this:
2727
//
2828
// %copy = alloc_stack $T
29-
// copy_addr %arg to [initialization] %copy : $*T
29+
// copy_addr %arg to [init] %copy : $*T
3030
// %ret = apply %callee<T>(%copy) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> ()
3131
// dealloc_stack %copy : $*T
3232
// destroy_addr %arg : $*T
@@ -927,7 +927,7 @@ static DeallocStackInst *getSingleDealloc(AllocStackInst *ASI) {
927927
/// %copy = alloc_stack $T
928928
/// ...
929929
/// CurrentBlock:
930-
/// copy_addr %arg to [initialization] %copy : $*T
930+
/// copy_addr %arg to [init] %copy : $*T
931931
/// ...
932932
/// %ret = apply %callee<T>(%copy) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> ()
933933
/// \endcode
@@ -1252,7 +1252,7 @@ void CopyForwarding::forwardCopiesOf(SILValue Def, SILFunction *F) {
12521252
/// %2 = alloc_stack $T
12531253
/// ... // arbitrary control flow, but no other uses of %0
12541254
/// bbN:
1255-
/// copy_addr [take] %2 to [initialization] %0 : $*T
1255+
/// copy_addr [take] %2 to [init] %0 : $*T
12561256
/// ... // no writes
12571257
/// return
12581258
static bool canNRVO(CopyAddrInst *CopyInst) {
@@ -1264,7 +1264,7 @@ static bool canNRVO(CopyAddrInst *CopyInst) {
12641264
// bb0(%in : $*T, %out : $T):
12651265
// %local = alloc_stack $T
12661266
// store %in to %local : $*T
1267-
// copy_addr %local to [initialization] %out : $*T
1267+
// copy_addr %local to [init] %out : $*T
12681268
if (!CopyInst->isTakeOfSrc())
12691269
return false;
12701270

@@ -1350,7 +1350,7 @@ class CopyForwardingPass : public SILFunctionTransform
13501350
// %ref = load %objaddr : $*AnyObject
13511351
// %alloc2 = alloc_stack $ObjWrapper
13521352
// # The in-memory reference is destroyed before retaining the loaded ref.
1353-
// copy_addr [take] %alloc1 to [initialization] %alloc2 : $*ObjWrapper
1353+
// copy_addr [take] %alloc1 to [init] %alloc2 : $*ObjWrapper
13541354
// retain_value %ref : $AnyObject
13551355
// destroy_addr %alloc2 : $*ObjWrapper
13561356
if (!getFunction()->hasOwnership())

lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static bool shouldExpandShim(SILFunction *fn, SILType type) {
8787
/// strong_release %old : $T
8888
/// store %new to %1 : $*T
8989
///
90-
/// copy_addr %0 to [initialization] %1 : $*T
90+
/// copy_addr %0 to [init] %1 : $*T
9191
/// ->
9292
/// %new = load [copy] %0 : $*T
9393
/// store %new to [init] %1 : $*T
@@ -97,7 +97,7 @@ static bool shouldExpandShim(SILFunction *fn, SILType type) {
9797
/// // no load/release of %old!
9898
/// store %new to %1 : $*T
9999
///
100-
/// copy_addr [take] %0 to [initialization] %1 : $*T
100+
/// copy_addr [take] %0 to [init] %1 : $*T
101101
/// ->
102102
/// %new = load [take] %0 : $*T
103103
/// store %new to [init] %1 : $*T

0 commit comments

Comments
 (0)