[clang] [CLANG][AArch64]Add Neon vectors for mfloat8_t (PR #99865)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 15 09:22:40 PDT 2024
https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/99865
>From bfcf7c00a0f7e2c619666d72bad4a48928c4b786 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Mon, 24 Jun 2024 09:59:24 +0000
Subject: [PATCH 1/8] [CLANG][AArch64] Add the modal 8 bit floating-point
scalar type
ARM ACLE PR#323[1] adds new modal types for 8-bit floating point intrinsic.
>From the PR#323:
```
ACLE defines the `__mfp8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.
````
The type should be an opaque type and its format in undefined in Clang.
Only defined in the backend by a status/format register, for AArch64 the FPMR.
This patch is an attempt to the add the MFloat8_t scalar type.
It has a parser and codegen for the new scalar type.
The patch it is lowering to and 8bit unsigned as it has no format.
But maybe we should add another opaque type.
[1] https://github.com/ARM-software/acle/pull/323
---
clang/include/clang/AST/Type.h | 7 ++++++
.../clang/Basic/AArch64SVEACLETypes.def | 9 +++++++
clang/include/clang/Basic/Specifiers.h | 1 +
clang/include/clang/Basic/TargetInfo.h | 3 +++
clang/include/clang/Sema/DeclSpec.h | 2 ++
.../include/clang/Serialization/ASTBitCodes.h | 2 +-
clang/lib/AST/ASTContext.cpp | 13 +++++++++-
clang/lib/AST/ItaniumMangle.cpp | 6 +++++
clang/lib/AST/Type.cpp | 25 ++++++++++++++++---
clang/lib/Basic/Targets/AArch64.cpp | 2 ++
clang/lib/Basic/Targets/AArch64.h | 2 ++
clang/lib/CodeGen/CGDebugInfo.cpp | 7 ++++++
clang/lib/CodeGen/CodeGenTypes.cpp | 6 ++++-
clang/lib/Parse/ParseDecl.cpp | 4 +++
clang/lib/Parse/ParseExprCXX.cpp | 4 +++
clang/lib/Sema/DeclSpec.cpp | 3 +++
clang/lib/Sema/SemaCast.cpp | 8 ++++++
clang/lib/Sema/SemaExpr.cpp | 6 +++++
clang/lib/Sema/SemaTemplateVariadic.cpp | 1 +
clang/lib/Sema/SemaType.cpp | 6 ++++-
clang/test/Modules/no-external-type-id.cppm | 2 +-
21 files changed, 111 insertions(+), 8 deletions(-)
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 8ff04cf89a6b91..037e5207babd1c 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2647,6 +2647,8 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
bool isQueueT() const; // OpenCL queue_t
bool isReserveIDT() const; // OpenCL reserve_id_t
+ bool isArmMFloat8Type() const; // AARCH64_OPAQUE_TYPE
+
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
bool is##Id##Type() const;
#include "clang/Basic/OpenCLExtensionTypes.def"
@@ -8404,6 +8406,11 @@ inline bool Type::isBitIntType() const {
return isa<BitIntType>(CanonicalType);
}
+// AARCH64_OPAQUE_TYPE
+inline bool Type::isArmMFloat8Type() const {
+ return isSpecificBuiltinType(BuiltinType::ArmMFloat8);
+}
+
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
inline bool Type::is##Id##Type() const { \
return isSpecificBuiltinType(BuiltinType::Id); \
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 55ed9c36f6c5cd..53644905b789b7 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -97,6 +97,12 @@
SVE_TYPE(Name, Id, SingletonId)
#endif
+#ifndef AARCH64_OPAQUE_TYPE
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF) \
+ SVE_TYPE(Name, Id, SingletonId)
+#endif
+
//===- Vector point types -----------------------------------------------===//
SVE_VECTOR_TYPE_INT("__SVInt8_t", "__SVInt8_t", SveInt8, SveInt8Ty, 16, 8, 1, true)
@@ -181,6 +187,8 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
+AARCH64_OPAQUE_TYPE("__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 8, 1)
+
#undef SVE_VECTOR_TYPE
#undef SVE_VECTOR_TYPE_BFLOAT
#undef SVE_VECTOR_TYPE_FLOAT
@@ -188,4 +196,5 @@ SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
#undef SVE_PREDICATE_TYPE
#undef SVE_PREDICATE_TYPE_ALL
#undef SVE_OPAQUE_TYPE
+#undef AARCH64_OPAQUE_TYPE
#undef SVE_TYPE
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index 9c089908fdc130..8216d35bd68800 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -68,6 +68,7 @@ namespace clang {
TST_Accum, // ISO/IEC JTC1 SC22 WG14 N1169 Extension
TST_Fract,
TST_BFloat16,
+ TST_ArmMFloat8_t, // AARCH64_OPAQUE_TYPE
TST_float,
TST_double,
TST_float128,
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 57783850606290..1693be6e1a5e89 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -701,6 +701,9 @@ class TargetInfo : public TransferrableTargetInfo,
return HasBFloat16 || HasFullBFloat16;
}
+ /// Determine whether the _mfp8 type is supported on this target.
+ virtual bool hasArmMFloat8Type() const { return HasMFloat8; }
+
/// Determine whether the BFloat type is fully supported on this target, i.e
/// arithemtic operations.
virtual bool hasFullBFloat16Type() const { return HasFullBFloat16; }
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 06243f2624876f..cbafa9aa06ced7 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -325,6 +325,8 @@ class DeclSpec {
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
static const TST TST_##Name = clang::TST_##Name;
#include "clang/Basic/HLSLIntangibleTypes.def"
+ // AARCH64_OPAQUE_TYPE
+ static const TST TST_ArmMFloat8_t = clang::TST_ArmMFloat8_t;
static const TST TST_error = clang::TST_error;
// type-qualifiers
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index 4b79d4b7711905..d735e2dcaa8c56 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1149,7 +1149,7 @@ enum PredefinedTypeIDs {
///
/// Type IDs for non-predefined types will start at
/// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 505;
+const unsigned NUM_PREDEF_TYPE_IDS = 506;
// Ensure we do not overrun the predefined types we reserved
// in the enum PredefinedTypeIDs above.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 034fbbe0bc7829..27e9c0bea916c8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1412,7 +1412,8 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
}
if (Target.hasAArch64SVETypes() ||
- (AuxTarget && AuxTarget->hasAArch64SVETypes())) {
+ (AuxTarget && AuxTarget->hasAArch64SVETypes()) ||
+ Target.hasArmMFloat8Type()) {
#define SVE_TYPE(Name, Id, SingletonId) \
InitBuiltinType(SingletonId, BuiltinType::Id);
#include "clang/Basic/AArch64SVEACLETypes.def"
@@ -2239,6 +2240,12 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
Width = 0; \
Align = 16; \
break;
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF)
+ case BuiltinType::ArmMFloat8:
+ Width = Target->getCharWidth();
+ Align = Target->getCharAlign();
+ break;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
@@ -4358,6 +4365,8 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
case BuiltinType::Id: \
return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF)
#include "clang/Basic/AArch64SVEACLETypes.def"
#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
@@ -4423,6 +4432,8 @@ QualType ASTContext::getScalableVectorType(QualType EltTy, unsigned NumElts,
if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
return SingletonId;
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF)
#include "clang/Basic/AArch64SVEACLETypes.def"
} else if (Target->hasRISCVVTypes()) {
uint64_t EltTySize = getTypeSize(EltTy);
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 777cdca1a0c0d7..007788d07a0d13 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3430,6 +3430,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
type_name = MangledName; \
Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
break;
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF) \
+ case BuiltinType::Id: \
+ type_name = MangledName; \
+ Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
+ break;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 6f4958801cfe82..651f278681e1e0 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2484,9 +2484,18 @@ bool Type::isSVESizelessBuiltinType() const {
if (const BuiltinType *BT = getAs<BuiltinType>()) {
switch (BT->getKind()) {
// SVE Types
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
+ case BuiltinType::Id:
+#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
+ case BuiltinType::Id:
+#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
+ case BuiltinType::Id:
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF)
#include "clang/Basic/AArch64SVEACLETypes.def"
return true;
+ case BuiltinType::ArmMFloat8:
+ return false;
default:
return false;
}
@@ -3437,9 +3446,19 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
case Id: \
return #ExtType;
#include "clang/Basic/OpenCLExtensionTypes.def"
-#define SVE_TYPE(Name, Id, SingletonId) \
- case Id: \
+#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
+ case Id: \
+ return Name;
+#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
+ case Id: \
+ return Name;
+#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
+ case Id: \
return Name;
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF)
+ case ArmMFloat8:
+ return "__mfp8";
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case Id: \
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 61889861c9c803..08286a963bd27a 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1246,6 +1246,8 @@ bool AArch64TargetInfo::hasBFloat16Type() const {
return true;
}
+bool AArch64TargetInfo::hasArmMFloat8Type() const { return true; }
+
TargetInfo::CallingConvCheckResult
AArch64TargetInfo::checkCallingConvention(CallingConv CC) const {
switch (CC) {
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index 1226ce4d4355c2..afeb4d57dc7649 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -171,6 +171,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool hasBFloat16Type() const override;
+ bool hasArmMFloat8Type() const override;
+
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
bool isCLZForZeroUndef() const override;
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 06015a9e541ea2..642e64b6584526 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -783,6 +783,13 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
{
+ if (BT->getKind() == BuiltinType::ArmMFloat8) {
+ Encoding = llvm::dwarf::DW_ATE_unsigned_char;
+ BTName = BT->getName(CGM.getLangOpts());
+ // Bit size and offset of the type.
+ uint64_t Size = CGM.getContext().getTypeSize(BT);
+ return DBuilder.createBasicType(BTName, Size, Encoding);
+ }
ASTContext::BuiltinVectorTypeInfo Info =
// For svcount_t, only the lower 2 bytes are relevant.
BT->getKind() == BuiltinType::SveCount
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 339632090a5b71..f074a9450bc989 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -477,7 +477,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
Context.getFloatTypeSemantics(T),
/* UseNativeHalf = */ false);
break;
-
case BuiltinType::NullPtr:
// Model std::nullptr_t as i8*
ResultType = llvm::PointerType::getUnqual(getLLVMContext());
@@ -505,6 +504,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
case BuiltinType::Id:
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id:
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF)
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
{
@@ -527,6 +528,9 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
}
case BuiltinType::SveCount:
return llvm::TargetExtType::get(getLLVMContext(), "aarch64.svcount");
+ case BuiltinType::ArmMFloat8:
+ ResultType = llvm::Type::getInt8Ty(getLLVMContext());
+ break;
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
ResultType = \
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 122a05be1c039a..0c6aa95f8f9c80 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4547,6 +4547,10 @@ void Parser::ParseDeclarationSpecifiers(
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec,
DiagID, Policy);
break;
+ case tok::kw___mfp8: // AARCH64_OPAQUE_TYPE
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_ArmMFloat8_t, Loc, PrevSpec,
+ DiagID, Policy);
+ break;
case tok::kw_half:
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec,
DiagID, Policy);
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index e96cddf88a1346..bb5bcec18e1a5a 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -2408,6 +2408,10 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
case tok::kw___int128:
DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec, DiagID, Policy);
break;
+ case tok::kw___mfp8: // AARCH64_OPAQUE_TYPE
+ DS.SetTypeSpecType(DeclSpec::TST_ArmMFloat8_t, Loc, PrevSpec, DiagID,
+ Policy);
+ break;
case tok::kw___bf16:
DS.SetTypeSpecType(DeclSpec::TST_BFloat16, Loc, PrevSpec, DiagID, Policy);
break;
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 12d2d3f6060c63..2bd44949e5eda1 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -379,6 +379,7 @@ bool Declarator::isDeclarationOfFunction() const {
#include "clang/Basic/OpenCLImageTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
#include "clang/Basic/HLSLIntangibleTypes.def"
+ case TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
return false;
case TST_decltype_auto:
@@ -613,6 +614,8 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
case DeclSpec::TST_##Name: \
return #Name;
+ case DeclSpec::TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
+ return "__mfp8";
#include "clang/Basic/HLSLIntangibleTypes.def"
case DeclSpec::TST_error: return "(error)";
}
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 6ac6201843476b..5c49bd57699a22 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2991,6 +2991,14 @@ void CastOperation::CheckCStyleCast() {
return;
}
+ if ((DestType->isArmMFloat8Type() && !SrcType->isArmMFloat8Type()) ||
+ (!DestType->isArmMFloat8Type() && SrcType->isArmMFloat8Type())) {
+ Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_mfloat8_cast)
+ << SrcType << DestType << SrcExpr.get()->getSourceRange();
+ SrcExpr = ExprError();
+ return;
+ }
+
// Allow casting a sizeless built-in type to itself.
if (DestType->isSizelessBuiltinType() &&
Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 531e7f6933d6d3..af32922a431b93 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8445,6 +8445,12 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
return QualType();
}
+ if (LHSTy->isArmMFloat8Type() || RHSTy->isArmMFloat8Type()) {
+ Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
+ << LHSTy << RHSTy << LHS.get()->getSourceRange()
+ << RHS.get()->getSourceRange();
+ }
+
// Diagnose attempts to convert between __ibm128, __float128 and long double
// where such conversions currently can't be handled.
if (unsupportedTypeConversion(*this, LHSTy, RHSTy)) {
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 19bd4547665835..1db5b3d49e6a13 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -972,6 +972,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
#include "clang/Basic/OpenCLImageTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
#include "clang/Basic/HLSLIntangibleTypes.def"
+ case TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
case TST_unknown_anytype:
case TST_error:
break;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index c44fc9c4194ca4..f2ff3a4004b5e6 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1375,7 +1375,11 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
Result = Context.SingletonId; \
break;
#include "clang/Basic/HLSLIntangibleTypes.def"
-
+ case DeclSpec::TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
+ if (!S.Context.getTargetInfo().hasArmMFloat8Type())
+ S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__mfp8";
+ Result = Context.ArmMFloat8Ty;
+ break;
case DeclSpec::TST_error:
Result = Context.IntTy;
declarator.setInvalidType(true);
diff --git a/clang/test/Modules/no-external-type-id.cppm b/clang/test/Modules/no-external-type-id.cppm
index 068e52646dcc1c..a4ca389739fbb5 100644
--- a/clang/test/Modules/no-external-type-id.cppm
+++ b/clang/test/Modules/no-external-type-id.cppm
@@ -23,7 +23,7 @@ export module b;
import a;
export int b();
-// CHECK: <DECL_FUNCTION {{.*}} op8=4056
+// CHECK: <DECL_FUNCTION {{.*}} op8=4064
// CHECK: <TYPE_FUNCTION_PROTO
//--- a.v1.cppm
>From 73e35b2c9d50c23021ea851be477b682494dd8d0 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Fri, 19 Jul 2024 09:10:57 +0000
Subject: [PATCH 2/8] [CLANG]Add Neon vectors for mfloat8
This patch adds these new vector sizes for neon:
mfloat8x16_t and mfloat8x8_t
According to the ARM ACLE PR#323[1].
`mfloat8_t` | equivalent to `__mfp8` |
[1]https://github.com/ARM-software/acle/pull/323
---
.../clang/Basic/DiagnosticSemaKinds.td | 2 +
clang/include/clang/Basic/TargetBuiltins.h | 4 +-
clang/include/clang/Basic/TargetInfo.h | 1 +
clang/include/clang/Basic/TokenKinds.def | 2 +
clang/include/clang/Basic/arm_mfp8.td | 14 +++
clang/include/clang/Basic/arm_neon_incl.td | 2 +
.../include/clang/Serialization/ASTBitCodes.h | 4 +-
clang/lib/AST/ItaniumMangle.cpp | 3 +
clang/lib/Basic/TargetInfo.cpp | 1 +
clang/lib/Basic/Targets/AArch64.cpp | 7 ++
clang/lib/Basic/Targets/AArch64.h | 1 +
clang/lib/Basic/Targets/ARM.cpp | 2 +
clang/lib/Basic/Targets/ARM.h | 2 +
clang/lib/CodeGen/CGBuiltin.cpp | 2 +
clang/lib/CodeGen/CodeGenModule.cpp | 1 +
clang/lib/CodeGen/CodeGenTypeCache.h | 3 +
clang/lib/Headers/CMakeLists.txt | 3 +
clang/lib/Lex/Lexer.cpp | 1 +
clang/lib/Parse/ParseDecl.cpp | 3 +
clang/lib/Parse/ParseExpr.cpp | 1 +
clang/lib/Parse/ParseTentative.cpp | 2 +
clang/lib/Sema/SemaARM.cpp | 2 +
clang/lib/Sema/SemaCast.cpp | 7 ++
clang/lib/Sema/SemaType.cpp | 3 +-
clang/test/AST/arm-mfp8.cpp | 94 +++++++++++++++++++
clang/test/CodeGen/arm-mfp8.c | 51 ++++++++++
clang/test/Sema/arm-mfp8.c | 11 +++
clang/test/Sema/arm-mfp8.cpp | 22 +++++
clang/utils/TableGen/NeonEmitter.cpp | 58 +++++++++++-
clang/utils/TableGen/TableGen.cpp | 5 +
clang/utils/TableGen/TableGenBackends.h | 1 +
31 files changed, 310 insertions(+), 5 deletions(-)
create mode 100644 clang/include/clang/Basic/arm_mfp8.td
create mode 100644 clang/test/AST/arm-mfp8.cpp
create mode 100644 clang/test/CodeGen/arm-mfp8.c
create mode 100644 clang/test/Sema/arm-mfp8.c
create mode 100644 clang/test/Sema/arm-mfp8.cpp
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3c62a017005e59..c3e4058826bc12 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7931,6 +7931,8 @@ def err_bad_lvalue_to_rvalue_cast : Error<
def err_bad_rvalue_to_rvalue_cast : Error<
"cannot cast from rvalue of type %1 to rvalue reference type %2; types are "
"not compatible">;
+def err_bad_mfloat8_cast : Error<
+ "cannot cast %0 to %1; types are not compatible">;
def err_bad_static_cast_pointer_nonpointer : Error<
"cannot cast from type %1 to pointer type %2">;
def err_bad_static_cast_member_pointer_nonmp : Error<
diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index d0f41b17c154f3..8160395c476337 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -198,7 +198,8 @@ namespace clang {
Float16,
Float32,
Float64,
- BFloat16
+ BFloat16,
+ ArmMFloat8
};
NeonTypeFlags(unsigned F) : Flags(F) {}
@@ -220,6 +221,7 @@ namespace clang {
switch (getEltType()) {
case Int8:
case Poly8:
+ case ArmMFloat8:
return 8;
case Int16:
case Float16:
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 1693be6e1a5e89..f508a2bd503895 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -235,6 +235,7 @@ class TargetInfo : public TransferrableTargetInfo,
bool HasFullBFloat16; // True if the backend supports native bfloat16
// arithmetic. Used to determine excess precision
// support in the frontend.
+ bool HasMFloat8;
bool HasIbm128;
bool HasLongDouble;
bool HasFPReturn;
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index fdfb35de9cf287..ba7b2b705b2fad 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -678,6 +678,8 @@ KEYWORD(__bool , KEYALTIVEC|KEYZVECTOR)
ALIAS("__fp16", half , KEYALL)
KEYWORD(__bf16 , KEYALL)
+KEYWORD(__mfp8 , KEYALL)
+
// OpenCL Extension.
KEYWORD(half , HALFSUPPORT)
diff --git a/clang/include/clang/Basic/arm_mfp8.td b/clang/include/clang/Basic/arm_mfp8.td
new file mode 100644
index 00000000000000..9c91cd10604945
--- /dev/null
+++ b/clang/include/clang/Basic/arm_mfp8.td
@@ -0,0 +1,14 @@
+//===--- arm_mfp8.td - ARM MFP8 compiler interface ------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the TableGen definitions from which the ARM MFP8 header
+// file will be generated.
+//
+//===----------------------------------------------------------------------===//
+
+include "arm_neon_incl.td"
diff --git a/clang/include/clang/Basic/arm_neon_incl.td b/clang/include/clang/Basic/arm_neon_incl.td
index b088e0794cdea3..b4f850f3c809af 100644
--- a/clang/include/clang/Basic/arm_neon_incl.td
+++ b/clang/include/clang/Basic/arm_neon_incl.td
@@ -218,6 +218,7 @@ def OP_UNAVAILABLE : Operation {
// h: half-float
// d: double
// b: bfloat16
+// m: mfloat8
//
// Typespec modifiers
// ------------------
@@ -242,6 +243,7 @@ def OP_UNAVAILABLE : Operation {
// B: change to BFloat16
// P: change to polynomial category.
// p: change polynomial to equivalent integer category. Otherwise nop.
+// M: change to MFloat8.
//
// >: double element width (vector size unchanged).
// <: half element width (vector size unchanged).
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index d735e2dcaa8c56..ed29751430fa69 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1112,6 +1112,8 @@ enum PredefinedTypeIDs {
/// \brief The '__ibm128' type
PREDEF_TYPE_IBM128_ID = 74,
+ PREDEF_TYPE_FPM8_ID = 75,
+
/// OpenCL image types with auto numeration
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
PREDEF_TYPE_##Id##_ID,
@@ -1149,7 +1151,7 @@ enum PredefinedTypeIDs {
///
/// Type IDs for non-predefined types will start at
/// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 506;
+const unsigned NUM_PREDEF_TYPE_IDS = 507;
// Ensure we do not overrun the predefined types we reserved
// in the enum PredefinedTypeIDs above.
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 007788d07a0d13..49ff36271445cf 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3850,6 +3850,7 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
case BuiltinType::Float: EltName = "float32_t"; break;
case BuiltinType::Half: EltName = "float16_t"; break;
case BuiltinType::BFloat16: EltName = "bfloat16_t"; break;
+ case BuiltinType::ArmMFloat8: EltName = "mfloat8_t"; break;
default:
llvm_unreachable("unexpected Neon vector element type");
}
@@ -3903,6 +3904,8 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
return "Float64";
case BuiltinType::BFloat16:
return "Bfloat16";
+ case BuiltinType::ArmMFloat8:
+ return "MFloat8_t";
default:
llvm_unreachable("Unexpected vector element base type");
}
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 92195333821097..b29f81b74b1bf9 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -60,6 +60,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
NoAsmVariants = false;
HasLegalHalfType = false;
HalfArgsAndReturns = false;
+ HasMFloat8 = false;
HasFloat128 = false;
HasIbm128 = false;
HasFloat16 = false;
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 08286a963bd27a..c88209f79e3f60 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -574,6 +574,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__ARM_FEATURE_BF16_SCALAR_ARITHMETIC", "1");
}
+ if (HasMFloat8) {
+ Builder.defineMacro("__ARM_FEATURE_FP8", "1");
+ }
if ((FPU & SveMode) && HasBFloat16) {
Builder.defineMacro("__ARM_FEATURE_SVE_BF16", "1");
}
@@ -755,6 +758,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
.Case("sha3", HasSHA3)
.Cases("aes", "pmull", HasAES)
.Cases("fp16", "fullfp16", HasFullFP16)
+ .Case("fp8", HasMFloat8)
.Case("dit", HasDIT)
.Case("dpb", HasCCPP)
.Case("dpb2", HasCCDP)
@@ -1002,6 +1006,9 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
FPU |= NeonMode;
HasSM4 = true;
}
+ if (Feature == "+fp8") {
+ HasMFloat8 = true;
+ }
if (Feature == "+strict-align")
HasUnalignedAccess = false;
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index afeb4d57dc7649..08f58343c23af8 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -47,6 +47,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool HasLS64 = false;
bool HasRandGen = false;
bool HasMatMul = false;
+ bool HasMFloat8 = false;
bool HasBFloat16 = false;
bool HasSVE2 = false;
bool HasSVE2p1 = false;
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index c87300bf2d60e0..3439da24bfaca9 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -665,6 +665,8 @@ bool ARMTargetInfo::hasBFloat16Type() const {
return HasBFloat16 || (FPU && !SoftFloat);
}
+bool ARMTargetInfo::hasArmMFloat8Type() const { return true; }
+
bool ARMTargetInfo::isValidCPUName(StringRef Name) const {
return Name == "generic" ||
llvm::ARM::parseCPUArch(Name) != llvm::ARM::ArchKind::INVALID;
diff --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h
index df9855a52e61c0..30c7d8271b152b 100644
--- a/clang/lib/Basic/Targets/ARM.h
+++ b/clang/lib/Basic/Targets/ARM.h
@@ -176,6 +176,8 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
bool hasBFloat16Type() const override;
+ bool hasArmMFloat8Type() const override;
+
bool isValidCPUName(StringRef Name) const override;
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c563f2618b42c8..6485a878cccc92 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6438,6 +6438,8 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
case NeonTypeFlags::Int8:
case NeonTypeFlags::Poly8:
return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
+ case NeonTypeFlags::ArmMFloat8:
+ return llvm::FixedVectorType::get(CGF->ArmMFloat8Ty, V1Ty ? 1 : (8 << IsQuad));
case NeonTypeFlags::Int16:
case NeonTypeFlags::Poly16:
return llvm::FixedVectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b05ab3606a698b..da658b6039182c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -352,6 +352,7 @@ CodeGenModule::CodeGenModule(ASTContext &C,
Int16Ty = llvm::Type::getInt16Ty(LLVMContext);
Int32Ty = llvm::Type::getInt32Ty(LLVMContext);
Int64Ty = llvm::Type::getInt64Ty(LLVMContext);
+ ArmMFloat8Ty = llvm::Type::getInt8Ty(LLVMContext);
HalfTy = llvm::Type::getHalfTy(LLVMContext);
BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
FloatTy = llvm::Type::getFloatTy(LLVMContext);
diff --git a/clang/lib/CodeGen/CodeGenTypeCache.h b/clang/lib/CodeGen/CodeGenTypeCache.h
index e273ebe3b060f2..9adf0544fa652b 100644
--- a/clang/lib/CodeGen/CodeGenTypeCache.h
+++ b/clang/lib/CodeGen/CodeGenTypeCache.h
@@ -38,6 +38,9 @@ struct CodeGenTypeCache {
/// half, bfloat, float, double
llvm::Type *HalfTy, *BFloatTy, *FloatTy, *DoubleTy;
+ /// fpm8 from FP8 is an alias for 8bits data
+ llvm::IntegerType *ArmMFloat8Ty;
+
/// int
llvm::IntegerType *IntTy;
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index ff392e7122a448..4f55dd8dd215f1 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -414,6 +414,8 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
clang_generate_header(-gen-arm-sme-header arm_sme.td arm_sme.h)
# Generate arm_bf16.h
clang_generate_header(-gen-arm-bf16 arm_bf16.td arm_bf16.h)
+ # Generate arm_mfp8.h
+ clang_generate_header(-gen-arm-mfp8 arm_mfp8.td arm_mfp8.h)
# Generate arm_mve.h
clang_generate_header(-gen-arm-mve-header arm_mve.td arm_mve.h)
# Generate arm_cde.h
@@ -437,6 +439,7 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
"${CMAKE_CURRENT_BINARY_DIR}/arm_sme.h"
"${CMAKE_CURRENT_BINARY_DIR}/arm_bf16.h"
"${CMAKE_CURRENT_BINARY_DIR}/arm_vector_types.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/arm_mfp8.h"
)
endif()
if(RISCV IN_LIST LLVM_TARGETS_TO_BUILD)
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 12cb46042c946b..e540360223b094 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -97,6 +97,7 @@ bool Token::isSimpleTypeSpecifier(const LangOptions &LangOpts) const {
case tok::kw___bf16:
case tok::kw__Float16:
case tok::kw___float128:
+ case tok::kw___mfp8:
case tok::kw___ibm128:
case tok::kw_wchar_t:
case tok::kw_bool:
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 0c6aa95f8f9c80..86d6ce685bd470 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5834,6 +5834,7 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
case tok::kw__ExtInt:
case tok::kw__BitInt:
case tok::kw___bf16:
+ case tok::kw___mfp8:
case tok::kw_half:
case tok::kw_float:
case tok::kw_double:
@@ -5919,6 +5920,7 @@ bool Parser::isTypeSpecifierQualifier() {
case tok::kw_int:
case tok::kw__ExtInt:
case tok::kw__BitInt:
+ case tok::kw___mfp8:
case tok::kw_half:
case tok::kw___bf16:
case tok::kw_float:
@@ -6143,6 +6145,7 @@ bool Parser::isDeclarationSpecifier(
case tok::kw_int:
case tok::kw__ExtInt:
case tok::kw__BitInt:
+ case tok::kw___mfp8:
case tok::kw_half:
case tok::kw___bf16:
case tok::kw_float:
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 2fb4be0035b667..ae0d49f6fc71dd 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1625,6 +1625,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
case tok::kw__BitInt:
case tok::kw_signed:
case tok::kw_unsigned:
+ case tok::kw___mfp8:
case tok::kw_half:
case tok::kw_float:
case tok::kw_double:
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 9f6b4f6118ede2..b3bfc8082345b7 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1788,6 +1788,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::kw_short:
case tok::kw_int:
case tok::kw_long:
+ case tok::kw___mfp8:
case tok::kw___int64:
case tok::kw___int128:
case tok::kw_signed:
@@ -1918,6 +1919,7 @@ bool Parser::isCXXDeclarationSpecifierAType() {
case tok::kw_long:
case tok::kw___int64:
case tok::kw___int128:
+ case tok::kw___mfp8:
case tok::kw_signed:
case tok::kw_unsigned:
case tok::kw_half:
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index c3a6e5ef8a9d44..b7dc32e430cd62 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -352,6 +352,8 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context,
return Context.DoubleTy;
case NeonTypeFlags::BFloat16:
return Context.BFloat16Ty;
+ case NeonTypeFlags::ArmMFloat8:
+ return Context.ArmMFloat8Ty;
}
llvm_unreachable("Invalid NeonTypeFlag!");
}
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 5c49bd57699a22..61c23776cea04f 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -3210,6 +3210,13 @@ void CastOperation::CheckCStyleCast() {
}
}
+ if ((DestType->isArmMFloat8Type() && !SrcType->isArmMFloat8Type()) ||
+ (!DestType->isArmMFloat8Type() && SrcType->isArmMFloat8Type())) {
+ Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_mfloat8_cast)
+ << SrcType << DestType << SrcExpr.get()->getSourceRange();
+ SrcExpr = ExprError();
+ return;
+ }
// ARC imposes extra restrictions on casts.
if (Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers()) {
checkObjCConversion(CheckedConversionKind::CStyleCast);
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index f2ff3a4004b5e6..1153f3d0aa4b2c 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8184,7 +8184,8 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) {
BTy->getKind() == BuiltinType::ULongLong ||
BTy->getKind() == BuiltinType::Float ||
BTy->getKind() == BuiltinType::Half ||
- BTy->getKind() == BuiltinType::BFloat16;
+ BTy->getKind() == BuiltinType::BFloat16 ||
+ BTy->getKind() == BuiltinType::ArmMFloat8;
}
static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp
new file mode 100644
index 00000000000000..d99b7cd062e305
--- /dev/null
+++ b/clang/test/AST/arm-mfp8.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -std=c++11 -triple aarch64-arm-none-eabi -target-feature -fp8 -ast-dump %s | \
+// RUN: FileCheck %s --strict-whitespace
+
+// REQUIRES: aarch64-registered-target || arm-registered-target
+
+/* Various contexts where type __mfp8 can appear. */
+
+/* Namespace */
+namespace {
+ __mfp8 f2n;
+ __mfp8 arr1n[10];
+}
+
+//CHECK: |-NamespaceDecl {{.*}}
+//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8'
+//CHECK-NEXT: | `-VarDecl {{.*}} arr1n '__mfp8[10]'
+
+ __mfp8 arr1[10];
+ //__mfp8 arr2n[] { 1, 3, 3 }; cannot initialize
+
+ const __mfp8 func1n(const __mfp8 mfp8) {
+ // this should fail
+ __mfp8 f1n;
+ f1n = mfp8;
+ return f1n;
+ }
+
+//CHECK: |-VarDecl {{.*}} '__mfp8[10]'
+
+//CHECK: | `-VarDecl {{.*}} f1n '__mfp8'
+//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8' lvalue '='
+//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
+//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8'
+//CHECK-NEXT: `-ReturnStmt {{.*}}
+//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
+
+
+/* Class */
+
+class C1 {
+ __mfp8 f1c;
+ static const __mfp8 f2c;
+ volatile __mfp8 f3c;
+public:
+ C1(__mfp8 arg) : f1c(arg), f3c(arg) { }
+ __mfp8 func1c(__mfp8 arg ) {
+ return arg;
+ }
+ static __mfp8 func2c(__mfp8 arg) {
+ return arg;
+ }
+};
+
+//CHECK: | |-CXXRecordDecl {{.*}} referenced class C1
+//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8'
+//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8' static
+//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __mfp8'
+//CHECK-NEXT: | |-AccessSpecDecl {{.*}}
+//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} C1 'void (__mfp8)' implicit-inline
+//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8'
+//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8'
+//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
+//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __mfp8'
+//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
+//CHECK-NEXT: | | `-CompoundStmt {{.*}}
+//CHECK-NEXT: | |-CXXMethodDecl {{.*}} func1c '__mfp8 (__mfp8)' implicit-inline
+//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8'
+//CHECK-NEXT: | | `-CompoundStmt {{.*}}
+//CHECK-NEXT: | | `-ReturnStmt {{.*}}
+//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}}8 'arg' '__mfp8'
+//CHECK-NEXT: | `-CXXMethodDecl {{.*}} func2c '__mfp8 (__mfp8)' static implicit-inline
+//CHECK-NEXT: | |-ParmVarDecl {{.*}} arg '__mfp8'
+//CHECK-NEXT: | `-CompoundStmt {{.*}}
+//CHECK-NEXT: | `-ReturnStmt {{.*}}
+//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
+
+template <class C> struct S1 {
+ C mem1;
+};
+
+template <> struct S1<__mfp8> {
+ __mfp8 mem2;
+};
+
+//CHECK: |-TemplateArgument type '__mfp8'
+//CHECK-NEXT: | `-BuiltinType {{.*}} '__mfp8'
+//CHECK-NEXT: |-CXXRecordDecl {{.*}} implicit struct S1
+//CHECK-NEXT: `-FieldDecl {{.*}} mem2 '__mfp8'
diff --git a/clang/test/CodeGen/arm-mfp8.c b/clang/test/CodeGen/arm-mfp8.c
new file mode 100644
index 00000000000000..d036bff90e39cc
--- /dev/null
+++ b/clang/test/CodeGen/arm-mfp8.c
@@ -0,0 +1,51 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
+// RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -target-feature +neon -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -target-feature +neon -o - -x c++ %s | FileCheck %s --check-prefixes=CHECK,CHECK-CXX
+
+// REQUIRES: aarch64-registered-target
+
+
+#include <arm_neon.h>
+
+// CHECK-C-LABEL: define dso_local <16 x i8> @test_ret_mfloat8x16_t(
+// CHECK-C-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-C-NEXT: [[ENTRY:.*:]]
+// CHECK-C-NEXT: [[V_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-C-NEXT: store <16 x i8> [[V]], ptr [[V_ADDR]], align 16
+// CHECK-C-NEXT: [[TMP0:%.*]] = load <16 x i8>, ptr [[V_ADDR]], align 16
+// CHECK-C-NEXT: ret <16 x i8> [[TMP0]]
+//
+// CHECK-CXX-LABEL: define dso_local noundef <16 x i8> @_Z21test_ret_mfloat8x16_t16__MFloat8_tx16_t(
+// CHECK-CXX-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-CXX-NEXT: [[ENTRY:.*:]]
+// CHECK-CXX-NEXT: [[V_ADDR:%.*]] = alloca <16 x i8>, align 16
+// CHECK-CXX-NEXT: store <16 x i8> [[V]], ptr [[V_ADDR]], align 16
+// CHECK-CXX-NEXT: [[TMP0:%.*]] = load <16 x i8>, ptr [[V_ADDR]], align 16
+// CHECK-CXX-NEXT: ret <16 x i8> [[TMP0]]
+//
+mfloat8x16_t test_ret_mfloat8x16_t(mfloat8x16_t v) {
+ return v;
+}
+
+// CHECK-C-LABEL: define dso_local <8 x i8> @test_ret_mfloat8x8_t(
+// CHECK-C-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-C-NEXT: [[ENTRY:.*:]]
+// CHECK-C-NEXT: [[V_ADDR:%.*]] = alloca <8 x i8>, align 8
+// CHECK-C-NEXT: store <8 x i8> [[V]], ptr [[V_ADDR]], align 8
+// CHECK-C-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr [[V_ADDR]], align 8
+// CHECK-C-NEXT: ret <8 x i8> [[TMP0]]
+//
+// CHECK-CXX-LABEL: define dso_local noundef <8 x i8> @_Z20test_ret_mfloat8x8_t15__MFloat8_tx8_t(
+// CHECK-CXX-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-CXX-NEXT: [[ENTRY:.*:]]
+// CHECK-CXX-NEXT: [[V_ADDR:%.*]] = alloca <8 x i8>, align 8
+// CHECK-CXX-NEXT: store <8 x i8> [[V]], ptr [[V_ADDR]], align 8
+// CHECK-CXX-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr [[V_ADDR]], align 8
+// CHECK-CXX-NEXT: ret <8 x i8> [[TMP0]]
+//
+mfloat8x8_t test_ret_mfloat8x8_t(mfloat8x8_t v) {
+ return v;
+}
+
+//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+// CHECK: {{.*}}
diff --git a/clang/test/Sema/arm-mfp8.c b/clang/test/Sema/arm-mfp8.c
new file mode 100644
index 00000000000000..c1e74a18b647d2
--- /dev/null
+++ b/clang/test/Sema/arm-mfp8.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s
+
+// REQUIRES: aarch64-registered-target
+
+__mfp8 test_cast_from_float(unsigned in) {
+ return (__mfp8)in; // expected-error {{cannot cast 'unsigned int' to '__mfp8'; types are not compatible}}
+}
+
+unsigned test_cast_to_int(__mfp8 in) {
+ return (unsigned)in; // expected-error {{cannot cast '__mfp8' to 'unsigned int'; types are not compatible}}
+}
diff --git a/clang/test/Sema/arm-mfp8.cpp b/clang/test/Sema/arm-mfp8.cpp
new file mode 100644
index 00000000000000..d36df9bba022f8
--- /dev/null
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=scalar,neon -triple aarch64-arm-none-eabi \
+// RUN: -target-feature -fp8 -target-feature +neon %s
+
+// REQUIRES: aarch64-registered-target
+
+#include <arm_neon.h>
+
+void test_vector(mfloat8x8_t a, mfloat8x8_t b, uint8x8_t c) {
+ a + b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
+ a - b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
+ a * b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
+ a / b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
+
+ a + c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ a - c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ a * c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ a / c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ c + b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
+ c - b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
+ c * b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
+ c / b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
+}
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index d4b42360e7fd32..1500ba09128e89 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -101,7 +101,8 @@ enum EltType {
Float16,
Float32,
Float64,
- BFloat16
+ BFloat16,
+ MFloat8
};
} // end namespace NeonTypeFlags
@@ -150,6 +151,7 @@ class Type {
UInt,
Poly,
BFloat16,
+ MFloat8,
};
TypeKind Kind;
bool Immediate, Constant, Pointer;
@@ -203,6 +205,7 @@ class Type {
bool isLong() const { return isInteger() && ElementBitwidth == 64; }
bool isVoid() const { return Kind == Void; }
bool isBFloat16() const { return Kind == BFloat16; }
+ bool isMFloat8() const { return Kind == MFloat8; }
unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
unsigned getSizeInBits() const { return Bitwidth; }
unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -629,6 +632,8 @@ class NeonEmitter {
// Emit arm_bf16.h.inc
void runBF16(raw_ostream &o);
+ void runMFloat8(raw_ostream &o);
+
void runVectorTypes(raw_ostream &o);
// Emit all the __builtin prototypes used in arm_neon.h, arm_fp16.h and
@@ -656,6 +661,8 @@ std::string Type::str() const {
S += "float";
else if (isBFloat16())
S += "bfloat";
+ else if (isMFloat8())
+ S += "mfloat";
else
S += "int";
@@ -698,6 +705,8 @@ std::string Type::builtin_str() const {
else if (isBFloat16()) {
assert(ElementBitwidth == 16 && "BFloat16 can only be 16 bits");
S += "y";
+ } else if (isMFloat8()) {
+ S += "c";
} else
switch (ElementBitwidth) {
case 16: S += "h"; break;
@@ -752,6 +761,11 @@ unsigned Type::getNeonEnum() const {
Base = (unsigned)NeonTypeFlags::Float16 + (Addend - 1);
}
+ if (isMFloat8()) {
+ assert(Addend == 1 && "MFloat8 is only 8 bit");
+ Base = (unsigned)NeonTypeFlags::MFloat8;
+ }
+
if (isBFloat16()) {
assert(Addend == 1 && "BFloat16 is only 16 bit");
Base = (unsigned)NeonTypeFlags::BFloat16;
@@ -778,6 +792,8 @@ Type Type::fromTypedefName(StringRef Name) {
T.Kind = Poly;
} else if (Name.consume_front("bfloat")) {
T.Kind = BFloat16;
+ } else if (Name.consume_front("mfp")) {
+ T.Kind = MFloat8;
} else {
assert(Name.starts_with("int"));
Name = Name.drop_front(3);
@@ -874,6 +890,10 @@ void Type::applyTypespec(bool &Quad) {
if (isPoly())
NumVectors = 0;
break;
+ case 'm':
+ Kind = MFloat8;
+ ElementBitwidth = 8;
+ break;
case 'b':
Kind = BFloat16;
ElementBitwidth = 16;
@@ -908,6 +928,10 @@ void Type::applyModifiers(StringRef Mods) {
Kind = BFloat16;
ElementBitwidth = 16;
break;
+ case 'M':
+ Kind = MFloat8;
+ ElementBitwidth = 8;
+ break;
case 'F':
Kind = Float;
break;
@@ -992,6 +1016,9 @@ std::string Intrinsic::getInstTypeCode(Type T, ClassKind CK) const {
if (T.isBFloat16())
return "bf16";
+ if (T.isMFloat8())
+ return "mfp8";
+
if (T.isPoly())
typeCode = 'p';
else if (T.isInteger())
@@ -1029,7 +1056,7 @@ std::string Intrinsic::getBuiltinTypeStr() {
Type RetT = getReturnType();
if ((LocalCK == ClassI || LocalCK == ClassW) && RetT.isScalar() &&
- !RetT.isFloating() && !RetT.isBFloat16())
+ !RetT.isFloating() && !RetT.isBFloat16() && !RetT.isMFloat8())
RetT.makeInteger(RetT.getElementSizeInBits(), false);
// Since the return value must be one type, return a vector type of the
@@ -2378,6 +2405,8 @@ void NeonEmitter::run(raw_ostream &OS) {
OS << "#include <arm_bf16.h>\n";
+ OS << "#include <arm_mfp8.h>\n";
+
OS << "#include <arm_vector_types.h>\n";
// For now, signedness of polynomial types depends on target
@@ -2557,6 +2586,27 @@ void NeonEmitter::runFP16(raw_ostream &OS) {
OS << "#endif /* __ARM_FP16_H */\n";
}
+void NeonEmitter::runMFloat8(raw_ostream &OS) {
+ OS << "/*===---- arm_mfp8 - ARM vector type "
+ "------===\n"
+ " *\n"
+ " *\n"
+ " * Part of the LLVM Project, under the Apache License v2.0 with LLVM "
+ "Exceptions.\n"
+ " * See https://llvm.org/LICENSE.txt for license information.\n"
+ " * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"
+ " *\n"
+ " *===-----------------------------------------------------------------"
+ "------===\n"
+ " */\n\n";
+ OS << "#ifndef __ARM_MFP8_H\n";
+ OS << "#define __ARM_MFP8_H\n\n";
+ OS << "typedef __mfp8 mfloat8_t;\n";
+
+ emitNeonTypeDefs("mQm", OS);
+ OS << "#endif // __ARM_MFP8_H\n";
+}
+
void NeonEmitter::runVectorTypes(raw_ostream &OS) {
OS << "/*===---- arm_vector_types - ARM vector type "
"------===\n"
@@ -2682,6 +2732,10 @@ void clang::EmitNeonSema(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runHeader(OS);
}
+void clang::EmitMFloat8(RecordKeeper &Records, raw_ostream &OS) {
+ NeonEmitter(Records).runMFloat8(OS);
+}
+
void clang::EmitVectorTypes(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runVectorTypes(OS);
}
diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp
index 39c178bc4f9baf..1020893fd08679 100644
--- a/clang/utils/TableGen/TableGen.cpp
+++ b/clang/utils/TableGen/TableGen.cpp
@@ -72,6 +72,7 @@ enum ActionType {
GenArmNeon,
GenArmFP16,
GenArmBF16,
+ GenArmMFloat8,
GenArmVectorType,
GenArmNeonSema,
GenArmNeonTest,
@@ -229,6 +230,7 @@ cl::opt<ActionType> Action(
clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
+ clEnumValN(GenArmMFloat8, "gen-arm-mfp8", "Generate arm_mfp8.h for clang"),
clEnumValN(GenArmVectorType, "gen-arm-vector-type",
"Generate arm_vector_types.h for clang"),
clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
@@ -468,6 +470,9 @@ bool ClangTableGenMain(raw_ostream &OS, const RecordKeeper &Records) {
case GenArmBF16:
EmitBF16(Records, OS);
break;
+ case GenArmMFloat8:
+ EmitMFloat8(Records, OS);
+ break;
case GenArmNeonSema:
EmitNeonSema(Records, OS);
break;
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index f7527ac535a870..901ac971d921bb 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -118,6 +118,7 @@ void EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
void EmitNeon(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitFP16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitBF16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitMFloat8(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitNeonSema(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitVectorTypes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitNeonTest(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
>From 023b63b5c26c42c94973dcb19d9e43364400a990 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Fri, 19 Jul 2024 09:10:57 +0000
Subject: [PATCH 3/8] [CLANG]Add Neon MFloat8x8 and MFloat8x16 into
AArch64SVEACLETypes.def
These types only work for aarch64 architecture now
---
clang/include/clang/AST/Type.h | 7 --
.../clang/Basic/AArch64SVEACLETypes.def | 17 +++-
clang/include/clang/Basic/Specifiers.h | 1 -
clang/include/clang/Basic/TargetBuiltins.h | 4 +-
clang/include/clang/Basic/TargetInfo.h | 3 -
clang/include/clang/Sema/DeclSpec.h | 2 -
.../include/clang/Serialization/ASTBitCodes.h | 2 +-
clang/lib/AST/ASTContext.cpp | 23 +++--
clang/lib/AST/ItaniumMangle.cpp | 6 +-
clang/lib/AST/Type.cpp | 24 ++---
clang/lib/Basic/Targets/AArch64.cpp | 2 -
clang/lib/Basic/Targets/AArch64.h | 2 -
clang/lib/Basic/Targets/ARM.cpp | 2 -
clang/lib/Basic/Targets/ARM.h | 2 -
clang/lib/CodeGen/CGBuiltin.cpp | 4 +-
clang/lib/CodeGen/CGDebugInfo.cpp | 7 --
clang/lib/CodeGen/CodeGenModule.cpp | 1 -
clang/lib/CodeGen/CodeGenTypeCache.h | 3 -
clang/lib/CodeGen/CodeGenTypes.cpp | 5 +-
clang/lib/Parse/ParseDecl.cpp | 4 -
clang/lib/Parse/ParseExprCXX.cpp | 4 -
clang/lib/Sema/DeclSpec.cpp | 3 -
clang/lib/Sema/SemaARM.cpp | 4 +-
clang/lib/Sema/SemaCast.cpp | 15 ---
clang/lib/Sema/SemaExpr.cpp | 6 --
clang/lib/Sema/SemaTemplateVariadic.cpp | 1 -
clang/lib/Sema/SemaType.cpp | 8 +-
clang/test/AST/arm-mfp8.cpp | 94 -------------------
clang/test/CodeGen/arm-mfp8.c | 12 +--
clang/test/Sema/arm-mfp8.c | 11 ---
clang/test/Sema/arm-mfp8.cpp | 28 +++---
clang/utils/TableGen/NeonEmitter.cpp | 11 ++-
clang/utils/TableGen/TableGenBackends.h | 2 +-
33 files changed, 75 insertions(+), 245 deletions(-)
delete mode 100644 clang/test/AST/arm-mfp8.cpp
delete mode 100644 clang/test/Sema/arm-mfp8.c
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 037e5207babd1c..8ff04cf89a6b91 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2647,8 +2647,6 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
bool isQueueT() const; // OpenCL queue_t
bool isReserveIDT() const; // OpenCL reserve_id_t
- bool isArmMFloat8Type() const; // AARCH64_OPAQUE_TYPE
-
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
bool is##Id##Type() const;
#include "clang/Basic/OpenCLExtensionTypes.def"
@@ -8406,11 +8404,6 @@ inline bool Type::isBitIntType() const {
return isa<BitIntType>(CanonicalType);
}
-// AARCH64_OPAQUE_TYPE
-inline bool Type::isArmMFloat8Type() const {
- return isSpecificBuiltinType(BuiltinType::ArmMFloat8);
-}
-
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
inline bool Type::is##Id##Type() const { \
return isSpecificBuiltinType(BuiltinType::Id); \
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 53644905b789b7..96eba0dd6ce24c 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -97,12 +97,17 @@
SVE_TYPE(Name, Id, SingletonId)
#endif
-#ifndef AARCH64_OPAQUE_TYPE
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF) \
+#ifndef AARCH64_VECTOR_TYPE
+#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
SVE_TYPE(Name, Id, SingletonId)
#endif
+#ifndef AARCH64_VECTOR_TYPE_MFLOAT
+#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \
+ AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId)
+#endif
+
+
//===- Vector point types -----------------------------------------------===//
SVE_VECTOR_TYPE_INT("__SVInt8_t", "__SVInt8_t", SveInt8, SveInt8Ty, 16, 8, 1, true)
@@ -187,7 +192,8 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
-AARCH64_OPAQUE_TYPE("__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 8, 1)
+AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1)
+AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1)
#undef SVE_VECTOR_TYPE
#undef SVE_VECTOR_TYPE_BFLOAT
@@ -196,5 +202,6 @@ AARCH64_OPAQUE_TYPE("__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 8
#undef SVE_PREDICATE_TYPE
#undef SVE_PREDICATE_TYPE_ALL
#undef SVE_OPAQUE_TYPE
-#undef AARCH64_OPAQUE_TYPE
+#undef AARCH64_VECTOR_TYPE_MFLOAT
+#undef AARCH64_VECTOR_TYPE
#undef SVE_TYPE
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index 8216d35bd68800..9c089908fdc130 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -68,7 +68,6 @@ namespace clang {
TST_Accum, // ISO/IEC JTC1 SC22 WG14 N1169 Extension
TST_Fract,
TST_BFloat16,
- TST_ArmMFloat8_t, // AARCH64_OPAQUE_TYPE
TST_float,
TST_double,
TST_float128,
diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index 8160395c476337..c0f9a98b433560 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -199,7 +199,7 @@ namespace clang {
Float32,
Float64,
BFloat16,
- ArmMFloat8
+ MFloat8
};
NeonTypeFlags(unsigned F) : Flags(F) {}
@@ -221,7 +221,7 @@ namespace clang {
switch (getEltType()) {
case Int8:
case Poly8:
- case ArmMFloat8:
+ case MFloat8:
return 8;
case Int16:
case Float16:
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index f508a2bd503895..1c15e30b20fdc7 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -702,9 +702,6 @@ class TargetInfo : public TransferrableTargetInfo,
return HasBFloat16 || HasFullBFloat16;
}
- /// Determine whether the _mfp8 type is supported on this target.
- virtual bool hasArmMFloat8Type() const { return HasMFloat8; }
-
/// Determine whether the BFloat type is fully supported on this target, i.e
/// arithemtic operations.
virtual bool hasFullBFloat16Type() const { return HasFullBFloat16; }
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index cbafa9aa06ced7..06243f2624876f 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -325,8 +325,6 @@ class DeclSpec {
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
static const TST TST_##Name = clang::TST_##Name;
#include "clang/Basic/HLSLIntangibleTypes.def"
- // AARCH64_OPAQUE_TYPE
- static const TST TST_ArmMFloat8_t = clang::TST_ArmMFloat8_t;
static const TST TST_error = clang::TST_error;
// type-qualifiers
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index ed29751430fa69..8cd85fe79cda19 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1151,7 +1151,7 @@ enum PredefinedTypeIDs {
///
/// Type IDs for non-predefined types will start at
/// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 507;
+const unsigned NUM_PREDEF_TYPE_IDS = 508;
// Ensure we do not overrun the predefined types we reserved
// in the enum PredefinedTypeIDs above.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 27e9c0bea916c8..e7496c163cd293 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1412,8 +1412,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
}
if (Target.hasAArch64SVETypes() ||
- (AuxTarget && AuxTarget->hasAArch64SVETypes()) ||
- Target.hasArmMFloat8Type()) {
+ (AuxTarget && AuxTarget->hasAArch64SVETypes())) {
#define SVE_TYPE(Name, Id, SingletonId) \
InitBuiltinType(SingletonId, BuiltinType::Id);
#include "clang/Basic/AArch64SVEACLETypes.def"
@@ -2240,12 +2239,12 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
Width = 0; \
Align = 16; \
break;
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF)
- case BuiltinType::ArmMFloat8:
- Width = Target->getCharWidth();
- Align = Target->getCharAlign();
- break;
+#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF) \
+ case BuiltinType::Id: \
+ Width = 0; \
+ Align = NumEls * ElBits; \
+ break;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
@@ -4364,6 +4363,11 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
case BuiltinType::Id: \
return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
+#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
+ ElBits, NF) \
+ case BuiltinType::Id: \
+ return {getIntTypeForBitwidth(ElBits, false), \
+ llvm::ElementCount::getFixed(NumEls), NF};
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
ElBits, NF)
@@ -4432,8 +4436,7 @@ QualType ASTContext::getScalableVectorType(QualType EltTy, unsigned NumElts,
if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
return SingletonId;
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF)
+#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
} else if (Target->hasRISCVVTypes()) {
uint64_t EltTySize = getTypeSize(EltTy);
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 49ff36271445cf..0e4756b9c27948 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3430,8 +3430,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
type_name = MangledName; \
Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
break;
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF) \
+#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id: \
type_name = MangledName; \
Out << (type_name == Name ? "u" : "") << type_name.size() << type_name; \
@@ -3850,7 +3849,6 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
case BuiltinType::Float: EltName = "float32_t"; break;
case BuiltinType::Half: EltName = "float16_t"; break;
case BuiltinType::BFloat16: EltName = "bfloat16_t"; break;
- case BuiltinType::ArmMFloat8: EltName = "mfloat8_t"; break;
default:
llvm_unreachable("unexpected Neon vector element type");
}
@@ -3904,8 +3902,6 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
return "Float64";
case BuiltinType::BFloat16:
return "Bfloat16";
- case BuiltinType::ArmMFloat8:
- return "MFloat8_t";
default:
llvm_unreachable("Unexpected vector element base type");
}
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 651f278681e1e0..749a5c05f4624a 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2485,17 +2485,18 @@ bool Type::isSVESizelessBuiltinType() const {
switch (BT->getKind()) {
// SVE Types
#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
- case BuiltinType::Id:
+ case BuiltinType::Id: \
+ return true;
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
- case BuiltinType::Id:
+ case BuiltinType::Id: \
+ return true;
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
- case BuiltinType::Id:
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF)
+ case BuiltinType::Id: \
+ return true;
+#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
+ case BuiltinType::Id: \
+ return false;
#include "clang/Basic/AArch64SVEACLETypes.def"
- return true;
- case BuiltinType::ArmMFloat8:
- return false;
default:
return false;
}
@@ -3455,10 +3456,9 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
case Id: \
return Name;
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF)
- case ArmMFloat8:
- return "__mfp8";
+#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
+ case Id: \
+ return Name;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case Id: \
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index c88209f79e3f60..10ebce32d8c05d 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1253,8 +1253,6 @@ bool AArch64TargetInfo::hasBFloat16Type() const {
return true;
}
-bool AArch64TargetInfo::hasArmMFloat8Type() const { return true; }
-
TargetInfo::CallingConvCheckResult
AArch64TargetInfo::checkCallingConvention(CallingConv CC) const {
switch (CC) {
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index 08f58343c23af8..6d9a7739a53799 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -172,8 +172,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool hasBFloat16Type() const override;
- bool hasArmMFloat8Type() const override;
-
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
bool isCLZForZeroUndef() const override;
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 3439da24bfaca9..c87300bf2d60e0 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -665,8 +665,6 @@ bool ARMTargetInfo::hasBFloat16Type() const {
return HasBFloat16 || (FPU && !SoftFloat);
}
-bool ARMTargetInfo::hasArmMFloat8Type() const { return true; }
-
bool ARMTargetInfo::isValidCPUName(StringRef Name) const {
return Name == "generic" ||
llvm::ARM::parseCPUArch(Name) != llvm::ARM::ArchKind::INVALID;
diff --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h
index 30c7d8271b152b..df9855a52e61c0 100644
--- a/clang/lib/Basic/Targets/ARM.h
+++ b/clang/lib/Basic/Targets/ARM.h
@@ -176,8 +176,6 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
bool hasBFloat16Type() const override;
- bool hasArmMFloat8Type() const override;
-
bool isValidCPUName(StringRef Name) const override;
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 6485a878cccc92..c3f21365a088b1 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6438,8 +6438,8 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
case NeonTypeFlags::Int8:
case NeonTypeFlags::Poly8:
return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
- case NeonTypeFlags::ArmMFloat8:
- return llvm::FixedVectorType::get(CGF->ArmMFloat8Ty, V1Ty ? 1 : (8 << IsQuad));
+ case NeonTypeFlags::MFloat8:
+ return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
case NeonTypeFlags::Int16:
case NeonTypeFlags::Poly16:
return llvm::FixedVectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 642e64b6584526..06015a9e541ea2 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -783,13 +783,6 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
{
- if (BT->getKind() == BuiltinType::ArmMFloat8) {
- Encoding = llvm::dwarf::DW_ATE_unsigned_char;
- BTName = BT->getName(CGM.getLangOpts());
- // Bit size and offset of the type.
- uint64_t Size = CGM.getContext().getTypeSize(BT);
- return DBuilder.createBasicType(BTName, Size, Encoding);
- }
ASTContext::BuiltinVectorTypeInfo Info =
// For svcount_t, only the lower 2 bytes are relevant.
BT->getKind() == BuiltinType::SveCount
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index da658b6039182c..b05ab3606a698b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -352,7 +352,6 @@ CodeGenModule::CodeGenModule(ASTContext &C,
Int16Ty = llvm::Type::getInt16Ty(LLVMContext);
Int32Ty = llvm::Type::getInt32Ty(LLVMContext);
Int64Ty = llvm::Type::getInt64Ty(LLVMContext);
- ArmMFloat8Ty = llvm::Type::getInt8Ty(LLVMContext);
HalfTy = llvm::Type::getHalfTy(LLVMContext);
BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
FloatTy = llvm::Type::getFloatTy(LLVMContext);
diff --git a/clang/lib/CodeGen/CodeGenTypeCache.h b/clang/lib/CodeGen/CodeGenTypeCache.h
index 9adf0544fa652b..e273ebe3b060f2 100644
--- a/clang/lib/CodeGen/CodeGenTypeCache.h
+++ b/clang/lib/CodeGen/CodeGenTypeCache.h
@@ -38,9 +38,6 @@ struct CodeGenTypeCache {
/// half, bfloat, float, double
llvm::Type *HalfTy, *BFloatTy, *FloatTy, *DoubleTy;
- /// fpm8 from FP8 is an alias for 8bits data
- llvm::IntegerType *ArmMFloat8Ty;
-
/// int
llvm::IntegerType *IntTy;
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index f074a9450bc989..51081251a8673d 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -507,6 +507,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
ElBits, NF)
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
+#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
+ case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
{
ASTContext::BuiltinVectorTypeInfo Info =
@@ -528,9 +530,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
}
case BuiltinType::SveCount:
return llvm::TargetExtType::get(getLLVMContext(), "aarch64.svcount");
- case BuiltinType::ArmMFloat8:
- ResultType = llvm::Type::getInt8Ty(getLLVMContext());
- break;
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
ResultType = \
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 86d6ce685bd470..32b6d9615520a0 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4547,10 +4547,6 @@ void Parser::ParseDeclarationSpecifiers(
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec,
DiagID, Policy);
break;
- case tok::kw___mfp8: // AARCH64_OPAQUE_TYPE
- isInvalid = DS.SetTypeSpecType(DeclSpec::TST_ArmMFloat8_t, Loc, PrevSpec,
- DiagID, Policy);
- break;
case tok::kw_half:
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec,
DiagID, Policy);
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index bb5bcec18e1a5a..e96cddf88a1346 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -2408,10 +2408,6 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
case tok::kw___int128:
DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec, DiagID, Policy);
break;
- case tok::kw___mfp8: // AARCH64_OPAQUE_TYPE
- DS.SetTypeSpecType(DeclSpec::TST_ArmMFloat8_t, Loc, PrevSpec, DiagID,
- Policy);
- break;
case tok::kw___bf16:
DS.SetTypeSpecType(DeclSpec::TST_BFloat16, Loc, PrevSpec, DiagID, Policy);
break;
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 2bd44949e5eda1..12d2d3f6060c63 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -379,7 +379,6 @@ bool Declarator::isDeclarationOfFunction() const {
#include "clang/Basic/OpenCLImageTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
#include "clang/Basic/HLSLIntangibleTypes.def"
- case TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
return false;
case TST_decltype_auto:
@@ -614,8 +613,6 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
case DeclSpec::TST_##Name: \
return #Name;
- case DeclSpec::TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
- return "__mfp8";
#include "clang/Basic/HLSLIntangibleTypes.def"
case DeclSpec::TST_error: return "(error)";
}
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index b7dc32e430cd62..e63d0ae5eae03d 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -323,6 +323,8 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context,
switch (Flags.getEltType()) {
case NeonTypeFlags::Int8:
return Flags.isUnsigned() ? Context.UnsignedCharTy : Context.SignedCharTy;
+ case NeonTypeFlags::MFloat8:
+ return Context.UnsignedCharTy;
case NeonTypeFlags::Int16:
return Flags.isUnsigned() ? Context.UnsignedShortTy : Context.ShortTy;
case NeonTypeFlags::Int32:
@@ -352,8 +354,6 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context,
return Context.DoubleTy;
case NeonTypeFlags::BFloat16:
return Context.BFloat16Ty;
- case NeonTypeFlags::ArmMFloat8:
- return Context.ArmMFloat8Ty;
}
llvm_unreachable("Invalid NeonTypeFlag!");
}
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 61c23776cea04f..6ac6201843476b 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2991,14 +2991,6 @@ void CastOperation::CheckCStyleCast() {
return;
}
- if ((DestType->isArmMFloat8Type() && !SrcType->isArmMFloat8Type()) ||
- (!DestType->isArmMFloat8Type() && SrcType->isArmMFloat8Type())) {
- Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_mfloat8_cast)
- << SrcType << DestType << SrcExpr.get()->getSourceRange();
- SrcExpr = ExprError();
- return;
- }
-
// Allow casting a sizeless built-in type to itself.
if (DestType->isSizelessBuiltinType() &&
Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
@@ -3210,13 +3202,6 @@ void CastOperation::CheckCStyleCast() {
}
}
- if ((DestType->isArmMFloat8Type() && !SrcType->isArmMFloat8Type()) ||
- (!DestType->isArmMFloat8Type() && SrcType->isArmMFloat8Type())) {
- Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_mfloat8_cast)
- << SrcType << DestType << SrcExpr.get()->getSourceRange();
- SrcExpr = ExprError();
- return;
- }
// ARC imposes extra restrictions on casts.
if (Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers()) {
checkObjCConversion(CheckedConversionKind::CStyleCast);
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index af32922a431b93..531e7f6933d6d3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8445,12 +8445,6 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
return QualType();
}
- if (LHSTy->isArmMFloat8Type() || RHSTy->isArmMFloat8Type()) {
- Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
- << LHSTy << RHSTy << LHS.get()->getSourceRange()
- << RHS.get()->getSourceRange();
- }
-
// Diagnose attempts to convert between __ibm128, __float128 and long double
// where such conversions currently can't be handled.
if (unsupportedTypeConversion(*this, LHSTy, RHSTy)) {
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 1db5b3d49e6a13..19bd4547665835 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -972,7 +972,6 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
#include "clang/Basic/OpenCLImageTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
#include "clang/Basic/HLSLIntangibleTypes.def"
- case TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
case TST_unknown_anytype:
case TST_error:
break;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1153f3d0aa4b2c..2db47f15c82fac 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1375,11 +1375,6 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
Result = Context.SingletonId; \
break;
#include "clang/Basic/HLSLIntangibleTypes.def"
- case DeclSpec::TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
- if (!S.Context.getTargetInfo().hasArmMFloat8Type())
- S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__mfp8";
- Result = Context.ArmMFloat8Ty;
- break;
case DeclSpec::TST_error:
Result = Context.IntTy;
declarator.setInvalidType(true);
@@ -8184,8 +8179,7 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) {
BTy->getKind() == BuiltinType::ULongLong ||
BTy->getKind() == BuiltinType::Float ||
BTy->getKind() == BuiltinType::Half ||
- BTy->getKind() == BuiltinType::BFloat16 ||
- BTy->getKind() == BuiltinType::ArmMFloat8;
+ BTy->getKind() == BuiltinType::BFloat16;
}
static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp
deleted file mode 100644
index d99b7cd062e305..00000000000000
--- a/clang/test/AST/arm-mfp8.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -triple aarch64-arm-none-eabi -target-feature -fp8 -ast-dump %s | \
-// RUN: FileCheck %s --strict-whitespace
-
-// REQUIRES: aarch64-registered-target || arm-registered-target
-
-/* Various contexts where type __mfp8 can appear. */
-
-/* Namespace */
-namespace {
- __mfp8 f2n;
- __mfp8 arr1n[10];
-}
-
-//CHECK: |-NamespaceDecl {{.*}}
-//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8'
-//CHECK-NEXT: | `-VarDecl {{.*}} arr1n '__mfp8[10]'
-
- __mfp8 arr1[10];
- //__mfp8 arr2n[] { 1, 3, 3 }; cannot initialize
-
- const __mfp8 func1n(const __mfp8 mfp8) {
- // this should fail
- __mfp8 f1n;
- f1n = mfp8;
- return f1n;
- }
-
-//CHECK: |-VarDecl {{.*}} '__mfp8[10]'
-
-//CHECK: | `-VarDecl {{.*}} f1n '__mfp8'
-//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8' lvalue '='
-//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
-//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8'
-//CHECK-NEXT: `-ReturnStmt {{.*}}
-//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
-
-
-/* Class */
-
-class C1 {
- __mfp8 f1c;
- static const __mfp8 f2c;
- volatile __mfp8 f3c;
-public:
- C1(__mfp8 arg) : f1c(arg), f3c(arg) { }
- __mfp8 func1c(__mfp8 arg ) {
- return arg;
- }
- static __mfp8 func2c(__mfp8 arg) {
- return arg;
- }
-};
-
-//CHECK: | |-CXXRecordDecl {{.*}} referenced class C1
-//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8'
-//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8' static
-//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __mfp8'
-//CHECK-NEXT: | |-AccessSpecDecl {{.*}}
-//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} C1 'void (__mfp8)' implicit-inline
-//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8'
-//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8'
-//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
-//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __mfp8'
-//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
-//CHECK-NEXT: | | `-CompoundStmt {{.*}}
-//CHECK-NEXT: | |-CXXMethodDecl {{.*}} func1c '__mfp8 (__mfp8)' implicit-inline
-//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8'
-//CHECK-NEXT: | | `-CompoundStmt {{.*}}
-//CHECK-NEXT: | | `-ReturnStmt {{.*}}
-//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}}8 'arg' '__mfp8'
-//CHECK-NEXT: | `-CXXMethodDecl {{.*}} func2c '__mfp8 (__mfp8)' static implicit-inline
-//CHECK-NEXT: | |-ParmVarDecl {{.*}} arg '__mfp8'
-//CHECK-NEXT: | `-CompoundStmt {{.*}}
-//CHECK-NEXT: | `-ReturnStmt {{.*}}
-//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
-
-template <class C> struct S1 {
- C mem1;
-};
-
-template <> struct S1<__mfp8> {
- __mfp8 mem2;
-};
-
-//CHECK: |-TemplateArgument type '__mfp8'
-//CHECK-NEXT: | `-BuiltinType {{.*}} '__mfp8'
-//CHECK-NEXT: |-CXXRecordDecl {{.*}} implicit struct S1
-//CHECK-NEXT: `-FieldDecl {{.*}} mem2 '__mfp8'
diff --git a/clang/test/CodeGen/arm-mfp8.c b/clang/test/CodeGen/arm-mfp8.c
index d036bff90e39cc..35ec24c8a7880d 100644
--- a/clang/test/CodeGen/arm-mfp8.c
+++ b/clang/test/CodeGen/arm-mfp8.c
@@ -8,15 +8,15 @@
#include <arm_neon.h>
// CHECK-C-LABEL: define dso_local <16 x i8> @test_ret_mfloat8x16_t(
-// CHECK-C-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-C-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-C-NEXT: [[ENTRY:.*:]]
// CHECK-C-NEXT: [[V_ADDR:%.*]] = alloca <16 x i8>, align 16
// CHECK-C-NEXT: store <16 x i8> [[V]], ptr [[V_ADDR]], align 16
// CHECK-C-NEXT: [[TMP0:%.*]] = load <16 x i8>, ptr [[V_ADDR]], align 16
// CHECK-C-NEXT: ret <16 x i8> [[TMP0]]
//
-// CHECK-CXX-LABEL: define dso_local noundef <16 x i8> @_Z21test_ret_mfloat8x16_t16__MFloat8_tx16_t(
-// CHECK-CXX-SAME: <16 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-CXX-LABEL: define dso_local <16 x i8> @_Z21test_ret_mfloat8x16_tu14__MFloat8x16_t(
+// CHECK-CXX-SAME: <16 x i8> [[V:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-CXX-NEXT: [[ENTRY:.*:]]
// CHECK-CXX-NEXT: [[V_ADDR:%.*]] = alloca <16 x i8>, align 16
// CHECK-CXX-NEXT: store <16 x i8> [[V]], ptr [[V_ADDR]], align 16
@@ -28,15 +28,15 @@ mfloat8x16_t test_ret_mfloat8x16_t(mfloat8x16_t v) {
}
// CHECK-C-LABEL: define dso_local <8 x i8> @test_ret_mfloat8x8_t(
-// CHECK-C-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-C-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] {
// CHECK-C-NEXT: [[ENTRY:.*:]]
// CHECK-C-NEXT: [[V_ADDR:%.*]] = alloca <8 x i8>, align 8
// CHECK-C-NEXT: store <8 x i8> [[V]], ptr [[V_ADDR]], align 8
// CHECK-C-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr [[V_ADDR]], align 8
// CHECK-C-NEXT: ret <8 x i8> [[TMP0]]
//
-// CHECK-CXX-LABEL: define dso_local noundef <8 x i8> @_Z20test_ret_mfloat8x8_t15__MFloat8_tx8_t(
-// CHECK-CXX-SAME: <8 x i8> noundef [[V:%.*]]) #[[ATTR0]] {
+// CHECK-CXX-LABEL: define dso_local <8 x i8> @_Z20test_ret_mfloat8x8_tu13__MFloat8x8_t(
+// CHECK-CXX-SAME: <8 x i8> [[V:%.*]]) #[[ATTR0]] {
// CHECK-CXX-NEXT: [[ENTRY:.*:]]
// CHECK-CXX-NEXT: [[V_ADDR:%.*]] = alloca <8 x i8>, align 8
// CHECK-CXX-NEXT: store <8 x i8> [[V]], ptr [[V_ADDR]], align 8
diff --git a/clang/test/Sema/arm-mfp8.c b/clang/test/Sema/arm-mfp8.c
deleted file mode 100644
index c1e74a18b647d2..00000000000000
--- a/clang/test/Sema/arm-mfp8.c
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s
-
-// REQUIRES: aarch64-registered-target
-
-__mfp8 test_cast_from_float(unsigned in) {
- return (__mfp8)in; // expected-error {{cannot cast 'unsigned int' to '__mfp8'; types are not compatible}}
-}
-
-unsigned test_cast_to_int(__mfp8 in) {
- return (unsigned)in; // expected-error {{cannot cast '__mfp8' to 'unsigned int'; types are not compatible}}
-}
diff --git a/clang/test/Sema/arm-mfp8.cpp b/clang/test/Sema/arm-mfp8.cpp
index d36df9bba022f8..9c2ddda88533af 100644
--- a/clang/test/Sema/arm-mfp8.cpp
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -1,22 +1,22 @@
-// RUN: %clang_cc1 -fsyntax-only -verify=scalar,neon -triple aarch64-arm-none-eabi \
+// RUN: %clang_cc1 -fsyntax-only -verify=neon -triple aarch64-arm-none-eabi \
// RUN: -target-feature -fp8 -target-feature +neon %s
// REQUIRES: aarch64-registered-target
#include <arm_neon.h>
-void test_vector(mfloat8x8_t a, mfloat8x8_t b, uint8x8_t c) {
- a + b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
- a - b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
- a * b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
- a / b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'mfloat8x8_t')}}
+void test_vector(mfloat8x8_t a, mfloat8x16_t b, uint8x8_t c) {
+ a + b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
+ a - b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
+ a * b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
+ a / b; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
- a + c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
- a - c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
- a * c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
- a / c; // neon-error {{invalid operands to binary expression ('mfloat8x8_t' (vector of 8 'mfloat8_t' values) and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
- c + b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
- c - b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
- c * b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
- c / b; // neon-error {{invalid operands to binary expression ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x8_t' (vector of 8 'mfloat8_t' values))}}
+ a + c; // neon-error {{cannot convert between vector and non-scalar values ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ a - c; // neon-error {{cannot convert between vector and non-scalar values ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ a * c; // neon-error {{cannot convert between vector and non-scalar values ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ a / c; // neon-error {{cannot convert between vector and non-scalar values ('mfloat8x8_t' (aka '__MFloat8x8_t') and 'uint8x8_t' (vector of 8 'uint8_t' values))}}
+ c + b; // neon-error {{cannot convert between vector and non-scalar values ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
+ c - b; // neon-error {{cannot convert between vector and non-scalar values ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
+ c * b; // neon-error {{cannot convert between vector and non-scalar values ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
+ c / b; // neon-error {{cannot convert between vector and non-scalar values ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
}
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 1500ba09128e89..fcde5b298864e9 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -102,7 +102,7 @@ enum EltType {
Float32,
Float64,
BFloat16,
- MFloat8
+ MFloat8,
};
} // end namespace NeonTypeFlags
@@ -2599,12 +2599,13 @@ void NeonEmitter::runMFloat8(raw_ostream &OS) {
" *===-----------------------------------------------------------------"
"------===\n"
" */\n\n";
+ OS << "#if defined(__aarch64__)\n";
OS << "#ifndef __ARM_MFP8_H\n";
OS << "#define __ARM_MFP8_H\n\n";
- OS << "typedef __mfp8 mfloat8_t;\n";
-
- emitNeonTypeDefs("mQm", OS);
+ OS << "typedef __MFloat8x8_t mfloat8x8_t;\n";
+ OS << "typedef __MFloat8x16_t mfloat8x16_t;\n";
OS << "#endif // __ARM_MFP8_H\n";
+ OS << "#endif //__aarch64__\n";
}
void NeonEmitter::runVectorTypes(raw_ostream &OS) {
@@ -2732,7 +2733,7 @@ void clang::EmitNeonSema(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runHeader(OS);
}
-void clang::EmitMFloat8(RecordKeeper &Records, raw_ostream &OS) {
+void clang::EmitMFloat8(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runMFloat8(OS);
}
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index 901ac971d921bb..24198b8e163598 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -118,7 +118,7 @@ void EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
void EmitNeon(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitFP16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitBF16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitMFloat8(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitMFloat8(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitNeonSema(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitVectorTypes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitNeonTest(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
>From 064f3a589be4c00badeb3a2ca45d0fdd247157cd Mon Sep 17 00:00:00 2001
From: CarolineConcatto <caroline.concatto at arm.com>
Date: Mon, 14 Oct 2024 16:55:55 +0100
Subject: [PATCH 4/8] Update DiagnosticSemaKinds.td
Remove diagnostic error for scalar mfp8
---
clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 --
1 file changed, 2 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c3e4058826bc12..3c62a017005e59 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7931,8 +7931,6 @@ def err_bad_lvalue_to_rvalue_cast : Error<
def err_bad_rvalue_to_rvalue_cast : Error<
"cannot cast from rvalue of type %1 to rvalue reference type %2; types are "
"not compatible">;
-def err_bad_mfloat8_cast : Error<
- "cannot cast %0 to %1; types are not compatible">;
def err_bad_static_cast_pointer_nonpointer : Error<
"cannot cast from type %1 to pointer type %2">;
def err_bad_static_cast_member_pointer_nonmp : Error<
>From 314364922be3b39b6529d5f98ee14fdd59b735a1 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Mon, 14 Oct 2024 16:03:43 +0000
Subject: [PATCH 5/8] Remove scalar implementation of mfp8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
With the new implementation all the changes for the mfp8 areĀ§ not needed.
---
clang/include/clang/Basic/TargetInfo.h | 1 -
clang/include/clang/Basic/TokenKinds.def | 2 --
clang/include/clang/Basic/arm_neon_incl.td | 1 -
clang/include/clang/Serialization/ASTBitCodes.h | 2 --
clang/lib/AST/ASTContext.cpp | 2 --
clang/lib/AST/Type.cpp | 11 +----------
clang/lib/Basic/TargetInfo.cpp | 1 -
clang/lib/Basic/Targets/AArch64.cpp | 7 -------
clang/lib/Basic/Targets/AArch64.h | 1 -
clang/lib/CodeGen/CodeGenTypes.cpp | 3 +--
clang/lib/Lex/Lexer.cpp | 1 -
clang/lib/Parse/ParseDecl.cpp | 3 ---
clang/lib/Parse/ParseExpr.cpp | 1 -
clang/lib/Parse/ParseTentative.cpp | 2 --
clang/lib/Sema/SemaType.cpp | 1 +
clang/utils/TableGen/NeonEmitter.cpp | 4 ----
16 files changed, 3 insertions(+), 40 deletions(-)
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 1c15e30b20fdc7..57783850606290 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -235,7 +235,6 @@ class TargetInfo : public TransferrableTargetInfo,
bool HasFullBFloat16; // True if the backend supports native bfloat16
// arithmetic. Used to determine excess precision
// support in the frontend.
- bool HasMFloat8;
bool HasIbm128;
bool HasLongDouble;
bool HasFPReturn;
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index ba7b2b705b2fad..fdfb35de9cf287 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -678,8 +678,6 @@ KEYWORD(__bool , KEYALTIVEC|KEYZVECTOR)
ALIAS("__fp16", half , KEYALL)
KEYWORD(__bf16 , KEYALL)
-KEYWORD(__mfp8 , KEYALL)
-
// OpenCL Extension.
KEYWORD(half , HALFSUPPORT)
diff --git a/clang/include/clang/Basic/arm_neon_incl.td b/clang/include/clang/Basic/arm_neon_incl.td
index b4f850f3c809af..fd800e5a6278e4 100644
--- a/clang/include/clang/Basic/arm_neon_incl.td
+++ b/clang/include/clang/Basic/arm_neon_incl.td
@@ -243,7 +243,6 @@ def OP_UNAVAILABLE : Operation {
// B: change to BFloat16
// P: change to polynomial category.
// p: change polynomial to equivalent integer category. Otherwise nop.
-// M: change to MFloat8.
//
// >: double element width (vector size unchanged).
// <: half element width (vector size unchanged).
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index 8cd85fe79cda19..f5b9908d1d1837 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1112,8 +1112,6 @@ enum PredefinedTypeIDs {
/// \brief The '__ibm128' type
PREDEF_TYPE_IBM128_ID = 74,
- PREDEF_TYPE_FPM8_ID = 75,
-
/// OpenCL image types with auto numeration
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
PREDEF_TYPE_##Id##_ID,
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e7496c163cd293..de440c9145ee24 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4369,8 +4369,6 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
return {getIntTypeForBitwidth(ElBits, false), \
llvm::ElementCount::getFixed(NumEls), NF};
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF)
#include "clang/Basic/AArch64SVEACLETypes.def"
#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 749a5c05f4624a..91485743fcb921 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3447,16 +3447,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
case Id: \
return #ExtType;
#include "clang/Basic/OpenCLExtensionTypes.def"
-#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
- case Id: \
- return Name;
-#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
- case Id: \
- return Name;
-#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
- case Id: \
- return Name;
-#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
+#define SVE_TYPE(Name, Id, SingletonId) \
case Id: \
return Name;
#include "clang/Basic/AArch64SVEACLETypes.def"
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index b29f81b74b1bf9..92195333821097 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -60,7 +60,6 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
NoAsmVariants = false;
HasLegalHalfType = false;
HalfArgsAndReturns = false;
- HasMFloat8 = false;
HasFloat128 = false;
HasIbm128 = false;
HasFloat16 = false;
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 10ebce32d8c05d..61889861c9c803 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -574,9 +574,6 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__ARM_FEATURE_BF16_SCALAR_ARITHMETIC", "1");
}
- if (HasMFloat8) {
- Builder.defineMacro("__ARM_FEATURE_FP8", "1");
- }
if ((FPU & SveMode) && HasBFloat16) {
Builder.defineMacro("__ARM_FEATURE_SVE_BF16", "1");
}
@@ -758,7 +755,6 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
.Case("sha3", HasSHA3)
.Cases("aes", "pmull", HasAES)
.Cases("fp16", "fullfp16", HasFullFP16)
- .Case("fp8", HasMFloat8)
.Case("dit", HasDIT)
.Case("dpb", HasCCPP)
.Case("dpb2", HasCCDP)
@@ -1006,9 +1002,6 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
FPU |= NeonMode;
HasSM4 = true;
}
- if (Feature == "+fp8") {
- HasMFloat8 = true;
- }
if (Feature == "+strict-align")
HasUnalignedAccess = false;
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index 6d9a7739a53799..1226ce4d4355c2 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -47,7 +47,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool HasLS64 = false;
bool HasRandGen = false;
bool HasMatMul = false;
- bool HasMFloat8 = false;
bool HasBFloat16 = false;
bool HasSVE2 = false;
bool HasSVE2p1 = false;
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 51081251a8673d..423621f99884f6 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -477,6 +477,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
Context.getFloatTypeSemantics(T),
/* UseNativeHalf = */ false);
break;
+
case BuiltinType::NullPtr:
// Model std::nullptr_t as i8*
ResultType = llvm::PointerType::getUnqual(getLLVMContext());
@@ -504,8 +505,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
case BuiltinType::Id:
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id:
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
- ElBits, NF)
#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id:
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index e540360223b094..12cb46042c946b 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -97,7 +97,6 @@ bool Token::isSimpleTypeSpecifier(const LangOptions &LangOpts) const {
case tok::kw___bf16:
case tok::kw__Float16:
case tok::kw___float128:
- case tok::kw___mfp8:
case tok::kw___ibm128:
case tok::kw_wchar_t:
case tok::kw_bool:
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 32b6d9615520a0..122a05be1c039a 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5830,7 +5830,6 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
case tok::kw__ExtInt:
case tok::kw__BitInt:
case tok::kw___bf16:
- case tok::kw___mfp8:
case tok::kw_half:
case tok::kw_float:
case tok::kw_double:
@@ -5916,7 +5915,6 @@ bool Parser::isTypeSpecifierQualifier() {
case tok::kw_int:
case tok::kw__ExtInt:
case tok::kw__BitInt:
- case tok::kw___mfp8:
case tok::kw_half:
case tok::kw___bf16:
case tok::kw_float:
@@ -6141,7 +6139,6 @@ bool Parser::isDeclarationSpecifier(
case tok::kw_int:
case tok::kw__ExtInt:
case tok::kw__BitInt:
- case tok::kw___mfp8:
case tok::kw_half:
case tok::kw___bf16:
case tok::kw_float:
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index ae0d49f6fc71dd..2fb4be0035b667 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1625,7 +1625,6 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
case tok::kw__BitInt:
case tok::kw_signed:
case tok::kw_unsigned:
- case tok::kw___mfp8:
case tok::kw_half:
case tok::kw_float:
case tok::kw_double:
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index b3bfc8082345b7..9f6b4f6118ede2 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1788,7 +1788,6 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::kw_short:
case tok::kw_int:
case tok::kw_long:
- case tok::kw___mfp8:
case tok::kw___int64:
case tok::kw___int128:
case tok::kw_signed:
@@ -1919,7 +1918,6 @@ bool Parser::isCXXDeclarationSpecifierAType() {
case tok::kw_long:
case tok::kw___int64:
case tok::kw___int128:
- case tok::kw___mfp8:
case tok::kw_signed:
case tok::kw_unsigned:
case tok::kw_half:
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 2db47f15c82fac..c44fc9c4194ca4 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1375,6 +1375,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
Result = Context.SingletonId; \
break;
#include "clang/Basic/HLSLIntangibleTypes.def"
+
case DeclSpec::TST_error:
Result = Context.IntTy;
declarator.setInvalidType(true);
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index fcde5b298864e9..aaa2c0c3a91b61 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -928,10 +928,6 @@ void Type::applyModifiers(StringRef Mods) {
Kind = BFloat16;
ElementBitwidth = 16;
break;
- case 'M':
- Kind = MFloat8;
- ElementBitwidth = 8;
- break;
case 'F':
Kind = Float;
break;
>From bdcfe3ca66487a3542cd0e106ce2ea06589fd687 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Tue, 15 Oct 2024 16:07:39 +0000
Subject: [PATCH 6/8] Remove arm_mfp8 header
---
clang/include/clang/Basic/arm_mfp8.td | 14 -------
clang/include/clang/Basic/arm_neon_incl.td | 1 -
clang/lib/Headers/CMakeLists.txt | 3 --
clang/utils/TableGen/NeonEmitter.cpp | 45 ++--------------------
clang/utils/TableGen/TableGen.cpp | 5 ---
clang/utils/TableGen/TableGenBackends.h | 1 -
6 files changed, 3 insertions(+), 66 deletions(-)
delete mode 100644 clang/include/clang/Basic/arm_mfp8.td
diff --git a/clang/include/clang/Basic/arm_mfp8.td b/clang/include/clang/Basic/arm_mfp8.td
deleted file mode 100644
index 9c91cd10604945..00000000000000
--- a/clang/include/clang/Basic/arm_mfp8.td
+++ /dev/null
@@ -1,14 +0,0 @@
-//===--- arm_mfp8.td - ARM MFP8 compiler interface ------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the TableGen definitions from which the ARM MFP8 header
-// file will be generated.
-//
-//===----------------------------------------------------------------------===//
-
-include "arm_neon_incl.td"
diff --git a/clang/include/clang/Basic/arm_neon_incl.td b/clang/include/clang/Basic/arm_neon_incl.td
index fd800e5a6278e4..b088e0794cdea3 100644
--- a/clang/include/clang/Basic/arm_neon_incl.td
+++ b/clang/include/clang/Basic/arm_neon_incl.td
@@ -218,7 +218,6 @@ def OP_UNAVAILABLE : Operation {
// h: half-float
// d: double
// b: bfloat16
-// m: mfloat8
//
// Typespec modifiers
// ------------------
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index 4f55dd8dd215f1..ff392e7122a448 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -414,8 +414,6 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
clang_generate_header(-gen-arm-sme-header arm_sme.td arm_sme.h)
# Generate arm_bf16.h
clang_generate_header(-gen-arm-bf16 arm_bf16.td arm_bf16.h)
- # Generate arm_mfp8.h
- clang_generate_header(-gen-arm-mfp8 arm_mfp8.td arm_mfp8.h)
# Generate arm_mve.h
clang_generate_header(-gen-arm-mve-header arm_mve.td arm_mve.h)
# Generate arm_cde.h
@@ -439,7 +437,6 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
"${CMAKE_CURRENT_BINARY_DIR}/arm_sme.h"
"${CMAKE_CURRENT_BINARY_DIR}/arm_bf16.h"
"${CMAKE_CURRENT_BINARY_DIR}/arm_vector_types.h"
- "${CMAKE_CURRENT_BINARY_DIR}/arm_mfp8.h"
)
endif()
if(RISCV IN_LIST LLVM_TARGETS_TO_BUILD)
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index aaa2c0c3a91b61..da3e5d27c9d97a 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -205,7 +205,6 @@ class Type {
bool isLong() const { return isInteger() && ElementBitwidth == 64; }
bool isVoid() const { return Kind == Void; }
bool isBFloat16() const { return Kind == BFloat16; }
- bool isMFloat8() const { return Kind == MFloat8; }
unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
unsigned getSizeInBits() const { return Bitwidth; }
unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -661,8 +660,6 @@ std::string Type::str() const {
S += "float";
else if (isBFloat16())
S += "bfloat";
- else if (isMFloat8())
- S += "mfloat";
else
S += "int";
@@ -705,8 +702,6 @@ std::string Type::builtin_str() const {
else if (isBFloat16()) {
assert(ElementBitwidth == 16 && "BFloat16 can only be 16 bits");
S += "y";
- } else if (isMFloat8()) {
- S += "c";
} else
switch (ElementBitwidth) {
case 16: S += "h"; break;
@@ -761,11 +756,6 @@ unsigned Type::getNeonEnum() const {
Base = (unsigned)NeonTypeFlags::Float16 + (Addend - 1);
}
- if (isMFloat8()) {
- assert(Addend == 1 && "MFloat8 is only 8 bit");
- Base = (unsigned)NeonTypeFlags::MFloat8;
- }
-
if (isBFloat16()) {
assert(Addend == 1 && "BFloat16 is only 16 bit");
Base = (unsigned)NeonTypeFlags::BFloat16;
@@ -1012,9 +1002,6 @@ std::string Intrinsic::getInstTypeCode(Type T, ClassKind CK) const {
if (T.isBFloat16())
return "bf16";
- if (T.isMFloat8())
- return "mfp8";
-
if (T.isPoly())
typeCode = 'p';
else if (T.isInteger())
@@ -1052,7 +1039,7 @@ std::string Intrinsic::getBuiltinTypeStr() {
Type RetT = getReturnType();
if ((LocalCK == ClassI || LocalCK == ClassW) && RetT.isScalar() &&
- !RetT.isFloating() && !RetT.isBFloat16() && !RetT.isMFloat8())
+ !RetT.isFloating() && !RetT.isBFloat16())
RetT.makeInteger(RetT.getElementSizeInBits(), false);
// Since the return value must be one type, return a vector type of the
@@ -2401,8 +2388,6 @@ void NeonEmitter::run(raw_ostream &OS) {
OS << "#include <arm_bf16.h>\n";
- OS << "#include <arm_mfp8.h>\n";
-
OS << "#include <arm_vector_types.h>\n";
// For now, signedness of polynomial types depends on target
@@ -2582,28 +2567,6 @@ void NeonEmitter::runFP16(raw_ostream &OS) {
OS << "#endif /* __ARM_FP16_H */\n";
}
-void NeonEmitter::runMFloat8(raw_ostream &OS) {
- OS << "/*===---- arm_mfp8 - ARM vector type "
- "------===\n"
- " *\n"
- " *\n"
- " * Part of the LLVM Project, under the Apache License v2.0 with LLVM "
- "Exceptions.\n"
- " * See https://llvm.org/LICENSE.txt for license information.\n"
- " * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n"
- " *\n"
- " *===-----------------------------------------------------------------"
- "------===\n"
- " */\n\n";
- OS << "#if defined(__aarch64__)\n";
- OS << "#ifndef __ARM_MFP8_H\n";
- OS << "#define __ARM_MFP8_H\n\n";
- OS << "typedef __MFloat8x8_t mfloat8x8_t;\n";
- OS << "typedef __MFloat8x16_t mfloat8x16_t;\n";
- OS << "#endif // __ARM_MFP8_H\n";
- OS << "#endif //__aarch64__\n";
-}
-
void NeonEmitter::runVectorTypes(raw_ostream &OS) {
OS << "/*===---- arm_vector_types - ARM vector type "
"------===\n"
@@ -2627,6 +2590,8 @@ void NeonEmitter::runVectorTypes(raw_ostream &OS) {
OS << "typedef __fp16 float16_t;\n";
OS << "#if defined(__aarch64__) || defined(__arm64ec__)\n";
+ OS << "typedef __MFloat8x8_t mfloat8x8_t;\n";
+ OS << "typedef __MFloat8x16_t mfloat8x16_t;\n";
OS << "typedef double float64_t;\n";
OS << "#endif\n\n";
@@ -2729,10 +2694,6 @@ void clang::EmitNeonSema(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runHeader(OS);
}
-void clang::EmitMFloat8(const RecordKeeper &Records, raw_ostream &OS) {
- NeonEmitter(Records).runMFloat8(OS);
-}
-
void clang::EmitVectorTypes(const RecordKeeper &Records, raw_ostream &OS) {
NeonEmitter(Records).runVectorTypes(OS);
}
diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp
index 1020893fd08679..39c178bc4f9baf 100644
--- a/clang/utils/TableGen/TableGen.cpp
+++ b/clang/utils/TableGen/TableGen.cpp
@@ -72,7 +72,6 @@ enum ActionType {
GenArmNeon,
GenArmFP16,
GenArmBF16,
- GenArmMFloat8,
GenArmVectorType,
GenArmNeonSema,
GenArmNeonTest,
@@ -230,7 +229,6 @@ cl::opt<ActionType> Action(
clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
- clEnumValN(GenArmMFloat8, "gen-arm-mfp8", "Generate arm_mfp8.h for clang"),
clEnumValN(GenArmVectorType, "gen-arm-vector-type",
"Generate arm_vector_types.h for clang"),
clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
@@ -470,9 +468,6 @@ bool ClangTableGenMain(raw_ostream &OS, const RecordKeeper &Records) {
case GenArmBF16:
EmitBF16(Records, OS);
break;
- case GenArmMFloat8:
- EmitMFloat8(Records, OS);
- break;
case GenArmNeonSema:
EmitNeonSema(Records, OS);
break;
diff --git a/clang/utils/TableGen/TableGenBackends.h b/clang/utils/TableGen/TableGenBackends.h
index 24198b8e163598..f7527ac535a870 100644
--- a/clang/utils/TableGen/TableGenBackends.h
+++ b/clang/utils/TableGen/TableGenBackends.h
@@ -118,7 +118,6 @@ void EmitClangSyntaxNodeClasses(const llvm::RecordKeeper &Records,
void EmitNeon(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitFP16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitBF16(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitMFloat8(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitNeonSema(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitVectorTypes(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitNeonTest(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
>From 79f757804004c6d3f21179ea3076e6b3b5ad423f Mon Sep 17 00:00:00 2001
From: CarolineConcatto <caroline.concatto at arm.com>
Date: Tue, 15 Oct 2024 17:20:24 +0100
Subject: [PATCH 7/8] Undo clang-format change
---
clang/lib/AST/Type.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 91485743fcb921..b9fe9e930cae8b 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3447,8 +3447,8 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
case Id: \
return #ExtType;
#include "clang/Basic/OpenCLExtensionTypes.def"
-#define SVE_TYPE(Name, Id, SingletonId) \
- case Id: \
+#define SVE_TYPE(Name, Id, SingletonId) \
+ case Id: \
return Name;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
>From 7b4c5504bb8e70c3e845c610222aa1e678040d1d Mon Sep 17 00:00:00 2001
From: CarolineConcatto <caroline.concatto at arm.com>
Date: Tue, 15 Oct 2024 17:22:26 +0100
Subject: [PATCH 8/8] Update NeonEmitter.cpp
---
clang/utils/TableGen/NeonEmitter.cpp | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index da3e5d27c9d97a..3aa1f52c82cda0 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -631,8 +631,6 @@ class NeonEmitter {
// Emit arm_bf16.h.inc
void runBF16(raw_ostream &o);
- void runMFloat8(raw_ostream &o);
-
void runVectorTypes(raw_ostream &o);
// Emit all the __builtin prototypes used in arm_neon.h, arm_fp16.h and
@@ -782,9 +780,7 @@ Type Type::fromTypedefName(StringRef Name) {
T.Kind = Poly;
} else if (Name.consume_front("bfloat")) {
T.Kind = BFloat16;
- } else if (Name.consume_front("mfp")) {
- T.Kind = MFloat8;
- } else {
+ else {
assert(Name.starts_with("int"));
Name = Name.drop_front(3);
}
@@ -880,10 +876,6 @@ void Type::applyTypespec(bool &Quad) {
if (isPoly())
NumVectors = 0;
break;
- case 'm':
- Kind = MFloat8;
- ElementBitwidth = 8;
- break;
case 'b':
Kind = BFloat16;
ElementBitwidth = 16;
More information about the cfe-commits
mailing list