Skip to content

Commit 51b25ba

Browse files
committed
Revert "[RISCV] Support __riscv_v_fixed_vlen for vbool types. (#76551)"
This reverts commit b051141. Test failure was reported.
1 parent a621198 commit 51b25ba

20 files changed

+34
-1065
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ LoongArch Support
149149
RISC-V Support
150150
^^^^^^^^^^^^^^
151151

152-
- ``__attribute__((rvv_vector_bits(N))) is now supported for RVV vbool*_t types.
153-
154152
CUDA/HIP Language Changes
155153
^^^^^^^^^^^^^^^^^^^^^^^^^
156154

clang/include/clang/AST/Type.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,9 +3495,6 @@ enum class VectorKind {
34953495

34963496
/// is RISC-V RVV fixed-length data vector
34973497
RVVFixedLengthData,
3498-
3499-
/// is RISC-V RVV fixed-length mask vector
3500-
RVVFixedLengthMask,
35013498
};
35023499

35033500
/// Represents a GCC generic vector type. This type is created using

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,10 +2424,7 @@ only be a power of 2 between 64 and 65536.
24242424
For types where LMUL!=1, ``__riscv_v_fixed_vlen`` needs to be scaled by the LMUL
24252425
of the type before passing to the attribute.
24262426

2427-
For ``vbool*_t`` types, ``__riscv_v_fixed_vlen`` needs to be divided by the
2428-
number from the type name. For example, ``vbool8_t`` needs to use
2429-
``__riscv_v_fixed_vlen`` / 8. If the resulting value is not a multiple of 8,
2430-
the type is not supported for that value of ``__riscv_v_fixed_vlen``.
2427+
``vbool*_t`` types are not supported at this time.
24312428
}];
24322429
}
24332430

clang/lib/AST/ASTContext.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,8 +1945,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
19451945
else if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate)
19461946
// Adjust the alignment for fixed-length SVE predicates.
19471947
Align = 16;
1948-
else if (VT->getVectorKind() == VectorKind::RVVFixedLengthData ||
1949-
VT->getVectorKind() == VectorKind::RVVFixedLengthMask)
1948+
else if (VT->getVectorKind() == VectorKind::RVVFixedLengthData)
19501949
// Adjust the alignment for fixed-length RVV vectors.
19511950
Align = std::min<unsigned>(64, Width);
19521951
break;
@@ -9417,9 +9416,7 @@ bool ASTContext::areCompatibleVectorTypes(QualType FirstVec,
94179416
Second->getVectorKind() != VectorKind::SveFixedLengthData &&
94189417
Second->getVectorKind() != VectorKind::SveFixedLengthPredicate &&
94199418
First->getVectorKind() != VectorKind::RVVFixedLengthData &&
9420-
Second->getVectorKind() != VectorKind::RVVFixedLengthData &&
9421-
First->getVectorKind() != VectorKind::RVVFixedLengthMask &&
9422-
Second->getVectorKind() != VectorKind::RVVFixedLengthMask)
9419+
Second->getVectorKind() != VectorKind::RVVFixedLengthData)
94239420
return true;
94249421

94259422
return false;
@@ -9525,11 +9522,8 @@ static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty) {
95259522

95269523
ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(Ty);
95279524

9528-
unsigned EltSize = Context.getTypeSize(Info.ElementType);
9529-
if (Info.ElementType == Context.BoolTy)
9530-
EltSize = 1;
9531-
9532-
unsigned MinElts = Info.EC.getKnownMinValue();
9525+
uint64_t EltSize = Context.getTypeSize(Info.ElementType);
9526+
uint64_t MinElts = Info.EC.getKnownMinValue();
95339527
return VScale->first * MinElts * EltSize;
95349528
}
95359529

