Skip to content

Commit

Permalink
[UpdateTestChecks] Add EraVM support in update_llc_test_checks.py
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Radosavljevic <[email protected]>
  • Loading branch information
vladimirradosavljevic committed Mar 21, 2024
1 parent 085a67c commit 38bb8fb
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: llc < %s -mtriple=eravm-unknown-unknown | FileCheck %s

@val = addrspace(4) global i256 42

define void @test1(i256 %rs1) {
%valptr = alloca i256
%val = load i256, i256 addrspace(4)* @val
%res = add i256 %rs1, %val
store i256 %res, i256* %valptr
ret void
}

define void @test2(i256 %rs1) {
%valptr = alloca i256
%destptr = alloca i256
%val = load i256, i256* %valptr
%res = add i256 %val, %rs1
store i256 %res, i256* %destptr
ret void
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=eravm-unknown-unknown | FileCheck %s

@val = addrspace(4) global i256 42

define void @test1(i256 %rs1) {
; CHECK-LABEL: test1:
; CHECK: ; %bb.0:
; CHECK-NEXT: nop stack+=[1]
; CHECK-NEXT: add @val[0], r1, stack-[1]
; CHECK-NEXT: ret
%valptr = alloca i256
%val = load i256, i256 addrspace(4)* @val
%res = add i256 %rs1, %val
store i256 %res, i256* %valptr
ret void
}

define void @test2(i256 %rs1) {
; CHECK-LABEL: test2:
; CHECK: ; %bb.0:
; CHECK-NEXT: nop stack+=[2]
; CHECK-NEXT: add stack-[2], r1, stack-[1]
; CHECK-NEXT: ret
%valptr = alloca i256
%destptr = alloca i256
%val = load i256, i256* %valptr
%res = add i256 %val, %rs1
store i256 %res, i256* %destptr
ret void
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# REQUIRES: eravm-registered-target

# RUN: cp -f %S/Inputs/eravm-basic.ll %t.ll && %update_llc_test_checks %t.ll
# RUN: diff -u %S/Inputs/eravm-basic.ll.expected %t.ll
19 changes: 18 additions & 1 deletion llvm/utils/UpdateTestChecks/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ class string:
r'.Lfunc_end[0-9]+:\n',
flags=(re.M | re.S))

ASM_FUNCTION_ERAVM_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\})?)? = .*)$',
Expand Down Expand Up @@ -441,6 +447,16 @@ def scrub_asm_loongarch(asm, args):
asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm)
return asm

def scrub_asm_eravm(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 @@ -485,7 +501,8 @@ def get_run_handler(triple):
'csky': (scrub_asm_csky, ASM_FUNCTION_CSKY_RE),
'nvptx': (scrub_asm_nvptx, ASM_FUNCTION_NVPTX_RE),
'loongarch32': (scrub_asm_loongarch, ASM_FUNCTION_LOONGARCH_RE),
'loongarch64': (scrub_asm_loongarch, ASM_FUNCTION_LOONGARCH_RE)
'loongarch64': (scrub_asm_loongarch, ASM_FUNCTION_LOONGARCH_RE),
'eravm' : (scrub_asm_eravm, ASM_FUNCTION_ERAVM_RE)
}
handler = None
best_prefix = ''
Expand Down

0 comments on commit 38bb8fb

Please sign in to comment.