[llvm] [UpdateTestChecks] Add support for SPIRV in update_llc_test_checks.py (PR #66213)

Thomas Preud'homme via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 06:45:16 PDT 2023


RoboTux wrote:

> > Why not just match OpName ? ASM_FUNCTION_X86_RE does something similar in matching the func name a few lines before the "Begin function" tag
> 
> As far as I understand we need to grab the body of the function. In the case of SPIRV, the body doesn't come after the name. Take the case of 2 functions called void1 and void2:
> 
> ```
> 	OpCapability Kernel
> 	OpCapability Addresses
> 	OpCapability Linkage
> 	OpCapability OptNoneINTEL
> 	OpExtension "SPV_INTEL_optnone"
> 	%1 = OpExtInstImport "OpenCL.std"
> 	OpMemoryModel Physical32 OpenCL
> 	OpExecutionMode %4 ContractionOff
> 	OpExecutionMode %5 ContractionOff
> 	OpSource Unknown 0
> 	OpName %4 "void1"
> 	OpName %5 "void2"
> 	OpDecorate %4 LinkageAttributes "void1" Export
> 	OpDecorate %5 LinkageAttributes "void2" Export
> 	%2 = OpTypeVoid
> 	%3 = OpTypeFunction %2
> 	%4 = OpFunction %2 DontInline %3        ; -- Begin function void1
> 	%6 = OpLabel
> 	OpReturn
> 	OpFunctionEnd
>                                         ; -- End function
> 	%5 = OpFunction %2 DontInline %3        ; -- Begin function void2
> 	%7 = OpLabel
> 	OpReturn
> 	OpFunctionEnd
>                                         ; -- End function
> ```
> 
> How would you grab with a regex the body of void2 if I parse the name from OpName?

How about something like something along the line of:
"OpName (?P<func>%[0-9_]+)(.*\n)+"\1 = OpFunction.*\n(?P<body>.*?)OpFunctionEnd"

https://github.com/llvm/llvm-project/pull/66213


More information about the llvm-commits mailing list