# -*- Python -*-
from lit import Test
import lit.formats
import lit.util
import os
import subprocess
clang_bolt_mode = config.clang_bolt_mode.lower()
clang_binary = "clang"
perf_wrapper = f"{config.python_exe} {config.perf_helper_dir}/perf-helper.py perf "
if clang_bolt_mode == "instrument":
perf_wrapper = ""
clang_binary = config.clang_bolt_name
elif clang_bolt_mode == "lbr":
perf_wrapper += " --lbr -- "
elif clang_bolt_mode == "perf":
perf_wrapper += " -- "
else:
assert 0, "Unsupported CLANG_BOLT_MODE variable"
config.clang = perf_wrapper + os.path.realpath(
lit.util.which(clang_binary, config.clang_tools_dir)
).replace("\\", "/")
config.name = "Clang Perf Training"
config.suffixes = [
".c",
".cc",
".cpp",
".m",
".mm",
".cu",
".ll",
".cl",
".s",
".S",
".modulemap",
".test",
]
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
config.test_format = lit.formats.ShTest(use_lit_shell == "0")
config.substitutions.append(
("%clang_cpp_skip_driver", f" {config.clang} --driver-mode=g++ ")
)
config.substitutions.append(("%clang_cpp", f" {config.clang} --driver-mode=g++ "))
config.substitutions.append(("%clang_skip_driver", config.clang))
config.substitutions.append(("%clang", config.clang))
config.substitutions.append(("%test_root", config.test_exec_root))