[clang] [CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 15 08:41:20 PDT 2024


https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/97277

>From edf2f6c977d06627f7a752a0128ffcb04c082c38 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Mon, 24 Jun 2024 09:59:24 +0000
Subject: [PATCH 1/4] [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/Basic/DiagnosticSemaKinds.td        |  2 +
 clang/include/clang/Basic/Specifiers.h        |  1 +
 clang/include/clang/Basic/TargetInfo.h        |  4 +
 clang/include/clang/Basic/TokenKinds.def      |  1 +
 clang/include/clang/Sema/DeclSpec.h           |  2 +
 .../include/clang/Serialization/ASTBitCodes.h |  2 +-
 clang/lib/AST/ASTContext.cpp                  | 13 ++-
 clang/lib/AST/ItaniumMangle.cpp               |  6 ++
 clang/lib/AST/Type.cpp                        | 25 ++++-
 clang/lib/Basic/TargetInfo.cpp                |  1 +
 clang/lib/Basic/Targets/AArch64.cpp           |  6 ++
 clang/lib/Basic/Targets/AArch64.h             |  3 +
 clang/lib/CodeGen/CGDebugInfo.cpp             |  7 ++
 clang/lib/CodeGen/CodeGenTypes.cpp            |  6 +-
 clang/lib/Parse/ParseDecl.cpp                 |  7 ++
 clang/lib/Parse/ParseExpr.cpp                 |  1 +
 clang/lib/Parse/ParseExprCXX.cpp              |  4 +
 clang/lib/Parse/ParseTentative.cpp            |  2 +
 clang/lib/Sema/DeclSpec.cpp                   |  3 +
 clang/lib/Sema/SemaCast.cpp                   |  8 ++
 clang/lib/Sema/SemaExpr.cpp                   |  6 ++
 clang/lib/Sema/SemaTemplateVariadic.cpp       |  1 +
 clang/lib/Sema/SemaType.cpp                   |  6 +-
 clang/test/AST/arm-mfp8.cpp                   | 94 +++++++++++++++++++
 clang/test/CodeGen/arm-mfp8.c                 | 26 +++++
 clang/test/Modules/no-external-type-id.cppm   |  2 +-
 clang/test/Sema/arm-mfp8.c                    | 11 +++
 clang/test/Sema/arm-mfp8.cpp                  | 35 +++++++
 30 files changed, 293 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/AST/arm-mfp8.cpp
 create mode 100644 clang/test/CodeGen/arm-mfp8.c
 create mode 100644 clang/test/Sema/arm-mfp8.c
 create mode 100644 clang/test/Sema/arm-mfp8.cpp

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index dc87b84153e74a..195d471bb155fb 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2644,6 +2644,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"
@@ -8312,6 +8314,11 @@ inline bool Type::isBitIntType() const {
   return isa<BitIntType>(CanonicalType);
 }
 
+// AARCH64_OPAQUE_TYPE
+inline bool Type::isArmMFloat8Type() const {
+  return isSpecificBuiltinType(BuiltinType::ArmMFloat8);
+}
+
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
   inline bool Type::is##Id##Type() const { \
     return isSpecificBuiltinType(BuiltinType::Id); \
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 55ed9c36f6c5cd..53644905b789b7 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -97,6 +97,12 @@
   SVE_TYPE(Name, Id, SingletonId)
 #endif
 
+#ifndef AARCH64_OPAQUE_TYPE
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+                            ElBits, NF) \
+  SVE_TYPE(Name, Id, SingletonId)
+#endif
+
 //===- Vector point types -----------------------------------------------===//
 
 SVE_VECTOR_TYPE_INT("__SVInt8_t",  "__SVInt8_t",  SveInt8,  SveInt8Ty, 16,  8, 1, true)
@@ -181,6 +187,8 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
 
 SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
 
+AARCH64_OPAQUE_TYPE("__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 8, 1)
+
 #undef SVE_VECTOR_TYPE
 #undef SVE_VECTOR_TYPE_BFLOAT
 #undef SVE_VECTOR_TYPE_FLOAT
@@ -188,4 +196,5 @@ SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
 #undef SVE_PREDICATE_TYPE
 #undef SVE_PREDICATE_TYPE_ALL
 #undef SVE_OPAQUE_TYPE
+#undef AARCH64_OPAQUE_TYPE
 #undef SVE_TYPE
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d42558d2223aae..16f58efbdfc91c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7931,6 +7931,8 @@ def err_bad_lvalue_to_rvalue_cast : Error<
 def err_bad_rvalue_to_rvalue_cast : Error<
   "cannot cast from rvalue of type %1 to rvalue reference type %2; types are "
   "not compatible">;
+def err_bad_mfloat8_cast : Error<
+  "cannot cast %0 to %1; types are not compatible">;
 def err_bad_static_cast_pointer_nonpointer : Error<
   "cannot cast from type %1 to pointer type %2">;
 def err_bad_static_cast_member_pointer_nonmp : Error<
diff --git a/clang/include/clang/Basic/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 f31d88a354ea28..674f312d23e4dc 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -234,6 +234,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;
@@ -700,6 +701,9 @@ class TargetInfo : public TransferrableTargetInfo,
     return HasBFloat16 || HasFullBFloat16;
   }
 
+  /// Determine whether the _mfp8 type is supported on this target.
+  virtual bool hasArmMFloat8Type() const { return HasMFloat8; }
+
   /// Determine whether the BFloat type is fully supported on this target, i.e
   /// arithemtic operations.
   virtual bool hasFullBFloat16Type() const { return HasFullBFloat16; }
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 00e150dbd7a3a7..0c24844e691301 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -675,6 +675,7 @@ KEYWORD(__bool                      , KEYALTIVEC|KEYZVECTOR)
 // ARM NEON extensions.
 ALIAS("__fp16", half                , KEYALL)
 KEYWORD(__bf16                      , KEYALL)
+KEYWORD(__mfp8                      , KEYALL)
 
 // OpenCL Extension.
 KEYWORD(half                        , HALFSUPPORT)
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 06243f2624876f..cbafa9aa06ced7 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -325,6 +325,8 @@ class DeclSpec {
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)                            \
   static const TST TST_##Name = clang::TST_##Name;
 #include "clang/Basic/HLSLIntangibleTypes.def"
+  // AARCH64_OPAQUE_TYPE
+  static const TST TST_ArmMFloat8_t = clang::TST_ArmMFloat8_t;
   static const TST TST_error = clang::TST_error;
 
   // type-qualifiers
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index 4410df296d8efc..2b2da106cb64dc 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1139,7 +1139,7 @@ enum PredefinedTypeIDs {
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 505;
+const unsigned NUM_PREDEF_TYPE_IDS = 506;
 
 // Ensure we do not overrun the predefined types we reserved
 // in the enum PredefinedTypeIDs above.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7cc69ca4a8a814..53dc75f4ab412e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1391,7 +1391,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"
@@ -2218,6 +2219,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:                                                        \
@@ -4302,6 +4309,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,         \
@@ -4367,6 +4376,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 b6e1da0c3192da..2ab4c9eb15a9eb 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3406,6 +3406,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 a55e6c8bf02611..8f3bedd38c6854 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2484,9 +2484,18 @@ bool Type::isSVESizelessBuiltinType() const {
   if (const BuiltinType *BT = getAs<BuiltinType>()) {
     switch (BT->getKind()) {
       // SVE Types
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId)                    \
+  case BuiltinType::Id:
+#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)                    \
+  case BuiltinType::Id:
+#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId)                 \
+  case BuiltinType::Id:
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls,        \
+                            ElBits, NF)
 #include "clang/Basic/AArch64SVEACLETypes.def"
       return true;
+    case BuiltinType::ArmMFloat8:
+      return false;
     default:
       return false;
     }
@@ -3437,9 +3446,19 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
   case Id: \
     return #ExtType;
 #include "clang/Basic/OpenCLExtensionTypes.def"
-#define SVE_TYPE(Name, Id, SingletonId) \
-  case Id: \
+#define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId)                    \
+  case Id:                                                                     \
+    return Name;
+#define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)                    \
+  case Id:                                                                     \
+    return Name;
+#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId)                 \
+  case Id:                                                                     \
     return Name;
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls,        \
+                            ElBits, NF)
+  case ArmMFloat8:
+    return "__mfp8";
 #include "clang/Basic/AArch64SVEACLETypes.def"
 #define PPC_VECTOR_TYPE(Name, Id, Size) \
   case Id: \
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 29f5cd14e46e11..040b49bb115b89 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 63fc15f916c558..b5931e63a56983 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -741,6 +741,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)
@@ -988,6 +989,9 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       FPU |= NeonMode;
       HasSM4 = true;
     }
