diff --git a/llvm/test/CodeGen/NVPTX/access-non-generic.ll b/llvm/test/CodeGen/NVPTX/access-non-generic.ll --- a/llvm/test/CodeGen/NVPTX/access-non-generic.ll +++ b/llvm/test/CodeGen/NVPTX/access-non-generic.ll @@ -1,5 +1,11 @@ -; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s --check-prefix PTX -; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s --check-prefix PTX +; RUN: llc < %s -march=nvptx -mcpu=sm_20 -o %t-nvptx.ptx +; RUN: FileCheck %s --input-file %t-nvptx.ptx --check-prefix PTX +; RUN: ptxas-verify %t-nvptx.ptx + +; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -o %t-nvptx64.ptx +; RUN: FileCheck %s --input-file %t-nvptx64.ptx --check-prefix PTX +; RUN: ptxas-verify %t-nvptx64.ptx + ; RUN: opt -mtriple=nvptx-- < %s -S -infer-address-spaces | FileCheck %s --check-prefix IR ; RUN: opt -mtriple=nvptx64-- < %s -S -infer-address-spaces | FileCheck %s --check-prefix IR diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py --- a/llvm/test/lit.cfg.py +++ b/llvm/test/lit.cfg.py @@ -191,6 +191,39 @@ ToolSubst('OrcV2CBindingsLazy', unresolved='ignore'), ToolSubst('OrcV2CBindingsVeryLazy', unresolved='ignore')]) +# Find (major, minor) version of ptxas +def ptxas_version(ptxas): + ptxas_cmd = subprocess.Popen([ptxas, '--version'], stdout=subprocess.PIPE) + ptxas_out = ptxas_cmd.stdout.read().decode('ascii') + ptxas_cmd.wait() + match = re.search('release (\d+)\.(\d+)', ptxas_out) + if match: + return (int(match.group(1)), int(match.group(2))) + print('couldn\'t determine ptxas version') + return None + +ptxas_executable = 'true' +ptxas_known_versions = [(11, 4)] +if config.ptxas_executable: + ptxas_executable = config.ptxas_executable + version = ptxas_version(ptxas_executable) + if version: + # ptxas is supposed to be backward compatible with previous + # versions, so add a feature for every known version prior to + # the current one. + for known_major, known_minor in ptxas_known_versions: + if known_major <= version[0] and known_minor <= version[1]: + config.available_features.add( + 'ptxas-{}.{}'.format(known_major, known_minor)) + + config.available_features.add("ptxas") + tools.extend([ToolSubst('ptxas', ptxas_executable)]) + +# verify PTX with ptxas, or substitute to 'true' if it is not +# available +tools.extend([ + ToolSubst('ptxas-verify', '{} -c -o /dev/null'.format(ptxas_executable))]) + llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir) # Targets diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in --- a/llvm/test/lit.site.cfg.py.in +++ b/llvm/test/lit.site.cfg.py.in @@ -23,6 +23,7 @@ config.ocaml_flags = "@OCAMLFLAGS@" config.include_go_tests = @LLVM_INCLUDE_GO_TESTS@ config.go_executable = "@GO_EXECUTABLE@" +config.ptxas_executable = "@PXTAS_EXECUTABLE@" config.enable_shared = @ENABLE_SHARED@ config.enable_assertions = @ENABLE_ASSERTIONS@ config.targets_to_build = "@TARGETS_TO_BUILD@"