Skip to content

Commit 86f971c

Browse files
committedNov 8, 2017
[utils] Add RISC-V support to update_llc_test_checks.py
This should be a trivial change, and I've started using it for generating all tests at https://github.com/lowrisc/riscv-llvm (i.e. it's been tested in action quite a lot). Note that the regex does not attempt to match .cfi_startproc, as I want to ensure compatibility with functions that have the nounwind attribute. Differential Revision: https://reviews.llvm.org/D39789 llvm-svn: 317693
1 parent 99beabf commit 86f971c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎llvm/utils/update_llc_test_checks.py

+18
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def llc(args, cmd_args, ir):
5858
r'.Lfunc_end[0-9]+:\n',
5959
flags=(re.M | re.S))
6060

61+
ASM_FUNCTION_RISCV_RE = re.compile(
62+
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n[^:]*?'
63+
r'(?P<body>^##?[ \t]+[^:]+:.*?)\s*'
64+
r'.Lfunc_end[0-9]+:\n',
65+
flags=(re.M | re.S))
66+
6167
ASM_FUNCTION_SYSTEMZ_RE = re.compile(
6268
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n'
6369
r'[ \t]+.cfi_startproc\n'
@@ -135,6 +141,16 @@ def scrub_asm_powerpc64(asm, args):
135141
asm = SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
136142
return asm
137143

144+
def scrub_asm_riscv(asm):
145+
# Scrub runs of whitespace out of the assembly, but leave the leading
146+
# whitespace in place.
147+
asm = SCRUB_WHITESPACE_RE.sub(r' ', asm)
148+
# Expand the tabs used for indentation.
149+
asm = string.expandtabs(asm, 2)
150+
# Strip trailing whitespace.
151+
asm = SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
152+
return asm
153+
138154
def scrub_asm_systemz(asm, args):
139155
# Scrub runs of whitespace out of the assembly, but leave the leading
140156
# whitespace in place.
@@ -161,6 +177,8 @@ def build_function_body_dictionary(raw_tool_output, triple, prefixes, func_dict,
161177
'armeb-eabi': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_RE),
162178
'powerpc64': (scrub_asm_powerpc64, ASM_FUNCTION_PPC_RE),
163179
'powerpc64le': (scrub_asm_powerpc64, ASM_FUNCTION_PPC_RE),
180+
'riscv32': (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE),
181+
'riscv64': (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE),
164182
's390x': (scrub_asm_systemz, ASM_FUNCTION_SYSTEMZ_RE),
165183
}
166184
handlers = None

0 commit comments

Comments
 (0)