Skip to content

Commit

Permalink
added remove dup options
Browse files Browse the repository at this point in the history
  • Loading branch information
broxigarchen committed Oct 9, 2024
1 parent 35684fa commit ac8ee83
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s

v_bfrev_b32 v5, v1

v_bfrev_b32 v5, v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py
// RUN: llvm-mc -triple=amdgcn -show-encoding %s 2>&1 | FileCheck --check-prefixes=CHECK %s

v_bfrev_b32 v5, v1
// CHECK: v_bfrev_b32_e32 v5, v1 ; encoding: [0x01,0x71,0x0a,0x7e]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK %s

0x00,0x00,0x00,0x7e

0x00,0x00,0x00,0x7e
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py
# RUN: llvm-mc -triple=amdgcn -mcpu=gfx1100 -disassemble -show-encoding %s 2>&1 | FileCheck -check-prefixes=CHECK %s

0x00,0x00,0x00,0x7e
# CHECK: v_nop ; encoding: [0x00,0x00,0x00,0x7e]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# REQUIRES: amdgpu-registered-target
## Check that remove duplicate is working

# RUN: cp -f %S/Inputs/amdgpu_asm_remove_duplicates.s %t.s && %update_mc_test_checks --remove-duplicate %t.s
# RUN: diff -u %S/Inputs/amdgpu_asm_remove_duplicates.s.expected %t.s
# RUN: cp -f %S/Inputs/amdgpu_dasm_remove_duplicates.txt %t.txt && %update_mc_test_checks --remove-duplicate %t.txt
# RUN: diff -u %S/Inputs/amdgpu_dasm_remove_duplicates.txt.expected %t.txt
27 changes: 21 additions & 6 deletions llvm/utils/update_mc_test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def main():
default=None,
help="Set a default -march for when neither triple nor arch are found in a RUN line",
)

parser.add_argument(
"--remove-duplicate",
action=argparse.BooleanOptionalAction,
help="remove duplicated test line if found",
)
parser.add_argument("tests", nargs="+")
initial_args = common.parse_commandline_args(parser)

Expand Down Expand Up @@ -196,6 +202,10 @@ def main():

# find all test line from input
testlines = [l for l in ti.input_lines if isTestLine(l, mc_mode)]
# remove duplicated lines to save running time
testlines = list(dict.fromkeys(testlines))
common.debug("Valid test line found: ", len(testlines))

run_list_size = len(run_list)
testnum = len(testlines)

Expand Down Expand Up @@ -233,7 +243,7 @@ def main():
raw_prefixes.append(prefixes)

output_lines = []
generated_prefixes = []
generated_prefixes = {}
used_prefixes = set()
prefix_set = set([prefix for p in run_list for prefix in p[0]])
common.debug("Rewriting FileCheck prefixes:", str(prefix_set))
Expand Down Expand Up @@ -298,16 +308,21 @@ def main():
else:
gen_prefix += getStdCheckLine(prefix, o, mc_mode)

generated_prefixes.append(gen_prefix.rstrip("\n"))
generated_prefixes[input_line] = gen_prefix.rstrip("\n")

# write output
prefix_id = 0
written_lines = set()
for input_info in ti.iterlines(output_lines):
input_line = input_info.line
if isTestLine(input_line, mc_mode):
if input_line in testlines:
if ti.args.remove_duplicate:
if input_line in written_lines:
common.debug("Duplicated line skipped: ", input_line)
continue
else:
written_lines.add(input_line)
output_lines.append(input_line)
output_lines.append(generated_prefixes[prefix_id])
prefix_id += 1
output_lines.append(generated_prefixes[input_line])

elif should_add_line_to_output(input_line, prefix_set, mc_mode):
output_lines.append(input_line)
Expand Down

0 comments on commit ac8ee83

Please sign in to comment.