Skip to content

Commit b24cd6c

Browse files
DavidSpickettZijunZhaoCCK
authored andcommitted
[lldb][AArch64] Add tests for SME's SVE register state to TestArm64DynamicRegsets
SME reuses SVE's register state but adds new modes to it. Therefore we can't check all those in the same test as the existing SVE checks. SME's ZA, SVG and SVCR register checks will be added to this test in later patches. Prior to this we didn't have any testing of writing streaming mode SVE registers from lldb, only writing SVE registers in normal (non-streaming) SVE mode. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D157846
1 parent ac6dc98 commit b24cd6c

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,37 @@ def test_aarch64_dynamic_regset_config(self):
120120
)
121121
self.expect("register read data_mask", substrs=["data_mask = 0x"])
122122
self.expect("register read code_mask", substrs=["code_mask = 0x"])
123+
124+
@no_debug_info_test
125+
@skipIf(archs=no_match(["aarch64"]))
126+
@skipIf(oslist=no_match(["linux"]))
127+
def test_aarch64_dynamic_regset_config_sme(self):
128+
"""Test AArch64 Dynamic Register sets configuration, but only SME
129+
registers."""
130+
if not self.isAArch64SME():
131+
self.skipTest("SME must be present.")
132+
133+
self.build()
134+
self.line = line_number("main.c", "// Set a break point here.")
135+
136+
exe = self.getBuildArtifact("a.out")
137+
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
138+
139+
lldbutil.run_break_set_by_file_and_line(
140+
self, "main.c", self.line, num_expected_locations=1
141+
)
142+
self.runCmd("settings set target.run-args sme")
143+
self.runCmd("run", RUN_SUCCEEDED)
144+
145+
self.expect(
146+
"thread backtrace",
147+
STOPPED_DUE_TO_BREAKPOINT,
148+
substrs=["stop reason = breakpoint 1."],
149+
)
150+
151+
register_sets = self.thread().GetSelectedFrame().GetRegisters()
152+
153+
ssve_registers = register_sets.GetFirstValueByName(
154+
"Scalable Vector Extension Registers")
155+
self.assertTrue(ssve_registers.IsValid())
156+
self.sve_regs_read_dynamic(ssve_registers)

lldb/test/API/commands/register/register/aarch64_dynamic_regset/main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <sys/auxv.h>
22

3+
#ifndef HWCAP2_SME
4+
#define HWCAP2_SME (1 << 23)
5+
#endif
6+
37
void set_sve_registers() {
48
// AArch64 SVE extension ISA adds a new set of vector and predicate registers:
59
// 32 Z registers, 16 P registers, and 1 FFR register.
@@ -64,8 +68,14 @@ void set_sve_registers() {
6468
asm volatile("cpy z31.b, p15/z, #32\n\t");
6569
}
6670

67-
int main() {
68-
if (getauxval(AT_HWCAP) & HWCAP_SVE) // check if SVE is present
71+
int main(int argc, char *argv[]) {
72+
if (argc > 1) {
73+
// Enable streaming mode SVE and the ZA array storage.
74+
asm volatile("msr s0_3_c4_c7_3, xzr" /*smstart*/);
75+
}
76+
77+
// If we have SVE or SME, set the SVE registers.
78+
if ((getauxval(AT_HWCAP) & HWCAP_SVE) || (getauxval(AT_HWCAP2) & HWCAP2_SME))
6979
set_sve_registers();
7080

7181
return 0; // Set a break point here.

0 commit comments

Comments
 (0)