@@ -1602,6 +1602,7 @@ void ClangToLLVMArgMapping::construct(const ASTContext &Context,
1602
1602
IRArgs.PaddingArgIndex = IRArgNo++;
1603
1603
1604
1604
switch (AI.getKind ()) {
1605
+ case ABIArgInfo::TargetSpecific:
1605
1606
case ABIArgInfo::Extend:
1606
1607
case ABIArgInfo::Direct: {
1607
1608
// FIXME: handle sseregparm someday...
@@ -1712,6 +1713,7 @@ llvm::FunctionType *CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
1712
1713
case ABIArgInfo::IndirectAliased:
1713
1714
llvm_unreachable (" Invalid ABI kind for return argument" );
1714
1715
1716
+ case ABIArgInfo::TargetSpecific:
1715
1717
case ABIArgInfo::Extend:
1716
1718
case ABIArgInfo::Direct:
1717
1719
resultType = retAI.getCoerceToType ();
@@ -1784,6 +1786,7 @@ llvm::FunctionType *CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
1784
1786
ArgTypes[FirstIRArg] = llvm::PointerType::get (
1785
1787
getLLVMContext (), ArgInfo.getIndirectAddrSpace ());
1786
1788
break ;
1789
+ case ABIArgInfo::TargetSpecific:
1787
1790
case ABIArgInfo::Extend:
1788
1791
case ABIArgInfo::Direct: {
1789
1792
// Fast-isel and the optimizer generally like scalar values better than
@@ -2697,6 +2700,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
2697
2700
else
2698
2701
RetAttrs.addAttribute (llvm::Attribute::NoExt);
2699
2702
[[fallthrough]];
2703
+ case ABIArgInfo::TargetSpecific:
2700
2704
case ABIArgInfo::Direct:
2701
2705
if (RetAI.getInReg ())
2702
2706
RetAttrs.addAttribute (llvm::Attribute::InReg);
@@ -2838,6 +2842,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
2838
2842
else
2839
2843
Attrs.addAttribute (llvm::Attribute::NoExt);
2840
2844
[[fallthrough]];
2845
+ case ABIArgInfo::TargetSpecific:
2841
2846
case ABIArgInfo::Direct:
2842
2847
if (ArgNo == 0 && FI.isChainCall ())
2843
2848
Attrs.addAttribute (llvm::Attribute::Nest);
@@ -3357,17 +3362,6 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
3357
3362
}
3358
3363
}
3359
3364
3360
- // Struct of fixed-length vectors and struct of array of fixed-length
3361
- // vector in VLS calling convention are coerced to vector tuple
3362
- // type(represented as TargetExtType) and scalable vector type
3363
- // respectively, they're no longer handled as struct.
3364
- if (ArgI.isDirect () && isa<llvm::StructType>(ConvertType (Ty)) &&
3365
- (isa<llvm::TargetExtType>(ArgI.getCoerceToType ()) ||
3366
- isa<llvm::ScalableVectorType>(ArgI.getCoerceToType ()))) {
3367
- ArgVals.push_back (ParamValue::forDirect (AI));
3368
- break ;
3369
- }
3370
-
3371
3365
llvm::StructType *STy =
3372
3366
dyn_cast<llvm::StructType>(ArgI.getCoerceToType ());
3373
3367
Address Alloca =
@@ -3508,6 +3502,25 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
3508
3502
break ;
3509
3503
}
3510
3504
3505
+ case ABIArgInfo::TargetSpecific: {
3506
+ auto *AI = Fn->getArg (FirstIRArg);
3507
+ AI->setName (Arg->getName () + " .target_coerce" );
3508
+ Address Alloca =
3509
+ CreateMemTemp (Ty, getContext ().getDeclAlign (Arg), Arg->getName ());
3510
+ Address Ptr = emitAddressAtOffset (*this , Alloca, ArgI);
3511
+ CGM.getABIInfo ().createCoercedStore (AI, Ptr, ArgI, false , *this );
3512
+ if (CodeGenFunction::hasScalarEvaluationKind (Ty)) {
3513
+ llvm::Value *V =
3514
+ EmitLoadOfScalar (Alloca, false , Ty, Arg->getBeginLoc ());
3515
+ if (isPromoted) {
3516
+ V = emitArgumentDemotion (*this , Arg, V);
3517
+ }
3518
+ ArgVals.push_back (ParamValue::forDirect (V));
3519
+ } else {
3520
+ ArgVals.push_back (ParamValue::forIndirect (Alloca));
3521
+ }
3522
+ break ;
3523
+ }
3511
3524
case ABIArgInfo::Ignore:
3512
3525
assert (NumIRArgs == 0 );
3513
3526
// Initialize the local variable appropriately.
@@ -4136,6 +4149,11 @@ void CodeGenFunction::EmitFunctionEpilog(
4136
4149
}
4137
4150
break ;
4138
4151
}
4152
+ case ABIArgInfo::TargetSpecific: {
4153
+ Address V = emitAddressAtOffset (*this , ReturnValue, RetAI);
4154
+ RV = CGM.getABIInfo ().createCoercedLoad (V, RetAI, *this );
4155
+ break ;
4156
+ }
4139
4157
case ABIArgInfo::Expand:
4140
4158
case ABIArgInfo::IndirectAliased:
4141
4159
llvm_unreachable (" Invalid ABI kind for return argument" );
@@ -5704,6 +5722,24 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
5704
5722
assert (IRArgPos == FirstIRArg + NumIRArgs);
5705
5723
break ;
5706
5724
}
5725
+
5726
+ case ABIArgInfo::TargetSpecific: {
5727
+ Address Src = Address::invalid ();
5728
+ if (!I->isAggregate ()) {
5729
+ Src = CreateMemTemp (I->Ty , " target_coerce" );
5730
+ I->copyInto (*this , Src);
5731
+ } else {
5732
+ Src = I->hasLValue () ? I->getKnownLValue ().getAddress ()
5733
+ : I->getKnownRValue ().getAggregateAddress ();
5734
+ }
5735
+
5736
+ // If the value is offset in memory, apply the offset now.
5737
+ Src = emitAddressAtOffset (*this , Src, ArgInfo);
5738
+ llvm::Value *Load =
5739
+ CGM.getABIInfo ().createCoercedLoad (Src, ArgInfo, *this );
5740
+ IRCallArgs[FirstIRArg] = Load;
5741
+ break ;
5742
+ }
5707
5743
}
5708
5744
}
5709
5745
@@ -6189,6 +6225,19 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
6189
6225
return convertTempToRValue (DestPtr, RetTy, SourceLocation ());
6190
6226
}
6191
6227
6228
+ case ABIArgInfo::TargetSpecific: {
6229
+ Address DestPtr = ReturnValue.getValue ();
6230
+ Address StorePtr = emitAddressAtOffset (*this , DestPtr, RetAI);
6231
+ bool DestIsVolatile = ReturnValue.isVolatile ();
6232
+ if (!DestPtr.isValid ()) {
6233
+ DestPtr = CreateMemTemp (RetTy, " target_coerce" );
6234
+ DestIsVolatile = false ;
6235
+ }
6236
+ CGM.getABIInfo ().createCoercedStore (CI, StorePtr, RetAI, DestIsVolatile,
6237
+ *this );
6238
+ return convertTempToRValue (DestPtr, RetTy, SourceLocation ());
6239
+ }
6240
+
6192
6241
case ABIArgInfo::Expand:
6193
6242
case ABIArgInfo::IndirectAliased:
6194
6243
llvm_unreachable (" Invalid ABI kind for return argument" );
0 commit comments