diff options
Diffstat (limited to 'llvm/utils')
-rw-r--r-- | llvm/utils/UpdateTestChecks/asm.py | 17 | ||||
-rw-r--r-- | llvm/utils/UpdateTestChecks/common.py | 32 | ||||
-rw-r--r-- | llvm/utils/UpdateTestChecks/isel.py | 57 | ||||
-rwxr-xr-x | llvm/utils/update_cc_test_checks.py | 2 | ||||
-rwxr-xr-x | llvm/utils/update_llc_test_checks.py | 16 |
5 files changed, 94 insertions, 30 deletions
diff --git a/llvm/utils/UpdateTestChecks/asm.py b/llvm/utils/UpdateTestChecks/asm.py index 95d17ba..bb59484 100644 --- a/llvm/utils/UpdateTestChecks/asm.py +++ b/llvm/utils/UpdateTestChecks/asm.py @@ -388,21 +388,6 @@ def scrub_asm_csky(asm, args): asm = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', asm) return asm -def get_triple_from_march(march): - triples = { - 'amdgcn': 'amdgcn', - 'r600': 'r600', - 'mips': 'mips', - 'sparc': 'sparc', - 'hexagon': 'hexagon', - 've': 've', - } - for prefix, triple in triples.items(): - if march.startswith(prefix): - return triple - print("Cannot find a triple. Assume 'x86'", file=sys.stderr) - return 'x86' - def get_run_handler(triple): target_handlers = { 'i686': (scrub_asm_x86, ASM_FUNCTION_X86_RE), @@ -456,7 +441,7 @@ def get_run_handler(triple): ##### Generator of assembly CHECK lines -def add_asm_checks(output_lines, comment_marker, prefix_list, func_dict, +def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, is_filtered): # Label format is based on ASM string. check_label_format = '{} %s-LABEL: %s%s:'.format(comment_marker) diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index dbcff53..3361f68 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -306,6 +306,7 @@ IR_FUNCTION_RE = re.compile(r'^\s*define\s+(?:internal\s+)?[^@]*@"?([\w.$-]+)"?\ TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$') TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)') MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)') +DEBUG_ONLY_ARG_RE = re.compile(r'-debug-only[= ]([^ ]+)') SCRUB_LEADING_WHITESPACE_RE = re.compile(r'^(\s+)') SCRUB_WHITESPACE_RE = re.compile(r'(?!^(| \w))[ \t]+', flags=re.M) @@ -351,6 +352,21 @@ def find_run_lines(test, lines): debug(' RUN: {}'.format(l)) return run_lines +def get_triple_from_march(march): + triples = { + 'amdgcn': 'amdgcn', + 'r600': 'r600', + 'mips': 'mips', + 'sparc': 'sparc', + 'hexagon': 'hexagon', + 've': 've', + } + for prefix, triple in triples.items(): + if march.startswith(prefix): + return triple + print("Cannot find a triple. Assume 'x86'", file=sys.stderr) + return 'x86' + def apply_filters(line, filters): has_filter = False for f in filters: @@ -390,7 +406,7 @@ class function_body(object): self.extrascrub = extra self.args_and_sig = args_and_sig self.attrs = attrs - def is_same_except_arg_names(self, extrascrub, args_and_sig, attrs, is_asm): + def is_same_except_arg_names(self, extrascrub, args_and_sig, attrs, is_backend): arg_names = set() def drop_arg_names(match): arg_names.add(match.group(variable_group_in_ir_value_match)) @@ -409,9 +425,9 @@ class function_body(object): ans1 = IR_VALUE_RE.sub(drop_arg_names, args_and_sig) if ans0 != ans1: return False - if is_asm: + if is_backend: # Check without replacements, the replacements are not applied to the - # body for asm checks. + # body for backend checks. return self.extrascrub == extrascrub es0 = IR_VALUE_RE.sub(repl_arg_names, self.extrascrub) @@ -460,7 +476,7 @@ class FunctionTestBuilder: def is_filtered(self): return bool(self._filters) - def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes, is_asm): + def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes, is_backend): build_global_values_dictionary(self._global_var_dict, raw_tool_output, prefixes) for m in function_re.finditer(raw_tool_output): if not m: @@ -528,7 +544,7 @@ class FunctionTestBuilder: scrubbed_extra, args_and_sig, attrs, - is_asm)): + is_backend)): self._func_dict[prefix][func].scrub = scrubbed_extra self._func_dict[prefix][func].args_and_sig = args_and_sig continue @@ -766,7 +782,7 @@ def generalize_check_lines(lines, is_analyze, vars_seen, global_vars_seen): return lines -def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, is_asm, is_analyze, global_vars_seen_dict, is_filtered): +def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, is_backend, is_analyze, global_vars_seen_dict, is_filtered): # prefix_exclusions are prefixes we cannot use to print the function because it doesn't exist in run lines that use these prefixes as well. prefix_exclusions = set() printed_prefixes = [] @@ -801,7 +817,7 @@ def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, # Add some space between different check prefixes, but not after the last # check line (before the test code). - if is_asm: + if is_backend: if len(printed_prefixes) != 0: output_lines.append(comment_marker) @@ -829,7 +845,7 @@ def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, continue # For ASM output, just emit the check lines. - if is_asm: + if is_backend: body_start = 1 if is_filtered: # For filtered output we don't add "-NEXT" so don't add extra spaces diff --git a/llvm/utils/UpdateTestChecks/isel.py b/llvm/utils/UpdateTestChecks/isel.py new file mode 100644 index 0000000..a77800a --- /dev/null +++ b/llvm/utils/UpdateTestChecks/isel.py @@ -0,0 +1,57 @@ +import re +from . import common +import sys + +if sys.version_info[0] > 2: + class string: + expandtabs = str.expandtabs +else: + import string + +# Support of isel debug checks +# RegEx: this is where the magic happens. + +##### iSel parser + +# TODO: add function prefix +ISEL_FUNCTION_DEFAULT_RE = re.compile( + r'Selected[\s]*selection[\s]*DAG:[\s]*%bb.0[\s]*\'(?P<func>.*?):[^\']*\'*\n' + r'(?P<body>.*?)\n' + r'Total[\s]*amount[\s]*of[\s]*phi[\s]*nodes[\s]*to[\s]*update:[\s]*[0-9]+', + flags=(re.M | re.S)) + +def scrub_isel_default(isel, args): + # Scrub runs of whitespace out of the iSel debug output, but leave the leading + # whitespace in place. + isel = common.SCRUB_WHITESPACE_RE.sub(r' ', isel) + # Expand the tabs used for indentation. + isel = string.expandtabs(isel, 2) + # Strip trailing whitespace. + isel = common.SCRUB_TRAILING_WHITESPACE_RE.sub(r'', isel) + return isel + +def get_run_handler(triple): + target_handlers = { + } + handler = None + best_prefix = '' + for prefix, s in target_handlers.items(): + if triple.startswith(prefix) and len(prefix) > len(best_prefix): + handler = s + best_prefix = prefix + + if handler is None: + common.debug('Using default handler.') + handler = (scrub_isel_default, ISEL_FUNCTION_DEFAULT_RE) + + return handler + +##### Generator of iSel CHECK lines + +def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, is_filtered): + # Label format is based on iSel string. + check_label_format = '{} %s-LABEL: %s%s:'.format(comment_marker) + global_vars_seen_dict = {} + common.add_checks(output_lines, comment_marker, prefix_list, func_dict, + func_name, check_label_format, True, False, + global_vars_seen_dict, is_filtered = is_filtered) diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index d9c53c3..1299efd4 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -347,7 +347,7 @@ def main(): global_vars_seen_dict, is_filtered=builder.is_filtered()) else: - asm.add_asm_checks(my_output_lines, '//', + asm.add_checks(my_output_lines, '//', prefixes, func_dict, func, is_filtered=builder.is_filtered()) diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py index cf68d23..03e30c8 100755 --- a/llvm/utils/update_llc_test_checks.py +++ b/llvm/utils/update_llc_test_checks.py @@ -12,7 +12,7 @@ from __future__ import print_function import argparse import os # Used to advertise this file's name ("autogenerated_note"). -from UpdateTestChecks import asm, common +from UpdateTestChecks import common # llc is the only llc-like in the LLVM tree but downstream forks can add # additional ones here if they have them. @@ -79,6 +79,12 @@ def main(): if m: march_in_cmd = m.groups()[0] + m = common.DEBUG_ONLY_ARG_RE.search(llc_cmd) + if m and m.groups()[0] == 'isel': + from UpdateTestChecks import isel as output_type + else: + from UpdateTestChecks import asm as output_type + common.verify_filecheck_prefixes(filecheck_cmd) if llc_tool not in LLC_LIKE_TOOLS: common.warn('Skipping non-llc RUN line: ' + l) @@ -127,9 +133,9 @@ def main(): verbose=ti.args.verbose) triple = triple_in_cmd or triple_in_ir if not triple: - triple = asm.get_triple_from_march(march_in_cmd) + triple = common.get_triple_from_march(march_in_cmd) - scrubber, function_re = asm.get_run_handler(triple) + scrubber, function_re = output_type.get_run_handler(triple) builder.process_run_line(function_re, scrubber, raw_tool_output, prefixes, True) func_dict = builder.finish_and_get_func_dict() @@ -160,7 +166,7 @@ def main(): common.add_checks_at_end(output_lines, run_list, builder.func_order(), check_indent + ';', lambda my_output_lines, prefixes, func: - asm.add_asm_checks(my_output_lines, + output_type.add_checks(my_output_lines, check_indent + ';', prefixes, func_dict, func, is_filtered=builder.is_filtered())) @@ -178,7 +184,7 @@ def main(): continue # Print out the various check lines here. - asm.add_asm_checks(output_lines, check_indent + ';', run_list, + output_type.add_checks(output_lines, check_indent + ';', run_list, func_dict, func_name, is_filtered=builder.is_filtered()) is_in_function_start = False |