@@ -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
@@ -548,10 +539,10 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
548
539
VT->getVectorKind () == VectorKind::RVVFixedLengthMask_2 ||
549
540
VT->getVectorKind () == VectorKind::RVVFixedLengthMask_4)
550
541
return coerceVLSVector (Ty);
551
- if (VT->getVectorKind () == VectorKind::Generic && ArgABIVLen != 1 )
542
+ if (VT->getVectorKind () == VectorKind::Generic && ABIVLen != 1 )
552
543
// Generic vector without riscv_vls_cc should fall through and pass by
553
544
// reference.
554
- return coerceVLSVector (Ty, ArgABIVLen );
545
+ return coerceVLSVector (Ty, ABIVLen );
555
546
}
556
547
557
548
// Aggregates which are <= 2*XLen will be passed in registers if possible,
@@ -576,7 +567,7 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
576
567
}
577
568
578
569
ABIArgInfo RISCVABIInfo::classifyReturnType (QualType RetTy,
579
- unsigned ArgABIVLen ) const {
570
+ unsigned ABIVLen ) const {
580
571
if (RetTy->isVoidType ())
581
572
return ABIArgInfo::getIgnore ();
582
573
@@ -586,7 +577,7 @@ ABIArgInfo RISCVABIInfo::classifyReturnType(QualType RetTy,
586
577
// The rules for return and argument types are the same, so defer to
587
578
// classifyArgumentType.
588
579
return classifyArgumentType (RetTy, /* IsFixed=*/ true , ArgGPRsLeft, ArgFPRsLeft,
589
- ArgABIVLen );
580
+ ABIVLen );
590
581
}
591
582
592
583
RValue RISCVABIInfo::EmitVAArg (CodeGenFunction &CGF, Address VAListAddr,
@@ -625,9 +616,9 @@ namespace {
625
616
class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
626
617
public:
627
618
RISCVTargetCodeGenInfo (CodeGen::CodeGenTypes &CGT, unsigned XLen,
628
- unsigned FLen, unsigned ABIVLen, bool EABI)
619
+ unsigned FLen, bool EABI)
629
620
: TargetCodeGenInfo(
630
- std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, ABIVLen, EABI)) {
621
+ std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, EABI)) {
631
622
SwiftInfo =
632
623
std::make_unique<SwiftABIInfo>(CGT, /* SwiftErrorInRegister=*/ false );
633
624
}
@@ -659,8 +650,7 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
659
650
660
651
std::unique_ptr<TargetCodeGenInfo>
661
652
CodeGen::createRISCVTargetCodeGenInfo (CodeGenModule &CGM, unsigned XLen,
662
- unsigned FLen, unsigned ABIVLen,
663
- bool EABI) {
653
+ unsigned FLen, bool EABI) {
664
654
return std::make_unique<RISCVTargetCodeGenInfo>(CGM.getTypes (), XLen, FLen,
665
- ABIVLen, EABI);
655
+ EABI);
666
656
}
0 commit comments