================
@@ -0,0 +1,68 @@
+"""
+Platform-agnostic helper to query for CPU features.
+"""
+
+import re
+
+
+class CPUFeature:
+    def __init__(self, linux_cpu_info_flag: str = None, darwin_sysctl_key: str 
= None):
+        self.cpu_info_flag = linux_cpu_info_flag
+        self.sysctl_key = darwin_sysctl_key
+
+    def __str__(self):
+        return self.cpu_info_flag
+
+    def is_supported(self, triple, cmd_runner):
+        if re.match(".*-.*-linux", triple):
+            err_msg, res = self._is_supported_linux(cmd_runner)
+        elif re.match(".*-apple-.*", triple):
+            err_msg, res = self._is_supported_darwin(cmd_runner)
+        else:
+            err_msg, res = None, False
+
+        if err_msg:
+            print(f"CPU feature check failed: {err_msg}")
+
+        return res
+
+    def _is_supported_linux(self, cmd_runner):
+        if not self.cpu_info_flag:
+            return "Unspecified cpuinfo flag", False
----------------
DavidSpickett wrote:

Format the message like "unspecified cpu info flag for <somehow get the class 
name>".

https://github.com/llvm/llvm-project/pull/153914
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to