================
@@ -51,47 +51,77 @@ class Arm64RegisterTypeDetector {
bool HasDetected() const { return m_has_detected; }
private:
- using DetectorFn =
- std::function<const RegisterType *(uint64_t, uint64_t, uint64_t)>;
+ // A detector function inspects the hwcaps and builds a type for that
+ // register. All types should be made using MakeType, and a raw pointer to
+ // the top level type must be returned.
+ using DetectorFn = const RegisterType *(Arm64RegisterTypeDetector::*)(
+ uint64_t, uint64_t, uint64_t);
- static const RegisterType *DetectCPSRType(uint64_t hwcap, uint64_t hwcap2,
+ const RegisterType *DetectCPSRType(uint64_t hwcap, uint64_t hwcap2,
+ uint64_t hwcap3);
+ const RegisterType *DetectFPSRType(uint64_t hwcap, uint64_t hwcap2,
+ uint64_t hwcap3);
+ const RegisterType *DetectFPCRType(uint64_t hwcap, uint64_t hwcap2,
+ uint64_t hwcap3);
+ const RegisterType *DetectMTECtrlType(uint64_t hwcap, uint64_t hwcap2,
+ uint64_t hwcap3);
+ const RegisterType *DetectSVCRType(uint64_t hwcap, uint64_t hwcap2,
+ uint64_t hwcap3);
+ const RegisterType *DetectFPMRType(uint64_t hwcap, uint64_t hwcap2,
+ uint64_t hwcap3);
+ const RegisterType *DetectGCSFeaturesType(uint64_t hwcap, uint64_t hwcap2,
uint64_t hwcap3);
- static const RegisterType *DetectFPSRType(uint64_t hwcap, uint64_t hwcap2,
- uint64_t hwcap3);
- static const RegisterType *DetectFPCRType(uint64_t hwcap, uint64_t hwcap2,
- uint64_t hwcap3);
- static const RegisterType *DetectMTECtrlType(uint64_t hwcap, uint64_t hwcap2,
- uint64_t hwcap3);
- static const RegisterType *DetectSVCRType(uint64_t hwcap, uint64_t hwcap2,
- uint64_t hwcap3);
- static const RegisterType *DetectFPMRType(uint64_t hwcap, uint64_t hwcap2,
- uint64_t hwcap3);
- static const RegisterType *
- DetectGCSFeaturesType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3);
- static const RegisterType *DetectPOREL0Type(uint64_t hwcap, uint64_t hwcap2,
- uint64_t hwcap3);
+ const RegisterType *DetectPOREL0Type(uint64_t hwcap, uint64_t hwcap2,
+ uint64_t hwcap3);
struct RegisterEntry {
RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector)
: m_name(name), m_type(nullptr), m_detector(detector) {}
llvm::StringRef m_name;
+ // A raw pointer to the top level type. This pointer's lifetime is managed
+ // by a unique pointer of the same value in m_detected_types.
const RegisterType *m_type;
DetectorFn m_detector;
} m_registers[9] = {
- RegisterEntry("cpsr", 4, DetectCPSRType),
- RegisterEntry("fpsr", 4, DetectFPSRType),
- RegisterEntry("fpcr", 4, DetectFPCRType),
- RegisterEntry("mte_ctrl", 8, DetectMTECtrlType),
- RegisterEntry("svcr", 8, DetectSVCRType),
- RegisterEntry("fpmr", 8, DetectFPMRType),
- RegisterEntry("gcs_features_enabled", 8, DetectGCSFeaturesType),
- RegisterEntry("gcs_features_locked", 8, DetectGCSFeaturesType),
- RegisterEntry("por_el0", 8, DetectPOREL0Type),
+ RegisterEntry("cpsr", 4, &Arm64RegisterTypeDetector::DetectCPSRType),
+ RegisterEntry("fpsr", 4, &Arm64RegisterTypeDetector::DetectFPSRType),
+ RegisterEntry("fpcr", 4, &Arm64RegisterTypeDetector::DetectFPCRType),
+ RegisterEntry("mte_ctrl", 8,
+ &Arm64RegisterTypeDetector::DetectMTECtrlType),
+ RegisterEntry("svcr", 8, &Arm64RegisterTypeDetector::DetectSVCRType),
+ RegisterEntry("fpmr", 8, &Arm64RegisterTypeDetector::DetectFPMRType),
+ RegisterEntry("gcs_features_enabled", 8,
+ &Arm64RegisterTypeDetector::DetectGCSFeaturesType),
----------------
DavidSpickett wrote:
https://github.com/llvm/llvm-project/blob/main/lldb/source/Utility/RegisterType.cpp
checks what we have previously emitted, and this is tested in the
RegisterTypeFlagsToXML test in
https://github.com/llvm/llvm-project/blob/09375e336d7cdbe96018300ef69d2be7d3c441a2/lldb/unittests/Utility/RegisterTypeTest.cpp#L565.
We could be more efficient by knowing that many registers might have the same
detector. I'll work on that as a follow up. I'd like to keep this PR about the
unique_ptr changeover.
https://github.com/llvm/llvm-project/pull/214515
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits