Skip to content

Commit 0495cd8

Browse files
authored
[UpdateTestChecks] Add support for SPIRV in update_llc_test_checks.py (llvm#66213)
Support for SPIRV added, updated test SPV_INTEL_optnone.ll using the script. Previously https://reviews.llvm.org/D157858
1 parent 0fe905d commit 0495cd8

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown --spirv-extensions=SPV_INTEL_optnone %s -o - | FileCheck %s --check-prefix=CHECK-EXTENSION
2-
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-NO-EXTENSION
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2+
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown --spirv-extensions=SPV_INTEL_optnone %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-EXTENSION
3+
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NO-EXTENSION
34

45
; CHECK-EXTENSION: OpCapability OptNoneINTEL
56
; CHECK-EXTENSION: OpExtension "SPV_INTEL_optnone"
67
; CHECK-NO-EXTENSION-NOT: OpCapability OptNoneINTEL
78
; CHECK-NO-EXTENSION-NOT: OpExtension "SPV_INTEL_optnone"
89

9-
;; Per SPIR-V spec:
10-
;; FunctionControlDontInlineMask = 0x2 (2)
11-
; CHECK-EXTENSION: %[[#]] = OpFunction %[[#]] DontInline
12-
1310
; Function Attrs: nounwind optnone noinline
1411
define spir_func void @_Z3foov() #0 {
12+
; CHECK-LABEL: _Z3foov
13+
; CHECK: %4 = OpFunction %2 DontInline %3
14+
; CHECK-NEXT: %5 = OpLabel
15+
; CHECK-NEXT: OpReturn
16+
; CHECK-NEXT: OpFunctionEnd
1517
entry:
1618
ret void
1719
}
1820

1921
attributes #0 = { nounwind optnone noinline }
22+
23+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
24+
; CHECK-EXTENSION: {{.*}}
25+
; CHECK-NO-EXTENSION: {{.*}}

llvm/utils/UpdateTestChecks/asm.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ class string:
1515
# RegEx: this is where the magic happens.
1616

1717
##### Assembly parser
18+
#
19+
# The set of per-arch regular expressions define several groups.
20+
# The required groups are "func" (function name) and "body" (body of the function).
21+
# Although some backends require some additional groups like: "directives"
22+
# and "func_name_separator"
1823

1924
ASM_FUNCTION_X86_RE = re.compile(
2025
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*(@"?(?P=func)"?| -- Begin function (?P=func))\n(?:\s*\.?Lfunc_begin[^:\n]*:\n)?'
@@ -197,6 +202,14 @@ class string:
197202
flags=(re.M | re.S),
198203
)
199204

205+
# We parse the function name from OpName, and grab the variable name 'var'
206+
# for this function. Then we match that when the variable is assigned with
207+
# OpFunction and match its body.
208+
ASM_FUNCTION_SPIRV_RE = re.compile(
209+
r'OpName (?P<var>%[0-9]+) "(?P<func>[^"]+)(?P<func_name_separator>)".*(?P<body>(?P=var) = OpFunction.+?OpFunctionEnd)',
210+
flags=(re.M | re.S),
211+
)
212+
200213
ASM_FUNCTION_VE_RE = re.compile(
201214
r"^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n"
202215
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):
433446
return asm
434447

435448

449+
def scrub_asm_spirv(asm, args):
450+
# Scrub runs of whitespace out of the assembly, but leave the leading
451+
# whitespace in place.
452+
asm = common.SCRUB_WHITESPACE_RE.sub(r" ", asm)
453+
# Expand the tabs used for indentation.
454+
asm = string.expandtabs(asm, 2)
455+
# Strip trailing whitespace.
456+
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r"", asm)
457+
return asm
458+
459+
436460
def scrub_asm_systemz(asm, args):
437461
# Scrub runs of whitespace out of the assembly, but leave the leading
438462
# whitespace in place.
@@ -547,6 +571,8 @@ def get_run_handler(triple):
547571
"riscv64": (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE),
548572
"lanai": (scrub_asm_lanai, ASM_FUNCTION_LANAI_RE),
549573
"sparc": (scrub_asm_sparc, ASM_FUNCTION_SPARC_RE),
574+
"spirv32": (scrub_asm_spirv, ASM_FUNCTION_SPIRV_RE),
575+
"spirv64": (scrub_asm_spirv, ASM_FUNCTION_SPIRV_RE),
550576
"s390x": (scrub_asm_systemz, ASM_FUNCTION_SYSTEMZ_RE),
551577
"wasm32": (scrub_asm_wasm, ASM_FUNCTION_WASM_RE),
552578
"wasm64": (scrub_asm_wasm, ASM_FUNCTION_WASM_RE),

0 commit comments

Comments
 (0)