Skip to content

Commit

Permalink
[utils] Add RISC-V support to update_llc_test_checks.py
Browse files Browse the repository at this point in the history
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
  • Loading branch information
asb committed Nov 8, 2017
1 parent 99beabf commit 86f971c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions llvm/utils/update_llc_test_checks.py
Expand Up @@ -58,6 +58,12 @@ def llc(args, cmd_args, ir):
r'.Lfunc_end[0-9]+:\n',
flags=(re.M | re.S))

ASM_FUNCTION_RISCV_RE = re.compile(
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n[^:]*?'
r'(?P<body>^##?[ \t]+[^:]+:.*?)\s*'
r'.Lfunc_end[0-9]+:\n',
flags=(re.M | re.S))

ASM_FUNCTION_SYSTEMZ_RE = re.compile(
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n'
r'[ \t]+.cfi_startproc\n'
Expand Down Expand Up @@ -135,6 +141,16 @@ def scrub_asm_powerpc64(asm, args):
asm = SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
return asm

def scrub_asm_riscv(asm):
# Scrub runs of whitespace out of the assembly, but leave the leading
# whitespace in place.
asm = SCRUB_WHITESPACE_RE.sub(r' ', asm)
# Expand the tabs used for indentation.
asm = string.expandtabs(asm, 2)
# Strip trailing whitespace.
asm = 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.
Expand All @@ -161,6 +177,8 @@ def build_function_body_dictionary(raw_tool_output, triple, prefixes, func_dict,
'armeb-eabi': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_RE),
'powerpc64': (scrub_asm_powerpc64, ASM_FUNCTION_PPC_RE),
'powerpc64le': (scrub_asm_powerpc64, ASM_FUNCTION_PPC_RE),
'riscv32': (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE),
'riscv64': (scrub_asm_riscv, ASM_FUNCTION_RISCV_RE),
's390x': (scrub_asm_systemz, ASM_FUNCTION_SYSTEMZ_RE),
}
handlers = None
Expand Down

0 comments on commit 86f971c

Please sign in to comment.