diff options
author | Paulo Matos <pmatos@igalia.com> | 2023-09-21 12:51:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-21 12:51:42 +0200 |
commit | 0495cd89fc6e108a70960ea1a21524dd15affdde (patch) | |
tree | 586278dd56b35110d5c3f1f7ce2ac8d806b86647 /llvm/utils/UpdateTestChecks/asm.py | |
parent | 0fe905daf0ed5a50413d0b2a231ec6b6097e7d38 (diff) | |
download | llvm-0495cd89fc6e108a70960ea1a21524dd15affdde.zip llvm-0495cd89fc6e108a70960ea1a21524dd15affdde.tar.gz llvm-0495cd89fc6e108a70960ea1a21524dd15affdde.tar.bz2 |
[UpdateTestChecks] Add support for SPIRV in update_llc_test_checks.py (#66213)
Support for SPIRV added, updated test SPV_INTEL_optnone.ll using the script.
Previously https://reviews.llvm.org/D157858
Diffstat (limited to 'llvm/utils/UpdateTestChecks/asm.py')
-rw-r--r-- | llvm/utils/UpdateTestChecks/asm.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/utils/UpdateTestChecks/asm.py b/llvm/utils/UpdateTestChecks/asm.py index 3357906..7c3c600 100644 --- a/llvm/utils/UpdateTestChecks/asm.py +++ b/llvm/utils/UpdateTestChecks/asm.py @@ -15,6 +15,11 @@ else: # RegEx: this is where the magic happens. ##### Assembly parser +# +# The set of per-arch regular expressions define several groups. +# The required groups are "func" (function name) and "body" (body of the function). +# Although some backends require some additional groups like: "directives" +# and "func_name_separator" ASM_FUNCTION_X86_RE = re.compile( r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*(@"?(?P=func)"?| -- Begin function (?P=func))\n(?:\s*\.?Lfunc_begin[^:\n]*:\n)?' @@ -197,6 +202,14 @@ ASM_FUNCTION_WASM_RE = re.compile( flags=(re.M | re.S), ) +# We parse the function name from OpName, and grab the variable name 'var' +# for this function. Then we match that when the variable is assigned with +# OpFunction and match its body. +ASM_FUNCTION_SPIRV_RE = re.compile( + r'OpName (?P<var>%[0-9]+) "(?P<func>[^"]+)(?P<func_name_separator>)".*(?P<body>(?P=var) = OpFunction.+?OpFunctionEnd)', + flags=(re.M | re.S), +) + ASM_FUNCTION_VE_RE = re.compile( r"^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n" r"(?:\s*\.?L(?P=func)\$local:\n)?" # optional .L<func>$local: due to -fno-semantic-interposition @@ -433,6 +446,17 @@ def scrub_asm_sparc(asm, args): return asm +def scrub_asm_spirv(asm, args): + # Scrub runs of whitespace out of the assembly, but leave the leading + # whitespace in place. + asm = common.SCRUB_WHITESPACE_RE.sub(r" ", asm) + # Expand the tabs used for indentation. + asm = string.expandtabs(asm, 2) + # Strip trailing whitespace. + asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r"", asm) + return asm + + def scrub_asm_systemz(asm, args): # Scrub runs of whitespace out of the assembly, but leave the leading # whitespace in place. @@ -547,6 +571,8 @@ def get_run_handler(triple): "riscv64": (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE), "lanai": (scrub_asm_lanai, ASM_FUNCTION_LANAI_RE), "sparc": (scrub_asm_sparc, ASM_FUNCTION_SPARC_RE), + "spirv32": (scrub_asm_spirv, ASM_FUNCTION_SPIRV_RE), + "spirv64": (scrub_asm_spirv, ASM_FUNCTION_SPIRV_RE), "s390x": (scrub_asm_systemz, ASM_FUNCTION_SYSTEMZ_RE), "wasm32": (scrub_asm_wasm, ASM_FUNCTION_WASM_RE), "wasm64": (scrub_asm_wasm, ASM_FUNCTION_WASM_RE), |