Skip to content

Commit 0e24611

Browse files
[lldb][AArch64] Add register fields for the fpmr register (#109934)
The FP8 formats have a "_" in the name so that they are: 1. Easier to read. 2. Possible to use in register expressions if/when they are supported. Some other bits do have defined meanings but they are not simple to name. Better that folks read the manual for those. See this page for the full details: https://developer.arm.com/documentation/ddi0601/2024-06/AArch64-Registers/FPMR--Floating-point-Mode-Register
1 parent 21ac5c8 commit 0e24611

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,33 @@
2323
#define HWCAP2_AFP (1ULL << 20)
2424
#define HWCAP2_SME (1ULL << 23)
2525
#define HWCAP2_EBF16 (1ULL << 32)
26+
#define HWCAP2_FPMR (1UL << 48)
2627

2728
using namespace lldb_private;
2829

30+
Arm64RegisterFlagsDetector::Fields
31+
Arm64RegisterFlagsDetector::DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2) {
32+
(void)hwcap;
33+
34+
if (!(hwcap2 & HWCAP2_FPMR))
35+
return {};
36+
37+
static const FieldEnum fp8_format_enum("fp8_format_enum", {
38+
{0, "FP8_E5M2"},
39+
{1, "FP8_E4M3"},
40+
});
41+
return {
42+
{"LSCALE2", 32, 37},
43+
{"NSCALE", 24, 31},
44+
{"LSCALE", 16, 22},
45+
{"OSC", 15},
46+
{"OSM", 14},
47+
{"F8D", 6, 8, &fp8_format_enum},
48+
{"F8S2", 3, 5, &fp8_format_enum},
49+
{"F8S1", 0, 2, &fp8_format_enum},
50+
};
51+
}
52+
2953
Arm64RegisterFlagsDetector::Fields
3054
Arm64RegisterFlagsDetector::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) {
3155
(void)hwcap;

lldb/source/Plugins/Process/Utility/RegisterFlagsDetector_arm64.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Arm64RegisterFlagsDetector {
6060
static Fields DetectFPCRFields(uint64_t hwcap, uint64_t hwcap2);
6161
static Fields DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2);
6262
static Fields DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2);
63+
static Fields DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2);
6364

6465
struct RegisterEntry {
6566
RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector)
@@ -69,12 +70,13 @@ class Arm64RegisterFlagsDetector {
6970
llvm::StringRef m_name;
7071
RegisterFlags m_flags;
7172
DetectorFn m_detector;
72-
} m_registers[5] = {
73+
} m_registers[6] = {
7374
RegisterEntry("cpsr", 4, DetectCPSRFields),
7475
RegisterEntry("fpsr", 4, DetectFPSRFields),
7576
RegisterEntry("fpcr", 4, DetectFPCRFields),
7677
RegisterEntry("mte_ctrl", 8, DetectMTECtrlFields),
7778
RegisterEntry("svcr", 8, DetectSVCRFields),
79+
RegisterEntry("fpmr", 8, DetectFPMRFields),
7880
};
7981

8082
// Becomes true once field detection has been run for all registers.

lldb/test/API/linux/aarch64/fpmr/TestAArch64LinuxFPMR.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def test_fpmr_register(self):
4545
substrs=["Floating Point Mode Register", f"fpmr = {expected_fpmr:#018x}"],
4646
)
4747

48+
if self.hasXMLSupport():
49+
self.expect(
50+
"register read fpmr", substrs=["LSCALE2 = 42", "F8S1 = FP8_E4M3 | 0x4"]
51+
)
52+
4853
# Write a value for the program to find. Same fields but with bit values
4954
# inverted.
5055
new_fpmr = (0b010101 << 32) | 0b010

0 commit comments

Comments
 (0)