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

via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 31 03:00:26 PDT 2024


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

>From fbeca5c357b1a5589757bbb2cac8208f8c9027ab 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/5] [WIP][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 `__fpm8` 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 fpm8_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/ASTContext.h          |  1 +
 clang/include/clang/AST/BuiltinTypes.def      |  4 +
 clang/include/clang/AST/Type.h                |  5 +
 clang/include/clang/Basic/Specifiers.h        |  1 +
 clang/include/clang/Basic/TokenKinds.def      |  1 +
 clang/include/clang/Sema/DeclSpec.h           |  1 +
 .../include/clang/Serialization/ASTBitCodes.h |  4 +-
 clang/lib/AST/ASTContext.cpp                  |  7 ++
 clang/lib/AST/ItaniumMangle.cpp               |  1 +
 clang/lib/AST/Type.cpp                        |  2 +
 clang/lib/AST/TypeLoc.cpp                     |  1 +
 clang/lib/CodeGen/CodeGenTypes.cpp            |  4 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp           |  1 +
 clang/lib/Index/USRGeneration.cpp             |  1 +
 clang/lib/Lex/Lexer.cpp                       |  1 +
 clang/lib/Parse/ParseDecl.cpp                 |  7 ++
 clang/lib/Parse/ParseExpr.cpp                 |  1 +
 clang/lib/Parse/ParseExprCXX.cpp              |  3 +
 clang/lib/Parse/ParseTentative.cpp            |  2 +
 clang/lib/Sema/DeclSpec.cpp                   |  3 +
 clang/lib/Sema/SemaTemplateVariadic.cpp       |  1 +
 clang/lib/Sema/SemaType.cpp                   |  3 +
 clang/lib/Serialization/ASTCommon.cpp         |  3 +
 clang/test/AST/fpm8_opaque.cpp                | 91 +++++++++++++++++++
 clang/test/CodeGen/fpm8_opaque.c              | 24 +++++
 25 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/AST/fpm8_opaque.cpp
 create mode 100644 clang/test/CodeGen/fpm8_opaque.c

diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 53ece996769a8..532ec05ab90a6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1115,6 +1115,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
       SatUnsignedLongFractTy;
+  CanQualType Fpm8Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a743..0c1cccf4f73b8 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -221,6 +221,10 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+
+// '__fpm8'
+UNSIGNED_TYPE(Fpm8, Fpm8Ty)
+
 //===- Language-specific types --------------------------------------------===//
 
 // This is the type of C++0x 'nullptr'.
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index fab233b62d8d1..9f835b8459847 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2492,6 +2492,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   bool isDoubleType() const;
   bool isBFloat16Type() const;
   bool isFloat128Type() const;
+  bool isFpm8Type() const;
   bool isIbm128Type() const;
   bool isRealType() const;         // C99 6.2.5p17 (real floating + integer)
   bool isArithmeticType() const;   // C99 6.2.5p18 (integer + floating)
@@ -7944,6 +7945,10 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isFpm8Type() const {
+  return isSpecificBuiltinType(BuiltinType::Fpm8);
+}
+
 inline bool Type::isFloat128Type() const {
   return isSpecificBuiltinType(BuiltinType::Float128);
 }
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index fb11e8212f8b6..b4db94d273949 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_Fpm8,
     TST_float,
     TST_double,
     TST_float128,
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 9c4b17465e18a..c08cf760962f3 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -655,6 +655,7 @@ KEYWORD(__bool                      , KEYALTIVEC|KEYZVECTOR)
 // ARM NEON extensions.
 ALIAS("__fp16", half                , KEYALL)
 KEYWORD(__bf16                      , KEYALL)
+KEYWORD(__fpm8                      , KEYALL)
 
 // OpenCL Extension.
 KEYWORD(half                        , HALFSUPPORT)
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 23bc780e04979..097cb8eb642ac 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -287,6 +287,7 @@ class DeclSpec {
   static const TST TST_bitint = clang::TST_bitint;
   static const TST TST_half = clang::TST_half;
   static const TST TST_BFloat16 = clang::TST_BFloat16;
+  static const TST TST_Fpm8 = clang::TST_Fpm8;
   static const TST TST_float = clang::TST_float;
   static const TST TST_double = clang::TST_double;
   static const TST TST_float16 = clang::TST_Float16;
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index a4728b1c06b3f..b2853c5e787d6 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1078,6 +1078,8 @@ enum PredefinedTypeIDs {
   /// \brief The '__ibm128' type
   PREDEF_TYPE_IBM128_ID = 74,
 
+  PREDEF_TYPE_FPM8_ID = 75,
+
 /// OpenCL image types with auto numeration
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
   PREDEF_TYPE_##Id##_ID,
@@ -1109,7 +1111,7 @@ enum PredefinedTypeIDs {
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 503;
+const unsigned NUM_PREDEF_TYPE_IDS = 504;
 
 // 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 34aa399fda2f8..7d810c1f8751e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1408,6 +1408,8 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
   // half type (OpenCL 6.1.1.1) / ARM NEON __fp16
   InitBuiltinType(HalfTy, BuiltinType::Half);
 
+  InitBuiltinType(Fpm8Ty, BuiltinType::Fpm8);
+
   InitBuiltinType(BFloat16Ty, BuiltinType::BFloat16);
 
   // Builtin type used to help define __builtin_va_list.
@@ -1977,6 +1979,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
       Width = Target->getBoolWidth();
       Align = Target->getBoolAlign();
       break;
+    case BuiltinType::Fpm8:
     case BuiltinType::Char_S:
     case BuiltinType::Char_U:
     case BuiltinType::UChar:
@@ -8129,6 +8132,7 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
     case BuiltinType::LongDouble: return 'D';
     case BuiltinType::NullPtr:    return '*'; // like char*
 
+    case BuiltinType::Fpm8:
     case BuiltinType::BFloat16:
     case BuiltinType::Float16:
     case BuiltinType::Float128:
@@ -11466,6 +11470,9 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
     else
       Type = Context.CharTy;
     break;
+  case '£':
+    Type = Context.Fpm8Ty;
+    break;
   case 'b': // boolean
     assert(HowLong == 0 && !Signed && !Unsigned && "Bad modifiers for 'b'!");
     Type = Context.BoolTy;
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index ed9e6eeb36c75..f974cf1b5f8a8 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3181,6 +3181,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
   case BuiltinType::SChar:
     Out << 'a';
     break;
+  case BuiltinType::Fpm8:
   case BuiltinType::WChar_S:
   case BuiltinType::WChar_U:
     Out << 'w';
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 33acae2cbafac..f629ae6d7b016 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3372,6 +3372,8 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
     return "unsigned __int128";
   case Half:
     return Policy.Half ? "half" : "__fp16";
+  case Fpm8:
+    return "__fpm8";
   case BFloat16:
     return "__bf16";
   case Float:
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index 9dd90d9bf4e54..8df92d3921c44 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -361,6 +361,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
   case BuiltinType::Long:
   case BuiltinType::LongLong:
   case BuiltinType::Int128:
+  case BuiltinType::Fpm8:
   case BuiltinType::Half:
   case BuiltinType::Float:
   case BuiltinType::Double:
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 0a926e4ac27fe..626525f66e3e7 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -419,7 +419,9 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
                                     Context.getFloatTypeSemantics(T),
                                     /* UseNativeHalf = */ false);
       break;
-
+    case BuiltinType::Fpm8:
+      ResultType = llvm::Type::getInt8Ty(getLLVMContext());
+      break;
     case BuiltinType::NullPtr:
       // Model std::nullptr_t as i8*
       ResultType = llvm::PointerType::getUnqual(getLLVMContext());
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 5a3e83de625c9..8ae3c1c38b3e5 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3331,6 +3331,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
     case BuiltinType::Float:
     case BuiltinType::Double:
     case BuiltinType::LongDouble:
+    case BuiltinType::Fpm8:
     case BuiltinType::Float16:
     case BuiltinType::Float128:
     case BuiltinType::Ibm128:
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index 31c4a3345c09d..553b788ee0e75 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -691,6 +691,7 @@ void USRGenerator::VisitType(QualType T) {
           Out << 'v'; break;
         case BuiltinType::Bool:
           Out << 'b'; break;
+        case BuiltinType::Fpm8:
         case BuiltinType::UChar:
           Out << 'c'; break;
         case BuiltinType::Char8:
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index e59c7805b3862..7806ea9d8604f 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -97,6 +97,7 @@ bool Token::isSimpleTypeSpecifier(const LangOptions &LangOpts) const {
   case tok::kw___bf16:
   case tok::kw__Float16:
   case tok::kw___float128:
+  case tok::kw___fpm8:
   case tok::kw___ibm128:
   case tok::kw_wchar_t:
   case tok::kw_bool:
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index c528917437332..25838d65f3e51 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4477,6 +4477,10 @@ void Parser::ParseDeclarationSpecifiers(
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec,
                                      DiagID, Policy);
       break;
+    case tok::kw___fpm8:
+      isInvalid =
+          DS.SetTypeSpecType(DeclSpec::TST_Fpm8, Loc, PrevSpec, DiagID, Policy);
+      break;
     case tok::kw_half:
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec,
                                      DiagID, Policy);
@@ -5752,6 +5756,7 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
   case tok::kw__ExtInt:
   case tok::kw__BitInt:
   case tok::kw___bf16:
+  case tok::kw___fpm8:
   case tok::kw_half:
   case tok::kw_float:
   case tok::kw_double:
@@ -5835,6 +5840,7 @@ bool Parser::isTypeSpecifierQualifier() {
   case tok::kw_int:
   case tok::kw__ExtInt:
   case tok::kw__BitInt:
+  case tok::kw___fpm8:
   case tok::kw_half:
   case tok::kw___bf16:
   case tok::kw_float:
@@ -6057,6 +6063,7 @@ bool Parser::isDeclarationSpecifier(
   case tok::kw_int:
   case tok::kw__ExtInt:
   case tok::kw__BitInt:
+  case tok::kw___fpm8:
   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 eb7447fa038e4..9103275aa9772 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1594,6 +1594,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
   case tok::kw__BitInt:
   case tok::kw_signed:
   case tok::kw_unsigned:
+  case tok::kw___fpm8:
   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 1d364f77a8146..72c4782cb53b3 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -2405,6 +2405,9 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
   case tok::kw___int128:
     DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec, DiagID, Policy);
     break;
+  case tok::kw___fpm8:
+    DS.SetTypeSpecType(DeclSpec::TST_Fpm8, 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 ea17c3e3252ec..695bbbba9433d 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1779,6 +1779,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
   case tok::kw_short:
   case tok::kw_int:
   case tok::kw_long:
+  case tok::kw___fpm8:
   case tok::kw___int64:
   case tok::kw___int128:
   case tok::kw_signed:
@@ -1907,6 +1908,7 @@ bool Parser::isCXXDeclarationSpecifierAType() {
   case tok::kw_long:
   case tok::kw___int64:
   case tok::kw___int128:
+  case tok::kw___fpm8:
   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 60e8189025700..168b98e90e6ec 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -358,6 +358,7 @@ bool Declarator::isDeclarationOfFunction() const {
     case TST_Fract:
     case TST_Float16:
     case TST_float128:
+    case TST_Fpm8:
     case TST_ibm128:
     case TST_enum:
     case TST_error:
@@ -575,6 +576,8 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
   case DeclSpec::TST_fract:       return "_Fract";
   case DeclSpec::TST_float16:     return "_Float16";
   case DeclSpec::TST_float128:    return "__float128";
+  case DeclSpec::TST_Fpm8:
+    return "fpm8_t";
   case DeclSpec::TST_ibm128:      return "__ibm128";
   case DeclSpec::TST_bool:        return Policy.Bool ? "bool" : "_Bool";
   case DeclSpec::TST_decimal32:   return "_Decimal32";
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 7a44b978aacdb..d7c4c04c130ef 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -908,6 +908,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
   case TST_char32:
   case TST_int:
   case TST_int128:
+  case TST_Fpm8:
   case TST_half:
   case TST_float:
   case TST_double:
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 441fdcca0758f..89c523990ce52 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1134,6 +1134,9 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
       S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__bf16";
     Result = Context.BFloat16Ty;
     break;
+  case DeclSpec::TST_Fpm8:
+    Result = Context.Fpm8Ty;
+    break;
   case DeclSpec::TST_float:   Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
     if (DS.getTypeSpecWidth() == TypeSpecifierWidth::Long)
diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp
index bc662a87a7bf3..a01d57cc1fcab 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -35,6 +35,9 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
   case BuiltinType::Char_U:
     ID = PREDEF_TYPE_CHAR_U_ID;
     break;
+  case BuiltinType::Fpm8:
+    ID = PREDEF_TYPE_FPM8_ID;
+    break;
   case BuiltinType::UChar:
     ID = PREDEF_TYPE_UCHAR_ID;
     break;
diff --git a/clang/test/AST/fpm8_opaque.cpp b/clang/test/AST/fpm8_opaque.cpp
new file mode 100644
index 0000000000000..3aeb3159ddc6a
--- /dev/null
+++ b/clang/test/AST/fpm8_opaque.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type __fpm8 can appear. */
+
+/*  Namespace */
+namespace {
+  __fpm8 f2n;
+  __fpm8 arr1n[10];
+}
+
+//CHECK:       |-NamespaceDecl {{.*}}
+//CHECK-NEXT:  | |-VarDecl {{.*}} f2n '__fpm8'
+//CHECK-NEXT:  | `-VarDecl {{.*}} arr1n '__fpm8[10]'
+
+  __fpm8 arr1[10];
+  //__fpm8 arr2n[] { 1, 3, 3 }; cannot initialize
+  
+  const __fpm8 func1n(const __fpm8 fpm8) {
+    // this should fail
+    __fpm8 f1n;
+    f1n  = fpm8;
+    return f1n;
+  }
+
+//CHECK:        |-VarDecl {{.*}} '__fpm8[10]'
+
+//CHECK:            | `-VarDecl {{.*}} f1n '__fpm8'
+//CHECK-NEXT:       |-BinaryOperator {{.*}} '__fpm8' lvalue '='
+//CHECK-NEXT:       | |-DeclRefExpr {{.*}} '__fpm8' lvalue Var {{.*}} 'f1n' '__fpm8'
+//CHECK-NEXT:       | `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
+//CHECK-NEXT:       |   `-DeclRefExpr {{.*}} 'const __fpm8' lvalue ParmVar {{.*}} 'fpm8' 'const __fpm8'
+//CHECK-NEXT:        `-ReturnStmt {{.*}}
+//CHECK-NEXT:         `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
+//CHECK-NEXT:           `-DeclRefExpr {{.*}} '__fpm8' lvalue Var {{.*}} 'f1n' '__fpm8'
+
+
+/* Class */
+
+class C1 {
+  __fpm8 f1c;
+  static const __fpm8 f2c;
+  volatile __fpm8 f3c;
+public:
+  C1(__fpm8 arg) : f1c(arg), f3c(arg) { }
+  __fpm8 func1c(__fpm8 arg ) {
+    return  arg;
+  }
+  static __fpm8 func2c(__fpm8 arg) {
+    return arg;
+  }
+};
+
+//CHECK:       | |-CXXRecordDecl {{.*}} referenced class C1
+//CHECK-NEXT:  | |-FieldDecl {{.*}} f1c '__fpm8'
+//CHECK-NEXT:  | |-VarDecl {{.*}} f2c 'const __fpm8' static
+//CHECK-NEXT:  | |-FieldDecl {{.*}} f3c 'volatile __fpm8'
+//CHECK-NEXT:  | |-AccessSpecDecl {{.*}}
+//CHECK-NEXT:  | |-CXXConstructorDecl {{.*}} C1 'void (__fpm8)' implicit-inline
+//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__fpm8'
+//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f1c' '__fpm8'
+//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
+//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}} 'arg' '__fpm8'
+//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __fpm8'
+//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
+//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}} 'arg' '__fpm8'
+//CHECK-NEXT:  | | `-CompoundStmt {{.*}}
+//CHECK-NEXT:  | |-CXXMethodDecl {{.*}} func1c '__fpm8 (__fpm8)' implicit-inline
+//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__fpm8'
+//CHECK-NEXT:  | | `-CompoundStmt {{.*}}
+//CHECK-NEXT:  | |   `-ReturnStmt {{.*}}
+//CHECK-NEXT:  | |     `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
+//CHECK-NEXT:  | |       `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}}8 'arg' '__fpm8'
+//CHECK-NEXT:  | `-CXXMethodDecl {{.*}} func2c '__fpm8 (__fpm8)' static implicit-inline
+//CHECK-NEXT:  |   |-ParmVarDecl {{.*}} arg '__fpm8'
+//CHECK-NEXT:  |   `-CompoundStmt {{.*}}
+//CHECK-NEXT:  |     `-ReturnStmt {{.*}}
+//CHECK-NEXT:  |       `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
+//CHECK-NEXT:  |         `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}} 'arg' '__fpm8'
+
+template <class C> struct S1 {
+  C mem1;
+};
+
+template <> struct S1<__fpm8> {
+  __fpm8 mem2;
+};
+
+//CHECK:       |-TemplateArgument type '__fpm8'
+//CHECK-NEXT:  | `-BuiltinType {{.*}} '__fpm8'
+//CHECK-NEXT:  |-CXXRecordDecl {{.*}} implicit struct S1
+//CHECK-NEXT:  `-FieldDecl {{.*}} mem2 '__fpm8'
diff --git a/clang/test/CodeGen/fpm8_opaque.c b/clang/test/CodeGen/fpm8_opaque.c
new file mode 100644
index 0000000000000..19b5128b8eff9
--- /dev/null
+++ b/clang/test/CodeGen/fpm8_opaque.c
@@ -0,0 +1,24 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define dso_local i8 @func1n(
+// CHECK-SAME: i8 noundef [[FPM8:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[FPM8_ADDR:%.*]] = alloca i8, align 1
+// CHECK-NEXT:    [[F1N:%.*]] = alloca [10 x i8], align 1
+// CHECK-NEXT:    store i8 [[FPM8]], ptr [[FPM8_ADDR]], align 1
+// CHECK-NEXT:    [[TMP0:%.*]] = load i8, ptr [[FPM8_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]]
+//
+__fpm8 func1n(__fpm8 fpm8) {
+  __fpm8 f1n[10];
+  f1n[2] = fpm8;
+  return f1n[2];
+}
+
+
+

>From d060f1f80fc854ac66e69df3e639587a8f2742af Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Wed, 10 Jul 2024 09:55:57 +0000
Subject: [PATCH 2/5] =?UTF-8?q?Replace=20=C2=A3=20by=20j=20in=20ASTContext?=
 =?UTF-8?q?.cpp?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 clang/lib/AST/ASTContext.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7d810c1f8751e..81bae00afe219 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11470,7 +11470,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
     else
       Type = Context.CharTy;
     break;
-  case '£':
+  case 'j':
     Type = Context.Fpm8Ty;
     break;
   case 'b': // boolean

>From 36af7587fdfb46e7b5239e0c09208ab4d5498322 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Tue, 16 Jul 2024 08:06:06 +0000
Subject: [PATCH 3/5] Add SEMA support

---
 .../clang/Basic/DiagnosticSemaKinds.td        |  2 ++
 clang/include/clang/Basic/TargetBuiltins.h    |  3 +-
 clang/include/clang/Basic/TargetInfo.h        |  4 +++
 clang/lib/AST/ASTContext.cpp                  |  2 +-
 clang/lib/AST/ItaniumMangle.cpp               |  5 +++
 clang/lib/AST/PrintfFormatString.cpp          |  1 +
 clang/lib/Basic/TargetInfo.cpp                |  1 +
 clang/lib/Basic/Targets/AArch64.cpp           |  6 ++++
 clang/lib/Basic/Targets/AArch64.h             |  3 ++
 clang/lib/CodeGen/CGBuiltin.cpp               |  3 +-
 clang/lib/CodeGen/CGDebugInfo.cpp             |  1 +
 clang/lib/CodeGen/CodeGenModule.cpp           |  1 +
 clang/lib/CodeGen/CodeGenTypeCache.h          |  3 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp           |  2 +-
 clang/lib/Sema/SemaARM.cpp                    |  3 ++
 clang/lib/Sema/SemaCast.cpp                   |  7 +++++
 clang/lib/Sema/SemaExpr.cpp                   |  6 ++++
 clang/lib/Sema/SemaType.cpp                   |  5 ++-
 clang/lib/Serialization/ASTReader.cpp         |  3 ++
 clang/test/Sema/arm-fp8-forbidden-ops.c       |  9 ++++++
 clang/test/Sema/arm-fp8-forbidden-ops.cpp     |  9 ++++++
 clang/test/Sema/arm-fpm8.cpp                  | 31 +++++++++++++++++++
 22 files changed, 105 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/Sema/arm-fp8-forbidden-ops.c
 create mode 100644 clang/test/Sema/arm-fp8-forbidden-ops.cpp
 create mode 100644 clang/test/Sema/arm-fpm8.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8f85371df3b85..ab16c1fa1a162 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7858,6 +7858,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_fpm8_cast : Error<
+  "cannot cast %0 to %1; types are not compatible">;
 def err_bad_static_cast_pointer_nonpointer : Error<
   "cannot cast from type %1 to pointer type %2">;
 def err_bad_static_cast_member_pointer_nonmp : Error<
diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index 4333830bf34f2..b456b75943af3 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -198,7 +198,8 @@ namespace clang {
       Float16,
       Float32,
       Float64,
-      BFloat16
+      BFloat16,
+      Fpm8
     };
 
     NeonTypeFlags(unsigned F) : Flags(F) {}
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 8a6511b9ced83..de5fd0fc09b0a 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 HasFpm8;
   bool HasIbm128;
   bool HasLongDouble;
   bool HasFPReturn;
@@ -700,6 +701,9 @@ class TargetInfo : public TransferrableTargetInfo,
     return HasBFloat16 || HasFullBFloat16;
   }
 
+  /// Determine whether the _fpm8 type is supported on this target.
+  virtual bool hasFpm8Type() const { return HasFpm8; }
+
   /// 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/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 81bae00afe219..9480ff8d4bae2 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8106,6 +8106,7 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
     switch (kind) {
     case BuiltinType::Void:       return 'v';
     case BuiltinType::Bool:       return 'B';
+    case BuiltinType::Fpm8:
     case BuiltinType::Char8:
     case BuiltinType::Char_U:
     case BuiltinType::UChar:      return 'C';
@@ -8132,7 +8133,6 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
     case BuiltinType::LongDouble: return 'D';
     case BuiltinType::NullPtr:    return '*'; // like char*
 
-    case BuiltinType::Fpm8:
     case BuiltinType::BFloat16:
     case BuiltinType::Float16:
     case BuiltinType::Float128:
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index f974cf1b5f8a8..76cb1e7556680 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3800,6 +3800,9 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
     case BuiltinType::Float:     EltName = "float32_t"; break;
     case BuiltinType::Half:      EltName = "float16_t"; break;
     case BuiltinType::BFloat16:  EltName = "bfloat16_t"; break;
+    case BuiltinType::Fpm8:
+      EltName = "fmp8_t";
+      break;
     default:
       llvm_unreachable("unexpected Neon vector element type");
     }
@@ -3853,6 +3856,8 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
     return "Float64";
   case BuiltinType::BFloat16:
     return "Bfloat16";
+  case BuiltinType::Fpm8:
+    return "Fpm8_t";
   default:
     llvm_unreachable("Unexpected vector element base type");
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp
index dd3b38fabb550..2d4967f82f4d3 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/PrintfFormatString.cpp
@@ -817,6 +817,7 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt,
   case BuiltinType::Char32:
   case BuiltinType::UInt128:
   case BuiltinType::Int128:
+  case BuiltinType::Fpm8:
   case BuiltinType::Half:
   case BuiltinType::BFloat16:
   case BuiltinType::Float16:
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 29f5cd14e46e1..c18a80384d518 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;
+  HasFpm8 = false;
   HasFloat128 = false;
   HasIbm128 = false;
   HasFloat16 = false;
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 13515699caea4..6b84ca1ebda86 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -726,6 +726,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
       .Case("sha3", HasSHA3)
       .Cases("aes", "pmull", HasAES)
       .Cases("fp16", "fullfp16", HasFullFP16)
+      .Case("fp8", HasFpm8)
       .Case("dit", HasDIT)
       .Case("dpb", HasCCPP)
       .Case("dpb2", HasCCDP)
@@ -937,6 +938,9 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       FPU |= NeonMode;
       HasSM4 = true;
     }
+    if (Feature == "+fp8") {
+      HasFpm8 = true;
+    }
     if (Feature == "+strict-align")
       HasUnalignedAccess = false;
 
@@ -1209,6 +1213,8 @@ bool AArch64TargetInfo::hasBFloat16Type() const {
   return true;
 }
 
+bool AArch64TargetInfo::hasFpm8Type() 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 22d7c420d5510..6a0f595c9996a 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 HasFpm8 = false;
   bool HasBFloat16 = false;
   bool HasSVE2 = false;
   bool HasSVE2AES = false;
@@ -169,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
 
   bool hasBFloat16Type() const override;
 
+  bool hasFpm8Type() const override;
+
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 
   bool isCLZForZeroUndef() const override;
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 511e1fd4016d7..484fcfd6b16ff 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6229,7 +6229,8 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
   switch (TypeFlags.getEltType()) {
   case NeonTypeFlags::Int8:
   case NeonTypeFlags::Poly8:
-    return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
+  case NeonTypeFlags::Fpm8:
+    return llvm::FixedVectorType::get(CGF->Fpm8Ty, V1Ty ? 1 : (8 << IsQuad));
   case NeonTypeFlags::Int16:
   case NeonTypeFlags::Poly16:
     return llvm::FixedVectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 572ba84d22ef5..6d448d31950b7 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -868,6 +868,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
 
   case BuiltinType::UChar:
   case BuiltinType::Char_U:
+  case BuiltinType::Fpm8:
     Encoding = llvm::dwarf::DW_ATE_unsigned_char;
     break;
   case BuiltinType::Char_S:
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index dd4a665ebc78b..6ace7ea48da68 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -351,6 +351,7 @@ CodeGenModule::CodeGenModule(ASTContext &C,
   Int16Ty = llvm::Type::getInt16Ty(LLVMContext);
   Int32Ty = llvm::Type::getInt32Ty(LLVMContext);
   Int64Ty = llvm::Type::getInt64Ty(LLVMContext);
+  Fpm8Ty = llvm::Type::getInt8Ty(LLVMContext);
   HalfTy = llvm::Type::getHalfTy(LLVMContext);
   BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
   FloatTy = llvm::Type::getFloatTy(LLVMContext);
diff --git a/clang/lib/CodeGen/CodeGenTypeCache.h b/clang/lib/CodeGen/CodeGenTypeCache.h
index e273ebe3b060f..a24d1234cc99e 100644
--- a/clang/lib/CodeGen/CodeGenTypeCache.h
+++ b/clang/lib/CodeGen/CodeGenTypeCache.h
@@ -38,6 +38,9 @@ struct CodeGenTypeCache {
   /// half, bfloat, float, double
   llvm::Type *HalfTy, *BFloatTy, *FloatTy, *DoubleTy;
 
+  /// fpm8 from FP8 is an alias for 8bits data
+  llvm::IntegerType *Fpm8Ty;
+
   /// int
   llvm::IntegerType *IntTy;
 
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 8ae3c1c38b3e5..e3c6cb53f9d15 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3331,7 +3331,6 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
     case BuiltinType::Float:
     case BuiltinType::Double:
     case BuiltinType::LongDouble:
-    case BuiltinType::Fpm8:
     case BuiltinType::Float16:
     case BuiltinType::Float128:
     case BuiltinType::Ibm128:
@@ -3388,6 +3387,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
     case BuiltinType::SatUFract:
     case BuiltinType::SatULongFract:
     case BuiltinType::BFloat16:
+    case BuiltinType::Fpm8:
       return false;
 
     case BuiltinType::Dependent:
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index 281d534152054..22e4506910dc6 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -321,6 +321,7 @@ static unsigned RFT(unsigned t, bool shift = false, bool ForceQuad = false) {
   switch (Type.getEltType()) {
   case NeonTypeFlags::Int8:
   case NeonTypeFlags::Poly8:
+  case NeonTypeFlags::Fpm8:
     return shift ? 7 : (8 << IsQuad) - 1;
   case NeonTypeFlags::Int16:
   case NeonTypeFlags::Poly16:
@@ -385,6 +386,8 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context,
     return Context.DoubleTy;
   case NeonTypeFlags::BFloat16:
     return Context.BFloat16Ty;
+  case NeonTypeFlags::Fpm8:
+    return Context.Fpm8Ty;
   }
   llvm_unreachable("Invalid NeonTypeFlag!");
 }
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index f03dcf05411df..04df8f49d70ec 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -3199,6 +3199,13 @@ void CastOperation::CheckCStyleCast() {
     }
   }
 
+  if ((DestType->isFpm8Type() && !SrcType->isFpm8Type()) ||
+      (!DestType->isFpm8Type() && SrcType->isFpm8Type())) {
+    Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_fpm8_cast)
+        << SrcType << DestType << SrcExpr.get()->getSourceRange();
+    SrcExpr = ExprError();
+    return;
+  }
   // ARC imposes extra restrictions on casts.
   if (Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers()) {
     checkObjCConversion(CheckedConversionKind::CStyleCast);
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 453af8f28f946..5b1608f6b58d3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8512,6 +8512,12 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
     return QualType();
   }
 
+  if (LHSTy->isFpm8Type() || RHSTy->isFpm8Type()) {
+    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/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 89c523990ce52..26ee0b7fd0ca2 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1135,6 +1135,8 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     Result = Context.BFloat16Ty;
     break;
   case DeclSpec::TST_Fpm8:
+    if (!S.Context.getTargetInfo().hasFpm8Type())
+      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__fpm8";
     Result = Context.Fpm8Ty;
     break;
   case DeclSpec::TST_float:   Result = Context.FloatTy; break;
@@ -8052,7 +8054,8 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) {
          BTy->getKind() == BuiltinType::ULongLong ||
          BTy->getKind() == BuiltinType::Float ||
          BTy->getKind() == BuiltinType::Half ||
-         BTy->getKind() == BuiltinType::BFloat16;
+         BTy->getKind() == BuiltinType::BFloat16 ||
+         BTy->getKind() == BuiltinType::Fpm8;
 }
 
 static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index a2c322087fd1e..ad82ee65d5f64 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7197,6 +7197,9 @@ QualType ASTReader::GetType(TypeID ID) {
     case PREDEF_TYPE_INT128_ID:
       T = Context.Int128Ty;
       break;
+    case PREDEF_TYPE_FPM8_ID:
+      T = Context.Fpm8Ty;
+      break;
     case PREDEF_TYPE_BFLOAT16_ID:
       T = Context.BFloat16Ty;
       break;
diff --git a/clang/test/Sema/arm-fp8-forbidden-ops.c b/clang/test/Sema/arm-fp8-forbidden-ops.c
new file mode 100644
index 0000000000000..7d8c1075abd5b
--- /dev/null
+++ b/clang/test/Sema/arm-fp8-forbidden-ops.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64 -target-feature +fp8 %s
+
+__fpm8 test_cast_from_float(unsigned in) {
+  return (__fpm8)in; // expected-error {{cannot cast 'unsigned int' to '__fpm8'; types are not compatible}}
+}
+
+unsigned test_cast_to_int(__fpm8 in) {
+  return (unsigned)in; // expected-error {{cannot cast '__fpm8' to 'unsigned int'; types are not compatible}}
+}
diff --git a/clang/test/Sema/arm-fp8-forbidden-ops.cpp b/clang/test/Sema/arm-fp8-forbidden-ops.cpp
new file mode 100644
index 0000000000000..3acc9cd15c23d
--- /dev/null
+++ b/clang/test/Sema/arm-fp8-forbidden-ops.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64 -target-feature +fp8 %s
+
+__fpm8 test_static_cast_from_char(char in) {
+  return static_cast<__fpm8>(in); // expected-error {{static_cast from 'char' to '__fpm8' is not allowed}}
+}
+
+char test_static_cast_to_char(__fpm8 in) {
+  return static_cast<char>(in); // expected-error {{static_cast from '__fpm8' to 'char' is not allowed}}
+}
diff --git a/clang/test/Sema/arm-fpm8.cpp b/clang/test/Sema/arm-fpm8.cpp
new file mode 100644
index 0000000000000..e3c22c7f49fc4
--- /dev/null
+++ b/clang/test/Sema/arm-fpm8.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=scalar,neon -std=c++11 \
+// RUN:   -triple aarch64 -target-cpu cortex-a75 \
+// RUN:   -target-feature +fp8 -Wno-unused %s
+
+// REQUIRES: aarch64-registered-target
+
+void test(bool b) {
+  __fpm8 fpm8;
+
+  fpm8 + fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
+  fpm8 - fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
+  fpm8 * fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
+  fpm8 / fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
+  ++fpm8;       // scalar-error {{cannot increment value of type '__fpm8'}}
+  --fpm8;       // scalar-error {{cannot decrement value of type '__fpm8'}}
+
+  char u8;
+
+  fpm8 + u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
+  u8 + fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
+  fpm8 - u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
+  u8 - fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
+  fpm8 * u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
+  u8 * fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
+  fpm8 / u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
+  u8 / fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
+  fpm8 = u8;   // scalar-error {{assigning to '__fpm8' from incompatible type 'char'}}
+  u8 = fpm8;   // scalar-error {{assigning to 'char' from incompatible type '__fpm8'}}
+  fpm8 + (b ? u8 : fpm8);  // scalar-error {{incompatible operand types ('char' and '__fpm8')}}
+}
+

>From 1fc6bf3a2edcb08962906e34d292afd3066c58a1 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Fri, 19 Jul 2024 14:44:33 +0000
Subject: [PATCH 4/5] Add REQUIRES in clang test for fpm8

---
 clang/test/AST/{fpm8_opaque.cpp => arm-fpm8.cpp}       |  5 ++++-
 clang/test/CodeGen/{fpm8_opaque.c => arm-fpm8.c}       |  4 +++-
 clang/test/Sema/arm-fp8-forbidden-ops.cpp              |  9 ---------
 .../test/Sema/{arm-fp8-forbidden-ops.c => arm-fpm8.c}  |  4 +++-
 clang/test/Sema/arm-fpm8.cpp                           | 10 +++++++---
 5 files changed, 17 insertions(+), 15 deletions(-)
 rename clang/test/AST/{fpm8_opaque.cpp => arm-fpm8.cpp} (94%)
 rename clang/test/CodeGen/{fpm8_opaque.c => arm-fpm8.c} (86%)
 delete mode 100644 clang/test/Sema/arm-fp8-forbidden-ops.cpp
 rename clang/test/Sema/{arm-fp8-forbidden-ops.c => arm-fpm8.c} (69%)

diff --git a/clang/test/AST/fpm8_opaque.cpp b/clang/test/AST/arm-fpm8.cpp
similarity index 94%
rename from clang/test/AST/fpm8_opaque.cpp
rename to clang/test/AST/arm-fpm8.cpp
index 3aeb3159ddc6a..72d61f123e79c 100644
--- a/clang/test/AST/fpm8_opaque.cpp
+++ b/clang/test/AST/arm-fpm8.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace
+// 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 __fpm8 can appear. */
 
diff --git a/clang/test/CodeGen/fpm8_opaque.c b/clang/test/CodeGen/arm-fpm8.c
similarity index 86%
rename from clang/test/CodeGen/fpm8_opaque.c
rename to clang/test/CodeGen/arm-fpm8.c
index 19b5128b8eff9..9a83323b2e412 100644
--- a/clang/test/CodeGen/fpm8_opaque.c
+++ b/clang/test/CodeGen/arm-fpm8.c
@@ -1,5 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
-// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// 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 noundef [[FPM8:%.*]]) #[[ATTR0:[0-9]+]] {
diff --git a/clang/test/Sema/arm-fp8-forbidden-ops.cpp b/clang/test/Sema/arm-fp8-forbidden-ops.cpp
deleted file mode 100644
index 3acc9cd15c23d..0000000000000
--- a/clang/test/Sema/arm-fp8-forbidden-ops.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64 -target-feature +fp8 %s
-
-__fpm8 test_static_cast_from_char(char in) {
-  return static_cast<__fpm8>(in); // expected-error {{static_cast from 'char' to '__fpm8' is not allowed}}
-}
-
-char test_static_cast_to_char(__fpm8 in) {
-  return static_cast<char>(in); // expected-error {{static_cast from '__fpm8' to 'char' is not allowed}}
-}
diff --git a/clang/test/Sema/arm-fp8-forbidden-ops.c b/clang/test/Sema/arm-fpm8.c
similarity index 69%
rename from clang/test/Sema/arm-fp8-forbidden-ops.c
rename to clang/test/Sema/arm-fpm8.c
index 7d8c1075abd5b..a3afa9b9e8662 100644
--- a/clang/test/Sema/arm-fp8-forbidden-ops.c
+++ b/clang/test/Sema/arm-fpm8.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64 -target-feature +fp8 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s
+
+// REQUIRES: aarch64-registered-target
 
 __fpm8 test_cast_from_float(unsigned in) {
   return (__fpm8)in; // expected-error {{cannot cast 'unsigned int' to '__fpm8'; types are not compatible}}
diff --git a/clang/test/Sema/arm-fpm8.cpp b/clang/test/Sema/arm-fpm8.cpp
index e3c22c7f49fc4..bb92596f750c5 100644
--- a/clang/test/Sema/arm-fpm8.cpp
+++ b/clang/test/Sema/arm-fpm8.cpp
@@ -1,9 +1,13 @@
-// RUN: %clang_cc1 -fsyntax-only -verify=scalar,neon -std=c++11 \
-// RUN:   -triple aarch64 -target-cpu cortex-a75 \
-// RUN:   -target-feature +fp8 -Wno-unused %s
+// RUN: %clang_cc1 -fsyntax-only -verify=scalar -triple aarch64-arm-none-eabi -target-feature -fp8  %s
 
 // REQUIRES: aarch64-registered-target
+__fpm8 test_static_cast_from_char(char in) {
+  return static_cast<__fpm8>(in); // scalar-error {{static_cast from 'char' to '__fpm8' is not allowed}}
+}
 
+char test_static_cast_to_char(__fpm8 in) {
+  return static_cast<char>(in); // scalar-error {{static_cast from '__fpm8' to 'char' is not allowed}}
+}
 void test(bool b) {
   __fpm8 fpm8;
 

>From c622d4473898f2f61a22788205c2a4ff49df58a0 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Wed, 31 Jul 2024 09:44:24 +0000
Subject: [PATCH 5/5] Rename 8-bit fp from fmp8 to mfloat8

 `mfloat8_t`     | equivalent to `__mfp8` |

According to ACLE[1] proposal
[1] https://github.com/ARM-software/acle/pull/323
---
 clang/include/clang/AST/ASTContext.h          |  2 +-
 clang/include/clang/AST/BuiltinTypes.def      |  2 +-
 clang/include/clang/AST/Type.h                |  6 +-
 .../clang/Basic/DiagnosticSemaKinds.td        |  2 +-
 clang/include/clang/Basic/Specifiers.h        |  2 +-
 clang/include/clang/Basic/TargetBuiltins.h    |  2 +-
 clang/include/clang/Basic/TargetInfo.h        |  4 +-
 clang/include/clang/Basic/TokenKinds.def      |  2 +-
 clang/include/clang/Sema/DeclSpec.h           |  2 +-
 .../include/clang/Serialization/ASTBitCodes.h |  3 +-
 clang/lib/AST/ASTContext.cpp                  |  8 +-
 clang/lib/AST/ItaniumMangle.cpp               | 10 +-
 clang/lib/AST/PrintfFormatString.cpp          |  2 +-
 clang/lib/AST/Type.cpp                        |  4 +-
 clang/lib/AST/TypeLoc.cpp                     |  2 +-
 clang/lib/Basic/TargetInfo.cpp                |  2 +-
 clang/lib/Basic/Targets/AArch64.cpp           |  6 +-
 clang/lib/Basic/Targets/AArch64.h             |  4 +-
 clang/lib/CodeGen/CGBuiltin.cpp               |  3 +-
 clang/lib/CodeGen/CGDebugInfo.cpp             |  2 +-
 clang/lib/CodeGen/CodeGenModule.cpp           |  2 +-
 clang/lib/CodeGen/CodeGenTypeCache.h          |  2 +-
 clang/lib/CodeGen/CodeGenTypes.cpp            |  2 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp           |  2 +-
 clang/lib/Index/USRGeneration.cpp             |  2 +-
 clang/lib/Lex/Lexer.cpp                       |  2 +-
 clang/lib/Parse/ParseDecl.cpp                 | 12 +--
 clang/lib/Parse/ParseExpr.cpp                 |  2 +-
 clang/lib/Parse/ParseExprCXX.cpp              |  4 +-
 clang/lib/Parse/ParseTentative.cpp            |  4 +-
 clang/lib/Sema/DeclSpec.cpp                   |  5 +-
 clang/lib/Sema/SemaARM.cpp                    |  3 -
 clang/lib/Sema/SemaCast.cpp                   |  6 +-
 clang/lib/Sema/SemaExpr.cpp                   |  2 +-
 clang/lib/Sema/SemaTemplateVariadic.cpp       |  2 +-
 clang/lib/Sema/SemaType.cpp                   | 10 +-
 clang/lib/Serialization/ASTCommon.cpp         |  4 +-
 clang/lib/Serialization/ASTReader.cpp         |  4 +-
 clang/test/AST/arm-fpm8.cpp                   | 94 -------------------
 clang/test/AST/arm-mfp8.cpp                   | 94 +++++++++++++++++++
 clang/test/CodeGen/{arm-fpm8.c => arm-mfp8.c} | 14 +--
 clang/test/Sema/arm-fpm8.c                    | 11 ---
 clang/test/Sema/arm-fpm8.cpp                  | 35 -------
 clang/test/Sema/arm-mfp8.c                    | 11 +++
 clang/test/Sema/arm-mfp8.cpp                  | 35 +++++++
 45 files changed, 214 insertions(+), 220 deletions(-)
 delete mode 100644 clang/test/AST/arm-fpm8.cpp
 create mode 100644 clang/test/AST/arm-mfp8.cpp
 rename clang/test/CodeGen/{arm-fpm8.c => arm-mfp8.c} (71%)
 delete mode 100644 clang/test/Sema/arm-fpm8.c
 delete mode 100644 clang/test/Sema/arm-fpm8.cpp
 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/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 532ec05ab90a6..a5f558c735906 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1115,7 +1115,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
       SatUnsignedLongFractTy;
-  CanQualType Fpm8Ty;
+  CanQualType MFloat8Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def
index 0c1cccf4f73b8..3c49852e3f255 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -223,7 +223,7 @@ FLOATING_TYPE(Ibm128, Ibm128Ty)
 
 
 // '__fpm8'
-UNSIGNED_TYPE(Fpm8, Fpm8Ty)
+UNSIGNED_TYPE(MFloat8, MFloat8Ty)
 
 //===- Language-specific types --------------------------------------------===//
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 9f835b8459847..3073391e88cb7 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2492,7 +2492,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   bool isDoubleType() const;
   bool isBFloat16Type() const;
   bool isFloat128Type() const;
-  bool isFpm8Type() const;
+  bool isMFloat8Type() const;
   bool isIbm128Type() const;
   bool isRealType() const;         // C99 6.2.5p17 (real floating + integer)
   bool isArithmeticType() const;   // C99 6.2.5p18 (integer + floating)
@@ -7945,8 +7945,8 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
-inline bool Type::isFpm8Type() const {
-  return isSpecificBuiltinType(BuiltinType::Fpm8);
+inline bool Type::isMFloat8Type() const {
+  return isSpecificBuiltinType(BuiltinType::MFloat8);
 }
 
 inline bool Type::isFloat128Type() const {
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ab16c1fa1a162..af41f65c5e736 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7858,7 +7858,7 @@ 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_fpm8_cast : Error<
+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">;
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index b4db94d273949..b5e8dacf63a5c 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_Fpm8,
+    TST_MFloat8,
     TST_float,
     TST_double,
     TST_float128,
diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index b456b75943af3..6120f54236626 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -199,7 +199,7 @@ namespace clang {
       Float32,
       Float64,
       BFloat16,
-      Fpm8
+      MFloat8
     };
 
     NeonTypeFlags(unsigned F) : Flags(F) {}
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index de5fd0fc09b0a..7671c40d1e81b 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -234,7 +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 HasFpm8;
+  bool HasMFloat8;
   bool HasIbm128;
   bool HasLongDouble;
   bool HasFPReturn;
@@ -702,7 +702,7 @@ class TargetInfo : public TransferrableTargetInfo,
   }
 
   /// Determine whether the _fpm8 type is supported on this target.
-  virtual bool hasFpm8Type() const { return HasFpm8; }
+  virtual bool hasMFloat8Type() const { return HasMFloat8; }
 
   /// Determine whether the BFloat type is fully supported on this target, i.e
   /// arithemtic operations.
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index c08cf760962f3..9da230fc4f1a3 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -655,7 +655,7 @@ KEYWORD(__bool                      , KEYALTIVEC|KEYZVECTOR)
 // ARM NEON extensions.
 ALIAS("__fp16", half                , KEYALL)
 KEYWORD(__bf16                      , KEYALL)
-KEYWORD(__fpm8                      , 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 097cb8eb642ac..d054320ba7adb 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -287,7 +287,7 @@ class DeclSpec {
   static const TST TST_bitint = clang::TST_bitint;
   static const TST TST_half = clang::TST_half;
   static const TST TST_BFloat16 = clang::TST_BFloat16;
-  static const TST TST_Fpm8 = clang::TST_Fpm8;
+  static const TST TST_MFloat8 = clang::TST_MFloat8;
   static const TST TST_float = clang::TST_float;
   static const TST TST_double = clang::TST_double;
   static const TST TST_float16 = clang::TST_Float16;
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index b2853c5e787d6..333aa174567fc 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1078,7 +1078,8 @@ enum PredefinedTypeIDs {
   /// \brief The '__ibm128' type
   PREDEF_TYPE_IBM128_ID = 74,
 
-  PREDEF_TYPE_FPM8_ID = 75,
+  /// \bried The '__mfp8' type
+  PREDEF_TYPE_MFLOAT8_ID = 75,
 
 /// OpenCL image types with auto numeration
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 9480ff8d4bae2..6cf7b21115a5b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1408,7 +1408,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
   // half type (OpenCL 6.1.1.1) / ARM NEON __fp16
   InitBuiltinType(HalfTy, BuiltinType::Half);
 
-  InitBuiltinType(Fpm8Ty, BuiltinType::Fpm8);
+  InitBuiltinType(MFloat8Ty, BuiltinType::MFloat8);
 
   InitBuiltinType(BFloat16Ty, BuiltinType::BFloat16);
 
@@ -1979,7 +1979,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
       Width = Target->getBoolWidth();
       Align = Target->getBoolAlign();
       break;
-    case BuiltinType::Fpm8:
+    case BuiltinType::MFloat8:
     case BuiltinType::Char_S:
     case BuiltinType::Char_U:
     case BuiltinType::UChar:
@@ -8106,7 +8106,7 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
     switch (kind) {
     case BuiltinType::Void:       return 'v';
     case BuiltinType::Bool:       return 'B';
-    case BuiltinType::Fpm8:
+    case BuiltinType::MFloat8:
     case BuiltinType::Char8:
     case BuiltinType::Char_U:
     case BuiltinType::UChar:      return 'C';
@@ -11471,7 +11471,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
       Type = Context.CharTy;
     break;
   case 'j':
-    Type = Context.Fpm8Ty;
+    Type = Context.MFloat8Ty;
     break;
   case 'b': // boolean
     assert(HowLong == 0 && !Signed && !Unsigned && "Bad modifiers for 'b'!");
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 76cb1e7556680..fe3234ef852fb 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3181,7 +3181,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
   case BuiltinType::SChar:
     Out << 'a';
     break;
-  case BuiltinType::Fpm8:
+  case BuiltinType::MFloat8:
   case BuiltinType::WChar_S:
   case BuiltinType::WChar_U:
     Out << 'w';
@@ -3800,9 +3800,7 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
     case BuiltinType::Float:     EltName = "float32_t"; break;
     case BuiltinType::Half:      EltName = "float16_t"; break;
     case BuiltinType::BFloat16:  EltName = "bfloat16_t"; break;
-    case BuiltinType::Fpm8:
-      EltName = "fmp8_t";
-      break;
+    case BuiltinType::MFloat8:   EltName = "mfloat8_t"; break;
     default:
       llvm_unreachable("unexpected Neon vector element type");
     }
@@ -3856,8 +3854,8 @@ static StringRef mangleAArch64VectorBase(const BuiltinType *EltType) {
     return "Float64";
   case BuiltinType::BFloat16:
     return "Bfloat16";
-  case BuiltinType::Fpm8:
-    return "Fpm8_t";
+  case BuiltinType::MFloat8:
+    return "MFloat8_t";
   default:
     llvm_unreachable("Unexpected vector element base type");
   }
diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp
index 2d4967f82f4d3..b0180f7554fa1 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/PrintfFormatString.cpp
@@ -817,7 +817,7 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt,
   case BuiltinType::Char32:
   case BuiltinType::UInt128:
   case BuiltinType::Int128:
-  case BuiltinType::Fpm8:
+  case BuiltinType::MFloat8:
   case BuiltinType::Half:
   case BuiltinType::BFloat16:
   case BuiltinType::Float16:
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index f629ae6d7b016..fdd7872580dc5 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3372,8 +3372,8 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
     return "unsigned __int128";
   case Half:
     return Policy.Half ? "half" : "__fp16";
-  case Fpm8:
-    return "__fpm8";
+  case MFloat8:
+    return "__mfp8";
   case BFloat16:
     return "__bf16";
   case Float:
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index 8df92d3921c44..531cd4e729332 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -361,7 +361,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
   case BuiltinType::Long:
   case BuiltinType::LongLong:
   case BuiltinType::Int128:
-  case BuiltinType::Fpm8:
+  case BuiltinType::MFloat8:
   case BuiltinType::Half:
   case BuiltinType::Float:
   case BuiltinType::Double:
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index c18a80384d518..040b49bb115b8 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -60,7 +60,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
   NoAsmVariants = false;
   HasLegalHalfType = false;
   HalfArgsAndReturns = false;
-  HasFpm8 = 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 6b84ca1ebda86..ef1b05d91f373 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -726,7 +726,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
       .Case("sha3", HasSHA3)
       .Cases("aes", "pmull", HasAES)
       .Cases("fp16", "fullfp16", HasFullFP16)
-      .Case("fp8", HasFpm8)
+      .Case("fp8", HasMFloat8)
       .Case("dit", HasDIT)
       .Case("dpb", HasCCPP)
       .Case("dpb2", HasCCDP)
@@ -939,7 +939,7 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       HasSM4 = true;
     }
     if (Feature == "+fp8") {
-      HasFpm8 = true;
+      HasMFloat8 = true;
     }
     if (Feature == "+strict-align")
       HasUnalignedAccess = false;
@@ -1213,7 +1213,7 @@ bool AArch64TargetInfo::hasBFloat16Type() const {
   return true;
 }
 
-bool AArch64TargetInfo::hasFpm8Type() const { return true; }
+bool AArch64TargetInfo::hasMFloat8Type() const { return true; }
 
 TargetInfo::CallingConvCheckResult
 AArch64TargetInfo::checkCallingConvention(CallingConv CC) const {
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index 6a0f595c9996a..fa3ec2be57d5f 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -47,7 +47,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
   bool HasLS64 = false;
   bool HasRandGen = false;
   bool HasMatMul = false;
-  bool HasFpm8 = false;
+  bool HasMFloat8 = false;
   bool HasBFloat16 = false;
   bool HasSVE2 = false;
   bool HasSVE2AES = false;
@@ -170,7 +170,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
 
   bool hasBFloat16Type() const override;
 
-  bool hasFpm8Type() const override;
+  bool hasMFloat8Type() const override;
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 484fcfd6b16ff..511e1fd4016d7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6229,8 +6229,7 @@ static llvm::FixedVectorType *GetNeonType(CodeGenFunction *CGF,
   switch (TypeFlags.getEltType()) {
   case NeonTypeFlags::Int8:
   case NeonTypeFlags::Poly8:
-  case NeonTypeFlags::Fpm8:
-    return llvm::FixedVectorType::get(CGF->Fpm8Ty, V1Ty ? 1 : (8 << IsQuad));
+    return llvm::FixedVectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
   case NeonTypeFlags::Int16:
   case NeonTypeFlags::Poly16:
     return llvm::FixedVectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 6d448d31950b7..c74bdfa91eb94 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -868,7 +868,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
 
   case BuiltinType::UChar:
   case BuiltinType::Char_U:
-  case BuiltinType::Fpm8:
+  case BuiltinType::MFloat8:
     Encoding = llvm::dwarf::DW_ATE_unsigned_char;
     break;
   case BuiltinType::Char_S:
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 6ace7ea48da68..327d926e6d0ac 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -351,7 +351,7 @@ CodeGenModule::CodeGenModule(ASTContext &C,
   Int16Ty = llvm::Type::getInt16Ty(LLVMContext);
   Int32Ty = llvm::Type::getInt32Ty(LLVMContext);
   Int64Ty = llvm::Type::getInt64Ty(LLVMContext);
-  Fpm8Ty = llvm::Type::getInt8Ty(LLVMContext);
+  MFloat8Ty = llvm::Type::getInt8Ty(LLVMContext);
   HalfTy = llvm::Type::getHalfTy(LLVMContext);
   BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
   FloatTy = llvm::Type::getFloatTy(LLVMContext);
diff --git a/clang/lib/CodeGen/CodeGenTypeCache.h b/clang/lib/CodeGen/CodeGenTypeCache.h
index a24d1234cc99e..7551fb996827d 100644
--- a/clang/lib/CodeGen/CodeGenTypeCache.h
+++ b/clang/lib/CodeGen/CodeGenTypeCache.h
@@ -39,7 +39,7 @@ struct CodeGenTypeCache {
   llvm::Type *HalfTy, *BFloatTy, *FloatTy, *DoubleTy;
 
   /// fpm8 from FP8 is an alias for 8bits data
-  llvm::IntegerType *Fpm8Ty;
+  llvm::IntegerType *MFloat8Ty;
 
   /// int
   llvm::IntegerType *IntTy;
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 626525f66e3e7..c6db0a62e56ba 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -419,7 +419,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
                                     Context.getFloatTypeSemantics(T),
                                     /* UseNativeHalf = */ false);
       break;
-    case BuiltinType::Fpm8:
+    case BuiltinType::MFloat8:
       ResultType = llvm::Type::getInt8Ty(getLLVMContext());
       break;
     case BuiltinType::NullPtr:
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index e3c6cb53f9d15..9ed26119cfdf6 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3387,7 +3387,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
     case BuiltinType::SatUFract:
     case BuiltinType::SatULongFract:
     case BuiltinType::BFloat16:
-    case BuiltinType::Fpm8:
+    case BuiltinType::MFloat8:
       return false;
 
     case BuiltinType::Dependent:
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index 553b788ee0e75..1198714cd73f2 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -691,7 +691,7 @@ void USRGenerator::VisitType(QualType T) {
           Out << 'v'; break;
         case BuiltinType::Bool:
           Out << 'b'; break;
-        case BuiltinType::Fpm8:
+        case BuiltinType::MFloat8:
         case BuiltinType::UChar:
           Out << 'c'; break;
         case BuiltinType::Char8:
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 7806ea9d8604f..32ccd0d410a7b 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -97,7 +97,7 @@ bool Token::isSimpleTypeSpecifier(const LangOptions &LangOpts) const {
   case tok::kw___bf16:
   case tok::kw__Float16:
   case tok::kw___float128:
-  case tok::kw___fpm8:
+  case tok::kw___mfp8:
   case tok::kw___ibm128:
   case tok::kw_wchar_t:
   case tok::kw_bool:
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 25838d65f3e51..e7963444ff90a 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4477,9 +4477,9 @@ void Parser::ParseDeclarationSpecifiers(
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec,
                                      DiagID, Policy);
       break;
-    case tok::kw___fpm8:
-      isInvalid =
-          DS.SetTypeSpecType(DeclSpec::TST_Fpm8, Loc, PrevSpec, DiagID, Policy);
+    case tok::kw___mfp8:
+      isInvalid = DS.SetTypeSpecType(DeclSpec::TST_MFloat8, Loc, PrevSpec,
+                                     DiagID, Policy);
       break;
     case tok::kw_half:
       isInvalid = DS.SetTypeSpecType(DeclSpec::TST_half, Loc, PrevSpec,
@@ -5756,7 +5756,7 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
   case tok::kw__ExtInt:
   case tok::kw__BitInt:
   case tok::kw___bf16:
-  case tok::kw___fpm8:
+  case tok::kw___mfp8:
   case tok::kw_half:
   case tok::kw_float:
   case tok::kw_double:
@@ -5840,7 +5840,7 @@ bool Parser::isTypeSpecifierQualifier() {
   case tok::kw_int:
   case tok::kw__ExtInt:
   case tok::kw__BitInt:
-  case tok::kw___fpm8:
+  case tok::kw___mfp8:
   case tok::kw_half:
   case tok::kw___bf16:
   case tok::kw_float:
@@ -6063,7 +6063,7 @@ bool Parser::isDeclarationSpecifier(
   case tok::kw_int:
   case tok::kw__ExtInt:
   case tok::kw__BitInt:
-  case tok::kw___fpm8:
+  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 9103275aa9772..25c577ab6f871 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1594,7 +1594,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
   case tok::kw__BitInt:
   case tok::kw_signed:
   case tok::kw_unsigned:
-  case tok::kw___fpm8:
+  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 72c4782cb53b3..27b03cb7afd21 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -2405,8 +2405,8 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
   case tok::kw___int128:
     DS.SetTypeSpecType(DeclSpec::TST_int128, Loc, PrevSpec, DiagID, Policy);
     break;
-  case tok::kw___fpm8:
-    DS.SetTypeSpecType(DeclSpec::TST_Fpm8, Loc, PrevSpec, DiagID, Policy);
+  case tok::kw___mfp8:
+    DS.SetTypeSpecType(DeclSpec::TST_MFloat8, Loc, PrevSpec, DiagID, Policy);
     break;
   case tok::kw___bf16:
     DS.SetTypeSpecType(DeclSpec::TST_BFloat16, Loc, PrevSpec, DiagID, Policy);
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 695bbbba9433d..bfc64cd8cd04d 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1779,7 +1779,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
   case tok::kw_short:
   case tok::kw_int:
   case tok::kw_long:
-  case tok::kw___fpm8:
+  case tok::kw___mfp8:
   case tok::kw___int64:
   case tok::kw___int128:
   case tok::kw_signed:
@@ -1908,7 +1908,7 @@ bool Parser::isCXXDeclarationSpecifierAType() {
   case tok::kw_long:
   case tok::kw___int64:
   case tok::kw___int128:
-  case tok::kw___fpm8:
+  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 168b98e90e6ec..3af64ea55e175 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -358,7 +358,7 @@ bool Declarator::isDeclarationOfFunction() const {
     case TST_Fract:
     case TST_Float16:
     case TST_float128:
-    case TST_Fpm8:
+    case TST_MFloat8:
     case TST_ibm128:
     case TST_enum:
     case TST_error:
@@ -576,8 +576,7 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
   case DeclSpec::TST_fract:       return "_Fract";
   case DeclSpec::TST_float16:     return "_Float16";
   case DeclSpec::TST_float128:    return "__float128";
-  case DeclSpec::TST_Fpm8:
-    return "fpm8_t";
+  case DeclSpec::TST_MFloat8:     return "__mfp8";
   case DeclSpec::TST_ibm128:      return "__ibm128";
   case DeclSpec::TST_bool:        return Policy.Bool ? "bool" : "_Bool";
   case DeclSpec::TST_decimal32:   return "_Decimal32";
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index 22e4506910dc6..281d534152054 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -321,7 +321,6 @@ static unsigned RFT(unsigned t, bool shift = false, bool ForceQuad = false) {
   switch (Type.getEltType()) {
   case NeonTypeFlags::Int8:
   case NeonTypeFlags::Poly8:
-  case NeonTypeFlags::Fpm8:
     return shift ? 7 : (8 << IsQuad) - 1;
   case NeonTypeFlags::Int16:
   case NeonTypeFlags::Poly16:
@@ -386,8 +385,6 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context,
     return Context.DoubleTy;
   case NeonTypeFlags::BFloat16:
     return Context.BFloat16Ty;
-  case NeonTypeFlags::Fpm8:
-    return Context.Fpm8Ty;
   }
   llvm_unreachable("Invalid NeonTypeFlag!");
 }
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 04df8f49d70ec..7348a97dedb32 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -3199,9 +3199,9 @@ void CastOperation::CheckCStyleCast() {
     }
   }
 
-  if ((DestType->isFpm8Type() && !SrcType->isFpm8Type()) ||
-      (!DestType->isFpm8Type() && SrcType->isFpm8Type())) {
-    Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_fpm8_cast)
+  if ((DestType->isMFloat8Type() && !SrcType->isMFloat8Type()) ||
+      (!DestType->isMFloat8Type() && SrcType->isMFloat8Type())) {
+    Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_bad_mfloat8_cast)
         << SrcType << DestType << SrcExpr.get()->getSourceRange();
     SrcExpr = ExprError();
     return;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5b1608f6b58d3..9d22be0b9864c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8512,7 +8512,7 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
     return QualType();
   }
 
-  if (LHSTy->isFpm8Type() || RHSTy->isFpm8Type()) {
+  if (LHSTy->isMFloat8Type() || RHSTy->isMFloat8Type()) {
     Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
         << LHSTy << RHSTy << LHS.get()->getSourceRange()
         << RHS.get()->getSourceRange();
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index d7c4c04c130ef..c5fcf6bfd7cad 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -908,7 +908,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
   case TST_char32:
   case TST_int:
   case TST_int128:
-  case TST_Fpm8:
+  case TST_MFloat8:
   case TST_half:
   case TST_float:
   case TST_double:
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 26ee0b7fd0ca2..4938e568b4a6f 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1134,10 +1134,10 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
       S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__bf16";
     Result = Context.BFloat16Ty;
     break;
-  case DeclSpec::TST_Fpm8:
-    if (!S.Context.getTargetInfo().hasFpm8Type())
-      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__fpm8";
-    Result = Context.Fpm8Ty;
+  case DeclSpec::TST_MFloat8:
+    if (!S.Context.getTargetInfo().hasMFloat8Type())
+      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__mfp8";
+    Result = Context.MFloat8Ty;
     break;
   case DeclSpec::TST_float:   Result = Context.FloatTy; break;
   case DeclSpec::TST_double:
@@ -8055,7 +8055,7 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) {
          BTy->getKind() == BuiltinType::Float ||
          BTy->getKind() == BuiltinType::Half ||
          BTy->getKind() == BuiltinType::BFloat16 ||
-         BTy->getKind() == BuiltinType::Fpm8;
+         BTy->getKind() == BuiltinType::MFloat8;
 }
 
 static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp
index a01d57cc1fcab..3bc813b4f75d7 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -35,8 +35,8 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
   case BuiltinType::Char_U:
     ID = PREDEF_TYPE_CHAR_U_ID;
     break;
-  case BuiltinType::Fpm8:
-    ID = PREDEF_TYPE_FPM8_ID;
+  case BuiltinType::MFloat8:
+    ID = PREDEF_TYPE_MFLOAT8_ID;
     break;
   case BuiltinType::UChar:
     ID = PREDEF_TYPE_UCHAR_ID;
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index ad82ee65d5f64..a15d2f4dd107d 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7197,8 +7197,8 @@ QualType ASTReader::GetType(TypeID ID) {
     case PREDEF_TYPE_INT128_ID:
       T = Context.Int128Ty;
       break;
-    case PREDEF_TYPE_FPM8_ID:
-      T = Context.Fpm8Ty;
+    case PREDEF_TYPE_MFLOAT8_ID:
+      T = Context.MFloat8Ty;
       break;
     case PREDEF_TYPE_BFLOAT16_ID:
       T = Context.BFloat16Ty;
diff --git a/clang/test/AST/arm-fpm8.cpp b/clang/test/AST/arm-fpm8.cpp
deleted file mode 100644
index 72d61f123e79c..0000000000000
--- a/clang/test/AST/arm-fpm8.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -triple aarch64-arm-none-eabi -target-feature -fp8 -ast-dump %s | \
-// RUN:  FileCheck %s --strict-whitespace
-
-// REQUIRES: aarch64-registered-target || arm-registered-target
-
-/*  Various contexts where type __fpm8 can appear. */
-
-/*  Namespace */
-namespace {
-  __fpm8 f2n;
-  __fpm8 arr1n[10];
-}
-
-//CHECK:       |-NamespaceDecl {{.*}}
-//CHECK-NEXT:  | |-VarDecl {{.*}} f2n '__fpm8'
-//CHECK-NEXT:  | `-VarDecl {{.*}} arr1n '__fpm8[10]'
-
-  __fpm8 arr1[10];
-  //__fpm8 arr2n[] { 1, 3, 3 }; cannot initialize
-  
-  const __fpm8 func1n(const __fpm8 fpm8) {
-    // this should fail
-    __fpm8 f1n;
-    f1n  = fpm8;
-    return f1n;
-  }
-
-//CHECK:        |-VarDecl {{.*}} '__fpm8[10]'
-
-//CHECK:            | `-VarDecl {{.*}} f1n '__fpm8'
-//CHECK-NEXT:       |-BinaryOperator {{.*}} '__fpm8' lvalue '='
-//CHECK-NEXT:       | |-DeclRefExpr {{.*}} '__fpm8' lvalue Var {{.*}} 'f1n' '__fpm8'
-//CHECK-NEXT:       | `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
-//CHECK-NEXT:       |   `-DeclRefExpr {{.*}} 'const __fpm8' lvalue ParmVar {{.*}} 'fpm8' 'const __fpm8'
-//CHECK-NEXT:        `-ReturnStmt {{.*}}
-//CHECK-NEXT:         `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
-//CHECK-NEXT:           `-DeclRefExpr {{.*}} '__fpm8' lvalue Var {{.*}} 'f1n' '__fpm8'
-
-
-/* Class */
-
-class C1 {
-  __fpm8 f1c;
-  static const __fpm8 f2c;
-  volatile __fpm8 f3c;
-public:
-  C1(__fpm8 arg) : f1c(arg), f3c(arg) { }
-  __fpm8 func1c(__fpm8 arg ) {
-    return  arg;
-  }
-  static __fpm8 func2c(__fpm8 arg) {
-    return arg;
-  }
-};
-
-//CHECK:       | |-CXXRecordDecl {{.*}} referenced class C1
-//CHECK-NEXT:  | |-FieldDecl {{.*}} f1c '__fpm8'
-//CHECK-NEXT:  | |-VarDecl {{.*}} f2c 'const __fpm8' static
-//CHECK-NEXT:  | |-FieldDecl {{.*}} f3c 'volatile __fpm8'
-//CHECK-NEXT:  | |-AccessSpecDecl {{.*}}
-//CHECK-NEXT:  | |-CXXConstructorDecl {{.*}} C1 'void (__fpm8)' implicit-inline
-//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__fpm8'
-//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f1c' '__fpm8'
-//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
-//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}} 'arg' '__fpm8'
-//CHECK-NEXT:  | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __fpm8'
-//CHECK-NEXT:  | | | `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
-//CHECK-NEXT:  | | |   `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}} 'arg' '__fpm8'
-//CHECK-NEXT:  | | `-CompoundStmt {{.*}}
-//CHECK-NEXT:  | |-CXXMethodDecl {{.*}} func1c '__fpm8 (__fpm8)' implicit-inline
-//CHECK-NEXT:  | | |-ParmVarDecl {{.*}} arg '__fpm8'
-//CHECK-NEXT:  | | `-CompoundStmt {{.*}}
-//CHECK-NEXT:  | |   `-ReturnStmt {{.*}}
-//CHECK-NEXT:  | |     `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
-//CHECK-NEXT:  | |       `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}}8 'arg' '__fpm8'
-//CHECK-NEXT:  | `-CXXMethodDecl {{.*}} func2c '__fpm8 (__fpm8)' static implicit-inline
-//CHECK-NEXT:  |   |-ParmVarDecl {{.*}} arg '__fpm8'
-//CHECK-NEXT:  |   `-CompoundStmt {{.*}}
-//CHECK-NEXT:  |     `-ReturnStmt {{.*}}
-//CHECK-NEXT:  |       `-ImplicitCastExpr {{.*}} '__fpm8' <LValueToRValue>
-//CHECK-NEXT:  |         `-DeclRefExpr {{.*}} '__fpm8' lvalue ParmVar {{.*}} 'arg' '__fpm8'
-
-template <class C> struct S1 {
-  C mem1;
-};
-
-template <> struct S1<__fpm8> {
-  __fpm8 mem2;
-};
-
-//CHECK:       |-TemplateArgument type '__fpm8'
-//CHECK-NEXT:  | `-BuiltinType {{.*}} '__fpm8'
-//CHECK-NEXT:  |-CXXRecordDecl {{.*}} implicit struct S1
-//CHECK-NEXT:  `-FieldDecl {{.*}} mem2 '__fpm8'
diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp
new file mode 100644
index 0000000000000..d99b7cd062e30
--- /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-fpm8.c b/clang/test/CodeGen/arm-mfp8.c
similarity index 71%
rename from clang/test/CodeGen/arm-fpm8.c
rename to clang/test/CodeGen/arm-mfp8.c
index 9a83323b2e412..c32410d458519 100644
--- a/clang/test/CodeGen/arm-fpm8.c
+++ b/clang/test/CodeGen/arm-mfp8.c
@@ -4,21 +4,21 @@
 // REQUIRES: aarch64-registered-target
 
 // CHECK-LABEL: define dso_local i8 @func1n(
-// CHECK-SAME: i8 noundef [[FPM8:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-SAME: i8 noundef [[MFP8:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:    [[FPM8_ADDR:%.*]] = alloca i8, align 1
+// CHECK-NEXT:    [[MFP8_ADDR:%.*]] = alloca i8, align 1
 // CHECK-NEXT:    [[F1N:%.*]] = alloca [10 x i8], align 1
-// CHECK-NEXT:    store i8 [[FPM8]], ptr [[FPM8_ADDR]], align 1
-// CHECK-NEXT:    [[TMP0:%.*]] = load i8, ptr [[FPM8_ADDR]], 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]]
 //
-__fpm8 func1n(__fpm8 fpm8) {
-  __fpm8 f1n[10];
-  f1n[2] = fpm8;
+__mfp8 func1n(__mfp8 mfp8) {
+  __mfp8 f1n[10];
+  f1n[2] = mfp8;
   return f1n[2];
 }
 
diff --git a/clang/test/Sema/arm-fpm8.c b/clang/test/Sema/arm-fpm8.c
deleted file mode 100644
index a3afa9b9e8662..0000000000000
--- a/clang/test/Sema/arm-fpm8.c
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s
-
-// REQUIRES: aarch64-registered-target
-
-__fpm8 test_cast_from_float(unsigned in) {
-  return (__fpm8)in; // expected-error {{cannot cast 'unsigned int' to '__fpm8'; types are not compatible}}
-}
-
-unsigned test_cast_to_int(__fpm8 in) {
-  return (unsigned)in; // expected-error {{cannot cast '__fpm8' to 'unsigned int'; types are not compatible}}
-}
diff --git a/clang/test/Sema/arm-fpm8.cpp b/clang/test/Sema/arm-fpm8.cpp
deleted file mode 100644
index bb92596f750c5..0000000000000
--- a/clang/test/Sema/arm-fpm8.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify=scalar -triple aarch64-arm-none-eabi -target-feature -fp8  %s
-
-// REQUIRES: aarch64-registered-target
-__fpm8 test_static_cast_from_char(char in) {
-  return static_cast<__fpm8>(in); // scalar-error {{static_cast from 'char' to '__fpm8' is not allowed}}
-}
-
-char test_static_cast_to_char(__fpm8 in) {
-  return static_cast<char>(in); // scalar-error {{static_cast from '__fpm8' to 'char' is not allowed}}
-}
-void test(bool b) {
-  __fpm8 fpm8;
-
-  fpm8 + fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
-  fpm8 - fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
-  fpm8 * fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
-  fpm8 / fpm8;  // scalar-error {{invalid operands to binary expression ('__fpm8' and '__fpm8')}}
-  ++fpm8;       // scalar-error {{cannot increment value of type '__fpm8'}}
-  --fpm8;       // scalar-error {{cannot decrement value of type '__fpm8'}}
-
-  char u8;
-
-  fpm8 + u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
-  u8 + fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
-  fpm8 - u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
-  u8 - fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
-  fpm8 * u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
-  u8 * fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
-  fpm8 / u8;   // scalar-error {{invalid operands to binary expression ('__fpm8' and 'char')}}
-  u8 / fpm8;   // scalar-error {{invalid operands to binary expression ('char' and '__fpm8')}}
-  fpm8 = u8;   // scalar-error {{assigning to '__fpm8' from incompatible type 'char'}}
-  u8 = fpm8;   // scalar-error {{assigning to 'char' from incompatible type '__fpm8'}}
-  fpm8 + (b ? u8 : fpm8);  // scalar-error {{incompatible operand types ('char' and '__fpm8')}}
-}
-
diff --git a/clang/test/Sema/arm-mfp8.c b/clang/test/Sema/arm-mfp8.c
new file mode 100644
index 0000000000000..c1e74a18b647d
--- /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 0000000000000..d9e03dc0e3f0d
--- /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')}}
+}
+



More information about the cfe-commits mailing list