llvm.org GIT mirror llvm / ddf3aca
update_mir_test_checks: Drop support for vreg block checks Since vregs are printed in the instruction stream now, checking the vreg block is always redundant. Remove the temporary feature that allowed us to do that. This reverts r316134 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326284 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 2 years ago
1 changed file(s) with 9 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
4040 r'^ *(?P{0}(?:, {0})*) '
4141 r'= (?P[A-Zt][A-Za-z0-9_]+)'.format(VREG_RE.pattern))
4242 MIR_PREFIX_DATA_RE = re.compile(r'^ *(;|bb.[0-9].*: *$|[a-z]+:( |$)|$)')
43 VREG_CLASS_RE = re.compile(r'^ *- *{ id: ([0-9]+), class: ([a-z0-9_]+)', re.M)
4443
4544 IR_FUNC_NAME_RE = re.compile(
4645 r'^\s*define\s+(?:internal\s+)?[^@]*@(?P[A-Za-z0-9_.]+)\s*\(')
5049 r'^---$'
5150 r'\n'
5251 r'^ *name: *(?P[A-Za-z0-9_.-]+)$'
53 r'(?:.*?(?P^ *registers: *(?:\n *- {[^\n]+$)*))?'
5452 r'.*?'
5553 r'^ *body: *\|\n'
5654 r'(?P.*?)\n'
195193 warn('Found conflicting asm for prefix: {}'.format(prefix),
196194 test_file=test)
197195 func_dict[prefix][func] = body
198 func_dict[prefix]['{}:vregs'.format(func)] = m.group('vregs')
199196
200197
201198 def add_checks_for_function(test, output_lines, run_list, func_dict, func_name,
202 add_vreg_checks, single_bb, verbose=False):
199 single_bb, verbose=False):
203200 printed_prefixes = set()
204201 for run in run_list:
205202 for prefix in run.prefixes:
212209 # output_lines.append('')
213210 printed_prefixes.add(prefix)
214211 log('Adding {} lines for {}'.format(prefix, func_name), verbose)
215 vregs = None
216 if add_vreg_checks:
217 vregs = func_dict[prefix]['{}:vregs'.format(func_name)]
218212 add_check_lines(test, output_lines, prefix, func_name, single_bb,
219 func_dict[prefix][func_name].splitlines(), vregs)
213 func_dict[prefix][func_name].splitlines())
220214 break
221215 return output_lines
222216
223217
224218 def add_check_lines(test, output_lines, prefix, func_name, single_bb,
225 func_body, vreg_data):
219 func_body):
226220 if single_bb:
227221 # Don't bother checking the basic block label for a single BB
228222 func_body.pop(0)
238232 check = '{:>{}}; {}'.format('', indent, prefix)
239233
240234 output_lines.append('{}-LABEL: name: {}'.format(check, func_name))
241
242 if vreg_data:
243 output_lines.append('{}: registers:'.format(check))
244 for m in VREG_CLASS_RE.finditer(vreg_data):
245 output_lines.append('{}-NEXT: id: {}, class: {}'.format(
246 check, m.group(1), m.group(2)))
247235
248236 vreg_map = {}
249237 for func_line in func_body:
303291 return True
304292
305293
306 def update_test_file(llc, test, remove_common_prefixes=False,
307 add_vreg_checks=False, verbose=False):
294 def update_test_file(llc, test, remove_common_prefixes=False, verbose=False):
308295 log('Scanning for RUN lines in test file: {}'.format(test), verbose)
309296 with open(test) as fd:
310297 input_lines = [l.rstrip() for l in fd]
383370 continue
384371 state = 'mir function body'
385372 add_checks_for_function(test, output_lines, run_list,
386 func_dict, func_name, add_vreg_checks,
387 single_bb=False, verbose=verbose)
373 func_dict, func_name, single_bb=False,
374 verbose=verbose)
388375 elif state == 'mir function prefix':
389376 m = MIR_PREFIX_DATA_RE.match(input_line)
390377 if not m:
391378 state = 'mir function body'
392379 add_checks_for_function(test, output_lines, run_list,
393 func_dict, func_name, add_vreg_checks,
394 single_bb=True, verbose=verbose)
380 func_dict, func_name, single_bb=True,
381 verbose=verbose)
395382
396383 if should_add_line_to_output(input_line, prefix_set):
397384 output_lines.append(input_line)
435422 parser.add_argument('--remove-common-prefixes', action='store_true',
436423 help='Remove existing check lines whose prefixes are '
437424 'shared between multiple commands')
438 parser.add_argument('--add-vreg-checks', action='store_true',
439 help='Add checks for the "registers:" block')
440425 parser.add_argument('tests', nargs='+')
441426 args = parser.parse_args()
442427
443428 for test in args.tests:
444429 try:
445430 update_test_file(args.llc, test, args.remove_common_prefixes,
446 args.add_vreg_checks, verbose=args.verbose)
431 verbose=args.verbose)
447432 except Exception:
448433 warn('Error processing file', test_file=test)
449434 raise