Skip to content

Commit 7df9ecb

Browse files
committed
formatter
1 parent b9275eb commit 7df9ecb

File tree

4 files changed

+50
-26
lines changed

4 files changed

+50
-26
lines changed
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_check.py UTC_ARGS: --version 5
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+
# CHECK: v_nop ; encoding: [0x00,0x00,0x00,0x7e]
6+
0x00,0x00,0x00,0x7e
7+
8+
# CHECKA: v_movrelsd_b32_e32 v5, v1 ; encoding: [0x01,0x71,0x0a,0x7e]
9+
# CHECKB: v_bfrev_b32_e32 v5, v1 ; encoding: [0x01,0x71,0x0a,0x7e]
10+
0x01,0x71,0x0a,0x7e

llvm/test/tools/UpdateTestChecks/update_mc_test_checks/amdgpu-basic.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
# RUN: diff -u %S/Inputs/amdgpu_asm.s.expected %t.s
66
# RUN: cp -f %S/Inputs/amdgpu_dasm.txt %t.txt && %update_mc_test_checks %t.txt
77
# RUN: diff -u %S/Inputs/amdgpu_dasm.txt.expected %t.txt
8+
# RUN: cp -f %S/Inputs/amdgpu_multi_dasm.txt %t.s && %update_mc_test_checks %t.txt
9+
# RUN: diff -u %S/Inputs/amdgpu_multi_dasm.txt.expected %t.txt

llvm/utils/update_mc_test_check.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
ERROR_RE = re.compile(r"(warning|error): .*")
2121
ERROR_CHECK_RE = re.compile(r"# COM: .*")
2222
OUTPUT_SKIPPED_RE = re.compile(r"(.text)")
23-
COMMENT = {
24-
"asm" : "//",
25-
"dasm" : "#"
26-
}
23+
COMMENT = {"asm": "//", "dasm": "#"}
2724

2825

2926
def invoke_tool(exe, cmd_args, testline, verbose=False):
@@ -32,7 +29,7 @@ def invoke_tool(exe, cmd_args, testline, verbose=False):
3229
else:
3330
args = cmd_args
3431

35-
cmd = "echo \"" + testline + "\" | " + exe + " " + args
32+
cmd = 'echo "' + testline + '" | ' + exe + " " + args
3633
if verbose:
3734
print("Command: ", cmd)
3835
out = subprocess.check_output(cmd, shell=True)
@@ -44,68 +41,76 @@ def invoke_tool(exe, cmd_args, testline, verbose=False):
4441
# and treat all others as tests
4542
def isTestLine(input_line, mc_mode):
4643
# Skip comment lines
47-
if input_line.strip(' \t\r').startswith(COMMENT[mc_mode]):
44+
if input_line.strip(" \t\r").startswith(COMMENT[mc_mode]):
4845
return False
49-
elif input_line.strip(' \t\r') == '':
46+
elif input_line.strip(" \t\r") == "":
5047
return False
5148
# skip any CHECK lines.
5249
elif common.CHECK_RE.match(input_line):
5350
return False
5451
return True
5552

53+
5654
def hasErr(err):
5755
if err is None or len(err) == 0:
5856
return False
5957
if ERROR_RE.search(err):
6058
return True
6159
return False
6260

61+
6362
def getErrString(err):
6463
if err is None or len(err) == 0:
6564
return ""
6665

67-
lines = err.split('\n')
66+
lines = err.split("\n")
6867
# take the first match
6968
for line in lines:
7069
s = ERROR_RE.search(line)
7170
if s:
7271
return s.group(0)
7372
return ""
7473

74+
7575
def getOutputString(out):
7676
if out is None or len(out) == 0:
7777
return ""
78-
lines = out.split('\n')
78+
lines = out.split("\n")
7979
output = ""
8080

8181
for line in lines:
8282
if OUTPUT_SKIPPED_RE.search(line):
8383
continue
84-
if line.strip('\t ') == '':
84+
if line.strip("\t ") == "":
8585
continue
86-
output += line.lstrip('\t ')
86+
output += line.lstrip("\t ")
8787
return output
8888

89+
8990
def should_add_line_to_output(input_line, prefix_set, mc_mode):
9091
# special check line
91-
if mc_mode == 'dasm' and ERROR_CHECK_RE.search(input_line):
92+
if mc_mode == "dasm" and ERROR_CHECK_RE.search(input_line):
9293
return False
9394
else:
94-
return common.should_add_line_to_output(input_line, prefix_set, comment_marker=COMMENT[mc_mode])
95+
return common.should_add_line_to_output(
96+
input_line, prefix_set, comment_marker=COMMENT[mc_mode]
97+
)
9598

9699

97100
def getStdCheckLine(prefix, output, mc_mode):
98-
lines = output.split('\n')
101+
lines = output.split("\n")
99102
output = ""
100103
for line in lines:
101-
output += COMMENT[mc_mode] + ' ' + prefix + ": " + line + '\n'
104+
output += COMMENT[mc_mode] + " " + prefix + ": " + line + "\n"
102105
return output
103106

107+
104108
def getErrCheckLine(prefix, output, mc_mode):
105-
if mc_mode == 'asm':
106-
return COMMENT[mc_mode] + ' ' + prefix + ": " + output + '\n'
107-
elif mc_mode == 'dasm':
108-
return COMMENT[mc_mode] + ' COM: ' + prefix + ": " + output + '\n'
109+
if mc_mode == "asm":
110+
return COMMENT[mc_mode] + " " + prefix + ": " + output + "\n"
111+
elif mc_mode == "dasm":
112+
return COMMENT[mc_mode] + " COM: " + prefix + ": " + output + "\n"
113+
109114

110115
def main():
111116
parser = argparse.ArgumentParser(description=__doc__)
@@ -132,9 +137,9 @@ def main():
132137
for ti in common.itertests(
133138
initial_args.tests, parser, script_name="utils/" + script_name
134139
):
135-
if ti.path.endswith('.s'):
140+
if ti.path.endswith(".s"):
136141
mc_mode = "asm"
137-
elif ti.path.endswith('.txt'):
142+
elif ti.path.endswith(".txt"):
138143
mc_mode = "dasm"
139144
else:
140145
common.warn("Expected .s and .txt, Skipping file : ", ti.path)
@@ -195,7 +200,6 @@ def main():
195200
march_in_cmd,
196201
)
197202
)
198-
199203

200204
# find all test line from input
201205
testlines = [l for l in ti.input_lines if isTestLine(l, mc_mode)]
@@ -232,7 +236,7 @@ def main():
232236
raw_output[-1].append(out)
233237

234238
common.debug("Collect raw tool lines:", str(len(raw_output[-1])))
235-
239+
236240
raw_prefixes.append(prefixes)
237241

238242
output_lines = []
@@ -255,7 +259,7 @@ def main():
255259
o = getErrString(out)
256260
else:
257261
o = getOutputString(out)
258-
262+
259263
prefixes = raw_prefixes[run_id]
260264

261265
for p in prefixes:
@@ -273,7 +277,9 @@ def main():
273277
# conflict, discard
274278
p_dict[p] = None, []
275279

276-
p_dict_sorted = dict(sorted(p_dict.items(), key=lambda item: -len(item[1][1])))
280+
p_dict_sorted = dict(
281+
sorted(p_dict.items(), key=lambda item: -len(item[1][1]))
282+
)
277283

278284
# prefix is selected and generated with most shared output lines
279285
# each run_id can only be used once
@@ -299,7 +305,7 @@ def main():
299305
else:
300306
gen_prefix += getStdCheckLine(prefix, o, mc_mode)
301307

302-
generated_prefixes.append(gen_prefix.rstrip('\n'))
308+
generated_prefixes.append(gen_prefix.rstrip("\n"))
303309

304310
# write output
305311
prefix_id = 0

0 commit comments

Comments
 (0)