Skip to content

Commit 35a9d1b

Browse files
committed
update_mir_test_checks: Use the regexes from UpdateTestChecks.common
Some of the update_*_test_checks regexes have been moved into a library, so we might as well use them in update_mir_test_checks. Also includes minor bugfixes to the regexes that are there so we don't regress update_mir_test_checks llvm-svn: 326288
1 parent 2074eab commit 35a9d1b

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

llvm/utils/UpdateTestChecks/common.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ def invoke_tool(exe, cmd_args, ir):
3838

3939
##### LLVM IR parser
4040

41-
RUN_LINE_RE = re.compile('^\s*;\s*RUN:\s*(.*)$')
42-
CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?=(\S+)')
43-
CHECK_RE = re.compile(r'^\s*;\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
41+
RUN_LINE_RE = re.compile('^\s*[;#]\s*RUN:\s*(.*)$')
42+
CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
43+
CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
4444

4545
OPT_FUNCTION_RE = re.compile(
4646
r'^\s*define\s+(?:internal\s+)?[^@]*@(?P<func>[\w-]+?)\s*\('
4747
r'(\s+)?[^)]*[^{]*\{\n(?P<body>.*?)^\}$',
4848
flags=(re.M | re.S))
4949

5050
IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@(\w+)\s*\(')
51-
TRIPLE_IR_RE = re.compile(r'^target\s+triple\s*=\s*"([^"]+)"$')
52-
TRIPLE_ARG_RE = re.compile(r'-mtriple=([^ ]+)')
51+
TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
52+
TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)')
53+
MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)')
5354

5455
SCRUB_LEADING_WHITESPACE_RE = re.compile(r'^(\s+)')
5556
SCRUB_WHITESPACE_RE = re.compile(r'(?!^(| \w))[ \t]+', flags=re.M)

llvm/utils/update_mir_test_checks.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@
2626
import subprocess
2727
import sys
2828

29-
RUN_LINE_RE = re.compile('^\s*[;#]\s*RUN:\s*(.*)$')
30-
TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)')
31-
MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)')
32-
TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
33-
CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
34-
CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
29+
from UpdateTestChecks import common
3530

3631
MIR_FUNC_NAME_RE = re.compile(r' *name: *(?P<func>[A-Za-z0-9_.-]+)')
3732
MIR_BODY_BEGIN_RE = re.compile(r' *body: *\|')
@@ -56,6 +51,7 @@
5651
r'^\.\.\.$',
5752
flags=(re.M | re.S))
5853

54+
5955
class LLC:
6056
def __init__(self, bin):
6157
self.bin = bin
@@ -94,15 +90,15 @@ def warn(msg, test_file=None):
9490

9591
def find_triple_in_ir(lines, verbose=False):
9692
for l in lines:
97-
m = TRIPLE_IR_RE.match(l)
93+
m = common.TRIPLE_IR_RE.match(l)
9894
if m:
9995
return m.group(1)
10096
return None
10197

10298

10399
def find_run_lines(test, lines, verbose=False):
104100
raw_lines = [m.group(1)
105-
for m in [RUN_LINE_RE.match(l) for l in lines] if m]
101+
for m in [common.RUN_LINE_RE.match(l) for l in lines] if m]
106102
run_lines = [raw_lines[0]] if len(raw_lines) > 0 else []
107103
for l in raw_lines[1:]:
108104
if run_lines[-1].endswith("\\"):
@@ -133,19 +129,21 @@ def build_run_list(test, run_lines, verbose=False):
133129
continue
134130

135131
triple = None
136-
m = TRIPLE_ARG_RE.search(llc_cmd)
132+
m = common.TRIPLE_ARG_RE.search(llc_cmd)
137133
if m:
138134
triple = m.group(1)
139135
# If we find -march but not -mtriple, use that.
140-
m = MARCH_ARG_RE.search(llc_cmd)
136+
m = common.MARCH_ARG_RE.search(llc_cmd)
141137
if m and not triple:
142138
triple = '{}--'.format(m.group(1))
143139

144140
cmd_args = llc_cmd[len('llc'):].strip()
145141
cmd_args = cmd_args.replace('< %s', '').replace('%s', '').strip()
146142

147-
check_prefixes = [item for m in CHECK_PREFIX_RE.finditer(filecheck_cmd)
148-
for item in m.group(1).split(',')]
143+
check_prefixes = [
144+
item
145+
for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
146+
for item in m.group(1).split(',')]
149147
if not check_prefixes:
150148
check_prefixes = ['CHECK']
151149
all_prefixes += check_prefixes
@@ -286,7 +284,7 @@ def mangle_vreg(opcode, current_names):
286284

287285
def should_add_line_to_output(input_line, prefix_set):
288286
# Skip any check lines that we're handling.
289-
m = CHECK_RE.match(input_line)
287+
m = common.CHECK_RE.match(input_line)
290288
if m and m.group(1) in prefix_set:
291289
return False
292290
return True

0 commit comments

Comments
 (0)