Skip to content

Commit 91aad9b

Browse files
[Clang][AArch64]Fix Name and Mangle name for scalar fp8 (#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 This patch fixes this problem by replacing the Name __MFloat8_t by __mfp8 and the Mangle Name __MFloat8_t by u6__mfp8 And we revert the incorrect typedef in NeonEmitter. [1]https://github.com/ARM-software/acle
1 parent fda4a32 commit 91aad9b

File tree

7 files changed

+70
-73
lines changed

7 files changed

+70
-73
lines changed

clang/include/clang/Basic/AArch64SVEACLETypes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T
200200

201201
SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
202202

203-
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8_t", "__MFloat8_t", MFloat8, MFloat8Ty, 1, 8, 1)
203+
AARCH64_VECTOR_TYPE_MFLOAT("__mfp8", "__mfp8", MFloat8, MFloat8Ty, 1, 8, 1)
204204
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1)
205205
AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1)
206206

clang/test/AST/arm-mfp8.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55

66
/* Various contexts where type __mfp8 can appear. */
77

8-
#include<arm_neon.h>
98
/* Namespace */
109
namespace {
1110
__mfp8 f2n;
1211
__mfp8 arr1n[10];
1312
}
1413

1514
//CHECK: |-NamespaceDecl {{.*}}
16-
//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8':'__MFloat8_t'
15+
//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8'
1716
//CHECK-NEXT: | `-VarDecl {{.*}} arr1n '__mfp8[10]'
1817

1918

@@ -24,22 +23,22 @@ namespace {
2423
return f1n;
2524
}
2625
//CHECK: |-FunctionDecl {{.*}} func1n 'const __mfp8 (const __mfp8)'
27-
//CHECK: | `-VarDecl {{.*}} f1n '__mfp8':'__MFloat8_t'
28-
//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8':'__MFloat8_t' lvalue '='
29-
//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t'
30-
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
31-
//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8':'const __MFloat8_t' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8':'const __MFloat8_t'
26+
//CHECK: | `-VarDecl {{.*}} f1n '__mfp8'
27+
//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8' lvalue '='
28+
//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
29+
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
30+
//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8'
3231
//CHECK-NEXT: `-ReturnStmt {{.*}}
33-
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
34-
//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t'
32+
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
33+
//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8'
3534

3635

3736
/* Class */
3837

