-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLANG][AArch64] Add the modal 8 bit floating-point scalar type (#97277)
ARM ACLE PR#323[1] adds new modal types for 8-bit floating point intrinsic. From the PR#323: ``` ACLE defines the `__mfp8` type, which can be used for the E5M2 and E4M3 8-bit floating-point formats. It is a storage and interchange only type with no arithmetic operations other than intrinsic calls. ```` The type should be an opaque type and its format in undefined in Clang. Only defined in the backend by a status/format register, for AArch64 the FPMR. This patch is an attempt to the add the mfloat8_t scalar type. It has a parser and codegen for the new scalar type. The patch it is lowering to and 8bit unsigned as it has no format. But maybe we should add another opaque type. [1] ARM-software/acle#323
- Loading branch information
1 parent
32baf29
commit 4994051
Showing
10 changed files
with
189 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// 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. */ | ||
|
||
#include<arm_neon.h> | ||
/* Namespace */ | ||
namespace { | ||
__mfp8 f2n; | ||
__mfp8 arr1n[10]; | ||
} | ||
|
||
//CHECK: |-NamespaceDecl {{.*}} | ||
//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8':'__MFloat8_t' | ||
//CHECK-NEXT: | `-VarDecl {{.*}} arr1n '__mfp8[10]' | ||
|
||
|
||
const __mfp8 func1n(const __mfp8 mfp8) { | ||
// this should fail | ||
__mfp8 f1n; | ||
f1n = mfp8; | ||
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-NEXT: `-ReturnStmt {{.*}} | ||
//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue> | ||
//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t' | ||
|
||
|
||
/* Class */ | ||
|
||
class C1 { | ||
__mfp8 f1c; | ||
static const __mfp8 f2c; | ||
volatile __MFloat8_t 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':'__MFloat8_t' | ||
//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8':'const __MFloat8_t' static | ||
//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __MFloat8_t' | ||
//CHECK-NEXT: | |-AccessSpecDecl {{.*}} | ||
//CHECK-NEXT: | |-CXXConstructorDecl {{.*}} C1 'void (__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: | | `-CompoundStmt {{.*}} | ||
//CHECK-NEXT: | |-CXXMethodDecl {{.*}} func1c '__mfp8 (__mfp8)' implicit-inline | ||
//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t' | ||
//CHECK-NEXT: | | `-CompoundStmt {{.*}} | ||
//CHECK-NEXT: | | `-ReturnStmt {{.*}} | ||
//CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue> | ||
//CHECK-NEXT: | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}}8 'arg' '__mfp8':'__MFloat8_t' | ||
//CHECK-NEXT: | `-CXXMethodDecl {{.*}} func2c '__mfp8 (__mfp8)' static implicit-inline | ||
//CHECK-NEXT: | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t' | ||
//CHECK-NEXT: | `-CompoundStmt {{.*}} | ||
//CHECK-NEXT: | `-ReturnStmt {{.*}} | ||
//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' <LValueToRValue> | ||
//CHECK-NEXT: | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t' | ||
|
||
template <class C> struct S1 { | ||
C mem1; | ||
}; | ||
|
||
template <> struct S1<__mfp8> { | ||
__mfp8 mem2; | ||
}; | ||
|
||
//CHECK: |-TemplateArgument type '__MFloat8_t' | ||
//CHECK-NEXT: | `-BuiltinType {{.*}} '__MFloat8_t' | ||
//CHECK-NEXT: |-CXXRecordDecl {{.*}} implicit struct S1 | ||
//CHECK-NEXT: `-FieldDecl {{.*}} mem2 '__mfp8':'__MFloat8_t' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -target-feature +fp8 \ | ||
// RUN: -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s | ||
#include<arm_neon.h> | ||
|
||
void test_locals(void) { | ||
// CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "__MFloat8_t", {{.*}}, baseType: ![[ELTTYU8:[0-9]+]] | ||
// CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "__MFloat8_t", size: 8, encoding: DW_ATE_unsigned_char) | ||
__MFloat8_t mfp8; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-arm-none-eabi -target-feature -fp8 %s | ||
|
||
// REQUIRES: aarch64-registered-target | ||
#include<arm_neon.h> | ||
__mfp8 test_cast_from_float(unsigned in) { | ||
return (__mfp8)in; // expected-error {{used type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}} | ||
} | ||
|
||
unsigned test_cast_to_int(__mfp8 in) { | ||
return (unsigned)in; // expected-error {{operand of type '__mfp8' (aka '__MFloat8_t') where arithmetic or pointer type is required}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters