update_llc_test_checks.py
Bash
usage: update_llc_test_checks.py [-h] [-v] [--llc-binary LLC_BINARY]
[--function FUNCTION] [--extra_scrub]
[--x86_scrub_rip] [--no_x86_scrub_rip]
tests [tests ...]
A test case update script. This script is a utility to update LLVM 'llc' based
test cases with new FileCheck patterns. It can either update all of the tests
in the file or a single test function.
positional arguments:
tests
optional arguments:
-h, --help show this help message and exit
-v, --verbose Show verbose output
--llc-binary LLC_BINARY
The "llc" binary to use to generate the test case
--function FUNCTION The function in the test file to update
--extra_scrub Always use additional regex to further reduce diffs
between various subtargets
--x86_scrub_rip Use more regex for x86 matching to reduce diffs
between various subtargets
--no_x86_scrub_rip
可以指定函数,下面的示例没指定
Below is a test case,你需要写至少一个check(经测试可以没有)
Bash
[shkzhang@pcom023:~/3410]$ cat pr30640.ll
; RUN: llc -O2 -mtriple=powerpc64-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
define i64 @foo() {
entry:
ret i64 -3617008641903833651
; CHECK: lis [[REG1:[0-9]+]], -12851
; CHECK: ori [[REG2:[0-9]+]], [[REG1]], 52685
; CHECK: rldimi 3, 3, 32, 0
}
After use the tool:
Bash
[shkzhang@pcom023:~/3410]$ ~/llvm/llvm/utils/update_llc_test_checks.py pr30640.ll
[shkzhang@pcom023:~/3410]$ cat pr30640.ll
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O2 -mtriple=powerpc64-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
define i64 @foo() {
; CHECK-LABEL: foo:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lis 3, -12851
; CHECK-NEXT: ori 3, 3, 52685
; CHECK-NEXT: rldimi 3, 3, 32, 0
; CHECK-NEXT: blr
entry:
ret i64 -3617008641903833651
}
该脚本只会删除和个性在函数内的check,对于函数外的CHECK,不会做任何处理
GAS
; RUN: llc -O2 -mtriple=powerpc64-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
; CHECK: lis [[REG1:[0-9]+]], -12851
; CHECK: ori [[REG2:[0-9]+]], [[REG1]], 52685
; CHECK: rldimi 3, 3, 32, 0
define i64 @foo() {
entry:
ret i64 -3617008641903833651
; CHECK: lis [[REG1:[0-9]+]], -12851
; CHECK: ori [[REG2:[0-9]+]], [[REG1]], 52685
; CHECK: rldimi 3, 3, 32, 0
}
使用该脚本后得到,应该先手动删除函数前的CHECK
GAS
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O2 -mtriple=powerpc64-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
; CHECK: lis [[REG1:[0-9]+]], -12851
; CHECK: ori [[REG2:[0-9]+]], [[REG1]], 52685
; CHECK: rldimi 3, 3, 32, 0
define i64 @foo() {
; CHECK-LABEL: foo:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lis 3, -12851
; CHECK-NEXT: ori 3, 3, 52685
; CHECK-NEXT: rldimi 3, 3, 32, 0
; CHECK-NEXT: blr
entry:
ret i64 -3617008641903833651
}
~/llvm/llvm/utils/update_mir_test_checks.py¶
用法同上,但对于mir使用