+    if (Feature == "+fp8") {
+      HasMFloat8 = true;
+    }
     if (Feature == "+strict-align")
       HasUnalignedAccess = false;
 
@@ -1229,6 +1233,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 526f7f30a38618..544ee206fdb618 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -47,6 +47,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
   bool HasLS64 = false;
   bool HasRandGen = false;
   bool HasMatMul = false;
+  bool HasMFloat8 = false;
   bool HasBFloat16 = false;
   bool HasSVE2 = false;
   bool HasSVE2p1 = false;
@@ -169,6 +170,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 6c433cf6a85d5e..20e37992f745c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -782,6 +782,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 d087e714882b33..4942e6f3fcb0e8 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -476,7 +476,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());
@@ -504,6 +503,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"
       {
@@ -526,6 +527,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 1f56884be392d6..df5104958199f7 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);
@@ -5828,6 +5832,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:
@@ -5913,6 +5918,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:
@@ -6137,6 +6143,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 e7514500dc53a4..815eeedec0d2dc 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/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/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/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 f01b22a72915c8..4e1ea65d681bb3 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2986,6 +2986,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 8f3e15cc9a9bb7..9962336087929d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8434,6 +8434,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 40522a07f6339c..bbf3a37aff4667 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -962,6 +962,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 11adfb0d7f3e98..cb80e03fdabc94 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1375,7 +1375,11 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     Result = Context.SingletonId;                                              \
     break;
 #include "clang/Basic/HLSLIntangibleTypes.def"
-
+  case DeclSpec::TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
+    if (!S.Context.getTargetInfo().hasArmMFloat8Type())
+      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__mfp8";
+    Result = Context.ArmMFloat8Ty;
+    break;
   case DeclSpec::TST_error:
     Result = Context.IntTy;
     declarator.setInvalidType(true);
diff --git a/clang/test/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..81fb9b257b4789
--- /dev/null
+++ b/clang/test/CodeGen/arm-mfp8.c
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
+// RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -o - %s | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+
+// CHECK-LABEL: define dso_local i8 @func1n(
+// CHECK-SAME: i8 [[MFP8:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[MFP8_ADDR:%.*]] = alloca i8, align 1
+// CHECK-NEXT:    [[F1N:%.*]] = alloca [10 x i8], align 1
+// CHECK-NEXT:    store i8 [[MFP8]], ptr [[MFP8_ADDR]], align 1
+// CHECK-NEXT:    [[TMP0:%.*]] = load i8, ptr [[MFP8_ADDR]], align 1
+// CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i8], ptr [[F1N]], i64 0, i64 2
+// CHECK-NEXT:    store i8 [[TMP0]], ptr [[ARRAYIDX]], align 1
+// CHECK-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x i8], ptr [[F1N]], i64 0, i64 2
+// CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[ARRAYIDX1]], align 1
+// CHECK-NEXT:    ret i8 [[TMP1]]
+//
+__mfp8 func1n(__mfp8 mfp8) {
+  __mfp8 f1n[10];
+  f1n[2] = mfp8;
+  return f1n[2];
+}
+
+
+
diff --git a/clang/test/Modules/no-external-type-id.cppm b/clang/test/Modules/no-external-type-id.cppm
index 068e52646dcc1c..a4ca389739fbb5 100644
--- a/clang/test/Modules/no-external-type-id.cppm
+++ b/clang/test/Modules/no-external-type-id.cppm
@@ -23,7 +23,7 @@ export module b;
 import a;
 export int b();
 
-// CHECK: <DECL_FUNCTION {{.*}} op8=4056
+// CHECK: <DECL_FUNCTION {{.*}} op8=4064
 // CHECK: <TYPE_FUNCTION_PROTO
 
 //--- a.v1.cppm
diff --git a/clang/test/Sema/arm-mfp8.c b/clang/test/Sema/arm-mfp8.c
new file mode 100644
index 00000000000000..c1e74a18b647d2
--- /dev/null
+++ b/clang/test/Sema/arm-mfp8.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s
+
+// REQUIRES: aarch64-registered-target
+
+__mfp8 test_cast_from_float(unsigned in) {
+  return (__mfp8)in; // expected-error {{cannot cast 'unsigned int' to '__mfp8'; types are not compatible}}
+}
+
+unsigned test_cast_to_int(__mfp8 in) {
+  return (unsigned)in; // expected-error {{cannot cast '__mfp8' to 'unsigned int'; types are not compatible}}
+}
diff --git a/clang/test/Sema/arm-mfp8.cpp b/clang/test/Sema/arm-mfp8.cpp
new file mode 100644
index 00000000000000..d9e03dc0e3f0de
--- /dev/null
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=scalar -triple aarch64-arm-none-eabi -target-feature -fp8  %s
+
+// REQUIRES: aarch64-registered-target
+__mfp8 test_static_cast_from_char(char in) {
+  return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__mfp8' is not allowed}}
+}
+
+char test_static_cast_to_char(__mfp8 in) {
+  return static_cast<char>(in); // scalar-error {{static_cast from '__mfp8' to 'char' is not allowed}}
+}
+void test(bool b) {
+  __mfp8 mfp8;
+
+  mfp8 + mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
+  mfp8 - mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
+  mfp8 * mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
+  mfp8 / mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
+  ++mfp8;       // scalar-error {{cannot increment value of type '__mfp8'}}
+  --mfp8;       // scalar-error {{cannot decrement value of type '__mfp8'}}
+
+  char u8;
+
+  mfp8 + u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
+  u8 + mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
+  mfp8 - u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
+  u8 - mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
+  mfp8 * u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
+  u8 * mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
+  mfp8 / u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
+  u8 / mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
+  mfp8 = u8;   // scalar-error {{assigning to '__mfp8' from incompatible type 'char'}}
+  u8 = mfp8;   // scalar-error {{assigning to 'char' from incompatible type '__mfp8'}}
+  mfp8 + (b ? u8 : mfp8);  // scalar-error {{incompatible operand types ('char' and '__mfp8')}}
+}
+

