@@ -26,7 +26,6 @@ class RISCVABIInfo : public DefaultABIInfo {
26
26
// ISA might have a wider FLen than the selected ABI (e.g. an RV32IF target
27
27
// with soft float ABI has FLen==0).
28
28
unsigned FLen;
29
- unsigned ABIVLen;
30
29
const int NumArgGPRs;
31
30
const int NumArgFPRs;
32
31
const bool EABI;
@@ -38,17 +37,17 @@ class RISCVABIInfo : public DefaultABIInfo {
38
37
39
38
public:
40
39
RISCVABIInfo (CodeGen::CodeGenTypes &CGT, unsigned XLen, unsigned FLen,
41
- unsigned ABIVLen, bool EABI)
42
- : DefaultABIInfo(CGT), XLen(XLen), FLen(FLen), ABIVLen(ABIVLen),
40
+ bool EABI)
41
+ : DefaultABIInfo(CGT), XLen(XLen), FLen(FLen),
43
42
NumArgGPRs (EABI ? 6 : 8 ), NumArgFPRs(FLen != 0 ? 8 : 0 ), EABI(EABI) {}
44
43
45
44
// DefaultABIInfo's classifyReturnType and classifyArgumentType are
46
45
// non-virtual, but computeInfo is virtual, so we overload it.
47
46
void computeInfo (CGFunctionInfo &FI) const override ;
48
47
49
48
ABIArgInfo classifyArgumentType (QualType Ty, bool IsFixed, int &ArgGPRsLeft,
50
- int &ArgFPRsLeft, unsigned ArgABIVLen ) const ;
51
- ABIArgInfo classifyReturnType (QualType RetTy, unsigned ArgABIVLen ) const ;
49
+ int &ArgFPRsLeft, unsigned ABIVLen ) const ;
50
+ ABIArgInfo classifyReturnType (QualType RetTy, unsigned ABIVLen ) const ;
52
51
53
52
RValue EmitVAArg (CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
54
53
AggValueSlot Slot) const override ;
@@ -64,7 +63,7 @@ class RISCVABIInfo : public DefaultABIInfo {
64
63
llvm::Type *Field2Ty,
65
64
CharUnits Field2Off) const ;
66
65
67
- ABIArgInfo coerceVLSVector (QualType Ty, unsigned ArgABIVLen = 0 ) const ;
66
+ ABIArgInfo coerceVLSVector (QualType Ty, unsigned ABIVLen = 0 ) const ;
68
67
69
68
using ABIInfo::appendAttributeMangling;
70
69
void appendAttributeMangling (TargetClonesAttr *Attr, unsigned Index,
@@ -113,18 +112,10 @@ void RISCVABIInfo::appendAttributeMangling(StringRef AttrStr,
113
112
}
114
113
115
114
void RISCVABIInfo::computeInfo (CGFunctionInfo &FI) const {
116
- unsigned ArgABIVLen = 1 << FI.getExtInfo ().getLog2RISCVABIVLen ();
117
- // If ArgABIVLen is default value(2), try to set it to the value passed by
118
- // option if any, otherwise, set it to default value 128.
119
- // Note that ArgABIVLen == 1 means vector_cc is not enabled.
120
- if (ArgABIVLen == 2 && ABIVLen)
121
- ArgABIVLen = ABIVLen;
122
- else if (ArgABIVLen == 2 )
123
- ArgABIVLen = 128 ;
124
-
115
+ unsigned ABIVLen = 1 << FI.getExtInfo ().getLog2RISCVABIVLen ();
125
116
QualType RetTy = FI.getReturnType ();
126
117
if (!getCXXABI ().classifyReturnType (FI))
127
- FI.getReturnInfo () = classifyReturnType (RetTy, ArgABIVLen );
118
+ FI.getReturnInfo () = classifyReturnType (RetTy, ABIVLen );
128
119
129
120
// IsRetIndirect is true if classifyArgumentType indicated the value should
130
121
// be passed indirect, or if the type size is a scalar greater than 2*XLen
@@ -151,7 +142,7 @@ void RISCVABIInfo::computeInfo(CGFunctionInfo &FI) const {
151
142
for (auto &ArgInfo : FI.arguments ()) {
152
143
bool IsFixed = ArgNum < NumFixedArgs;
153
144
ArgInfo.info = classifyArgumentType (ArgInfo.type , IsFixed, ArgGPRsLeft,
154
- ArgFPRsLeft, ArgABIVLen );
145
+ ArgFPRsLeft, ABIVLen );
155
146
ArgNum++;
156
147
}
157
148
}
@@ -373,7 +364,7 @@ ABIArgInfo RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
373
364
// Fixed-length RVV vectors are represented as scalable vectors in function
374
365
// args/return and must be coerced from fixed vectors.
375
366
ABIArgInfo RISCVABIInfo::coerceVLSVector (QualType Ty,
376
- unsigned ArgABIVLen ) const {
367
+ unsigned ABIVLen ) const {
377
368
assert (Ty->isVectorType () && " expected vector type!" );
378
369
379
370
const auto *VT = Ty->castAs <VectorType>();
@@ -405,7 +396,7 @@ ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty,
405
396
406
397
llvm::ScalableVectorType *ResType;
407
398
408
- if (ArgABIVLen == 0 ) {
399
+ if (ABIVLen == 0 ) {
409
400
// The MinNumElts is simplified from equation:
410
401
// NumElts / VScale =
411
402
// (EltSize * NumElts / (VScale * RVVBitsPerBlock))
@@ -429,7 +420,7 @@ ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty,
429
420
// The number of elements needs to be at least 1.
430
421
ResType = llvm::ScalableVectorType::get (
431
422
EltType,
432
- llvm::divideCeil (NumElts * llvm::RISCV::RVVBitsPerBlock, ArgABIVLen ));
423
+ llvm::divideCeil (NumElts * llvm::RISCV::RVVBitsPerBlock, ABIVLen ));
433
424
}
434
425
435
426
return ABIArgInfo::getDirect (ResType);
@@ -438,7 +429,7 @@ ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty,
438
429
ABIArgInfo RISCVABIInfo::classifyArgumentType (QualType Ty, bool IsFixed,
439
430
int &ArgGPRsLeft,
440
431
int &ArgFPRsLeft,
441
- unsigned ArgABIVLen ) const {
432
+ unsigned ABIVLen ) const {
442
433
assert (ArgGPRsLeft <= NumArgGPRs && " Arg GPR tracking underflow" );
443
434
Ty = useFirstFieldIfTransparentUnion (Ty);
444
435
@@ -542,10 +533,10 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
542
533
VT->getVectorKind () == VectorKind::RVVFixedLengthMask_2 ||
543
534
VT->getVectorKind () == VectorKind::RVVFixedLengthMask_4)
544
535
return coerceVLSVector (Ty);
545
- if (VT->getVectorKind () == VectorKind::Generic && ArgABIVLen != 1 )
536
+ if (VT->getVectorKind () == VectorKind::Generic && ABIVLen != 1 )
546
537
// Generic vector without riscv_vls_cc should fall through and pass by
547
538
// reference.
548
- return coerceVLSVector (Ty, ArgABIVLen );
539
+ return coerceVLSVector (Ty, ABIVLen );
549
540
}
550
541
551
542
// Aggregates which are <= 2*XLen will be passed in registers if possible,
@@ -570,7 +561,7 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
570
561
}
571
562
572
563
ABIArgInfo RISCVABIInfo::classifyReturnType (QualType RetTy,
573
- unsigned ArgABIVLen ) const {
564
+ unsigned ABIVLen ) const {
574
565
if (RetTy->isVoidType ())
575
566
return ABIArgInfo::getIgnore ();
576
567
@@ -580,7 +571,7 @@ ABIArgInfo RISCVABIInfo::classifyReturnType(QualType RetTy,
580
571
// The rules for return and argument types are the same, so defer to
581
572
// classifyArgumentType.
582
573
return classifyArgumentType (RetTy, /* IsFixed=*/ true , ArgGPRsLeft, ArgFPRsLeft,
583
- ArgABIVLen );
574
+ ABIVLen );
584
575
}
585
576
586
577
RValue RISCVABIInfo::EmitVAArg (CodeGenFunction &CGF, Address VAListAddr,
@@ -619,9 +610,9 @@ namespace {
619
610
class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
620
611
public:
621
612
RISCVTargetCodeGenInfo (CodeGen::CodeGenTypes &CGT, unsigned XLen,
622
- unsigned FLen, unsigned ABIVLen, bool EABI)
613
+ unsigned FLen, bool EABI)
623
614
: TargetCodeGenInfo(
624
- std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, ABIVLen, EABI)) {
615
+ std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, EABI)) {
625
616
SwiftInfo =
626
617
std::make_unique<SwiftABIInfo>(CGT, /* SwiftErrorInRegister=*/ false );
627
618
}
@@ -653,8 +644,7 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
653
644
654
645
std::unique_ptr<TargetCodeGenInfo>
655
646
CodeGen::createRISCVTargetCodeGenInfo (CodeGenModule &CGM, unsigned XLen,
656
- unsigned FLen, unsigned ABIVLen,
657
- bool EABI) {
647
+ unsigned FLen, bool EABI) {
658
648
return std::make_unique<RISCVTargetCodeGenInfo>(CGM.getTypes (), XLen, FLen,
659
- ABIVLen, EABI);
649
+ EABI);
660
650
}
0 commit comments