Skip to content

Commit

Permalink
[UpdateTestChecks] Add EVM support in update_llc_test_checks.py
Browse files Browse the repository at this point in the history
  • Loading branch information
akiramenai committed Nov 19, 2024
1 parent 1cddc81 commit 6d6934d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; RUN: llc < %s -mtriple=evm | FileCheck %s

define i256 @swap_second_no_junk(i256 %a1, i256 %a2, i256 %a3, i256 %a4) nounwind {
%x1 = sub i256 %a4, %a1
ret i256 %x1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=evm | FileCheck %s

define i256 @swap_second_no_junk(i256 %a1, i256 %a2, i256 %a3, i256 %a4) nounwind {
; CHECK-LABEL: swap_second_no_junk:
; CHECK: ; %bb.0:
; CHECK-NEXT: JUMPDEST
; CHECK-NEXT: DUP2
; CHECK-NEXT: DUP6
; CHECK-NEXT: SUB
; CHECK-NEXT: SWAP5
; CHECK-NEXT: POP
; CHECK-NEXT: DUP1
; CHECK-NEXT: SWAP4
; CHECK-NEXT: POP
; CHECK-NEXT: POP
; CHECK-NEXT: POP
; CHECK-NEXT: POP
; CHECK-NEXT: JUMP
%x1 = sub i256 %a4, %a1
ret i256 %x1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# REQUIRES: evm-registered-target

# RUN: cp -f %S/Inputs/evm-basic.ll %t.ll && %update_llc_test_checks %t.ll
# RUN: diff -u %S/Inputs/evm-basic.ll.expected %t.ll
17 changes: 17 additions & 0 deletions llvm/utils/UpdateTestChecks/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ class string:
r'\s*; -- End function',
flags=(re.M | re.S))

ASM_FUNCTION_EVM_RE = re.compile(
r'^_?(?P<func>[^:]+):[ \t]*;+[ \t]*@"?(?P=func)"?\n[^:]*?'
r'(?P<body>.*?)\n'
r'\s*; -- End function',
flags=(re.M | re.S))

SCRUB_X86_SHUFFLES_RE = re.compile(
r"^(\s*\w+) [^#\n]+#+ ((?:[xyz]mm\d+|mem)( \{%k\d+\}( \{z\})?)? = .*)$", flags=re.M
)
Expand Down Expand Up @@ -516,6 +522,16 @@ def scrub_asm_eravm(asm, args):
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
return asm

def scrub_asm_evm(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

# Returns a tuple of a scrub function and a function regex. Scrub function is
# used to alter function body in some way, for example, remove trailing spaces.
# Function regex is used to match function name, body, etc. in raw llc output.
Expand Down Expand Up @@ -571,6 +587,7 @@ def get_run_handler(triple):
"loongarch32": (scrub_asm_loongarch, ASM_FUNCTION_LOONGARCH_RE),
"loongarch64": (scrub_asm_loongarch, ASM_FUNCTION_LOONGARCH_RE),
"eravm" : (scrub_asm_eravm, ASM_FUNCTION_ERAVM_RE),
"evm" : (scrub_asm_evm, ASM_FUNCTION_EVM_RE),
}
handler = None
best_prefix = ""
Expand Down

0 comments on commit 6d6934d

Please sign in to comment.