>From f07581b7d28f1babbc32c5909318f0c4e76b8e51 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Mon, 7 Oct 2024 09:01:03 +0000
Subject: [PATCH 2/4] Lower MFloat8 to a vector in LLVM-IR

---
 clang/include/clang/AST/Type.h                |  3 +-
 .../clang/Basic/AArch64SVEACLETypes.def       | 18 +++--
 clang/include/clang/Basic/Specifiers.h        |  2 +-
 clang/include/clang/Sema/DeclSpec.h           |  1 -
 clang/lib/AST/ASTContext.cpp                  |  9 +--
 clang/lib/AST/ItaniumMangle.cpp               |  3 +-
 clang/lib/AST/Type.cpp                        | 15 +----
 clang/lib/CodeGen/CodeGenTypes.cpp            |  7 +-
 clang/lib/Parse/ParseDecl.cpp                 |  2 +-
 clang/lib/Parse/ParseExprCXX.cpp              |  4 --
 clang/lib/Sema/DeclSpec.cpp                   |  6 +-
 clang/lib/Sema/SemaCast.cpp                   |  3 +-
 clang/lib/Sema/SemaTemplateVariadic.cpp       |  2 +-
 clang/lib/Sema/SemaType.cpp                   |  2 +-
 clang/test/AST/arm-mfp8.cpp                   | 66 +++++++++----------
 clang/test/CodeGen/aarch64-debug-types.c      |  9 +++
 clang/test/CodeGen/arm-mfp8.c                 | 22 +++----
 clang/test/Sema/arm-mfp8.c                    |  4 +-
 clang/test/Sema/arm-mfp8.cpp                  | 38 +++++------
 19 files changed, 106 insertions(+), 110 deletions(-)
 create mode 100644 clang/test/CodeGen/aarch64-debug-types.c

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 195d471bb155fb..6d255bc20c6a5e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2644,7 +2644,7 @@ 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
+  bool isArmMFloat8Type() const;
 
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
   bool is##Id##Type() const;
@@ -8314,7 +8314,6 @@ inline bool Type::isBitIntType() const {
   return isa<BitIntType>(CanonicalType);
 }
 
-// AARCH64_OPAQUE_TYPE
 inline bool Type::isArmMFloat8Type() const {
   return isSpecificBuiltinType(BuiltinType::ArmMFloat8);
 }
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 53644905b789b7..4f1cdc8b0776d7 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -32,6 +32,8 @@
 //
 // where:
 //
+//  - Acronym is for the scalar types that have a short name
+//
 //  - Name is the name of the builtin type.
 //
 //  - MangledName is the mangled name of the builtin type.
@@ -97,12 +99,17 @@
   SVE_TYPE(Name, Id, SingletonId)
 #endif
 
-#ifndef AARCH64_OPAQUE_TYPE
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
-                            ElBits, NF) \
+#ifndef AARCH64_SCALAR_TYPE
+#define AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId) \
   SVE_TYPE(Name, Id, SingletonId)
 #endif
 
+
+#ifndef AARCH64_SCALAR_TYPE_MFLOAT
+#define AARCH64_SCALAR_TYPE_MFLOAT(Acronym, Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \
+  AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
+#endif
+
 //===- Vector point types -----------------------------------------------===//
 
 SVE_VECTOR_TYPE_INT("__SVInt8_t",  "__SVInt8_t",  SveInt8,  SveInt8Ty, 16,  8, 1, true)
@@ -187,7 +194,7 @@ 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_SCALAR_TYPE_MFLOAT("__mpf8", "__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 8, 1)
 
 #undef SVE_VECTOR_TYPE
 #undef SVE_VECTOR_TYPE_BFLOAT
@@ -196,5 +203,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_SCALAR_TYPE_MFLOAT
+#undef AARCH64_SCALAR_TYPE
 #undef SVE_TYPE
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index 8216d35bd68800..860a5d809e9b8d 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -68,7 +68,7 @@ namespace clang {
     TST_Accum,   // ISO/IEC JTC1 SC22 WG14 N1169 Extension
     TST_Fract,
     TST_BFloat16,
-    TST_ArmMFloat8_t, // AARCH64_OPAQUE_TYPE
+    TST_ArmMFloat8_t,
     TST_float,
     TST_double,
     TST_float128,
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index cbafa9aa06ced7..49721442e4ef86 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -325,7 +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;
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 53dc75f4ab412e..a2d16d5d1ebf05 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2219,8 +2219,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
     Width = 0;                                                                 \
     Align = 16;                                                                \
     break;
-#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls,        \
-                            ElBits, NF)
+#define AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
     case BuiltinType::ArmMFloat8:
       Width = Target->getCharWidth();
       Align = Target->getCharAlign();
@@ -4309,8 +4308,7 @@ 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)
+#define AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
 #include "clang/Basic/AArch64SVEACLETypes.def"
 
 #define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF,         \
@@ -4376,8 +4374,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_SCALAR_TYPE(Acronym, 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 2ab4c9eb15a9eb..0c319d76bbc42f 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3406,8 +3406,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_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)       \
   case BuiltinType::Id:                                                        \
     type_name = MangledName;                                                   \
     Out << (type_name == Name ? "u" : "") << type_name.size() << type_name;    \
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 8f3bedd38c6854..fce65fbcbe799b 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2490,8 +2490,7 @@ bool Type::isSVESizelessBuiltinType() const {
   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 AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
 #include "clang/Basic/AArch64SVEACLETypes.def"
       return true;
     case BuiltinType::ArmMFloat8:
@@ -3446,19 +3445,9 @@ 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)                 \
+#define SVE_TYPE(Name, 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/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 4942e6f3fcb0e8..f1456e9c3dd4e6 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -503,8 +503,7 @@ 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 AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
 #define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
 #include "clang/Basic/AArch64SVEACLETypes.def"
       {
@@ -528,7 +527,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());
+      ResultType =
+          llvm::VectorType::get(llvm::Type::getInt8Ty(getLLVMContext()),
+                                llvm::ElementCount::getFixed(1));
       break;
 #define PPC_VECTOR_TYPE(Name, Id, Size) \
     case BuiltinType::Id: \
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index df5104958199f7..7902969ba14d0a 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4547,7 +4547,7 @@ void Parser::ParseDeclarationSpecifiers(
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec,
                                      DiagID, Policy);
       break;
-    case tok::kw___mfp8: // AARCH64_OPAQUE_TYPE
+    case tok::kw___mfp8:
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_ArmMFloat8_t, Loc, PrevSpec,
                                      DiagID, Policy);
       break;
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..920c3d92701ff5 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -379,7 +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
+    case TST_ArmMFloat8_t:
       return false;
 
     case TST_decltype_auto:
@@ -614,9 +614,9 @@ 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_ArmMFloat8_t:
+    return "__mfp8";
   case DeclSpec::TST_error:       return "(error)";
   }
   llvm_unreachable("Unknown typespec!");
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 4e1ea65d681bb3..a0dc1d55dbc51a 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2986,8 +2986,7 @@ void CastOperation::CheckCStyleCast() {
     return;
   }
 
