llvm.org GIT mirror llvm / 537c6ee
update_mir_test_checks: Add "mir" to some states and regex names For tests that do lowering we need to support IR as input, so here we clarify some names to avoid ambiguity in upcoming commits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321039 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 2 years ago
1 changed file(s) with 16 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
3232 CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
3333 CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
3434
35 FUNC_NAME_RE = re.compile(r' *name: *(?P[A-Za-z0-9_.-]+)')
36 BODY_BEGIN_RE = re.compile(r' *body: *\|')
37 BASIC_BLOCK_RE = re.compile(r' *bb\.[0-9]+.*:$')
35 MIR_FUNC_NAME_RE = re.compile(r' *name: *(?P[A-Za-z0-9_.-]+)')
36 MIR_BODY_BEGIN_RE = re.compile(r' *body: *\|')
37 MIR_BASIC_BLOCK_RE = re.compile(r' *bb\.[0-9]+.*:$')
3838 VREG_RE = re.compile(r'(%[0-9]+)(?::[a-z0-9_]+)?(?:\([<>a-z0-9 ]+\))?')
3939 VREG_DEF_RE = re.compile(
4040 r'^ *(?P{0}(?:, {0})*) '
4141 r'= (?P[A-Zt][A-Za-z0-9_]+)'.format(VREG_RE.pattern))
42 PREFIX_DATA_RE = re.compile(r'^ *(;|bb.[0-9].*: *$|[a-z]+:( |$)|$)')
42 MIR_PREFIX_DATA_RE = re.compile(r'^ *(;|bb.[0-9].*: *$|[a-z]+:( |$)|$)')
4343 VREG_CLASS_RE = re.compile(r'^ *- *{ id: ([0-9]+), class: ([a-z0-9_]+)', re.M)
4444
4545 MIR_FUNC_RE = re.compile(
163163 cur_func = None
164164 bbs = 0
165165 for line in lines:
166 m = FUNC_NAME_RE.match(line)
166 m = MIR_FUNC_NAME_RE.match(line)
167167 if m:
168168 if bbs == 1:
169169 result.append(cur_func)
170170 cur_func = m.group('func')
171171 bbs = 0
172 m = BASIC_BLOCK_RE.match(line)
172 m = MIR_BASIC_BLOCK_RE.match(line)
173173 if m:
174174 bbs += 1
175175 if bbs == 1:
353353 state = 'document'
354354 output_lines.append(input_line)
355355 elif state == 'document':
356 m = FUNC_NAME_RE.match(input_line)
356 m = MIR_FUNC_NAME_RE.match(input_line)
357357 if m:
358 state = 'function metadata'
358 state = 'mir function metadata'
359359 func_name = m.group('func')
360360 if input_line.strip() == '...':
361361 state = 'toplevel'
362362 func_name = None
363363 if should_add_line_to_output(input_line, prefix_set):
364364 output_lines.append(input_line)
365 elif state == 'function metadata':
365 elif state == 'mir function metadata':
366366 if should_add_line_to_output(input_line, prefix_set):
367367 output_lines.append(input_line)
368 m = BODY_BEGIN_RE.match(input_line)
368 m = MIR_BODY_BEGIN_RE.match(input_line)
369369 if m:
370370 if func_name in simple_functions:
371371 # If there's only one block, put the checks inside it
372 state = 'function prefix'
372 state = 'mir function prefix'
373373 continue
374 state = 'function body'
374 state = 'mir function body'
375375 add_checks_for_function(test, output_lines, run_list,
376376 func_dict, func_name, add_vreg_checks,
377377 single_bb=False, verbose=verbose)
378 elif state == 'function prefix':
379 m = PREFIX_DATA_RE.match(input_line)
378 elif state == 'mir function prefix':
379 m = MIR_PREFIX_DATA_RE.match(input_line)
380380 if not m:
381 state = 'function body'
381 state = 'mir function body'
382382 add_checks_for_function(test, output_lines, run_list,
383383 func_dict, func_name, add_vreg_checks,
384384 single_bb=True, verbose=verbose)
385385
386386 if should_add_line_to_output(input_line, prefix_set):
387387 output_lines.append(input_line)
388 elif state == 'function body':
388 elif state == 'mir function body':
389389 if input_line.strip() == '...':
390390 state = 'toplevel'
391391 func_name = None