diff options
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), |