3938
class C1 {
4039
__mfp8 f1c;
4140
static const __mfp8 f2c;
42-
volatile __MFloat8_t f3c;
41+
volatile __mfp8 f3c;
4342
public:
4443
C1(__mfp8 arg) : f1c(arg), f3c(arg) { }
4544
__mfp8 func1c(__mfp8 arg ) {
@@ -51,31 +50,31 @@ class C1 {
5150
};
5251

5352
//CHECK: | |-CXXRecordDecl {{.*}} referenced class C1
54-
//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8':'__MFloat8_t'
55-
//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8':'const __MFloat8_t' static
56-
//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __MFloat8_t'
53+
//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8'
54+
//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8' static
55+
//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __mfp8'
5756
//CHECK-NEXT: | |-AccessSpecDecl {{.*}}
5857
//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} C1 'void (__mfp8)' implicit-inline
59-
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t'
60-
//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8':'__MFloat8_t'
61-
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
62-
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
63-
//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __MFloat8_t'
64-
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
65-
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
58+
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8'
59+
//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8'
60+
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
61+
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
62+
//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __mfp8'
63+
//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
64+
//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
6665
//CHECK-NEXT: | | `-CompoundStmt {{.*}}
6766
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} func1c '__mfp8 (__mfp8)' implicit-inline
68-
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t'
67+
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8'
6968
//CHECK-NEXT: | | `-CompoundStmt {{.*}}
7069
//CHECK-NEXT: | | `-ReturnStmt {{.*}}
71-
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
72-
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
70+
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
71+
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
7372
//CHECK-NEXT: | `-CXXMethodDecl {{.*}} func2c '__mfp8 (__mfp8)' static implicit-inline
74-
//CHECK-NEXT: | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t'
73+
//CHECK-NEXT: | |-ParmVarDecl {{.*}} arg '__mfp8'
7574
//CHECK-NEXT: | `-CompoundStmt {{.*}}
7675
//CHECK-NEXT: | `-ReturnStmt {{.*}}
77-
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue>
78-
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t'
76+
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' <LValueToRValue>
77+
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__mfp8' lvalue ParmVar {{.*}} 'arg' '__mfp8'
7978

8079
template <class C> struct S1 {
8180
C mem1;
@@ -85,7 +84,7 @@ template <> struct S1<__mfp8> {
8584
__mfp8 mem2;
8685
};
8786

88-
//CHECK: |-TemplateArgument type '__MFloat8_t'
89-
//CHECK-NEXT: | `-BuiltinType {{.*}} '__MFloat8_t'
87+
//CHECK: |-TemplateArgument type '__mfp8'
88+
//CHECK-NEXT: | `-BuiltinType {{.*}} '__mfp8'
9089
//CHECK-NEXT: |-CXXRecordDecl {{.*}} implicit struct S1
91-
//CHECK-NEXT: `-FieldDecl {{.*}} mem2 '__mfp8':'__MFloat8_t'
90+
//CHECK-NEXT: `-FieldDecl {{.*}} mem2 '__mfp8'
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +fp8 \
1+
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fp8 \
22
// RUN: -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s
33

44
// REQUIRES: aarch64-registered-target
55

6-
#include<arm_neon.h>
7-
86
void test_locals(void) {
9-
// CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "__MFloat8_t", {{.*}}, baseType: ![[ELTTYU8:[0-9]+]]
10-
// CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "__MFloat8_t", size: 8, encoding: DW_ATE_unsigned_char)
11-
__MFloat8_t mfp8;
7+
// CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "__mfp8", {{.*}}, baseType: ![[ELTTYU8:[0-9]+]]
8+
// CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "__mfp8", size: 8, encoding: DW_ATE_unsigned_char)
9+
__mfp8 mfp8;
1210
}

clang/test/CodeGen/arm-mfp8.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mfloat8x8_t test_ret_mfloat8x8_t(mfloat8x8_t v) {
6060
// CHECK-C-NEXT: [[TMP1:%.*]] = load <1 x i8>, ptr [[ARRAYIDX1]], align 1
6161
// CHECK-C-NEXT: ret <1 x i8> [[TMP1]]
6262
//
63-
// CHECK-CXX-LABEL: define dso_local <1 x i8> @_Z6func1nu11__MFloat8_t(
63+
// CHECK-CXX-LABEL: define dso_local <1 x i8> @_Z6func1nu6__mfp8(
6464
// CHECK-CXX-SAME: <1 x i8> [[MFP8:%.*]]) #[[ATTR0]] {
6565
// CHECK-CXX-NEXT: [[ENTRY:.*:]]
6666
// CHECK-CXX-NEXT: [[MFP8_ADDR:%.*]] = alloca <1 x i8>, align 1

clang/test/Sema/arm-mfp8.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s
22

33
// REQUIRES: aarch64-registered-target
4-
#include<arm_neon.h>
54
__mfp8 test_cast_from_float(unsigned in) {
6-
return (__mfp8)in; // expected-error {{used type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}}
5+
return (__mfp8)in; // expected-error {{used type '__mfp8' where arithmetic or pointer type is required}}
76
}
87

98
unsigned test_cast_to_int(__mfp8 in) {
10-
return (unsigned)in; // expected-error {{operand of type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}}
9+
return (unsigned)in; // expected-error {{operand of type '__mfp8' where arithmetic or pointer type is required}}
1110
}

clang/test/Sema/arm-mfp8.cpp

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,39 @@
33

44
// REQUIRES: aarch64-registered-target
55

6+
__mfp8 test_static_cast_from_char(char in) {
7+
return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__mfp8' is not allowed}}
8+
}
9+
10+
char test_static_cast_to_char(__mfp8 in) {
11+
return static_cast<char>(in); // scalar-error {{static_cast from '__mfp8' to 'char' is not allowed}}
12+
}
13+
14+
void test(bool b) {
15+
__mfp8 mfp8;
16+
17+
mfp8 + mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
18+
mfp8 - mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
19+
mfp8 * mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
20+
mfp8 / mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' and '__mfp8')}}
21+
++mfp8; // scalar-error {{cannot increment value of type '__mfp8'}}
22+
--mfp8; // scalar-error {{cannot decrement value of type '__mfp8'}}
23+
24+
char u8;
25+
26+
mfp8 + u8; // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
27+
u8 + mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
28+
mfp8 - u8; // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
29+
u8 - mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
30+
mfp8 * u8; // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
31+
u8 * mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
32+
mfp8 / u8; // scalar-error {{invalid operands to binary expression ('__mfp8' and 'char')}}
33+
u8 / mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8')}}
34+
mfp8 = u8; // scalar-error {{assigning to '__mfp8' from incompatible type 'char'}}
35+
u8 = mfp8; // scalar-error {{assigning to 'char' from incompatible type '__mfp8'}}
36+
mfp8 + (b ? u8 : mfp8); // scalar-error {{incompatible operand types ('char' and '__mfp8')}}
37+
}
38+
639
#include <arm_sve.h>
740
void test_vector_sve(svmfloat8_t a, svuint8_t c) {
841
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) {
2962
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'))}}
3063
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'))}}
3164
}
32-
__mfp8 test_static_cast_from_char(char in) {
33-
return static_cast<__mfp8>(in); // scalar-error {{static_cast from 'char' to '__mfp8' (aka '__MFloat8_t') is not allowed}}
34-
}
35-
36-
char test_static_cast_to_char(__mfp8 in) {
37-
return static_cast<char>(in); // scalar-error {{static_cast from '__mfp8' (aka '__MFloat8_t') to 'char' is not allowed}}
38-
}
39-
void test(bool b) {
40-
__mfp8 mfp8;
41-
42-
mfp8 + mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
43-
mfp8 - mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
44-
mfp8 * mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
45-
mfp8 / mfp8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and '__mfp8')}}
46-
++mfp8; // scalar-error {{cannot increment value of type '__mfp8' (aka '__MFloat8_t')}}
47-
--mfp8; // scalar-error {{cannot decrement value of type '__mfp8' (aka '__MFloat8_t')}}
48-
49-
char u8;
50-
51-
mfp8 + u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
52-
u8 + mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
53-
mfp8 - u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
54-
u8 - mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
55-
mfp8 * u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
56-
u8 * mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
57-
mfp8 / u8; // scalar-error {{invalid operands to binary expression ('__mfp8' (aka '__MFloat8_t') and 'char')}}
58-
u8 / mfp8; // scalar-error {{invalid operands to binary expression ('char' and '__mfp8' (aka '__MFloat8_t'))}}
59-
mfp8 = u8; // scalar-error {{assigning to '__mfp8' (aka '__MFloat8_t') from incompatible type 'char'}}
60-
u8 = mfp8; // scalar-error {{assigning to 'char' from incompatible type '__mfp8' (aka '__MFloat8_t')}}
61-
mfp8 + (b ? u8 : mfp8); // scalar-error {{incompatible operand types ('char' and '__mfp8' (aka '__MFloat8_t'))}}
62-
}
63-

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,7 @@ void NeonEmitter::runVectorTypes(raw_ostream &OS) {
25882588
OS << "typedef __fp16 float16_t;\n";
25892589

25902590
OS << "#if defined(__aarch64__) || defined(__arm64ec__)\n";
2591-
OS << "typedef __MFloat8_t __mfp8;\n";
2591+
OS << "typedef __mfp8 mfloat8_t;\n";
25922592
OS << "typedef __MFloat8x8_t mfloat8x8_t;\n";
25932593
OS << "typedef __MFloat8x16_t mfloat8x16_t;\n";
25942594
OS << "typedef double float64_t;\n";

0 commit comments

Comments
 (0)