@@ -9543,12 +9537,6 @@ bool ASTContext::areCompatibleRVVTypes(QualType FirstType,
95439537
auto IsValidCast = [this](QualType FirstType, QualType SecondType) {
95449538
if (const auto *BT = FirstType->getAs<BuiltinType>()) {
95459539
if (const auto *VT = SecondType->getAs<VectorType>()) {
9546-
if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask) {
9547-
BuiltinVectorTypeInfo Info = getBuiltinVectorTypeInfo(BT);
9548-
return FirstType->isRVVVLSBuiltinType() &&
9549-
Info.ElementType == BoolTy &&
9550-
getTypeSize(SecondType) == getRVVTypeSize(*this, BT);
9551-
}
95529540
if (VT->getVectorKind() == VectorKind::RVVFixedLengthData ||
95539541
VT->getVectorKind() == VectorKind::Generic)
95549542
return FirstType->isRVVVLSBuiltinType() &&

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,8 +3994,7 @@ void CXXNameMangler::mangleAArch64FixedSveVectorType(
39943994
}
39953995

39963996
void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
3997-
assert((T->getVectorKind() == VectorKind::RVVFixedLengthData ||
3998-
T->getVectorKind() == VectorKind::RVVFixedLengthMask) &&
3997+
assert(T->getVectorKind() == VectorKind::RVVFixedLengthData &&
39993998
"expected fixed-length RVV vector!");
40003999

40014000
QualType EltType = T->getElementType();
@@ -4010,10 +4009,7 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
40104009
TypeNameOS << "int8";
40114010
break;
40124011
case BuiltinType::UChar:
4013-
if (T->getVectorKind() == VectorKind::RVVFixedLengthData)
4014-
TypeNameOS << "uint8";
4015-
else
4016-
TypeNameOS << "bool";
4012+
TypeNameOS << "uint8";
40174013
break;
40184014
case BuiltinType::Short:
40194015
TypeNameOS << "int16";
@@ -4052,16 +4048,12 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
40524048
auto VScale = getASTContext().getTargetInfo().getVScaleRange(
40534049
getASTContext().getLangOpts());
40544050
unsigned VLen = VScale->first * llvm::RISCV::RVVBitsPerBlock;
4051+
TypeNameOS << 'm';
4052+
if (VecSizeInBits >= VLen)
4053+
TypeNameOS << (VecSizeInBits / VLen);
4054+
else
4055+
TypeNameOS << 'f' << (VLen / VecSizeInBits);
40554056

4056-
if (T->getVectorKind() == VectorKind::RVVFixedLengthData) {
4057-
TypeNameOS << 'm';
4058-
if (VecSizeInBits >= VLen)
4059-
TypeNameOS << (VecSizeInBits / VLen);
4060-
else
4061-
TypeNameOS << 'f' << (VLen / VecSizeInBits);
4062-
} else {
4063-
TypeNameOS << (VLen / VecSizeInBits);
4064-
}
40654057
TypeNameOS << "_t";
40664058

40674059
Out << "9__RVV_VLSI" << 'u' << TypeNameStr.size() << TypeNameStr << "Lj"
@@ -4101,8 +4093,7 @@ void CXXNameMangler::mangleType(const VectorType *T) {
41014093
T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
41024094
mangleAArch64FixedSveVectorType(T);
41034095
return;
4104-
} else if (T->getVectorKind() == VectorKind::RVVFixedLengthData ||
4105-
T->getVectorKind() == VectorKind::RVVFixedLengthMask) {
4096+
} else if (T->getVectorKind() == VectorKind::RVVFixedLengthData) {
41064097
mangleRISCVFixedRVVVectorType(T);
41074098
return;
41084099
}

clang/lib/AST/JSONNodeDumper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,6 @@ void JSONNodeDumper::VisitVectorType(const VectorType *VT) {
703703
case VectorKind::RVVFixedLengthData:
704704
JOS.attribute("vectorKind", "fixed-length rvv data vector");
705705
break;
706-
case VectorKind::RVVFixedLengthMask:
707-
JOS.attribute("vectorKind", "fixed-length rvv mask vector");
708-
break;
709706
}
710707
}
711708

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,6 @@ void TextNodeDumper::VisitVectorType(const VectorType *T) {
16231623
case VectorKind::RVVFixedLengthData:
16241624
OS << " fixed-length rvv data vector";
16251625
break;
1626-
case VectorKind::RVVFixedLengthMask:
1627-
OS << " fixed-length rvv mask vector";
1628-
break;
16291626
}
16301627
OS << " " << T->getNumElements();
16311628
}

clang/lib/AST/Type.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,9 +2479,6 @@ bool Type::isRVVVLSBuiltinType() const {
24792479
IsFP, IsBF) \
24802480
case BuiltinType::Id: \
24812481
return NF == 1;
2482-
#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2483-
case BuiltinType::Id: \
2484-
return true;
24852482
#include "clang/Basic/RISCVVTypes.def"
24862483
default:
24872484
return false;
@@ -2494,17 +2491,7 @@ QualType Type::getRVVEltType(const ASTContext &Ctx) const {
24942491
assert(isRVVVLSBuiltinType() && "unsupported type!");
24952492

24962493
const BuiltinType *BTy = castAs<BuiltinType>();
2497-
2498-
switch (BTy->getKind()) {
2499-
#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls) \
2500-
case BuiltinType::Id: \
2501-
return Ctx.UnsignedCharTy;
2502-
default:
2503-
return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType;
2504-
#include "clang/Basic/RISCVVTypes.def"
2505-
}
2506-
2507-
llvm_unreachable("Unhandled type");
2494+
return Ctx.getBuiltinVectorTypeInfo(BTy).ElementType;
25082495
}
25092496

25102497
bool QualType::isPODType(const ASTContext &Context) const {

clang/lib/AST/TypePrinter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,6 @@ void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
694694
printBefore(T->getElementType(), OS);
695695
break;
696696
case VectorKind::RVVFixedLengthData:
697-
case VectorKind::RVVFixedLengthMask:
698697
// FIXME: We prefer to print the size directly here, but have no way
699698
// to get the size of the type.
700699
OS << "__attribute__((__riscv_rvv_vector_bits__(";
@@ -774,7 +773,6 @@ void TypePrinter::printDependentVectorBefore(
774773
printBefore(T->getElementType(), OS);
775774
break;
776775
case VectorKind::RVVFixedLengthData:
777-
case VectorKind::RVVFixedLengthMask:
778776
// FIXME: We prefer to print the size directly here, but have no way
779777
// to get the size of the type.
780778
OS << "__attribute__((__riscv_rvv_vector_bits__(";

clang/lib/CodeGen/Targets/RISCV.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -321,28 +321,20 @@ ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty) const {
321321
assert(Ty->isVectorType() && "expected vector type!");
322322

323323
const auto *VT = Ty->castAs<VectorType>();
324+
assert(VT->getVectorKind() == VectorKind::RVVFixedLengthData &&
325+
"Unexpected vector kind");
326+
324327
assert(VT->getElementType()->isBuiltinType() && "expected builtin type!");
325328

326329
auto VScale =
327330
getContext().getTargetInfo().getVScaleRange(getContext().getLangOpts());
328-
329-
unsigned NumElts = VT->getNumElements();
330-
llvm::Type *EltType;
331-
if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask) {
332-
NumElts *= 8;
333-
EltType = llvm::Type::getInt1Ty(getVMContext());
334-
} else {
335-
assert(VT->getVectorKind() == VectorKind::RVVFixedLengthData &&
336-
"Unexpected vector kind");
337-
EltType = CGT.ConvertType(VT->getElementType());
338-
}
339-
340331
// The MinNumElts is simplified from equation:
341332
// NumElts / VScale =
342333
// (EltSize * NumElts / (VScale * RVVBitsPerBlock))
343334
// * (RVVBitsPerBlock / EltSize)
344335
llvm::ScalableVectorType *ResType =
345-
llvm::ScalableVectorType::get(EltType, NumElts / VScale->first);
336+
llvm::ScalableVectorType::get(CGT.ConvertType(VT->getElementType()),
337+
VT->getNumElements() / VScale->first);
346338
return ABIArgInfo::getDirect(ResType);
347339
}
348340

@@ -445,8 +437,7 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
445437
}
446438

447439
if (const VectorType *VT = Ty->getAs<VectorType>())
448-
if (VT->getVectorKind() == VectorKind::RVVFixedLengthData ||
449-
VT->getVectorKind() == VectorKind::RVVFixedLengthMask)
440+
if (VT->getVectorKind() == VectorKind::RVVFixedLengthData)
450441
return coerceVLSVector(Ty);
451442

452443
// Aggregates which are <= 2*XLen will be passed in registers if possible,

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11142,8 +11142,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
1114211142
if (VecType->getVectorKind() == VectorKind::SveFixedLengthData ||
1114311143
VecType->getVectorKind() == VectorKind::SveFixedLengthPredicate)
1114411144
return true;
11145-
if (VecType->getVectorKind() == VectorKind::RVVFixedLengthData ||
11146-
VecType->getVectorKind() == VectorKind::RVVFixedLengthMask) {
11145+
if (VecType->getVectorKind() == VectorKind::RVVFixedLengthData) {
1114711146
SVEorRVV = 1;
1114811147
return true;
1114911148
}
@@ -11174,8 +11173,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
1117411173
SecondVecType->getVectorKind() ==
1117511174
VectorKind::SveFixedLengthPredicate)
1117611175
return true;
11177-
if (SecondVecType->getVectorKind() == VectorKind::RVVFixedLengthData ||
11178-
SecondVecType->getVectorKind() == VectorKind::RVVFixedLengthMask) {
11176+
if (SecondVecType->getVectorKind() == VectorKind::RVVFixedLengthData) {
1117911177
SVEorRVV = 1;
1118011178
return true;
1118111179
}

clang/lib/Sema/SemaType.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8646,30 +8646,21 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType,
86468646

86478647
ASTContext::BuiltinVectorTypeInfo Info =
86488648
S.Context.getBuiltinVectorTypeInfo(CurType->castAs<BuiltinType>());
8649+
unsigned EltSize = S.Context.getTypeSize(Info.ElementType);
86498650
unsigned MinElts = Info.EC.getKnownMinValue();
86508651

8651-
VectorKind VecKind = VectorKind::RVVFixedLengthData;
8652-
unsigned ExpectedSize = VScale->first * MinElts;
8653-
QualType EltType = CurType->getRVVEltType(S.Context);
8654-
unsigned EltSize = S.Context.getTypeSize(EltType);
8655-
unsigned NumElts;
8656-
if (Info.ElementType == S.Context.BoolTy) {
8657-
NumElts = VecSize / S.Context.getCharWidth();
8658-
VecKind = VectorKind::RVVFixedLengthMask;
8659-
} else {
8660-
ExpectedSize *= EltSize;
8661-
NumElts = VecSize / EltSize;
8662-
}
8663-
86648652
// The attribute vector size must match -mrvv-vector-bits.
8665-
if (ExpectedSize % 8 != 0 || VecSize != ExpectedSize) {
8653+
unsigned ExpectedSize = VScale->first * MinElts * EltSize;
8654+
if (VecSize != ExpectedSize) {
86668655
S.Diag(Attr.getLoc(), diag::err_attribute_bad_rvv_vector_size)
86678656
<< VecSize << ExpectedSize;
86688657
Attr.setInvalid();
86698658
return;
86708659
}
86718660

8672-
CurType = S.Context.getVectorType(EltType, NumElts, VecKind);
8661+
VectorKind VecKind = VectorKind::RVVFixedLengthData;
8662+
VecSize /= EltSize;
8663+
CurType = S.Context.getVectorType(Info.ElementType, VecSize, VecKind);
86738664
}
86748665

86758666
/// Handle OpenCL Access Qualifier Attribute.

0 commit comments

Comments
 (0)