[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 5 05:13:19 PST 2024
https://github.com/CarolineConcatto created https://github.com/llvm/llvm-project/pull/114983
The scalar __mfp8 type has the wrong name and mangle name in AArch64SVEACLETypes.def
According to the ACLE[1] the name should be __mfp8, then mangle name __u6mfp8.
This patch fixes this problem by replacing
the Name __MFloat8_t by __mfp8
and
the Mangle Name __MFloat8_t by __u6mfp8
And we revert the incorrect typedef in NeonEmitter.
[1]https://github.com/ARM-software/acle
>From 3839546afb0136507e8220803389e1ef5571f1bf Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Tue, 5 Nov 2024 09:53:08 +0000
Subject: [PATCH] [Clang][AArch64]Fix Name and Mangle name for scalar fp8
The scalar __mfp8 type has the wrong name and mangle name in
AArch64SVEACLETypes.def
According to the ACLE[1] the name should be __mfp8, then mangle
name __u6mfp8.
This patch fixes this problem by replacing
the Name __MFloat8_t by __mfp8
and
the Mangle Name __MFloat8_t by __u6mfp8
And we revert the incorrect typedef in NeonEmitter.
[1]https://github.com/ARM-software/acle
---
.../clang/Basic/AArch64SVEACLETypes.def | 2 +-
clang/test/AST/arm-mfp8.cpp | 57 ++++++++--------
clang/test/CodeGen/aarch64-debug-types.c | 6 +-
clang/test/CodeGen/arm-mfp8.c | 2 +-
clang/test/Sema/arm-mfp8.c | 4 +-
clang/test/Sema/arm-mfp8.cpp | 65 ++++++++++---------
clang/utils/TableGen/NeonEmitter.cpp | 2 +-
7 files changed, 69 insertions(+), 69 deletions(-)
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 62f6087e962466..cec5ab19a01730 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -200,7 +200,7 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
-AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8_t", "__MFloat8_t", MFloat8, MFloat8Ty, 1, 8, 1)
+AARCH64_VECTOR_TYPE_MFLOAT("__mfp8", "__u6mfp8", MFloat8, MFloat8Ty, 1, 8, 1)
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1)
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1)
diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp
index 51bebba067eb9f..195c734fc753e5 100644
--- a/clang/test/AST/arm-mfp8.cpp
+++ b/clang/test/AST/arm-mfp8.cpp
@@ -5,7 +5,6 @@
/* Various contexts where type __mfp8 can appear. */
-#include<arm_neon.h>
/* Namespace */
namespace {
__mfp8 f2n;
@@ -13,7 +12,7 @@ namespace {
}
//CHECK: |-NamespaceDecl {{.*}}
-//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8':'__MFloat8_t'
+//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8'
//CHECK-NEXT: | `-VarDecl {{.*}} arr1n '__mfp8[10]'
@@ -24,14 +23,14 @@ namespace {
return f1n;
}
//CHECK: |-FunctionDecl {{.*}} func1n 'const __mfp8 (const __mfp8)'
-//CHECK: | `-VarDecl {{.*}} f1n '__mfp8':'__MFloat8_t'
-//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8':'__MFloat8_t' lvalue '='
-//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t'
-//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8':'const __MFloat8_t' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8':'const __MFloat8_t'
+//CHECK: | `-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':'__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t'
+//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
/* Class */
@@ -39,7 +38,7 @@ namespace {
class C1 {
__mfp8 f1c;
static const __mfp8 f2c;
- volatile __MFloat8_t f3c;
+ volatile __mfp8 f3c;
public:
C1(__mfp8 arg) : f1c(arg), f3c(arg) { }
__mfp8 func1c(__mfp8 arg ) {
@@ -51,31 +50,31 @@ class C1 {
};
//CHECK: | |-CXXRecordDecl {{.*}} referenced class C1
-//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8':'__MFloat8_t'
-//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8':'const __MFloat8_t' static
-//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __MFloat8_t'
+//CHECK-NEXT: | |-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':'__MFloat8_t'
-//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8':'__MFloat8_t'
-//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
-//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __MFloat8_t'
-//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
+//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':'__MFloat8_t'
+//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8'
//CHECK-NEXT: | | `-CompoundStmt {{.*}}
//CHECK-NEXT: | | `-ReturnStmt {{.*}}
-//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
+//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
//CHECK-NEXT: | `-CXXMethodDecl {{.*}} func2c '__mfp8 (__mfp8)' static implicit-inline
-//CHECK-NEXT: | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t'
+//CHECK-NEXT: | |-ParmVarDecl {{.*}} arg '__mfp8'
//CHECK-NEXT: | `-CompoundStmt {{.*}}
//CHECK-NEXT: | `-ReturnStmt {{.*}}
-//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
-//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
+//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
+//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
template <class C> struct S1 {
C mem1;
@@ -85,7 +84,7 @@ template <> struct S1<__mfp8> {
__mfp8 mem2;
};
-//CHECK: |-TemplateArgument type '__MFloat8_t'
-//CHECK-NEXT: | `-BuiltinType {{.*}} '__MFloat8_t'
+//CHECK: |-TemplateArgument type '__mfp8'
+//CHECK-NEXT: | `-BuiltinType {{.*}} '__mfp8'
//CHECK-NEXT: |-CXXRecordDecl {{.*}} implicit struct S1
-//CHECK-NEXT: `-FieldDecl {{.*}} mem2 '__mfp8':'__MFloat8_t'
+//CHECK-NEXT: `-FieldDecl {{.*}} mem2 '__mfp8'
diff --git a/clang/test/CodeGen/aarch64-debug-types.c b/clang/test/CodeGen/aarch64-debug-types.c
index f1ab74c5c31bdb..5352ec77f9d382 100644
--- a/clang/test/CodeGen/aarch64-debug-types.c
+++ b/clang/test/CodeGen/aarch64-debug-types.c
@@ -6,7 +6,7 @@
#include<arm_neon.h>
void test_locals(void) {
- // CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "__MFloat8_t", {{.*}}, baseType: ![[ELTTYU8:[0-9]+]]
- // CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "__MFloat8_t", size: 8, encoding: DW_ATE_unsigned_char)
- __MFloat8_t mfp8;
+ // CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "__mfp8", {{.*}}, baseType: ![[ELTTYU8:[0-9]+]]
+ // CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "__mfp8", size: 8, encoding: DW_ATE_unsigned_char)
+ __mfp8 mfp8;
}
diff --git a/clang/test/CodeGen/arm-mfp8.c b/clang/test/CodeGen/arm-mfp8.c
index 8c817fd5be1c9b..8515b39b3899e7 100644
--- a/clang/test/CodeGen/arm-mfp8.c
+++ b/clang/test/CodeGen/arm-mfp8.c
@@ -60,7 +60,7 @@ mfloat8x8_t test_ret_mfloat8x8_t(mfloat8x8_t v) {
// CHECK-C-NEXT: [[TMP1:%.*]] = load <1 x i8>, ptr [[ARRAYIDX1]], align 1
// CHECK-C-NEXT: ret <1 x i8> [[TMP1]]
//
-// CHECK-CXX-LABEL: define dso_local <1 x i8> @_Z6func1nu11__MFloat8_t(
+// CHECK-CXX-LABEL: define dso_local <1 x i8> @_Z6func1n8__u6mfp8(
// CHECK-CXX-SAME: <1 x i8> [[MFP8:%.*]]) #[[ATTR0]] {
// CHECK-CXX-NEXT: [[ENTRY:.*:]]
// CHECK-CXX-NEXT: [[MFP8_ADDR:%.*]] = alloca <1 x i8>, align 1
diff --git a/clang/test/Sema/arm-mfp8.c b/clang/test/Sema/arm-mfp8.c
index e917078f50ed7e..9ddfd7d8a003cf 100644
--- a/clang/test/Sema/arm-mfp8.c
+++ b/clang/test/Sema/arm-mfp8.c
@@ -3,9 +3,9 @@
// REQUIRES: aarch64-registered-target
#include<arm_neon.h>
__mfp8 test_cast_from_float(unsigned in) {
- return (__mfp8)in; // expected-error {{used type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}}
+ return (__mfp8)in; // expected-error {{used type '__mfp8' where arithmetic or pointer type is required}}
}
unsigned test_cast_to_int(__mfp8 in) {
- return (unsigned)in; // expected-error {{operand of type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}}
+ return (unsigned)in; // expected-error {{operand of type '__mfp8' where arithmetic or pointer type is required}}
}
diff --git a/clang/test/Sema/arm-mfp8.cpp b/clang/test/Sema/arm-mfp8.cpp
index e882c382522c22..be5bc9bb71dbd2 100644
--- a/clang/test/Sema/arm-mfp8.cpp
+++ b/clang/test/Sema/arm-mfp8.cpp
@@ -3,6 +3,39 @@
// 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')}}
+}
+
#include <arm_sve.h>
void test_vector_sve(svmfloat8_t a, svuint8_t c) {
a + c; // sve-error {{cannot convert between vector type 'svuint8_t' (aka '__SVUint8_t') and vector type 'svmfloat8_t' (aka '__SVMfloat8_t') as implicit conversion would cause truncation}}
@@ -29,35 +62,3 @@ void test_vector(mfloat8x8_t a, mfloat8x16_t b, uint8x8_t c) {
c * b; // neon-error {{cannot convert between vector and non-scalar values ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
c / b; // neon-error {{cannot convert between vector and non-scalar values ('uint8x8_t' (vector of 8 'uint8_t' values) and 'mfloat8x16_t' (aka '__MFloat8x16_t'))}}
}
-__mfp8 test_static_cast_from_char(char in) {
- return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__mfp8' (aka '__MFloat8_t') is not allowed}}
-}
-
-char test_static_cast_to_char(__mfp8 in) {
- return static_cast<char>(in); // scalar-error {{static_cast from '__mfp8' (aka '__MFloat8_t') to 'char' is not allowed}}
-}
-void test(bool b) {
- __mfp8 mfp8;
-
- mfp8 + mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
- mfp8 - mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
- mfp8 * mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
- mfp8 / mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
- ++mfp8; // scalar-error {{cannot increment value of type '__mfp8' (aka '__MFloat8_t')}}
- --mfp8; // scalar-error {{cannot decrement value of type '__mfp8' (aka '__MFloat8_t')}}
-
- char u8;
-
- mfp8 + u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
- u8 + mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
- mfp8 - u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
- u8 - mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
- mfp8 * u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
- u8 * mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
- mfp8 / u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
- u8 / mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
- mfp8 = u8; // scalar-error {{assigning to '__mfp8' (aka '__MFloat8_t') from incompatible type 'char'}}
- u8 = mfp8; // scalar-error {{assigning to 'char' from incompatible type '__mfp8' (aka '__MFloat8_t')}}
- mfp8 + (b ? u8 : mfp8); // scalar-error {{incompatible operand types ('char' and '__mfp8' (aka '__MFloat8_t'))}}
-}
-
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index c6d82646b40de2..101d7b1824f3db 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -2588,7 +2588,7 @@ void NeonEmitter::runVectorTypes(raw_ostream &OS) {
OS << "typedef __fp16 float16_t;\n";
OS << "#if defined(__aarch64__) || defined(__arm64ec__)\n";
- OS << "typedef __MFloat8_t __mfp8;\n";
+ OS << "typedef __mfp8 mfloat8_t;\n";
OS << "typedef __MFloat8x8_t mfloat8x8_t;\n";
OS << "typedef __MFloat8x16_t mfloat8x16_t;\n";
OS << "typedef double float64_t;\n";
More information about the cfe-commits
mailing list