1import subprocess 2import lit.util 3 4if not ('AArch64' in config.root.targets): 5 # We need support for AArch64. 6 config.unsupported = True 7 8elif not ('aarch64' in config.root.host_triple): 9 # We need to be running on an AArch64 host. 10 config.unsupported = True 11 12else: 13 # We need libpfm to be installed and allow reading perf counters. We can 14 # only know that at runtime, so we try to measure the latency of an empty 15 # code snippet and bail out on error. 16 llvm_exegesis_exe = lit.util.which('llvm-exegesis', config.llvm_tools_dir) 17 if not llvm_exegesis_exe: 18 print('llvm-exegesis not found') 19 config.unsupported = True 20 else: 21 try: 22 with open(os.devnull, 'w') as quiet: 23 check_llvm_exegesis_result = subprocess.call( 24 [llvm_exegesis_exe, '-mode', 'latency', '-snippets-file', '/dev/null'], stdout=quiet, stderr=quiet) 25 except OSError: 26 print('could not exec llvm-exegesis') 27 config.unsupported = True 28 if not check_llvm_exegesis_result == 0: 29 config.unsupported = True 30