aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks
diff options
context:
space:
mode:
authorMircea Trofin <mtrofin@google.com>2020-12-16 10:20:12 -0800
committerMircea Trofin <mtrofin@google.com>2020-12-16 21:12:06 -0800
commited1e565aaff6a2b6ad9064bcc58c50a46100a836 (patch)
tree893cfe12b044b97839d5b3c3556862472e9de192 /llvm/utils/UpdateTestChecks
parent541e476fc0682e71d70f6cfc7a42592910acf2a5 (diff)
downloadllvm-ed1e565aaff6a2b6ad9064bcc58c50a46100a836.zip
llvm-ed1e565aaff6a2b6ad9064bcc58c50a46100a836.tar.gz
llvm-ed1e565aaff6a2b6ad9064bcc58c50a46100a836.tar.bz2
[NFC] factor update test function test builder as a class
This allows us to have shared logic over multiple test runs, e.g. do we have unused prefixes, or which function bodies have conflicting outputs for a prefix appearing in different RUN lines. This patch is just wrapping existing functionality, and replacing its uses. A subsequent patch would then fold the current functionality into the newly introduced class. Differential Revision: https://reviews.llvm.org/D93413
Diffstat (limited to 'llvm/utils/UpdateTestChecks')
-rw-r--r--llvm/utils/UpdateTestChecks/asm.py8
-rw-r--r--llvm/utils/UpdateTestChecks/common.py27
2 files changed, 28 insertions, 7 deletions
diff --git a/llvm/utils/UpdateTestChecks/asm.py b/llvm/utils/UpdateTestChecks/asm.py
index 476e7f1..839b727 100644
--- a/llvm/utils/UpdateTestChecks/asm.py
+++ b/llvm/utils/UpdateTestChecks/asm.py
@@ -324,8 +324,7 @@ def get_triple_from_march(march):
print("Cannot find a triple. Assume 'x86'", file=sys.stderr)
return 'x86'
-def build_function_body_dictionary_for_triple(args, raw_tool_output, triple,
- prefixes, func_dict, func_order):
+def get_run_handler(triple):
target_handlers = {
'i686': (scrub_asm_x86, ASM_FUNCTION_X86_RE),
'x86': (scrub_asm_x86, ASM_FUNCTION_X86_RE),
@@ -366,10 +365,7 @@ def build_function_body_dictionary_for_triple(args, raw_tool_output, triple,
if handler is None:
raise KeyError('Triple %r is not supported' % (triple))
- scrubber, function_re = handler
- common.build_function_body_dictionary(
- function_re, scrubber, [args], raw_tool_output, prefixes,
- func_dict, func_order, args.verbose, False, False)
+ return handler
##### Generator of assembly CHECK lines
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 21878e8..128792d 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -322,7 +322,32 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too
func_dict[prefix][func] = function_body(scrubbed_body, scrubbed_extra, args_and_sig, attrs)
func_order[prefix].append(func)
- warn_on_failed_prefixes(func_dict)
+
+class FunctionTestBuilder:
+ def __init__(self, run_list, flags, scrubber_args):
+ self._verbose = flags.verbose
+ self._record_args = flags.function_signature
+ self._check_attributes = flags.check_attributes
+ self._scrubber_args = scrubber_args
+ self._func_dict = {}
+ self._func_order = {}
+ for tuple in run_list:
+ for prefix in tuple[0]:
+ self._func_dict.update({prefix:dict()})
+ self._func_order.update({prefix: []})
+
+ def finish_and_get_func_dict(self):
+ warn_on_failed_prefixes(self._func_dict)
+ return self._func_dict
+
+ def func_order(self):
+ return self._func_order
+
+ def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes):
+ build_function_body_dictionary(function_re, scrubber, self._scrubber_args,
+ raw_tool_output, prefixes, self._func_dict,
+ self._func_order, self._verbose,
+ self._record_args, self._check_attributes)
##### Generator of LLVM IR CHECK lines