-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[CLANG][AArch64] Add the modal 8 bit floating-point scalar type #97277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this
}8
is a typo and it should be{{.*}}
only? I will try it locally.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's perhaps because the test uses
aarch64-registered-target || arm-registered-target
for what's effectively an AArch64 specific test. From what I can see there are many such tests that are miss classified but I guess fp8 being strictly AArch64 specific means this is the first time we get an explicit failure?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test passed with the 8 removed so I committed 81e536e. As the number its checking doesn't seem to be significant. I can revert if that's going to cause other problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I recall correctly, clang can always produce IR or AST in this case, for a given target triple regardless of the backends included. So the
aarch64-registered-target || arm-registered-target
is probably just so includingarm_neon.h
doesn't error?If you actually tried to use the fp8 stuff on Arm 32, you'd have other problems I assume.