diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -13,6 +13,14 @@ ##### Common utilities for update_*test_checks.py + +def parse_commandline_args(parser): + parser.add_argument('-v', '--verbose', action='store_true', + help='Show verbose output') + parser.add_argument('-u', '--update-only', action='store_true', + help='Only update test if it was already autogened') + return parser.parse_args() + def should_add_line_to_output(input_line, prefix_set): # Skip any blank comment lines in the IR. if input_line.strip() == ';': diff --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py --- a/llvm/utils/update_analyze_test_checks.py +++ b/llvm/utils/update_analyze_test_checks.py @@ -52,16 +52,12 @@ def main(): from argparse import RawTextHelpFormatter parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter) - parser.add_argument('-v', '--verbose', action='store_true', - help='Show verbose output') parser.add_argument('--opt-binary', default='opt', help='The opt binary used to generate the test case') parser.add_argument( '--function', help='The function in the test file to update') - parser.add_argument('-u', '--update-only', action='store_true', - help='Only update test if it was already autogened') parser.add_argument('tests', nargs='+') - args = parser.parse_args() + args = common.parse_commandline_args(parser) script_name = os.path.basename(__file__) autogenerated_note = (ADVERT + 'utils/' + script_name) diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -90,7 +90,6 @@ parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawTextHelpFormatter) - parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('--llvm-bin', help='llvm $prefix/bin path') parser.add_argument('--clang', help='"clang" executable, defaults to $llvm_bin/clang') @@ -104,10 +103,8 @@ parser.add_argument( '--x86_extra_scrub', action='store_true', help='Use more regex for x86 matching to reduce diffs between various subtargets') - parser.add_argument('-u', '--update-only', action='store_true', - help='Only update test if it was already autogened') parser.add_argument('tests', nargs='+') - args = parser.parse_args() + args = common.parse_commandline_args(parser) args.clang_args = shlex.split(args.clang_args or '') if args.clang is None: diff --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py --- a/llvm/utils/update_llc_test_checks.py +++ b/llvm/utils/update_llc_test_checks.py @@ -24,8 +24,6 @@ def main(): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('-v', '--verbose', action='store_true', - help='Show verbose output') parser.add_argument('--llc-binary', default='llc', help='The "llc" binary to use to generate the test case') parser.add_argument( @@ -38,10 +36,8 @@ help='Use more regex for x86 matching to reduce diffs between various subtargets') parser.add_argument( '--no_x86_scrub_rip', action='store_false', dest='x86_scrub_rip') - parser.add_argument('-u', '--update-only', action='store_true', - help='Only update test if it was already autogened') parser.add_argument('tests', nargs='+') - args = parser.parse_args() + args = common.parse_commandline_args(parser) script_name = os.path.basename(__file__) diff --git a/llvm/utils/update_mca_test_checks.py b/llvm/utils/update_mca_test_checks.py --- a/llvm/utils/update_mca_test_checks.py +++ b/llvm/utils/update_mca_test_checks.py @@ -56,9 +56,6 @@ def _parse_args(): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('-v', '--verbose', - action='store_true', - help='show verbose output') parser.add_argument('-w', action='store_true', help='suppress warnings') @@ -73,7 +70,7 @@ parser.add_argument('tests', metavar='', nargs='+') - args = parser.parse_args() + args = common.parse_commandline_args(parser) _configure_warnings(args) diff --git a/llvm/utils/update_mir_test_checks.py b/llvm/utils/update_mir_test_checks.py --- a/llvm/utils/update_mir_test_checks.py +++ b/llvm/utils/update_mir_test_checks.py @@ -430,17 +430,13 @@ def main(): parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawTextHelpFormatter) - parser.add_argument('-v', '--verbose', action='store_true', - help='Show verbose output') parser.add_argument('--llc-binary', dest='llc', default='llc', type=LLC, help='The "llc" binary to generate the test case with') parser.add_argument('--remove-common-prefixes', action='store_true', help='Remove existing check lines whose prefixes are ' 'shared between multiple commands') - parser.add_argument('-u', '--update-only', action='store_true', - help='Only update test if it was already autogened') parser.add_argument('tests', nargs='+') - args = parser.parse_args() + args = common.parse_commandline_args(parser) test_paths = [test for pattern in args.tests for test in glob.glob(pattern)] for test in test_paths: diff --git a/llvm/utils/update_test_checks.py b/llvm/utils/update_test_checks.py --- a/llvm/utils/update_test_checks.py +++ b/llvm/utils/update_test_checks.py @@ -56,20 +56,16 @@ def main(): from argparse import RawTextHelpFormatter parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter) - parser.add_argument('-v', '--verbose', action='store_true', - help='Show verbose output') parser.add_argument('--opt-binary', default='opt', help='The opt binary used to generate the test case') parser.add_argument( '--function', help='The function in the test file to update') - parser.add_argument('-u', '--update-only', action='store_true', - help='Only update test if it was already autogened') parser.add_argument('-p', '--preserve-names', action='store_true', help='Do not scrub IR names') parser.add_argument('--function-signature', action='store_true', help='Keep function signature information around for the check line') parser.add_argument('tests', nargs='+') - args = parser.parse_args() + args = common.parse_commandline_args(parser) script_name = os.path.basename(__file__) autogenerated_note = (ADVERT + 'utils/' + script_name)