-  if ((DestType->isArmMFloat8Type() && !SrcType->isArmMFloat8Type()) ||
-      (!DestType->isArmMFloat8Type() && SrcType->isArmMFloat8Type())) {
+  if (DestType->isArmMFloat8Type() != SrcType->isArmMFloat8Type()) {
     Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_mfloat8_cast)
         << SrcType << DestType << SrcExpr.get()->getSourceRange();
     SrcExpr = ExprError();
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index bbf3a37aff4667..909f393135c37a 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -962,7 +962,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_ArmMFloat8_t:
   case TST_unknown_anytype:
   case TST_error:
     break;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index cb80e03fdabc94..f9a2f65bce7fcd 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1375,7 +1375,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     Result = Context.SingletonId;                                              \
     break;
 #include "clang/Basic/HLSLIntangibleTypes.def"
-  case DeclSpec::TST_ArmMFloat8_t: // AARCH64_OPAQUE_TYPE
+  case DeclSpec::TST_ArmMFloat8_t:
     if (!S.Context.getTargetInfo().hasArmMFloat8Type())
       S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__mfp8";
     Result = Context.ArmMFloat8Ty;
diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp
index d99b7cd062e305..7730ad418461d0 100644
--- a/clang/test/AST/arm-mfp8.cpp
+++ b/clang/test/AST/arm-mfp8.cpp
@@ -12,8 +12,8 @@ namespace {
 }
 
 //CHECK:       |-NamespaceDecl {{.*}}
-//CHECK-NEXT:  | |-VarDecl {{.*}} f2n '__mfp8'
-//CHECK-NEXT:  | `-VarDecl {{.*}} arr1n '__mfp8[10]'
+//CHECK-NEXT:  | |-VarDecl {{.*}} f2n '__MFloat8_t'
+//CHECK-NEXT:  | `-VarDecl {{.*}} arr1n '__MFloat8_t[10]'
 
   __mfp8 arr1[10];
   //__mfp8 arr2n[] { 1, 3, 3 }; cannot initialize
@@ -25,16 +25,16 @@ namespace {
     return f1n;
   }
 
-//CHECK:        |-VarDecl {{.*}} '__mfp8[10]'
+//CHECK:        |-VarDecl {{.*}} '__MFloat8_t[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:            | `-VarDecl {{.*}} f1n '__MFloat8_t'
+//CHECK-NEXT:       |-BinaryOperator {{.*}} '__MFloat8_t' lvalue '='
+//CHECK-NEXT:       | |-DeclRefExpr {{.*}} '__MFloat8_t' lvalue Var {{.*}} 'f1n' '__MFloat8_t'
+//CHECK-NEXT:       | `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:       |   `-DeclRefExpr {{.*}} 'const __MFloat8_t' lvalue ParmVar {{.*}} 'mfp8' 'const __MFloat8_t'
 //CHECK-NEXT:        `-ReturnStmt {{.*}}
-//CHECK-NEXT:         `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT:           `-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
+//CHECK-NEXT:         `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:           `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue Var {{.*}} 'f1n' '__MFloat8_t'
 
 
 /* Class */
@@ -42,7 +42,7 @@ namespace {
 class C1 {
   __mfp8 f1c;
   static const __mfp8 f2c;
-  volatile __mfp8 f3c;
+  volatile __MFloat8_t f3c;
 public:
   C1(__mfp8 arg) : f1c(arg), f3c(arg) { }
   __mfp8 func1c(__mfp8 arg ) {
@@ -54,31 +54,31 @@ class C1 {
 };
 
 //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:  | |-FieldDecl {{.*}} f1c '__MFloat8_t'
+//CHECK-NEXT:  | |-VarDecl {{.*}} f2c 'const __MFloat8_t' static
+//CHECK-NEXT:  | |-FieldDecl {{.*}} f3c 'volatile __MFloat8_t'
 //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:  | |-CXXConstructorDecl {{.*}} C1 'void (__MFloat8_t)' implicit-inline
+//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__MFloat8_t'
+//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f1c' '__MFloat8_t'
+//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__MFloat8_t'
+//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __MFloat8_t'
+//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__MFloat8_t'
 //CHECK-NEXT:  | | `-CompoundStmt {{.*}}
-//CHECK-NEXT:  | |-CXXMethodDecl {{.*}} func1c '__mfp8 (__mfp8)' implicit-inline
-//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__mfp8'
+//CHECK-NEXT:  | |-CXXMethodDecl {{.*}} func1c '__MFloat8_t (__MFloat8_t)' implicit-inline
+//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__MFloat8_t'
 //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:  | |     `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  | |       `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}}8 'arg' '__MFloat8_t'
+//CHECK-NEXT:  | `-CXXMethodDecl {{.*}} func2c '__MFloat8_t (__MFloat8_t)' static implicit-inline
+//CHECK-NEXT:  |   |-ParmVarDecl {{.*}} arg '__MFloat8_t'
 //CHECK-NEXT:  |   `-CompoundStmt {{.*}}
 //CHECK-NEXT:  |     `-ReturnStmt {{.*}}
-//CHECK-NEXT:  |       `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
-//CHECK-NEXT:  |         `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
+//CHECK-NEXT:  |       `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  |         `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__MFloat8_t'
 
 template <class C> struct S1 {
   C mem1;
@@ -88,7 +88,7 @@ template <> struct S1<__mfp8> {
   __mfp8 mem2;
 };
 
-//CHECK:       |-TemplateArgument type '__mfp8'
-//CHECK-NEXT:  | `-BuiltinType {{.*}} '__mfp8'
+//CHECK:       |-TemplateArgument type '__MFloat8_t'
+//CHECK-NEXT:  | `-BuiltinType {{.*}} '__MFloat8_t'
 //CHECK-NEXT:  |-CXXRecordDecl {{.*}} implicit struct S1
-//CHECK-NEXT:  `-FieldDecl {{.*}} mem2 '__mfp8'
+//CHECK-NEXT:  `-FieldDecl {{.*}} mem2 '__MFloat8_t'
diff --git a/clang/test/CodeGen/aarch64-debug-types.c b/clang/test/CodeGen/aarch64-debug-types.c
new file mode 100644
index 00000000000000..c109610023ed49
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-debug-types.c
@@ -0,0 +1,9 @@
+// RUN:  %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon  -target-feature +fp8 \
+// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s
+#include<arm_neon.h>
+
+void test_locals(void) {
+  // CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "__MFloat8_t", {{.*}}, baseType: ![[ELTTYU8:[0-9]+]]
+  // CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "__MFloat8_t", size: 8, encoding: DW_ATE_unsigned_char)
+  __MFloat8_t mfp8;
+}
diff --git a/clang/test/CodeGen/arm-mfp8.c b/clang/test/CodeGen/arm-mfp8.c
index 81fb9b257b4789..6a0829682a6271 100644
--- a/clang/test/CodeGen/arm-mfp8.c
+++ b/clang/test/CodeGen/arm-mfp8.c
@@ -3,18 +3,18 @@
 
 // REQUIRES: aarch64-registered-target
 
-// CHECK-LABEL: define dso_local i8 @func1n(
-// CHECK-SAME: i8 [[MFP8:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-LABEL: define dso_local <1 x i8> @func1n(
+// CHECK-SAME: <1 x i8> [[MFP8:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:    [[MFP8_ADDR:%.*]] = alloca i8, align 1
-// CHECK-NEXT:    [[F1N:%.*]] = alloca [10 x i8], align 1
-// CHECK-NEXT:    store i8 [[MFP8]], ptr [[MFP8_ADDR]], align 1
-// CHECK-NEXT:    [[TMP0:%.*]] = load i8, ptr [[MFP8_ADDR]], align 1
-// CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i8], ptr [[F1N]], i64 0, i64 2
-// CHECK-NEXT:    store i8 [[TMP0]], ptr [[ARRAYIDX]], align 1
-// CHECK-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x i8], ptr [[F1N]], i64 0, i64 2
-// CHECK-NEXT:    [[TMP1:%.*]] = load i8, ptr [[ARRAYIDX1]], align 1
-// CHECK-NEXT:    ret i8 [[TMP1]]
+// CHECK-NEXT:    [[MFP8_ADDR:%.*]] = alloca <1 x i8>, align 1
+// CHECK-NEXT:    [[F1N:%.*]] = alloca [10 x <1 x i8>], align 1
+// CHECK-NEXT:    store <1 x i8> [[MFP8]], ptr [[MFP8_ADDR]], align 1
+// CHECK-NEXT:    [[TMP0:%.*]] = load <1 x i8>, ptr [[MFP8_ADDR]], align 1
+// CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x <1 x i8>], ptr [[F1N]], i64 0, i64 2
+// CHECK-NEXT:    store <1 x i8> [[TMP0]], ptr [[ARRAYIDX]], align 1
+// CHECK-NEXT:    [[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x <1 x i8>], ptr [[F1N]], i64 0, i64 2
+// CHECK-NEXT:    [[TMP1:%.*]] = load <1 x i8>, ptr [[ARRAYIDX1]], align 1
+// CHECK-NEXT:    ret <1 x i8> [[TMP1]]
 //
 __mfp8 func1n(__mfp8 mfp8) {
   __mfp8 f1n[10];
diff --git a/clang/test/Sema/arm-mfp8.c b/clang/test/Sema/arm-mfp8.c
index c1e74a18b647d2..d9229742cb91d3 100644
--- a/clang/test/Sema/arm-mfp8.c
+++ b/clang/test/Sema/arm-mfp8.c
@@ -3,9 +3,9 @@
 // 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}}
+  return (__mfp8)in; // expected-error {{cannot cast 'unsigned int' to '__MFloat8_t'; 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}}
+  return (unsigned)in; // expected-error {{cannot cast '__MFloat8_t' to 'unsigned int'; types are not compatible}}
 }
diff --git a/clang/test/Sema/arm-mfp8.cpp b/clang/test/Sema/arm-mfp8.cpp
index d9e03dc0e3f0de..0f17dd06817f84 100644
--- a/clang/test/Sema/arm-mfp8.cpp
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -2,34 +2,34 @@
 
 // REQUIRES: aarch64-registered-target
 __mfp8 test_static_cast_from_char(char in) {
-  return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__mfp8' is not allowed}}
+  return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__MFloat8_t' is not allowed}}
 }
 
 char test_static_cast_to_char(__mfp8 in) {
-  return static_cast<char>(in); // scalar-error {{static_cast from '__mfp8' to 'char' is not allowed}}
+  return static_cast<char>(in); // scalar-error {{static_cast from '__MFloat8_t' to 'char' is not allowed}}
 }
 void test(bool b) {
   __mfp8 mfp8;
 
-  mfp8 + mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
-  mfp8 - mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
-  mfp8 * mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
-  mfp8 / mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
-  ++mfp8;       // scalar-error {{cannot increment value of type '__mfp8'}}
-  --mfp8;       // scalar-error {{cannot decrement value of type '__mfp8'}}
+  mfp8 + mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
+  mfp8 - mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
+  mfp8 * mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
+  mfp8 / mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
+  ++mfp8;       // scalar-error {{cannot increment value of type '__MFloat8_t'}}
+  --mfp8;       // scalar-error {{cannot decrement value of type '__MFloat8_t'}}
 
   char u8;
 
-  mfp8 + u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
-  u8 + mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
-  mfp8 - u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
-  u8 - mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
-  mfp8 * u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
-  u8 * mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
-  mfp8 / u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
-  u8 / mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
-  mfp8 = u8;   // scalar-error {{assigning to '__mfp8' from incompatible type 'char'}}
-  u8 = mfp8;   // scalar-error {{assigning to 'char' from incompatible type '__mfp8'}}
-  mfp8 + (b ? u8 : mfp8);  // scalar-error {{incompatible operand types ('char' and '__mfp8')}}
+  mfp8 + u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
+  u8 + mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
+  mfp8 - u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
+  u8 - mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
+  mfp8 * u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
+  u8 * mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
+  mfp8 / u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
+  u8 / mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
+  mfp8 = u8;   // scalar-error {{assigning to '__MFloat8_t' from incompatible type 'char'}}
+  u8 = mfp8;   // scalar-error {{assigning to 'char' from incompatible type '__MFloat8_t'}}
+  mfp8 + (b ? u8 : mfp8);  // scalar-error {{incompatible operand types ('char' and '__MFloat8_t')}}
 }
 

>From 4d5f8d1049bbd4740554c9adcbff96385e196646 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Tue, 15 Oct 2024 14:33:53 +0000
Subject: [PATCH 3/4] Attach the scalar typedef to a header file

---
 clang/include/clang/AST/Type.h                |  6 --
 .../clang/Basic/AArch64SVEACLETypes.def       | 10 ++-
 .../clang/Basic/DiagnosticSemaKinds.td        |  2 -
 clang/include/clang/Basic/Specifiers.h        |  1 -
 clang/include/clang/Basic/TargetInfo.h        |  4 --
 clang/include/clang/Basic/TokenKinds.def      |  1 -
 clang/include/clang/Sema/DeclSpec.h           |  1 -
 clang/lib/AST/ASTContext.cpp                  | 21 ++++---
 clang/lib/AST/ItaniumMangle.cpp               |  2 +-
 clang/lib/AST/Type.cpp                        | 14 +++--
 clang/lib/Basic/TargetInfo.cpp                |  1 -
 clang/lib/Basic/Targets/AArch64.cpp           |  6 --
 clang/lib/Basic/Targets/AArch64.h             |  2 -
 clang/lib/CodeGen/CodeGenTypes.cpp            |  9 +--
 clang/lib/Parse/ParseDecl.cpp                 |  7 ---
 clang/lib/Parse/ParseExpr.cpp                 |  1 -
 clang/lib/Parse/ParseTentative.cpp            |  2 -
 clang/lib/Sema/DeclSpec.cpp                   |  4 --
 clang/lib/Sema/SemaCast.cpp                   |  7 ---
 clang/lib/Sema/SemaExpr.cpp                   |  6 --
 clang/lib/Sema/SemaTemplateVariadic.cpp       |  1 -
 clang/lib/Sema/SemaType.cpp                   |  5 --
 clang/test/AST/arm-mfp8.cpp                   | 61 +++++++++----------
 clang/test/CodeGen/arm-mfp8.c                 |  2 +-
 clang/test/Sema/arm-mfp8.c                    |  6 +-
 clang/test/Sema/arm-mfp8.cpp                  | 40 ++++++------
 clang/utils/TableGen/NeonEmitter.cpp          |  1 +
 27 files changed, 83 insertions(+), 140 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 6d255bc20c6a5e..dc87b84153e74a 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2644,8 +2644,6 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   bool isQueueT() const;                        // OpenCL queue_t
   bool isReserveIDT() const;                    // OpenCL reserve_id_t
 
-  bool isArmMFloat8Type() const;
-
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
   bool is##Id##Type() const;
 #include "clang/Basic/OpenCLExtensionTypes.def"
@@ -8314,10 +8312,6 @@ inline bool Type::isBitIntType() const {
   return isa<BitIntType>(CanonicalType);
 }
 
-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 4f1cdc8b0776d7..d3ae6c81f1138c 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -32,8 +32,6 @@
 //
 // where:
 //
-//  - Acronym is for the scalar types that have a short name
-//
 //  - Name is the name of the builtin type.
 //
 //  - MangledName is the mangled name of the builtin type.
@@ -100,14 +98,14 @@
 #endif
 
 #ifndef AARCH64_SCALAR_TYPE
-#define AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId) \
+#define AARCH64_SCALAR_TYPE(Name, MangledName, Id, SingletonId) \
   SVE_TYPE(Name, Id, SingletonId)
 #endif
 
 
 #ifndef AARCH64_SCALAR_TYPE_MFLOAT
-#define AARCH64_SCALAR_TYPE_MFLOAT(Acronym, Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \
-  AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
+#define AARCH64_SCALAR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \
+  AARCH64_SCALAR_TYPE(Name, MangledName, Id, SingletonId)
 #endif
 
 //===- Vector point types -----------------------------------------------===//
@@ -194,7 +192,7 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
 
 SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
 
-AARCH64_SCALAR_TYPE_MFLOAT("__mpf8", "__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 8, 1)
+AARCH64_SCALAR_TYPE_MFLOAT("__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 8, 1)
 
 #undef SVE_VECTOR_TYPE
 #undef SVE_VECTOR_TYPE_BFLOAT
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 16f58efbdfc91c..d42558d2223aae 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7931,8 +7931,6 @@ def err_bad_lvalue_to_rvalue_cast : Error<
 def err_bad_rvalue_to_rvalue_cast : Error<
   "cannot cast from rvalue of type %1 to rvalue reference type %2; types are "
   "not compatible">;
-def err_bad_mfloat8_cast : Error<
-  "cannot cast %0 to %1; types are not compatible">;
 def err_bad_static_cast_pointer_nonpointer : Error<
   "cannot cast from type %1 to pointer type %2">;
 def err_bad_static_cast_member_pointer_nonmp : Error<
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index 860a5d809e9b8d..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,
     TST_float,
     TST_double,
     TST_float128,
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 674f312d23e4dc..f31d88a354ea28 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -234,7 +234,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;
@@ -701,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/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 0c24844e691301..00e150dbd7a3a7 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -675,7 +675,6 @@ KEYWORD(__bool                      , KEYALTIVEC|KEYZVECTOR)
 // ARM NEON extensions.
 ALIAS("__fp16", half                , KEYALL)
 KEYWORD(__bf16                      , KEYALL)
-KEYWORD(__mfp8                      , KEYALL)
 
 // OpenCL Extension.
 KEYWORD(half                        , HALFSUPPORT)
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 49721442e4ef86..06243f2624876f 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -325,7 +325,6 @@ class DeclSpec {
 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)                            \
   static const TST TST_##Name = clang::TST_##Name;
 #include "clang/Basic/HLSLIntangibleTypes.def"
-  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 a2d16d5d1ebf05..48a2fc65436cd3 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1391,8 +1391,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"
@@ -2219,11 +2218,11 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
     Width = 0;                                                                 \
     Align = 16;                                                                \
     break;
-#define AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
-    case BuiltinType::ArmMFloat8:
-      Width = Target->getCharWidth();
-      Align = Target->getCharAlign();
-      break;
+#define AARCH64_SCALAR_TYPE(Name, MangledName, Id, SingletonId)                \
+  case BuiltinType::Id:                                                        \
+    Width = 8;                                                                 \
+    Align = 8;                                                                 \
+    break;
 #include "clang/Basic/AArch64SVEACLETypes.def"
 #define PPC_VECTOR_TYPE(Name, Id, Size)                                        \
   case BuiltinType::Id:                                                        \
@@ -4307,8 +4306,12 @@ 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_SCALAR_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_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
 #include "clang/Basic/AArch64SVEACLETypes.def"
 
 #define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF,         \
@@ -4374,7 +4377,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_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
+#define AARCH64_SCALAR_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 0c319d76bbc42f..32f8133805aeb7 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3406,7 +3406,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
     type_name = MangledName;                                                   \
     Out << (type_name == Name ? "u" : "") << type_name.size() << type_name;    \
     break;
-#define AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)       \
+#define AARCH64_SCALAR_TYPE(Name, MangledName, Id, SingletonId)                \
   case BuiltinType::Id:                                                        \
     type_name = MangledName;                                                   \
     Out << (type_name == Name ? "u" : "") << type_name.size() << type_name;    \
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index fce65fbcbe799b..ea98bce339c05e 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2485,16 +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_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
-#include "clang/Basic/AArch64SVEACLETypes.def"
+  case BuiltinType::Id:                                                        \
       return true;
-    case BuiltinType::ArmMFloat8:
+#define AARCH64_SCALAR_TYPE(Name, MangledName, Id, SingletonId)                \
+  case BuiltinType::Id:
       return false;
+#include "clang/Basic/AArch64SVEACLETypes.def"
     default:
       return false;
     }
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 040b49bb115b89..29f5cd14e46e11 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 b5931e63a56983..63fc15f916c558 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -741,7 +741,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)
@@ -989,9 +988,6 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       FPU |= NeonMode;
       HasSM4 = true;
     }
-    if (Feature == "+fp8") {
-      HasMFloat8 = true;
-    }
     if (Feature == "+strict-align")
       HasUnalignedAccess = false;
 
@@ -1233,8 +1229,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 544ee206fdb618..9ff708cd035346 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -47,7 +47,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
   bool HasLS64 = false;
   bool HasRandGen = false;
   bool HasMatMul = false;
-  bool HasMFloat8 = false;
   bool HasBFloat16 = false;
   bool HasSVE2 = false;
   bool HasSVE2p1 = false;
@@ -170,7 +169,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
 
   bool hasBFloat16Type() const override;
 
-  bool hasArmMFloat8Type() const override;
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index f1456e9c3dd4e6..6b1eddcba34dde 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -476,6 +476,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());
@@ -503,7 +504,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
   case BuiltinType::Id:
 #define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId)                 \
   case BuiltinType::Id:
-#define AARCH64_SCALAR_TYPE(Acronym, Name, MangledName, Id, SingletonId)
+#define AARCH64_SCALAR_TYPE(Name, MangledName, Id, SingletonId)                \
+  case BuiltinType::Id:
 #define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId)
 #include "clang/Basic/AArch64SVEACLETypes.def"
       {
@@ -526,11 +528,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
       }
     case BuiltinType::SveCount:
       return llvm::TargetExtType::get(getLLVMContext(), "aarch64.svcount");
-    case BuiltinType::ArmMFloat8:
-      ResultType =
-          llvm::VectorType::get(llvm::Type::getInt8Ty(getLLVMContext()),
-                                llvm::ElementCount::getFixed(1));
-      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 7902969ba14d0a..1f56884be392d6 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:
-      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);
@@ -5832,7 +5828,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:
@@ -5918,7 +5913,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:
@@ -6143,7 +6137,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 815eeedec0d2dc..e7514500dc53a4 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/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 920c3d92701ff5..73fc98711667d1 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:
       return false;
 
     case TST_decltype_auto:
@@ -615,9 +614,6 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
   case DeclSpec::TST_##Name:                                                   \
     return #Name;
 #include "clang/Basic/HLSLIntangibleTypes.def"
-  case DeclSpec::TST_ArmMFloat8_t:
-    return "__mfp8";
-  case DeclSpec::TST_error:       return "(error)";
   }
   llvm_unreachable("Unknown typespec!");
 }
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index a0dc1d55dbc51a..f01b22a72915c8 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2986,13 +2986,6 @@ void CastOperation::CheckCStyleCast() {
     return;
   }
 
