|
35 | 35 | #include "llvm/ADT/StringExtras.h"
|
36 | 36 | #include "llvm/Support/ErrorHandling.h"
|
37 | 37 | #include "llvm/Support/raw_ostream.h"
|
| 38 | +#include "llvm/TargetParser/RISCVTargetParser.h" |
38 | 39 | #include <optional>
|
39 | 40 |
|
40 | 41 | using namespace clang;
|
@@ -3826,48 +3827,62 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
|
3826 | 3827 | assert(EltType->isBuiltinType() &&
|
3827 | 3828 | "expected builtin type for fixed-length RVV vector!");
|
3828 | 3829 |
|
3829 |
| - StringRef TypeName; |
| 3830 | + SmallString<20> TypeNameStr; |
| 3831 | + llvm::raw_svector_ostream TypeNameOS(TypeNameStr); |
| 3832 | + TypeNameOS << "__rvv_"; |
3830 | 3833 | switch (cast<BuiltinType>(EltType)->getKind()) {
|
3831 | 3834 | case BuiltinType::SChar:
|
3832 |
| - TypeName = "__rvv_int8m1_t"; |
| 3835 | + TypeNameOS << "int8"; |
3833 | 3836 | break;
|
3834 | 3837 | case BuiltinType::UChar:
|
3835 |
| - TypeName = "__rvv_uint8m1_t"; |
| 3838 | + TypeNameOS << "uint8"; |
3836 | 3839 | break;
|
3837 | 3840 | case BuiltinType::Short:
|
3838 |
| - TypeName = "__rvv_int16m1_t"; |
| 3841 | + TypeNameOS << "int16"; |
3839 | 3842 | break;
|
3840 | 3843 | case BuiltinType::UShort:
|
3841 |
| - TypeName = "__rvv_uint16m1_t"; |
| 3844 | + TypeNameOS << "uint16"; |
3842 | 3845 | break;
|
3843 | 3846 | case BuiltinType::Int:
|
3844 |
| - TypeName = "__rvv_int32m1_t"; |
| 3847 | + TypeNameOS << "int32"; |
3845 | 3848 | break;
|
3846 | 3849 | case BuiltinType::UInt:
|
3847 |
| - TypeName = "__rvv_uint32m1_t"; |
| 3850 | + TypeNameOS << "uint32"; |
3848 | 3851 | break;
|
3849 | 3852 | case BuiltinType::Long:
|
3850 |
| - TypeName = "__rvv_int64m1_t"; |
| 3853 | + TypeNameOS << "int64"; |
3851 | 3854 | break;
|
3852 | 3855 | case BuiltinType::ULong:
|
3853 |
| - TypeName = "__rvv_uint64m1_t"; |
| 3856 | + TypeNameOS << "uint64"; |
3854 | 3857 | break;
|
3855 | 3858 | case BuiltinType::Half:
|
3856 |
| - TypeName = "__rvv_float16m1_t"; |
| 3859 | + TypeNameOS << "float16"; |
3857 | 3860 | break;
|
3858 | 3861 | case BuiltinType::Float:
|
3859 |
| - TypeName = "__rvv_float32m1_t"; |
| 3862 | + TypeNameOS << "float32"; |
3860 | 3863 | break;
|
3861 | 3864 | case BuiltinType::Double:
|
3862 |
| - TypeName = "__rvv_float64m1_t"; |
| 3865 | + TypeNameOS << "float64"; |
3863 | 3866 | break;
|
3864 | 3867 | default:
|
3865 | 3868 | llvm_unreachable("unexpected element type for fixed-length RVV vector!");
|
3866 | 3869 | }
|
3867 | 3870 |
|
3868 | 3871 | unsigned VecSizeInBits = getASTContext().getTypeInfo(T).Width;
|
3869 | 3872 |
|
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" |
3871 | 3886 | << VecSizeInBits << "EE";
|
3872 | 3887 | }
|
3873 | 3888 |
|
|
0 commit comments