[clang] [CLANG][AArch64]Add Neon vectors for mfloat8_t (PR #99865)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 23 02:07:01 PDT 2024
https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/99865
>From 2197d410d0ec07145482d0c6dd002e604aac4181 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 01/12] [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 ++
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 ++++-
19 files changed, 109 insertions(+), 6 deletions(-)
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 40e617bf8f3b8d..8b05e92fb0fe27 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"
@@ -8418,6 +8420,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 2b80e43b506384..0826edcb30ad63 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)
@@ -190,6 +196,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
@@ -197,4 +205,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 e7469e1e989128..bf3ffc2629ff76 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -699,6 +699,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/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 4bf8ddd762e9a5..669870f3525774 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: \
@@ -4362,6 +4369,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, \
@@ -4427,6 +4436,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 d3ed35deb2b1d2..3aa43485ba75a2 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 5232efae4e3630..a8d97b78b5ef63 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;
}
@@ -3438,9 +3447,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 3dbba2b4d25bd6..cf1768b30e3aba 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1248,6 +1248,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 16a02e102e045d..e83e254e736786 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -199,6 +199,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 54aa1d59d351af..baa2528382ae65 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 6807f44562f6ca..cc70b39a758ec6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8454,6 +8454,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);
>From a09a8e139a63e0560acd0ff16d284621b0ce1ea8 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 02/12] [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 | 2 +
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, 307 insertions(+), 6 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
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 883db838ca0147..08fac4d34e927c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7936,6 +7936,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 bf3ffc2629ff76..2e9342263efad4 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -236,6 +236,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 e397dff097652b..9398038a46763d 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,
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 3aa43485ba75a2..2a34a4af3a4ac0 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 145ca545854da7..8c3d6e08d9e0e9 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 cf1768b30e3aba..48f592ca763921 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -576,6 +576,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");
}
@@ -757,6 +760,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)
@@ -1004,6 +1008,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 e83e254e736786..294dc831f9f9d2 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -75,6 +75,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 1ad950798c2118..30bfc9ff375ea4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6432,6 +6432,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 24655b809b2eff..ad91164636536f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -353,6 +353,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
index b1509c542473a5..1f73d8c32525ee 100644
--- a/clang/test/Sema/arm-mfp8.cpp
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify=sve -triple aarch64-arm-none-eabi \
-// RUN: -target-feature -fp8 -target-feature +sve %s
+// RUN: %clang_cc1 -fsyntax-only -verify=sve,neon -triple aarch64-arm-none-eabi \
+// RUN: -target-feature -fp8 -target-feature +sve -target-feature +neon %s
// REQUIRES: aarch64-registered-target
@@ -11,3 +11,21 @@ void test_vector_sve(svmfloat8_t a, svuint8_t c) {
a / c; // sve-error {{cannot convert between vector type 'svuint8_t' (aka '__SVUint8_t') and vector type 'svmfloat8_t' (aka '__SVMfloat8_t') as implicit conversion would cause truncation}}
}
+
+#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 adff7c70219bbf..46be687386a7ed 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; }
@@ -630,6 +633,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
@@ -657,6 +662,8 @@ std::string Type::str() const {
S += "float";
else if (isBFloat16())
S += "bfloat";
+ else if (isMFloat8())
+ S += "mfloat";
else
S += "int";
@@ -699,6 +706,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;
@@ -753,6 +762,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;
@@ -779,6 +793,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);
@@ -875,6 +891,10 @@ void Type::applyTypespec(bool &Quad) {
if (isPoly())
NumVectors = 0;
break;
+ case 'm':
+ Kind = MFloat8;
+ ElementBitwidth = 8;
+ break;
case 'b':
Kind = BFloat16;
ElementBitwidth = 16;
@@ -909,6 +929,10 @@ void Type::applyModifiers(StringRef Mods) {
Kind = BFloat16;
ElementBitwidth = 16;
break;
+ case 'M':
+ Kind = MFloat8;
+ ElementBitwidth = 8;
+ break;
case 'F':
Kind = Float;
break;
@@ -993,6 +1017,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())
@@ -1030,7 +1057,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
@@ -2386,6 +2413,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
@@ -2565,6 +2594,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"
@@ -2690,6 +2740,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 a3d988a9f8990268bb7c0400c95a138aa5a4e6f3 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 03/12] [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 -
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 | 26 ++---
clang/utils/TableGen/NeonEmitter.cpp | 11 ++-
clang/utils/TableGen/TableGenBackends.h | 2 +-
32 files changed, 73 insertions(+), 243 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 8b05e92fb0fe27..40e617bf8f3b8d 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"
@@ -8420,11 +8418,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 0826edcb30ad63..25abf5f3f86b7d 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)
@@ -196,7 +201,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
@@ -205,5 +211,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 2e9342263efad4..4372b1791797ec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -700,9 +700,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/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 669870f3525774..4ad8b9c04a3fbf 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: \
@@ -4368,6 +4367,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)
@@ -4436,8 +4440,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 2a34a4af3a4ac0..b3e46508cf596d 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 a8d97b78b5ef63..0e9e4d6d01724a 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;
}
@@ -3456,10 +3457,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 48f592ca763921..e7e808409b87f4 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1255,8 +1255,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 294dc831f9f9d2..aba67f39b03097 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -200,8 +200,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 30bfc9ff375ea4..a52cbf0cd6a994 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6432,8 +6432,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 ad91164636536f..24655b809b2eff 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -353,7 +353,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 baa2528382ae65..a9d1c8878f71da 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 cc70b39a758ec6..6807f44562f6ca 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8454,12 +8454,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 1f73d8c32525ee..f270168faceb32 100644
--- a/clang/test/Sema/arm-mfp8.cpp
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -14,18 +14,18 @@ void test_vector_sve(svmfloat8_t a, svuint8_t c) {
#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 46be687386a7ed..566ce6ec9e7a90 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
@@ -2607,12 +2607,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) {
@@ -2740,7 +2741,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 a6054551368b6b845a17c1bd40169b8029ff402a 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 04/12] 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 08fac4d34e927c..883db838ca0147 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7936,8 +7936,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 4c370d5d3a0c4cee572860a15c3a1c2e60c93928 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 05/12] 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 4372b1791797ec..e7469e1e989128 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -236,7 +236,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 9398038a46763d..e397dff097652b 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 4ad8b9c04a3fbf..4623d740816cd6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4373,8 +4373,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 0e9e4d6d01724a..316cd77f7ba07e 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3448,16 +3448,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 8c3d6e08d9e0e9..145ca545854da7 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 e7e808409b87f4..3dbba2b4d25bd6 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -576,9 +576,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");
}
@@ -760,7 +757,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)
@@ -1008,9 +1004,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 aba67f39b03097..16a02e102e045d 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -75,7 +75,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 a9d1c8878f71da..3810214939f6ff 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 566ce6ec9e7a90..d70d784faa6f98 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -929,10 +929,6 @@ void Type::applyModifiers(StringRef Mods) {
Kind = BFloat16;
ElementBitwidth = 16;
break;
- case 'M':
- Kind = MFloat8;
- ElementBitwidth = 8;
- break;
case 'F':
Kind = Float;
break;
>From 2384c5da1015cf933512d35297e498cd881a888a 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 06/12] 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 d70d784faa6f98..eecc1391d5f066 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; }
@@ -662,8 +661,6 @@ std::string Type::str() const {
S += "float";
else if (isBFloat16())
S += "bfloat";
- else if (isMFloat8())
- S += "mfloat";
else
S += "int";
@@ -706,8 +703,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;
@@ -762,11 +757,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;
@@ -1013,9 +1003,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())
@@ -1053,7 +1040,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
@@ -2409,8 +2396,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
@@ -2590,28 +2575,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"
@@ -2635,6 +2598,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";
@@ -2737,10 +2702,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 f304872f5db05c01828b1ea6e4488130aba38533 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 07/12] 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 316cd77f7ba07e..1b5b5a7a3e5030 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3448,8 +3448,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 c9737d67afea20040fe8bb2103643e286840d99e 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 08/12] 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 eecc1391d5f066..caeb0e44d59162 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -632,8 +632,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
@@ -783,9 +781,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);
}
@@ -881,10 +877,6 @@ void Type::applyTypespec(bool &Quad) {
if (isPoly())
NumVectors = 0;
break;
- case 'm':
- Kind = MFloat8;
- ElementBitwidth = 8;
- break;
case 'b':
Kind = BFloat16;
ElementBitwidth = 16;
>From 0074b75e21c81e99af3b921f979657a2fa5e1c79 Mon Sep 17 00:00:00 2001
From: CarolineConcatto <caroline.concatto at arm.com>
Date: Tue, 15 Oct 2024 17:23:35 +0100
Subject: [PATCH 09/12] Update NeonEmitter.cpp
---
clang/utils/TableGen/NeonEmitter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index caeb0e44d59162..077656e72e35fb 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -781,7 +781,7 @@ Type Type::fromTypedefName(StringRef Name) {
T.Kind = Poly;
} else if (Name.consume_front("bfloat")) {
T.Kind = BFloat16;
- else {
+ }else {
assert(Name.starts_with("int"));
Name = Name.drop_front(3);
}
>From b65c5bf448fb22592038feb29a7420cfab4ff939 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Wed, 16 Oct 2024 14:18:38 +0000
Subject: [PATCH 10/12] Address review comments
---
clang/include/clang/Basic/TargetBuiltins.h | 6 ++----
clang/include/clang/Serialization/ASTBitCodes.h | 2 +-
clang/lib/AST/ASTContext.cpp | 2 +-
clang/lib/CodeGen/CGBuiltin.cpp | 2 --
clang/lib/CodeGen/CodeGenTypes.cpp | 2 +-
clang/lib/Sema/SemaARM.cpp | 2 --
clang/utils/TableGen/NeonEmitter.cpp | 8 +++-----
7 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index c0f9a98b433560..9192f1ef7e09a8 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -198,8 +198,7 @@ namespace clang {
Float16,
Float32,
Float64,
- BFloat16,
- MFloat8
+ BFloat16
};
NeonTypeFlags(unsigned F) : Flags(F) {}
@@ -221,8 +220,7 @@ namespace clang {
switch (getEltType()) {
case Int8:
case Poly8:
- case MFloat8:
- return 8;
+ return 16;
case Int16:
case Float16:
case Poly16:
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index e397dff097652b..13173dc96e71ae 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 = 509;
+const unsigned NUM_PREDEF_TYPE_IDS = 511;
// 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 4623d740816cd6..a4e8d95035b974 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2242,7 +2242,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, \
ElBits, NF) \
case BuiltinType::Id: \
- Width = 0; \
+ Width = NumEls * ElBits * NF; \
Align = NumEls * ElBits; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a52cbf0cd6a994..1ad950798c2118 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6432,8 +6432,6 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
case NeonTypeFlags::Int8:
case NeonTypeFlags::Poly8:
return llvm::FixedVectorType::get(CGF->Int8Ty, 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/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 3810214939f6ff..f87184fc77832c 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -505,9 +505,9 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
case BuiltinType::Id:
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id:
-#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id:
+#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
{
ASTContext::BuiltinVectorTypeInfo Info =
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index e63d0ae5eae03d..c3a6e5ef8a9d44 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -323,8 +323,6 @@ 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:
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 077656e72e35fb..59c023ca336063 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -101,8 +101,7 @@ enum EltType {
Float16,
Float32,
Float64,
- BFloat16,
- MFloat8,
+ BFloat16
};
} // end namespace NeonTypeFlags
@@ -150,8 +149,7 @@ class Type {
SInt,
UInt,
Poly,
- BFloat16,
- MFloat8,
+ BFloat16
};
TypeKind Kind;
bool Immediate, Constant, Pointer;
@@ -781,7 +779,7 @@ Type Type::fromTypedefName(StringRef Name) {
T.Kind = Poly;
} else if (Name.consume_front("bfloat")) {
T.Kind = BFloat16;
- }else {
+ } else {
assert(Name.starts_with("int"));
Name = Name.drop_front(3);
}
>From 9c186c8f573adae5ad5eddd4737e7653f9f75934 Mon Sep 17 00:00:00 2001
From: CarolineConcatto <caroline.concatto at arm.com>
Date: Tue, 22 Oct 2024 17:07:22 +0100
Subject: [PATCH 11/12] Update TargetBuiltins.h
---
clang/include/clang/Basic/TargetBuiltins.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index 9192f1ef7e09a8..d0f41b17c154f3 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -220,7 +220,7 @@ namespace clang {
switch (getEltType()) {
case Int8:
case Poly8:
- return 16;
+ return 8;
case Int16:
case Float16:
case Poly16:
>From ac5c0dc4ee72353fb58df4b3e89325151e25ca92 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Wed, 23 Oct 2024 09:05:41 +0000
Subject: [PATCH 12/12] Fix no-external-type-id.cppm test
---
clang/test/Modules/no-external-type-id.cppm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Modules/no-external-type-id.cppm b/clang/test/Modules/no-external-type-id.cppm
index 577b97f5930e75..b8b987403812f2 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=4088
+// CHECK: <DECL_FUNCTION {{.*}} op8=4104
// CHECK: <TYPE_FUNCTION_PROTO
//--- a.v1.cppm
More information about the cfe-commits
mailing list