Skip to content

Commit 36af758

Browse files
Add SEMA support
1 parent d060f1f commit 36af758

22 files changed

+105
-5
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7858,6 +7858,8 @@ def err_bad_lvalue_to_rvalue_cast : Error<
78587858
def err_bad_rvalue_to_rvalue_cast : Error<
78597859
"cannot cast from rvalue of type %1 to rvalue reference type %2; types are "
78607860
"not compatible">;
7861+
def err_bad_fpm8_cast : Error<
7862+
"cannot cast %0 to %1; types are not compatible">;
78617863
def err_bad_static_cast_pointer_nonpointer : Error<
78627864
"cannot cast from type %1 to pointer type %2">;
78637865
def err_bad_static_cast_member_pointer_nonmp : Error<

clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ namespace clang {
198198
Float16,
199199
Float32,
200200
Float64,
201-
BFloat16
201+
BFloat16,
202+
Fpm8
202203
};
203204

204205
NeonTypeFlags(unsigned F) : Flags(F) {}

clang/include/clang/Basic/TargetInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ class TargetInfo : public TransferrableTargetInfo,
234234
bool HasFullBFloat16; // True if the backend supports native bfloat16
235235
// arithmetic. Used to determine excess precision
236236
// support in the frontend.
237+
bool HasFpm8;
237238
bool HasIbm128;
238239
bool HasLongDouble;
239240
bool HasFPReturn;
@@ -700,6 +701,9 @@ class TargetInfo : public TransferrableTargetInfo,
700701
return HasBFloat16 || HasFullBFloat16;
701702
}
702703

704+
/// Determine whether the _fpm8 type is supported on this target.
705+
virtual bool hasFpm8Type() const { return HasFpm8; }
706+
703707
/// Determine whether the BFloat type is fully supported on this target, i.e
704708
/// arithemtic operations.
705709
virtual bool hasFullBFloat16Type() const { return HasFullBFloat16; }

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8106,6 +8106,7 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
81068106
switch (kind) {
81078107
case BuiltinType::Void: return 'v';
81088108
case BuiltinType::Bool: return 'B';
8109+
case BuiltinType::Fpm8:
81098110
case BuiltinType::Char8:
81108111
case BuiltinType::Char_U:
81118112
case BuiltinType::UChar: return 'C';
@@ -8132,7 +8133,6 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
81328133
case BuiltinType::LongDouble: return 'D';
81338134
case BuiltinType::NullPtr: return '*'; // like char*
81348135

8135-
case BuiltinType::Fpm8:
81368136
case BuiltinType::BFloat16:
81378137
case BuiltinType::Float16:
81388138
case BuiltinType::Float128:

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,6 +3800,9 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
38003800
case BuiltinType::Float: EltName = "float32_t"; break;
38013801
case BuiltinType::Half: EltName = "float16_t"; break;
38023802
case BuiltinType::BFloat16: EltName = "bfloat16_t"; break;
3803+
case BuiltinType::Fpm8:
3804+
EltName = "fmp8_t";
3805+
break;
38033806
default:
38043807
llvm_unreachable("unexpected Neon vector element type");
38053808
}
@@ -3853,6 +3856,8 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
38533856
return "Float64";
38543857
case BuiltinType::BFloat16:
38553858
return "Bfloat16";
3859+
case BuiltinType::Fpm8:
3860+
return "Fpm8_t";
38563861
default:
38573862
llvm_unreachable("Unexpected vector element base type");
38583863
}

clang/lib/AST/PrintfFormatString.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt,
817817
case BuiltinType::Char32:
818818
case BuiltinType::UInt128:
819819
case BuiltinType::Int128:
820+
case BuiltinType::Fpm8:
820821
case BuiltinType::Half:
821822
case BuiltinType::BFloat16:
822823
case BuiltinType::Float16:

clang/lib/Basic/TargetInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
6060
NoAsmVariants = false;
6161
HasLegalHalfType = false;
6262
HalfArgsAndReturns = false;
63+
HasFpm8 = false;
6364
HasFloat128 = false;
6465
HasIbm128 = false;
6566
HasFloat16 = false;

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
726726
.Case("sha3", HasSHA3)
727727
.Cases("aes", "pmull", HasAES)
728728
.Cases("fp16", "fullfp16", HasFullFP16)
729+
.Case("fp8", HasFpm8)
729730
.Case("dit", HasDIT)
730731
.Case("dpb", HasCCPP)
731732
.Case("dpb2", HasCCDP)
@@ -937,6 +938,9 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
937938
FPU |= NeonMode;
938939
HasSM4 = true;
939940
}
941+
if (Feature == "+fp8") {
942+
HasFpm8 = true;
943+
}
940944
if (Feature == "+strict-align")
941945
HasUnalignedAccess = false;
942946

@@ -1209,6 +1213,8 @@ bool AArch64TargetInfo::hasBFloat16Type() const {
12091213
return true;
12101214
}
12111215

1216+
bool AArch64TargetInfo::hasFpm8Type() const { return true; }
1217+
12121218
TargetInfo::CallingConvCheckResult
12131219
AArch64TargetInfo::checkCallingConvention(CallingConv CC) const {
12141220
switch (CC) {

clang/lib/Basic/Targets/AArch64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
4747
bool HasLS64 = false;
4848
bool HasRandGen = false;
4949
bool HasMatMul = false;
50+
bool HasFpm8 = false;
5051
bool HasBFloat16 = false;
5152
bool HasSVE2 = false;
5253
bool HasSVE2AES = false;
@@ -169,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
169170

170171
bool hasBFloat16Type() const override;
171172

173+
bool hasFpm8Type() const override;
174+
172175
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
173176

174177
bool isCLZForZeroUndef() const override;

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6229,7 +6229,8 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
62296229
switch (TypeFlags.getEltType()) {
62306230
case NeonTypeFlags::Int8:
62316231
case NeonTypeFlags::Poly8:
6232-
return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
6232+
case NeonTypeFlags::Fpm8:
6233+
return llvm::FixedVectorType::get(CGF->Fpm8Ty, V1Ty ? 1 : (8 << IsQuad));
62336234
case NeonTypeFlags::Int16:
62346235
case NeonTypeFlags::Poly16:
62356236
return llvm::FixedVectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));

0 commit comments

Comments
 (0)