1 ; RUN: opt -S -mtriple=aarch64-linux-gnu -aarch64-sme-abi %s | FileCheck %s
2 ; RUN: opt -S -mtriple=aarch64-linux-gnu -aarch64-sme-abi -aarch64-sme-abi %s | FileCheck %s
4 declare void @shared_za_callee() "aarch64_pstate_za_shared"
6 define void @private_za() "aarch64_pstate_za_new" {
7 ; CHECK-LABEL: @private_za(
9 ; CHECK-NEXT: [[TPIDR2:%.*]] = call i64 @llvm.aarch64.sme.get.tpidr2()
10 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[TPIDR2]], 0
11 ; CHECK-NEXT: br i1 [[CMP]], label [[SAVE_ZA:%.*]], label [[TMP0:%.*]]
13 ; CHECK-NEXT: call aarch64_sme_preservemost_from_x0 void @__arm_tpidr2_save()
14 ; CHECK-NEXT: call void @llvm.aarch64.sme.set.tpidr2(i64 0)
15 ; CHECK-NEXT: br label [[TMP0]]
17 ; CHECK-NEXT: call void @llvm.aarch64.sme.za.enable()
18 ; CHECK-NEXT: call void @llvm.aarch64.sme.zero(i32 255)
19 ; CHECK-NEXT: call void @shared_za_callee()
20 ; CHECK-NEXT: call void @llvm.aarch64.sme.za.disable()
21 ; CHECK-NEXT: ret void
23 call void @shared_za_callee()
27 define i32 @private_za_multiple_exit(i32 %a, i32 %b, i64 %cond) "aarch64_pstate_za_new" {
28 ; CHECK-LABEL: @private_za_multiple_exit(
29 ; CHECK-NEXT: prelude:
30 ; CHECK-NEXT: [[TPIDR2:%.*]] = call i64 @llvm.aarch64.sme.get.tpidr2()
31 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[TPIDR2]], 0
32 ; CHECK-NEXT: br i1 [[CMP]], label [[SAVE_ZA:%.*]], label [[ENTRY:%.*]]
34 ; CHECK-NEXT: call aarch64_sme_preservemost_from_x0 void @__arm_tpidr2_save()
35 ; CHECK-NEXT: call void @llvm.aarch64.sme.set.tpidr2(i64 0)
36 ; CHECK-NEXT: br label [[ENTRY]]
38 ; CHECK-NEXT: call void @llvm.aarch64.sme.za.enable()
39 ; CHECK-NEXT: call void @llvm.aarch64.sme.zero(i32 255)
40 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[COND:%.*]], 1
41 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_ELSE:%.*]], label [[IF_END:%.*]]
43 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[A:%.*]], [[B:%.*]]
44 ; CHECK-NEXT: call void @llvm.aarch64.sme.za.disable()
45 ; CHECK-NEXT: ret i32 [[ADD]]
47 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 [[A]], [[B]]
48 ; CHECK-NEXT: call void @llvm.aarch64.sme.za.disable()
49 ; CHECK-NEXT: ret i32 [[SUB]]
52 %tobool = icmp eq i64 %cond, 1
53 br i1 %tobool, label %if.else, label %if.end
64 ; CHECK: declare void @__arm_tpidr2_save() #[[ATTR:[0-9]+]]
65 ; CHECK: attributes #[[ATTR]] = { "aarch64_pstate_sm_compatible" "aarch64_pstate_za_preserved" }