-  if (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 9962336087929d..8f3e15cc9a9bb7 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8434,12 +8434,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 909f393135c37a..40522a07f6339c 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -962,7 +962,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:
   case TST_unknown_anytype:
   case TST_error:
     break;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index f9a2f65bce7fcd..22a44942cbe988 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:
-    if (!S.Context.getTargetInfo().hasArmMFloat8Type())
-      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__mfp8";
-    Result = Context.ArmMFloat8Ty;
-    break;
   case DeclSpec::TST_error:
     Result = Context.IntTy;
     declarator.setInvalidType(true);
diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp
index 7730ad418461d0..2568a2f3a747f7 100644
--- a/clang/test/AST/arm-mfp8.cpp
+++ b/clang/test/AST/arm-mfp8.cpp
@@ -5,6 +5,7 @@
 
 /*  Various contexts where type __mfp8 can appear. */
 
+#include<arm_neon.h>
 /*  Namespace */
 namespace {
   __mfp8 f2n;
@@ -12,11 +13,9 @@ namespace {
 }
 
 //CHECK:       |-NamespaceDecl {{.*}}
-//CHECK-NEXT:  | |-VarDecl {{.*}} f2n '__MFloat8_t'
-//CHECK-NEXT:  | `-VarDecl {{.*}} arr1n '__MFloat8_t[10]'
+//CHECK-NEXT:  | |-VarDecl {{.*}} f2n '__mfp8':'__MFloat8_t'
+//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
@@ -24,17 +23,15 @@ namespace {
     f1n  = mfp8;
     return f1n;
   }
-
-//CHECK:        |-VarDecl {{.*}} '__MFloat8_t[10]'
-
-//CHECK:            | `-VarDecl {{.*}} f1n '__MFloat8_t'
-//CHECK-NEXT:       |-BinaryOperator {{.*}} '__MFloat8_t' lvalue '='
-//CHECK-NEXT:       | |-DeclRefExpr {{.*}} '__MFloat8_t' lvalue Var {{.*}} 'f1n' '__MFloat8_t'
-//CHECK-NEXT:       | `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT:       |   `-DeclRefExpr {{.*}} 'const __MFloat8_t' lvalue ParmVar {{.*}} 'mfp8' 'const __MFloat8_t'
+//CHECK:    |-FunctionDecl {{.*}} func1n 'const __mfp8 (const __mfp8)'
+//CHECK:            | `-VarDecl {{.*}} f1n '__mfp8':'__MFloat8_t'
+//CHECK-NEXT:       |-BinaryOperator {{.*}} '__mfp8':'__MFloat8_t' lvalue '='
+//CHECK-NEXT:       | |-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t'
+//CHECK-NEXT:       | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:       |   `-DeclRefExpr {{.*}} 'const __mfp8':'const __MFloat8_t' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8':'const __MFloat8_t'
 //CHECK-NEXT:        `-ReturnStmt {{.*}}
-//CHECK-NEXT:         `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT:           `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue Var {{.*}} 'f1n' '__MFloat8_t'
+//CHECK-NEXT:         `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:           `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t'
 
 
 /* Class */
@@ -54,31 +51,31 @@ class C1 {
 };
 
 //CHECK:       | |-CXXRecordDecl {{.*}} referenced class C1
-//CHECK-NEXT:  | |-FieldDecl {{.*}} f1c '__MFloat8_t'
-//CHECK-NEXT:  | |-VarDecl {{.*}} f2c 'const __MFloat8_t' static
+//CHECK-NEXT:  | |-FieldDecl {{.*}} f1c '__mfp8':'__MFloat8_t'
+//CHECK-NEXT:  | |-VarDecl {{.*}} f2c 'const __mfp8':'const __MFloat8_t' static
 //CHECK-NEXT:  | |-FieldDecl {{.*}} f3c 'volatile __MFloat8_t'
 //CHECK-NEXT:  | |-AccessSpecDecl {{.*}}
-//CHECK-NEXT:  | |-CXXConstructorDecl {{.*}} C1 'void (__MFloat8_t)' implicit-inline
-//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__MFloat8_t'
-//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f1c' '__MFloat8_t'
-//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__MFloat8_t'
+//CHECK-NEXT:  | |-CXXConstructorDecl {{.*}} C1 'void (__mfp8)' implicit-inline
+//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t'
+//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8':'__MFloat8_t'
+//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
 //CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __MFloat8_t'
-//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__MFloat8_t'
+//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
 //CHECK-NEXT:  | | `-CompoundStmt {{.*}}
-//CHECK-NEXT:  | |-CXXMethodDecl {{.*}} func1c '__MFloat8_t (__MFloat8_t)' implicit-inline
-//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__MFloat8_t'
+//CHECK-NEXT:  | |-CXXMethodDecl {{.*}} func1c '__mfp8 (__mfp8)' implicit-inline
+//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t'
 //CHECK-NEXT:  | | `-CompoundStmt {{.*}}
 //CHECK-NEXT:  | |   `-ReturnStmt {{.*}}
-//CHECK-NEXT:  | |     `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT:  | |       `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}}8 'arg' '__MFloat8_t'
-//CHECK-NEXT:  | `-CXXMethodDecl {{.*}} func2c '__MFloat8_t (__MFloat8_t)' static implicit-inline
-//CHECK-NEXT:  |   |-ParmVarDecl {{.*}} arg '__MFloat8_t'
+//CHECK-NEXT:  | |     `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  | |       `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}}8 'arg' '__mfp8':'__MFloat8_t'
+//CHECK-NEXT:  | `-CXXMethodDecl {{.*}} func2c '__mfp8 (__mfp8)' static implicit-inline
+//CHECK-NEXT:  |   |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t'
 //CHECK-NEXT:  |   `-CompoundStmt {{.*}}
 //CHECK-NEXT:  |     `-ReturnStmt {{.*}}
-//CHECK-NEXT:  |       `-ImplicitCastExpr {{.*}} '__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT:  |         `-DeclRefExpr {{.*}} '__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__MFloat8_t'
+//CHECK-NEXT:  |       `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
+//CHECK-NEXT:  |         `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
 
 template <class C> struct S1 {
   C mem1;
@@ -91,4 +88,4 @@ template <> struct S1<__mfp8> {
 //CHECK:       |-TemplateArgument type '__MFloat8_t'
 //CHECK-NEXT:  | `-BuiltinType {{.*}} '__MFloat8_t'
 //CHECK-NEXT:  |-CXXRecordDecl {{.*}} implicit struct S1
-//CHECK-NEXT:  `-FieldDecl {{.*}} mem2 '__MFloat8_t'
+//CHECK-NEXT:  `-FieldDecl {{.*}} mem2 '__mfp8':'__MFloat8_t'
diff --git a/clang/test/CodeGen/arm-mfp8.c b/clang/test/CodeGen/arm-mfp8.c
index 6a0829682a6271..adcbf13f4c9d31 100644
--- a/clang/test/CodeGen/arm-mfp8.c
+++ b/clang/test/CodeGen/arm-mfp8.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -emit-llvm -triple aarch64-arm-none-eabi -target-feature -fp8 -o - %s | FileCheck %s
 
 // REQUIRES: aarch64-registered-target
-
+#include<arm_neon.h>
 // CHECK-LABEL: define dso_local <1 x i8> @func1n(
 // CHECK-SAME: <1 x i8> [[MFP8:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
diff --git a/clang/test/Sema/arm-mfp8.c b/clang/test/Sema/arm-mfp8.c
index d9229742cb91d3..e917078f50ed7e 100644
--- a/clang/test/Sema/arm-mfp8.c
+++ b/clang/test/Sema/arm-mfp8.c
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s
 
 // REQUIRES: aarch64-registered-target
-
+#include<arm_neon.h>
 __mfp8 test_cast_from_float(unsigned in) {
-  return (__mfp8)in; // expected-error {{cannot cast 'unsigned int' to '__MFloat8_t'; types are not compatible}}
+  return (__mfp8)in; // expected-error {{used type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}}
 }
 
 unsigned test_cast_to_int(__mfp8 in) {
-  return (unsigned)in; // expected-error {{cannot cast '__MFloat8_t' to 'unsigned int'; types are not compatible}}
+  return (unsigned)in; // expected-error {{operand of type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}}
 }
diff --git a/clang/test/Sema/arm-mfp8.cpp b/clang/test/Sema/arm-mfp8.cpp
index 0f17dd06817f84..01e3bad316f0f2 100644
--- a/clang/test/Sema/arm-mfp8.cpp
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -1,35 +1,37 @@
 // RUN: %clang_cc1 -fsyntax-only -verify=scalar -triple aarch64-arm-none-eabi -target-feature -fp8  %s
 
 // REQUIRES: aarch64-registered-target
+
+#include<arm_neon.h>
 __mfp8 test_static_cast_from_char(char in) {
-  return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__MFloat8_t' is not allowed}}
+  return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__mfp8' (aka '__MFloat8_t') is not allowed}}
 }
 
 char test_static_cast_to_char(__mfp8 in) {
-  return static_cast<char>(in); // scalar-error {{static_cast from '__MFloat8_t' to 'char' is not allowed}}
+  return static_cast<char>(in); // scalar-error {{static_cast from '__mfp8' (aka '__MFloat8_t') to 'char' is not allowed}}
 }
 void test(bool b) {
   __mfp8 mfp8;
 
-  mfp8 + mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
-  mfp8 - mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
-  mfp8 * mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
-  mfp8 / mfp8;  // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and '__MFloat8_t')}}
-  ++mfp8;       // scalar-error {{cannot increment value of type '__MFloat8_t'}}
-  --mfp8;       // scalar-error {{cannot decrement value of type '__MFloat8_t'}}
+  mfp8 + mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
+  mfp8 - mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
+  mfp8 * mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
+  mfp8 / mfp8;  // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
+  ++mfp8;       // scalar-error {{cannot increment value of type '__mfp8' (aka '__MFloat8_t')}}
+  --mfp8;       // scalar-error {{cannot decrement value of type '__mfp8' (aka '__MFloat8_t')}}
 
   char u8;
 
-  mfp8 + u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
-  u8 + mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
-  mfp8 - u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
-  u8 - mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
-  mfp8 * u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
-  u8 * mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
-  mfp8 / u8;   // scalar-error {{invalid operands to binary expression ('__MFloat8_t' and 'char')}}
-  u8 / mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__MFloat8_t')}}
-  mfp8 = u8;   // scalar-error {{assigning to '__MFloat8_t' from incompatible type 'char'}}
-  u8 = mfp8;   // scalar-error {{assigning to 'char' from incompatible type '__MFloat8_t'}}
-  mfp8 + (b ? u8 : mfp8);  // scalar-error {{incompatible operand types ('char' and '__MFloat8_t')}}
+  mfp8 + u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
+  u8 + mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
+  mfp8 - u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
+  u8 - mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
+  mfp8 * u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
+  u8 * mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
+  mfp8 / u8;   // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
+  u8 / mfp8;   // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
+  mfp8 = u8;   // scalar-error {{assigning to '__mfp8' (aka '__MFloat8_t') from incompatible type 'char'}}
+  u8 = mfp8;   // scalar-error {{assigning to 'char' from incompatible type '__mfp8' (aka '__MFloat8_t')}}
+  mfp8 + (b ? u8 : mfp8);  // scalar-error {{incompatible operand types ('char' and '__mfp8' (aka '__MFloat8_t'))}}
 }
 
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 202573e2ac740e..c958c2bcaea0c4 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -2581,6 +2581,7 @@ void NeonEmitter::runVectorTypes(raw_ostream &OS) {
   OS << "typedef __fp16 float16_t;\n";
 
   OS << "#if defined(__aarch64__) || defined(__arm64ec__)\n";
+  OS << "typedef __MFloat8_t __mfp8;\n";
   OS << "typedef double float64_t;\n";
   OS << "#endif\n\n";
 

>From 042c77a7989e550ec8acbf9ca8d5b804b8ce78e4 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Tue, 15 Oct 2024 15:39:31 +0000
Subject: [PATCH 4/4] Remove not intentional changes

---
 clang/lib/AST/Type.cpp            | 6 +++---
 clang/lib/Basic/Targets/AArch64.h | 1 -
 clang/lib/Sema/DeclSpec.cpp       | 1 +
 clang/lib/Sema/SemaType.cpp       | 1 +
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index ea98bce339c05e..6009d14b0e4efb 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2494,7 +2494,7 @@ bool Type::isSVESizelessBuiltinType() const {
   case BuiltinType::Id:                                                        \
       return true;
 #define AARCH64_SCALAR_TYPE(Name, MangledName, Id, SingletonId)                \
-  case BuiltinType::Id:
+  case BuiltinType::Id:                                                        \
       return false;
 #include "clang/Basic/AArch64SVEACLETypes.def"
     default:
@@ -3447,8 +3447,8 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
   case Id: \
     return #ExtType;
 #include "clang/Basic/OpenCLExtensionTypes.def"
-#define SVE_TYPE(Name, Id, SingletonId)                                        \
-  case Id:                                                                     \
+#define SVE_TYPE(Name, Id, SingletonId) \
+  case Id: \
     return Name;
 #include "clang/Basic/AArch64SVEACLETypes.def"
 #define PPC_VECTOR_TYPE(Name, Id, Size) \
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index 9ff708cd035346..526f7f30a38618 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -169,7 +169,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
 
   bool hasBFloat16Type() const override;
 
-
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 
   bool isCLZForZeroUndef() const override;
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 73fc98711667d1..12d2d3f6060c63 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -614,6 +614,7 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
   case DeclSpec::TST_##Name:                                                   \
     return #Name;
 #include "clang/Basic/HLSLIntangibleTypes.def"
+  case DeclSpec::TST_error:       return "(error)";
   }
   llvm_unreachable("Unknown typespec!");
 }
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 22a44942cbe988..11adfb0d7f3e98 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);



More information about the cfe-commits mailing list