-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Add more ZA modes #77361
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
Add more ZA modes #77361
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,25 @@ def ArmStreamingMode : I32EnumAttr<"ArmStreamingMode", "Armv9 Streaming SVE mode | |
let genSpecializedAttr = 0; | ||
} | ||
|
||
// TODO: Add other ZA modes. | ||
// https://arm-software.github.io/acle/main/acle.html#sme-attributes-relating-to-za | ||
// See also the LLVM definitions: https://llvm.org/docs/AArch64SME.html | ||
// | ||
// Various frontends (e.g. Flang) that build on top of this may restrict or | ||
// enforce how these attributes are used, both individually and in terms of | ||
// combinations that are allowed. | ||
// | ||
// The MLIR interface here does not make any attempt to perform any checking, | ||
// it is up to the higher level to ensure that these attributes are used in a | ||
// way that both makes sense and is legal according to the Arm architecture. | ||
def ArmZaMode : I32EnumAttr<"ArmZaMode", "Armv9 ZA storage mode", | ||
[ | ||
I32EnumAttrCase<"Disabled", 0, "disabled">, | ||
// A function's ZA state is created on entry and destroyed on exit. | ||
I32EnumAttrCase<"NewZA", 1, "arm_new_za">, | ||
// A function that preserves ZA state. | ||
I32EnumAttrCase<"PreservesZA", 2, "arm_preserves_za">, | ||
Comment on lines
+46
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a little odd to have 'PreservesZA' as a ZA mode, as it's an attribute that can be used alongside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are referring to C semantics (as per https://arm-software.github.io/acle/main/acle.html#sme-attributes-relating-to-za). However, we are not required to follow that in MLIR and can focus on LLVM instead (i.e. https://llvm.org/docs/AArch64SME.html). That's a very good point nonetheless that will be very relevant within Flang. Not sure we could capture it here. |
||
// A function that uses ZA state as input and/or output | ||
I32EnumAttrCase<"SharedZA", 3, "arm_shared_za">, | ||
]>{ | ||
let cppNamespace = "mlir::arm_sme"; | ||
let genSpecializedAttr = 0; | ||
|
@@ -79,7 +91,15 @@ def EnableArmStreaming | |
clEnumValN(mlir::arm_sme::ArmZaMode::NewZA, | ||
"new-za", | ||
"The function has ZA state. The ZA state is " | ||
"created on entry and destroyed on exit.") | ||
"created on entry and destroyed on exit."), | ||
clEnumValN(mlir::arm_sme::ArmZaMode::PreservesZA, | ||
"preserves-za", | ||
"The function preserves ZA state. The ZA state is " | ||
"saved on entry and restored on exit."), | ||
clEnumValN(mlir::arm_sme::ArmZaMode::SharedZA, | ||
"shared-za", | ||
"The function uses ZA state. The ZA state may " | ||
"be used for input and/or output.") | ||
)}]>, | ||
Option<"onlyIfRequiredByOps", "only-if-required-by-ops", "bool", | ||
/*default=*/"false", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
// RUN: mlir-opt %s -enable-arm-streaming=za-mode=new-za -convert-arm-sme-to-llvm | FileCheck %s -check-prefix=ENABLE-ZA | ||
// RUN: mlir-opt %s -enable-arm-streaming -convert-arm-sme-to-llvm | FileCheck %s -check-prefix=DISABLE-ZA | ||
// RUN: mlir-opt %s -enable-arm-streaming=za-mode=shared-za -convert-arm-sme-to-llvm | FileCheck %s -check-prefix=SHARED-ZA | ||
// RUN: mlir-opt %s -enable-arm-streaming=za-mode=preserves-za -convert-arm-sme-to-llvm | FileCheck %s -check-prefix=PRESERVES-ZA | ||
// RUN: mlir-opt %s -convert-arm-sme-to-llvm | FileCheck %s -check-prefix=NO-ARM-STREAMING | ||
|
||
// CHECK-LABEL: @declaration | ||
func.func private @declaration() | ||
|
||
// ENABLE-ZA-LABEL: @arm_new_za | ||
// ENABLE-ZA-SAME: attributes {arm_new_za, arm_streaming} | ||
// SHARED-ZA-LABEL: @arm_new_za | ||
// SHARED-ZA-SAME: attributes {arm_shared_za, arm_streaming} | ||
// PRESERVES-ZA-LABEL: @arm_new_za | ||
// PRESERVES-ZA-SAME: attributes {arm_preserves_za, arm_streaming} | ||
// DISABLE-ZA-LABEL: @arm_new_za | ||
// DISABLE-ZA-NOT: arm_new_za | ||
// DISABLE-ZA-SAME: attributes {arm_streaming} | ||
// NO-ARM-STREAMING-LABEL: @arm_new_za | ||
// NO-ARM-STREAMING-NOT: arm_new_za | ||
// NO-ARM-STREAMING-NOT: arm_streaming | ||
// NO-ARM-STREAMING-NOT: arm_shared_za | ||
// NO-ARM-STREAMING-NOT: arm_preserves_za | ||
func.func @arm_new_za() { return } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2319,6 +2319,29 @@ llvm.func @streaming_compatible_func() attributes {arm_streaming_compatible} { | |
|
||
// ----- | ||
|
||
// CHECK-LABEL: @new_za_func | ||
// CHECK: #[[ATTR:[0-9]*]] | ||
llvm.func @new_za_func() attributes {arm_new_za} { | ||
llvm.return | ||
} | ||
// CHECK #[[ATTR]] = { "aarch64_pstate_za_new" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a |
||
|
||
// CHECK-LABEL: @shared_za_func | ||
// CHECK: #[[ATTR:[0-9]*]] | ||
llvm.func @shared_za_func() attributes {arm_shared_za } { | ||
llvm.return | ||
} | ||
// CHECK #[[ATTR]] = { "aarch64_pstate_za_shared" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a |
||
|
||
// CHECK-LABEL: @preserves_za_func | ||
// CHECK: #[[ATTR:[0-9]*]] | ||
llvm.func @preserves_za_func() attributes {arm_preserves_za} { | ||
llvm.return | ||
} | ||
// CHECK #[[ATTR]] = { "aarch64_pstate_za_preserved" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a |
||
|
||
// ----- | ||
|
||
// | ||
// Zero-initialize operation. | ||
// | ||
|
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.
Keep the link to the ACLE