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);
}
{
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);
}
{
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
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 */
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 */
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;
#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
" --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"
" --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 *);
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);
}
-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