blob: a51a2d73442fa0500a3830cbbfcd94dd5514080c [file] [log] [blame]
import subprocess
import re
import lit.util
def can_execute_generated_snippets(arch):
is_host_arch = arch in config.root.host_triple
# 'native' feature is defined as "host arch == default triple arch"
is_native_codegen = "native" in config.available_features
return is_host_arch and is_native_codegen
def can_use_perf_counters(mode, extra_options=[]):
# We need libpfm to be installed and allow reading perf counters. We can
# only know that at runtime, so we try to measure an empty code snippet
# and bail out on error.
llvm_exegesis_exe = lit.util.which("llvm-exegesis", config.llvm_tools_dir)
if llvm_exegesis_exe is None:
print("could not find llvm-exegesis")
return False
return_code =
[llvm_exegesis_exe, "-mode", mode, "-snippets-file", "/dev/null"]
+ extra_options,
return return_code == 0
except OSError:
print("could not exec llvm-exegesis")
return False
for arch in ["aarch64", "mips", "powerpc", "x86_64"]:
if can_execute_generated_snippets(arch):
config.available_features.add("exegesis-can-execute-%s" % arch)
if can_use_perf_counters("latency"):
if can_use_perf_counters("uops"):
if can_execute_generated_snippets("x86_64"):
# Check for support of LBR format with cycles.
if can_use_perf_counters(
"latency", ["-x86-lbr-sample-period", "123", "-repetition-mode", "loop"]