From: Florian K. <fk...@so...> - 2025-03-30 21:33:00
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=19b70d658a24903a9f0b179301a0300c1b256646 commit 19b70d658a24903a9f0b179301a0300c1b256646 Author: Florian Krohm <fl...@ei...> Date: Sun Mar 30 21:32:37 2025 +0000 s390x disasm-test: Remove command line flags --d12, --d20, --sint, --uint These were somewhat useful in the early days of development. Not anymore. Diff: --- none/tests/s390x/disasm-test/README | 22 ------ none/tests/s390x/disasm-test/generate.c | 114 +++++++++++++------------------- none/tests/s390x/disasm-test/main.c | 37 ----------- none/tests/s390x/disasm-test/main.h | 4 -- 4 files changed, 47 insertions(+), 130 deletions(-) diff --git a/none/tests/s390x/disasm-test/README b/none/tests/s390x/disasm-test/README index d04292374a..36485aec33 100644 --- a/none/tests/s390x/disasm-test/README +++ b/none/tests/s390x/disasm-test/README @@ -77,28 +77,6 @@ Debugging options --debug Additional debugging output. ---d12=INT - Use INT as the value for d12 fields. The given value is checked - for feasibility. - ---d20=INT - Use INT as the value for d20 fields. The given value is checked - for feasibility. - ---sint=INT - Use INT as the only value for signed integer fields. The given value - is NOT checked for feasibility (as the field width is not known). - The value is expected to fit in 32 bits (and is complained about - if it doesn't), as there are no opcodes with immediate operands - that have more than 32 bits. - ---uint=INT - Use INT as the only value for unsigned integer fields. The given value - is NOT checked for feasibility (as the field width is not known). - The value is expected to fit in 32 bits (and is complained about - if it doesn't), as there are no opcodes with immediate operands - that have more than 32 bits. - Testcase generation ------------------- diff --git a/none/tests/s390x/disasm-test/generate.c b/none/tests/s390x/disasm-test/generate.c index 25bcdae26e..2dc1970425 100644 --- a/none/tests/s390x/disasm-test/generate.c +++ b/none/tests/s390x/disasm-test/generate.c @@ -144,14 +144,14 @@ random_sint(unsigned num_bits) static unsigned d12_value(void) { - return d12_val_specified ? d12_val : random_uint(12); + return random_uint(12); } static int d20_value(void) { - return d20_val_specified ? d20_val : random_sint(20); + return random_sint(20); } @@ -160,7 +160,7 @@ uint_value(unsigned num_bits) { if (num_bits > 32) fatal("integer operand > 32 bits not supported\n"); - return uint_val_specified ? uint_val : random_uint(num_bits); + return random_uint(num_bits); } @@ -169,7 +169,7 @@ sint_value(unsigned num_bits) { if (num_bits > 32) fatal("integer operand > 32 bits not supported\n"); - return sint_val_specified ? sint_val : random_sint(num_bits); + return random_sint(num_bits); } #endif @@ -338,17 +338,12 @@ iterate(FILE *fp, const opcode *opc, field fields[], unsigned ix) case OPND_D12LB: case OPND_D12VB: if (f->is_displacement) { - if (d12_val_specified) { - f->assigned_value = d12_val; + /* Choose these interesting values */ + static const long long values[] = { 0, 1, 2, 0xfff }; + + for (int i = 0; i < sizeof values / sizeof *values; ++i) { + f->assigned_value = values[i]; iterate(fp, opc, fields, ix + 1); - } else { - /* Choose these interesting values */ - static const long long values[] = { 0, 1, 2, 0xfff }; - - for (int i = 0; i < sizeof values / sizeof *values; ++i) { - f->assigned_value = values[i]; - iterate(fp, opc, fields, ix + 1); - } } } else if (f->is_length) { /* Choose these interesting values */ @@ -376,19 +371,14 @@ iterate(FILE *fp, const opcode *opc, field fields[], unsigned ix) case OPND_D20B: case OPND_D20XB: if (f->is_displacement) { - if (d20_val_specified) { - f->assigned_value = d20_val; + /* Choose these interesting values */ + static const long long values[] = { + 0, 1, 2, -1, -2, 0x7ffff, -0x80000 + }; + + for (int i = 0; i < sizeof values / sizeof *values; ++i) { + f->assigned_value = values[i]; iterate(fp, opc, fields, ix + 1); - } else { - /* Choose these interesting values */ - static const long long values[] = { - 0, 1, 2, -1, -2, 0x7ffff, -0x80000 - }; - - for (int i = 0; i < sizeof values / sizeof *values; ++i) { - f->assigned_value = values[i]; - iterate(fp, opc, fields, ix + 1); - } } } else { /* base or index register */ @@ -401,54 +391,44 @@ iterate(FILE *fp, const opcode *opc, field fields[], unsigned ix) case OPND_SINT: case OPND_PCREL: - if (sint_val_specified) { - f->assigned_value = sint_val; - iterate(fp, opc, fields, ix + 1); + if (operand->allowed_values == NULL) { + /* No constraint: Choose these interesting values */ + const long long values[] = { + 0, 1, 2, -1, -2, (1LL << (operand->num_bits - 1)) - 1, + -(1LL << (operand->num_bits - 1)) + }; + + for (int i = 0; i < sizeof values / sizeof *values; ++i) { + f->assigned_value = values[i]; + iterate(fp, opc, fields, ix + 1); + } } else { - if (operand->allowed_values == NULL) { - /* No constraint: Choose these interesting values */ - const long long values[] = { - 0, 1, 2, -1, -2, (1LL << (operand->num_bits - 1)) - 1, - -(1LL << (operand->num_bits - 1)) - }; - - for (int i = 0; i < sizeof values / sizeof *values; ++i) { - f->assigned_value = values[i]; - iterate(fp, opc, fields, ix + 1); - } - } else { - /* Constraint. Choose only allowed values */ - unsigned num_val = operand->allowed_values[0]; - for (int i = 1; i <= num_val; ++i) { - f->assigned_value = operand->allowed_values[i]; - iterate(fp, opc, fields, ix + 1); - } + /* Constraint. Choose only allowed values */ + unsigned num_val = operand->allowed_values[0]; + for (int i = 1; i <= num_val; ++i) { + f->assigned_value = operand->allowed_values[i]; + iterate(fp, opc, fields, ix + 1); } } break; case OPND_UINT: - if (uint_val_specified) { - f->assigned_value = uint_val; - iterate(fp, opc, fields, ix + 1); + if (operand->allowed_values == NULL) { + /* No constraint: Choose these interesting values */ + const long long values[] = { + 0, 1, 2, (1LL << operand->num_bits) - 1 + }; + + for (int i = 0; i < sizeof values / sizeof *values; ++i) { + f->assigned_value = values[i]; + iterate(fp, opc, fields, ix + 1); + } } else { - if (operand->allowed_values == NULL) { - /* No constraint: Choose these interesting values */ - const long long values[] = { - 0, 1, 2, (1LL << operand->num_bits) - 1 - }; - - for (int i = 0; i < sizeof values / sizeof *values; ++i) { - f->assigned_value = values[i]; - iterate(fp, opc, fields, ix + 1); - } - } else { - /* Constraint. Choose only allowed values */ - unsigned num_val = operand->allowed_values[0]; - for (int i = 1; i <= num_val; ++i) { - f->assigned_value = operand->allowed_values[i]; - iterate(fp, opc, fields, ix + 1); - } + /* Constraint. Choose only allowed values */ + unsigned num_val = operand->allowed_values[0]; + for (int i = 1; i <= num_val; ++i) { + f->assigned_value = operand->allowed_values[i]; + iterate(fp, opc, fields, ix + 1); } } break; diff --git a/none/tests/s390x/disasm-test/main.c b/none/tests/s390x/disasm-test/main.c index 46f55cf4ce..f74dc73894 100644 --- a/none/tests/s390x/disasm-test/main.c +++ b/none/tests/s390x/disasm-test/main.c @@ -33,10 +33,6 @@ #include "main.h" int verbose, debug, show_spec_exc, show_miscompares; -int d12_val, d20_val; -long long uint_val, sint_val; -int d12_val_specified, d20_val_specified; -int uint_val_specified, sint_val_specified; const char *gcc = "gcc"; // path to GCC const char *objdump = "objdump"; // path to objdump @@ -62,10 +58,6 @@ static const char usage[] = " --gcc=/path/to/gcc\n" " --gcc-flags=FLAGS\n" " --objdump=/path/to/objdump\n" - " --d12=INT - Use INT as value for d12 offsets\n" - " --d20=INT - Use INT as value for d20 offsets\n" - " --sint=INT - Use INT as value for signed integer fields\n" - " --uint=INT - Use INT as value for unsigned integer fields\n" " --keep-temp - Do not remove temporary files\n" " --summary - Output test generation summary (with --all)\n" " --unit-test - Run unit tests\n" @@ -73,8 +65,6 @@ static const char usage[] = " --no-show-miscompares - Do not show disassembly miscompares\n" ; -static long long get_clo_value(const char *, const char *, long long, - long long); static void remove_temp_files(const char *); static int opcode_has_errors(const opcode *); @@ -137,17 +127,6 @@ main(int argc, char *argv[]) gcc_flags = strchr(clo, '=') + 1; } else if (CHECK_CLO(clo, "--objdump=")) { objdump = strchr(clo, '=') + 1; - } else if (CHECK_CLO(clo, "--d12=")) { - d12_val = get_clo_value(clo, "d12", 0, 0xfff); - } else if (CHECK_CLO(clo, "--d20=")) { - d20_val = get_clo_value(clo, "d20", -0x80000, 0x7ffff); - } else if (CHECK_CLO(clo, "--sint=")) { - /* Integer field is restricted to 32-bit */ - long long max = 0x7fffffff; - sint_val = get_clo_value(clo, "sint", -max - 1, max); - } else if (CHECK_CLO(clo, "--uint=")) { - /* Integer field is restricted to 32-bit */ - uint_val = get_clo_value(clo, "uint", 0, 0xffffffffU); } else { if (strncmp(clo, "--", 2) == 0) fatal("Invalid command line option '%s'\n", clo); @@ -341,22 +320,6 @@ strnsave(const char *s, unsigned len) } -static long long -get_clo_value(const char *clo, const char *field_name, long long min, - long long max) -{ - long long value; - - const char *p = strchr(clo, '=') + 1; // succeeds - - if (sscanf(p, "%lld", &value) != 1) - fatal("%s value '%s' is not an integer\n", field_name, p); - if (value < min || value > max) - fatal("%s value '%lld' is out of range\n", field_name, value); - return value; -} - - /* Return 1, if the given opcode has at least one invalid operand. This indicates that there were parse errors earlier. */ static int diff --git a/none/tests/s390x/disasm-test/main.h b/none/tests/s390x/disasm-test/main.h index f51ad0c0b7..8c51b1dc20 100644 --- a/none/tests/s390x/disasm-test/main.h +++ b/none/tests/s390x/disasm-test/main.h @@ -91,10 +91,6 @@ extern int verbose; extern int debug; extern int show_spec_exc; extern int show_miscompares; -extern int d12_val, d20_val; -extern long long sint_val, uint_val; -extern int d12_val_specified, d20_val_specified; -extern int uint_val_specified, sint_val_specified; extern unsigned num_opcodes; extern const char *gcc; extern const char *gcc_flags; |