Skip to content

Commit 42118c4

Browse files
author
git apple-llvm automerger
committed
Merge commit '30962268e7a5' from llvm.org/main into next
2 parents efcb90a + 3096226 commit 42118c4

File tree

3 files changed

+862
-13
lines changed

3 files changed

+862
-13
lines changed

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "llvm/ADT/StringExtras.h"
3636
#include "llvm/Support/ErrorHandling.h"
3737
#include "llvm/Support/raw_ostream.h"
38+
#include "llvm/TargetParser/RISCVTargetParser.h"
3839
#include <optional>
3940

4041
using namespace clang;
@@ -3826,48 +3827,62 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
38263827
assert(EltType->isBuiltinType() &&
38273828
"expected builtin type for fixed-length RVV vector!");
38283829

3829-
StringRef TypeName;
3830+
SmallString<20> TypeNameStr;
3831+
llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
3832+
TypeNameOS << "__rvv_";
38303833
switch (cast<BuiltinType>(EltType)->getKind()) {
38313834
case BuiltinType::SChar:
3832-
TypeName = "__rvv_int8m1_t";
3835+
TypeNameOS << "int8";
38333836
break;
38343837
case BuiltinType::UChar:
3835-
TypeName = "__rvv_uint8m1_t";
3838+
TypeNameOS << "uint8";
38363839
break;
38373840
case BuiltinType::Short:
3838-
TypeName = "__rvv_int16m1_t";
3841+
TypeNameOS << "int16";
38393842
break;
38403843
case BuiltinType::UShort:
3841-
TypeName = "__rvv_uint16m1_t";
3844+
TypeNameOS << "uint16";
38423845
break;
38433846
case BuiltinType::Int:
3844-
TypeName = "__rvv_int32m1_t";
3847+
TypeNameOS << "int32";
38453848
break;
38463849
case BuiltinType::UInt:
3847-
TypeName = "__rvv_uint32m1_t";
3850+
TypeNameOS << "uint32";
38483851
break;
38493852
case BuiltinType::Long:
3850-
TypeName = "__rvv_int64m1_t";
3853+
TypeNameOS << "int64";
38513854
break;
38523855
case BuiltinType::ULong:
3853-
TypeName = "__rvv_uint64m1_t";
3856+
TypeNameOS << "uint64";
38543857
break;
38553858
case BuiltinType::Half:
3856-
TypeName = "__rvv_float16m1_t";
3859+
TypeNameOS << "float16";
38573860
break;
38583861
case BuiltinType::Float:
3859-
TypeName = "__rvv_float32m1_t";
3862+
TypeNameOS << "float32";
38603863
break;
38613864
case BuiltinType::Double:
3862-
TypeName = "__rvv_float64m1_t";
3865+
TypeNameOS << "float64";
38633866
break;
38643867
default:
38653868
llvm_unreachable("unexpected element type for fixed-length RVV vector!");
38663869
}
38673870

38683871
unsigned VecSizeInBits = getASTContext().getTypeInfo(T).Width;
38693872

3870-
Out << "9__RVV_VLSI" << 'u' << TypeName.size() << TypeName << "Lj"
3873+
// Apend the LMUL suffix.
3874+
auto VScale = getASTContext().getTargetInfo().getVScaleRange(
3875+
getASTContext().getLangOpts());
3876+
unsigned VLen = VScale->first * llvm::RISCV::RVVBitsPerBlock;
3877+
TypeNameOS << 'm';
3878+
if (VecSizeInBits >= VLen)
3879+
TypeNameOS << (VecSizeInBits / VLen);
3880+
else
3881+
TypeNameOS << 'f' << (VLen / VecSizeInBits);
3882+
3883+
TypeNameOS << "_t";
3884+
3885+
Out << "9__RVV_VLSI" << 'u' << TypeNameStr.size() << TypeNameStr << "Lj"
38713886
<< VecSizeInBits << "EE";
38723887
}
38733888

0 commit comments

Comments
 (0)