Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EVM][UpdateTestChecks] Add EVM support in update_llc_test_checks.py #738

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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