Skip to content

[lldb][AArch64] Add register fields for the fpmr register #109934

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 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,33 @@
#define HWCAP2_AFP (1ULL << 20)
#define HWCAP2_SME (1ULL << 23)
#define HWCAP2_EBF16 (1ULL << 32)
#define HWCAP2_FPMR (1UL << 48)

using namespace lldb_private;

Arm64RegisterFlagsDetector::Fields
Arm64RegisterFlagsDetector::DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2) {
(void)hwcap;

if (!(hwcap2 & HWCAP2_FPMR))
return {};

static const FieldEnum fp8_format_enum("fp8_format_enum", {
{0, "FP8_E5M2"},
{1, "FP8_E4M3"},
});
return {
{"LSCALE2", 32, 37},
{"NSCALE", 24, 31},
{"LSCALE", 16, 22},
{"OSC", 15},
{"OSM", 14},
{"F8D", 6, 8, &fp8_format_enum},
{"F8S2", 3, 5, &fp8_format_enum},
{"F8S1", 0, 2, &fp8_format_enum},
};
}

Arm64RegisterFlagsDetector::Fields
Arm64RegisterFlagsDetector::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) {
(void)hwcap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Arm64RegisterFlagsDetector {
static Fields DetectFPCRFields(uint64_t hwcap, uint64_t hwcap2);
static Fields DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2);
static Fields DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2);
static Fields DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2);

struct RegisterEntry {
RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector)
Expand All @@ -69,12 +70,13 @@ class Arm64RegisterFlagsDetector {
llvm::StringRef m_name;
RegisterFlags m_flags;
DetectorFn m_detector;
} m_registers[5] = {
} m_registers[6] = {
RegisterEntry("cpsr", 4, DetectCPSRFields),
RegisterEntry("fpsr", 4, DetectFPSRFields),
RegisterEntry("fpcr", 4, DetectFPCRFields),
RegisterEntry("mte_ctrl", 8, DetectMTECtrlFields),
RegisterEntry("svcr", 8, DetectSVCRFields),
RegisterEntry("fpmr", 8, DetectFPMRFields),
};

// Becomes true once field detection has been run for all registers.
Expand Down
5 changes: 5 additions & 0 deletions lldb/test/API/linux/aarch64/fpmr/TestAArch64LinuxFPMR.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def test_fpmr_register(self):
substrs=["Floating Point Mode Register", f"fpmr = {expected_fpmr:#018x}"],
)

if self.hasXMLSupport():
self.expect(
"register read fpmr", substrs=["LSCALE2 = 42", "F8S1 = FP8_E4M3 | 0x4"]
)

# Write a value for the program to find. Same fields but with bit values
# inverted.
new_fpmr = (0b010101 << 32) | 0b010
Expand Down
Loading