llvm.org GIT mirror llvm / 6028581
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326288 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 2 years ago
2 changed file(s) with 17 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
3737
3838 ##### LLVM IR parser
3939
40 RUN_LINE_RE = re.compile('^\s*;\s*RUN:\s*(.*)$')
41 CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?=(\S+)')
42 CHECK_RE = re.compile(r'^\s*;\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
40 RUN_LINE_RE = re.compile('^\s*[;#]\s*RUN:\s*(.*)$')
41 CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
42 CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
4343
4444 OPT_FUNCTION_RE = re.compile(
4545 r'^\s*define\s+(?:internal\s+)?[^@]*@(?P[\w-]+?)\s*\('
4747 flags=(re.M | re.S))
4848
4949 IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@(\w+)\s*\(')
50 TRIPLE_IR_RE = re.compile(r'^target\s+triple\s*=\s*"([^"]+)"$')
51 TRIPLE_ARG_RE = re.compile(r'-mtriple=([^ ]+)')
50 TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
51 TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)')
52 MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)')
5253
5354 SCRUB_LEADING_WHITESPACE_RE = re.compile(r'^(\s+)')
5455 SCRUB_WHITESPACE_RE = re.compile(r'(?!^(| \w))[ \t]+', flags=re.M)
2525 import subprocess
2626 import sys
2727
28 RUN_LINE_RE = re.compile('^\s*[;#]\s*RUN:\s*(.*)$')
29 TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)')
30 MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)')
31 TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
32 CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
33 CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
28 from UpdateTestChecks import common
3429
3530 MIR_FUNC_NAME_RE = re.compile(r' *name: *(?P[A-Za-z0-9_.-]+)')
3631 MIR_BODY_BEGIN_RE = re.compile(r' *body: *\|')
5550 r'^\.\.\.$',
5651 flags=(re.M | re.S))
5752
53
5854 class LLC:
5955 def __init__(self, bin):
6056 self.bin = bin
9389
9490 def find_triple_in_ir(lines, verbose=False):
9591 for l in lines:
96 m = TRIPLE_IR_RE.match(l)
92 m = common.TRIPLE_IR_RE.match(l)
9793 if m:
9894 return m.group(1)
9995 return None
10197
10298 def find_run_lines(test, lines, verbose=False):
10399 raw_lines = [m.group(1)
104 for m in [RUN_LINE_RE.match(l) for l in lines] if m]
100 for m in [common.RUN_LINE_RE.match(l) for l in lines] if m]
105101 run_lines = [raw_lines[0]] if len(raw_lines) > 0 else []
106102 for l in raw_lines[1:]:
107103 if run_lines[-1].endswith("\\"):
132128 continue
133129
134130 triple = None
135 m = TRIPLE_ARG_RE.search(llc_cmd)
131 m = common.TRIPLE_ARG_RE.search(llc_cmd)
136132 if m:
137133 triple = m.group(1)
138134 # If we find -march but not -mtriple, use that.
139 m = MARCH_ARG_RE.search(llc_cmd)
135 m = common.MARCH_ARG_RE.search(llc_cmd)
140136 if m and not triple:
141137 triple = '{}--'.format(m.group(1))
142138
143139 cmd_args = llc_cmd[len('llc'):].strip()
144140 cmd_args = cmd_args.replace('< %s', '').replace('%s', '').strip()
145141
146 check_prefixes = [item for m in CHECK_PREFIX_RE.finditer(filecheck_cmd)
147 for item in m.group(1).split(',')]
142 check_prefixes = [
143 item
144 for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
145 for item in m.group(1).split(',')]
148146 if not check_prefixes:
149147 check_prefixes = ['CHECK']
150148 all_prefixes += check_prefixes
285283
286284 def should_add_line_to_output(input_line, prefix_set):
287285 # Skip any check lines that we're handling.
288 m = CHECK_RE.match(input_line)
286 m = common.CHECK_RE.match(input_line)
289287 if m and m.group(1) in prefix_set:
290288 return False
291289 return True