@@ -1668,7 +1668,7 @@ static PreparedArguments emitStringLiteral(SILGenFunction &SGF, Expr *E,
1668
1668
unicode::extractFirstUnicodeScalar (Str));
1669
1669
1670
1670
AnyFunctionType::Param param (Int32Ty.getASTType ());
1671
- PreparedArguments args ({param}, /* scalar */ false );
1671
+ PreparedArguments args ({param});
1672
1672
args.add (E, RValue (SGF, E, Int32Ty.getASTType (),
1673
1673
ManagedValue::forUnmanaged (UnicodeScalarValue)));
1674
1674
return args;
@@ -1717,7 +1717,7 @@ static PreparedArguments emitStringLiteral(SILGenFunction &SGF, Expr *E,
1717
1717
llvm_unreachable (" these cannot be formed here" );
1718
1718
}
1719
1719
1720
- PreparedArguments args (TypeElts, /* scalar */ false );
1720
+ PreparedArguments args (TypeElts);
1721
1721
for (unsigned i = 0 , e = Elts.size (); i != e; ++i) {
1722
1722
args.add (E, RValue (SGF, Elts[i], CanType (TypeElts[i].getPlainType ())));
1723
1723
}
@@ -2719,51 +2719,6 @@ class ArgEmitter {
2719
2719
maybeEmitForeignErrorArgument ();
2720
2720
}
2721
2721
2722
- // origFormalType is a function type.
2723
- //
2724
- // FIXME: This is all a bunch of hacks that can be removed once "scalar"
2725
- // PreparedArguments goes away.
2726
- void emitTopLevel (ArgumentSource &&arg, AbstractionPattern origFormalType) {
2727
- SmallVector<AbstractionPattern, 8 > origParamTypes;
2728
- for (unsigned i = 0 , e = origFormalType.getNumFunctionParams (); i < e; ++i) {
2729
- origParamTypes.push_back (origFormalType.getFunctionParamType (i));
2730
- }
2731
-
2732
- auto origParamType = AbstractionPattern::getTuple (origParamTypes);
2733
-
2734
- if (arg.isShuffle ()) {
2735
- auto *shuffle = cast<ArgumentShuffleExpr>(std::move (arg).asKnownExpr ());
2736
- emitShuffle (shuffle, origParamType);
2737
- maybeEmitForeignErrorArgument ();
2738
- return ;
2739
- }
2740
-
2741
- if (arg.isLValue ()) {
2742
- assert (origParamTypes.size () == 1 );
2743
- emitSingleArg (std::move (arg), origParamTypes[0 ]);
2744
- return ;
2745
- }
2746
-
2747
- if (arg.isExpr ()) {
2748
- if (origParamTypes.size () == 1 ) {
2749
- auto *e = std::move (arg).asKnownExpr ();
2750
-
2751
- origParamType = origParamTypes[0 ];
2752
- if (auto *paren = dyn_cast<ParenExpr>(e))
2753
- e = paren->getSubExpr ();
2754
- else if (auto *tuple = dyn_cast<TupleExpr>(e)) {
2755
- assert (tuple->getNumElements () == 1 );
2756
- e = tuple->getElement (0 );
2757
- }
2758
-
2759
- emitSingleArg (e, origParamType);
2760
- return ;
2761
- }
2762
- }
2763
-
2764
- emitSingleArg (std::move (arg), origParamType);
2765
- }
2766
-
2767
2722
// origFormalType is a function type.
2768
2723
void emitPreparedArgs (PreparedArguments &&args,
2769
2724
AbstractionPattern origFormalType) {
@@ -2772,7 +2727,18 @@ class ArgEmitter {
2772
2727
2773
2728
if (args.isScalar ()) {
2774
2729
assert (argSources.size () == 1 );
2775
- emitTopLevel (std::move (argSources[0 ]), origFormalType);
2730
+ auto arg = std::move (argSources[0 ]);
2731
+ auto *shuffle = cast<ArgumentShuffleExpr>(std::move (arg).asKnownExpr ());
2732
+
2733
+ SmallVector<AbstractionPattern, 8 > origParamTypes;
2734
+ for (unsigned i = 0 , e = origFormalType.getNumFunctionParams (); i < e; ++i) {
2735
+ origParamTypes.push_back (origFormalType.getFunctionParamType (i));
2736
+ }
2737
+
2738
+ auto origParamType = AbstractionPattern::getTuple (origParamTypes);
2739
+
2740
+ emitShuffle (shuffle, origParamType);
2741
+ maybeEmitForeignErrorArgument ();
2776
2742
} else {
2777
2743
maybeEmitForeignErrorArgument ();
2778
2744
for (auto i : indices (argSources)) {
@@ -4138,7 +4104,7 @@ class CallEmission {
4138
4104
ArgumentSource &&selfArg,
4139
4105
AnyFunctionType::Param selfParam,
4140
4106
CanType methodType) {
4141
- PreparedArguments preparedSelf ({selfParam}, /* scalar */ false );
4107
+ PreparedArguments preparedSelf ({selfParam});
4142
4108
preparedSelf.addArbitrary (std::move (selfArg));
4143
4109
4144
4110
addCallSite (loc, std::move (preparedSelf), methodType,
@@ -5527,15 +5493,15 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5527
5493
builtinInit = stringLiteral->getBuiltinInitializer ();
5528
5494
init = stringLiteral->getInitializer ();
5529
5495
} else if (auto nilLiteral = dyn_cast<NilLiteralExpr>(literal)) {
5530
- builtinLiteralArgs.emplace ({}, /* scalar */ false );
5496
+ builtinLiteralArgs.emplace ({});
5531
5497
builtinInit = nilLiteral->getInitializer ();
5532
5498
} else if (auto booleanLiteral = dyn_cast<BooleanLiteralExpr>(literal)) {
5533
5499
auto i1Ty = SILType::getBuiltinIntegerType (1 , getASTContext ());
5534
5500
SILValue boolValue = B.createIntegerLiteral (booleanLiteral, i1Ty,
5535
5501
booleanLiteral->getValue ());
5536
5502
ManagedValue boolManaged = ManagedValue::forUnmanaged (boolValue);
5537
5503
CanType ty = boolManaged.getType ().getASTType ()->getCanonicalType ();
5538
- builtinLiteralArgs.emplace (AnyFunctionType::Param (ty), /* scalar */ false );
5504
+ builtinLiteralArgs.emplace (AnyFunctionType::Param (ty));
5539
5505
builtinLiteralArgs.add (literal, RValue (*this , {boolManaged}, ty));
5540
5506
builtinInit = booleanLiteral->getBuiltinInitializer ();
5541
5507
init = booleanLiteral->getInitializer ();
@@ -5546,7 +5512,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5546
5512
SILType::getBuiltinIntegerLiteralType (getASTContext ()),
5547
5513
integerLiteral->getRawValue ()));
5548
5514
CanType ty = integerManaged.getType ().getASTType ();
5549
- builtinLiteralArgs.emplace (AnyFunctionType::Param (ty), /* scalar */ false );
5515
+ builtinLiteralArgs.emplace (AnyFunctionType::Param (ty));
5550
5516
builtinLiteralArgs.add (literal, RValue (*this , {integerManaged}, ty));
5551
5517
builtinInit = integerLiteral->getBuiltinInitializer ();
5552
5518
init = integerLiteral->getInitializer ();
@@ -5558,7 +5524,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5558
5524
floatLiteral->getValue ()));
5559
5525
5560
5526
CanType ty = floatManaged.getType ().getASTType ();
5561
- builtinLiteralArgs.emplace (AnyFunctionType::Param (ty), /* scalar */ false );
5527
+ builtinLiteralArgs.emplace (AnyFunctionType::Param (ty));
5562
5528
builtinLiteralArgs.add (literal, RValue (*this , {floatManaged}, ty));
5563
5529
builtinInit = floatLiteral->getBuiltinInitializer ();
5564
5530
init = floatLiteral->getInitializer ();
@@ -5604,7 +5570,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5604
5570
auto ty = silTy.getASTType ();
5605
5571
SILValue integer = B.createIntegerLiteral (literal, silTy, Value);
5606
5572
ManagedValue integerManaged = ManagedValue::forUnmanaged (integer);
5607
- builtinLiteralArgs.emplace (AnyFunctionType::Param (ty), /* scalar */ false );
5573
+ builtinLiteralArgs.emplace (AnyFunctionType::Param (ty));
5608
5574
builtinLiteralArgs.add (literal, RValue (*this , {integerManaged}, ty));
5609
5575
builtinInit = magicLiteral->getBuiltinInitializer ();
5610
5576
init = magicLiteral->getInitializer ();
@@ -5627,7 +5593,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5627
5593
5628
5594
// Otherwise, perform the second initialization step.
5629
5595
auto ty = builtinLiteral.getType ();
5630
- PreparedArguments args (AnyFunctionType::Param (ty), /* scalar */ false );
5596
+ PreparedArguments args (( AnyFunctionType::Param (ty)) );
5631
5597
args.add (literal, std::move (builtinLiteral));
5632
5598
5633
5599
RValue result = emitApplyAllocatingInitializer (literal, init,
@@ -6074,7 +6040,7 @@ SILGenFunction::prepareSubscriptIndices(SubscriptDecl *subscript,
6074
6040
// Finally, prepare the evaluated index expression. We might be calling
6075
6041
// the getter and setter, and it is important to only evaluate the
6076
6042
// index expression once.
6077
- PreparedArguments result (substParams, /* isScalar= */ false );
6043
+ PreparedArguments result (substParams);
6078
6044
6079
6045
ArrayRef<ManagedValue> remainingArgs = argValues;
6080
6046
for (auto substParam : substParams) {
@@ -6121,7 +6087,7 @@ RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
6121
6087
}
6122
6088
// Index or () if none.
6123
6089
if (subscriptIndices.isNull ())
6124
- subscriptIndices.emplaceEmptyArgumentList (* this );
6090
+ subscriptIndices.emplace ({} );
6125
6091
6126
6092
emission.addCallSite (loc, std::move (subscriptIndices),
6127
6093
accessType.getResult (),
@@ -6157,7 +6123,7 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
6157
6123
}
6158
6124
6159
6125
// (value) or (value, indices...)
6160
- PreparedArguments values (accessType->getParams (), /* scalar */ false );
6126
+ PreparedArguments values (accessType->getParams ());
6161
6127
values.addArbitrary (std::move (setValue));
6162
6128
6163
6129
if (!subscriptIndices.isNull ()) {
@@ -6202,7 +6168,7 @@ ManagedValue SILGenFunction::emitAddressorAccessor(
6202
6168
}
6203
6169
// Index or () if none.
6204
6170
if (subscriptIndices.isNull ())
6205
- subscriptIndices.emplaceEmptyArgumentList (* this );
6171
+ subscriptIndices.emplace ({} );
6206
6172
6207
6173
emission.addCallSite (loc, std::move (subscriptIndices),
6208
6174
accessType.getResult (),
@@ -6267,7 +6233,7 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
6267
6233
}
6268
6234
// Index or () if none.
6269
6235
if (subscriptIndices.isNull ())
6270
- subscriptIndices.emplaceEmptyArgumentList (* this );
6236
+ subscriptIndices.emplace ({} );
6271
6237
6272
6238
emission.addCallSite (loc, std::move (subscriptIndices),
6273
6239
accessType.getResult (),
0 commit comments