Skip to content

Commit 2b892b0

Browse files
added a script to update llvm-mc test file (#107246)
Added a script to update the test file generated by llvm-mc binary. The script accepts .s and .txt for asm and dasm. For mc test I am targetting there is no function name which can be used as a key, thus no clear mapping between input and output. The script assumes the test are always line-by-line and it update the output marker for each test line-by-line. --------- Co-authored-by: Alexander Richardson <[email protected]>
1 parent 6e6d5ea commit 2b892b0

File tree

13 files changed

+394
-1
lines changed

13 files changed

+394
-1
lines changed

llvm/test/tools/UpdateTestChecks/lit.local.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ if os.path.isfile(llvm_mca_path):
5252
split_file_path = os.path.join(config.llvm_tools_dir, "split-file")
5353
if os.path.isfile(split_file_path):
5454
add_update_script_substition("%update_test_body")
55+
56+
llvm_mc_path = os.path.join(config.llvm_tools_dir, "llvm-mc")
57+
if os.path.isfile(llvm_mc_path):
58+
add_update_script_substition("%update_mc_test_checks")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s
2+
3+
v_bfrev_b32 v5, v1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py
2+
// RUN: llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s
3+
4+
v_bfrev_b32 v5, v1
5+
// CHECK: v_bfrev_b32_e32 v5, v1 ; encoding: [0x01,0x71,0x0a,0x7e]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: not llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s
2+
3+
v_bfrev_b32 v5, v299
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py
2+
// RUN: not llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s
3+
4+
v_bfrev_b32 v5, v299
5+
// CHECK: :[[@LINE-1]]:17: error: register index is out of range
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK %s
2+
3+
0x00,0x00,0x00,0x7e
4+
5+
0xfd,0xb8,0x0a,0x7f
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py
2+
# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK %s
3+
4+
0x00,0x00,0x00,0x7e
5+
# CHECK: v_nop ; encoding: [0x00,0x00,0x00,0x7e]
6+
7+
0xfd,0xb8,0x0a,0x7f
8+
# CHECK: :[[@LINE-1]]:1: warning: invalid instruction encoding
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# RUN: llvm-mc -triple=amdgcn -mcpu=tonga -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK,CHECKA %s
2+
# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK,CHECKB %s
3+
4+
0x00,0x00,0x00,0x7e
5+
6+
0x01,0x71,0x0a,0x7e
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py
2+
# RUN: llvm-mc -triple=amdgcn -mcpu=tonga -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK,CHECKA %s
3+
# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK,CHECKB %s
4+
5+
0x00,0x00,0x00,0x7e
6+
# CHECK: v_nop ; encoding: [0x00,0x00,0x00,0x7e]
7+
8+
0x01,0x71,0x0a,0x7e
9+
# CHECKA: v_movrelsd_b32_e32 v5, v1 ; encoding: [0x01,0x71,0x0a,0x7e]
10+
# CHECKB: v_bfrev_b32_e32 v5, v1 ; encoding: [0x01,0x71,0x0a,0x7e]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# REQUIRES: amdgpu-registered-target
2+
## Check that basic asm/dasm process is correct
3+
4+
# RUN: cp -f %S/Inputs/amdgpu_asm.s %t.s && %update_mc_test_checks %t.s
5+
# RUN: diff -u %S/Inputs/amdgpu_asm.s.expected %t.s
6+
# RUN: cp -f %S/Inputs/amdgpu_asm_err.s %t.s && %update_mc_test_checks %t.s
7+
# RUN: diff -u %S/Inputs/amdgpu_asm_err.s.expected %t.s
8+
# RUN: cp -f %S/Inputs/amdgpu_dasm.txt %t.txt && %update_mc_test_checks %t.txt
9+
# RUN: diff -u %S/Inputs/amdgpu_dasm.txt.expected %t.txt
10+
# RUN: cp -f %S/Inputs/amdgpu_multirun_dasm.txt %t.txt && %update_mc_test_checks %t.txt
11+
# RUN: diff -u %S/Inputs/amdgpu_multirun_dasm.txt.expected %t.txt
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import platform
2+
3+
if platform.system() == "Windows":
4+
config.unsupported = True

llvm/utils/UpdateTestChecks/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ def invoke_tool(exe, cmd_args, ir, preprocess_cmd=None, verbose=False):
573573

574574
IR_FUNCTION_RE = re.compile(r'^\s*define\s+(?:internal\s+)?[^@]*@"?([\w.$-]+)"?\s*\(')
575575
TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
576-
TRIPLE_ARG_RE = re.compile(r"-mtriple[= ]([^ ]+)")
576+
TRIPLE_ARG_RE = re.compile(r"-m?triple[= ]([^ ]+)")
577577
MARCH_ARG_RE = re.compile(r"-march[= ]([^ ]+)")
578578
DEBUG_ONLY_ARG_RE = re.compile(r"-debug-only[= ]([^ ]+)")
579579

0 commit comments

Comments
 (0)