Skip to content

Commit ac8ee83

Browse files
committed
added remove dup options
1 parent 35684fa commit ac8ee83

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s
2+
3+
v_bfrev_b32 v5, v1
4+
5+
v_bfrev_b32 v5, v1
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: 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+
0x00,0x00,0x00,0x7e
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 -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]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# REQUIRES: amdgpu-registered-target
2+
## Check that remove duplicate is working
3+
4+
# RUN: cp -f %S/Inputs/amdgpu_asm_remove_duplicates.s %t.s && %update_mc_test_checks --remove-duplicate %t.s
5+
# RUN: diff -u %S/Inputs/amdgpu_asm_remove_duplicates.s.expected %t.s
6+
# RUN: cp -f %S/Inputs/amdgpu_dasm_remove_duplicates.txt %t.txt && %update_mc_test_checks --remove-duplicate %t.txt
7+
# RUN: diff -u %S/Inputs/amdgpu_dasm_remove_duplicates.txt.expected %t.txt

llvm/utils/update_mc_test_checks.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ def main():
118118
default=None,
119119
help="Set a default -march for when neither triple nor arch are found in a RUN line",
120120
)
121+
122+
parser.add_argument(
123+
"--remove-duplicate",
124+
action=argparse.BooleanOptionalAction,
125+
help="remove duplicated test line if found",
126+
)
121127
parser.add_argument("tests", nargs="+")
122128
initial_args = common.parse_commandline_args(parser)
123129

@@ -196,6 +202,10 @@ def main():
196202

197203
# find all test line from input
198204
testlines = [l for l in ti.input_lines if isTestLine(l, mc_mode)]
205+
# remove duplicated lines to save running time
206+
testlines = list(dict.fromkeys(testlines))
207+
common.debug("Valid test line found: ", len(testlines))
208+
199209
run_list_size = len(run_list)
200210
testnum = len(testlines)
201211

@@ -233,7 +243,7 @@ def main():
233243
raw_prefixes.append(prefixes)
234244

235245
output_lines = []
236-
generated_prefixes = []
246+
generated_prefixes = {}
237247
used_prefixes = set()
238248
prefix_set = set([prefix for p in run_list for prefix in p[0]])
239249
common.debug("Rewriting FileCheck prefixes:", str(prefix_set))
@@ -298,16 +308,21 @@ def main():
298308
else:
299309
gen_prefix += getStdCheckLine(prefix, o, mc_mode)
300310

301-
generated_prefixes.append(gen_prefix.rstrip("\n"))
311+
generated_prefixes[input_line] = gen_prefix.rstrip("\n")
302312

303313
# write output
304-
prefix_id = 0
314+
written_lines = set()
305315
for input_info in ti.iterlines(output_lines):
306316
input_line = input_info.line
307-
if isTestLine(input_line, mc_mode):
317+
if input_line in testlines:
318+
if ti.args.remove_duplicate:
319+
if input_line in written_lines:
320+
common.debug("Duplicated line skipped: ", input_line)
321+
continue
322+
else:
323+
written_lines.add(input_line)
308324
output_lines.append(input_line)
309-
output_lines.append(generated_prefixes[prefix_id])
310-
prefix_id += 1
325+
output_lines.append(generated_prefixes[input_line])
311326

312327
elif should_add_line_to_output(input_line, prefix_set, mc_mode):
313328
output_lines.append(input_line)

0 commit comments

Comments
 (0)