diff options
author | David Schleef <ds@schleef.org> | 2010-08-18 18:24:10 -0700 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2010-08-18 18:24:10 -0700 |
commit | 0b26518f52bcd9f227c042ed68d7516484fce0eb (patch) | |
tree | 55efbfa2d538e54359b8200a74aa16abc2cc2e33 /orc-test | |
parent | 1a5aca288f297520542bb88a9160c13b5b0b3619 (diff) |
test: Improve opcode test program generation
Diffstat (limited to 'orc-test')
-rw-r--r-- | orc-test/orctest.c | 100 |
1 files changed, 71 insertions, 29 deletions
diff --git a/orc-test/orctest.c b/orc-test/orctest.c index bcf2b36..7ddc1b2 100644 --- a/orc-test/orctest.c +++ b/orc-test/orctest.c @@ -724,21 +724,25 @@ orc_test_get_program_for_opcode (OrcStaticOpcode *opcode) { OrcProgram *p; char s[40]; + int flags = 0; + p = orc_program_new (); if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { - if (opcode->src_size[1] == 0) { - p = orc_program_new_as (opcode->dest_size[0], opcode->src_size[0]); - } else { - p = orc_program_new_ass (opcode->dest_size[0], opcode->src_size[0], - opcode->src_size[1]); - } + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); } else { - if (opcode->src_size[1] == 0) { - p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); - } else { - p = orc_program_new_dss (opcode->dest_size[0], opcode->src_size[0], - opcode->src_size[1]); - } + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + orc_program_add_source (p, opcode->src_size[0], "s1"); + if (opcode->src_size[1] != 0) { + orc_program_add_source (p, opcode->src_size[1], "s2"); + } + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; } sprintf(s, "test_%s", opcode->name); @@ -759,26 +763,45 @@ orc_test_get_program_for_opcode_const (OrcStaticOpcode *opcode) { OrcProgram *p; char s[40]; + int args[4] = { -1, -1, -1, -1 }; + int flags; + int n_args = 0; if (opcode->src_size[1] == 0) { return NULL; } + p = orc_program_new (); if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { - p = orc_program_new_as (opcode->dest_size[0], opcode->src_size[0]); + args[n_args++] = + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); } else { - p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); + args[n_args++] = + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + args[n_args++] = + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + args[n_args++] = + orc_program_add_source (p, opcode->src_size[0], "s1"); + args[n_args++] = + orc_program_add_constant (p, opcode->src_size[1], 1, "c1"); + if (opcode->src_size[2]) { + args[n_args++] = + orc_program_add_constant (p, opcode->src_size[2], 1, "c2"); + } + + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; } - orc_program_add_constant (p, opcode->src_size[1], 1, "c1"); sprintf(s, "test_const_%s", opcode->name); orc_program_set_name (p, s); - if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { - orc_program_append_str (p, opcode->name, "a1", "s1", "c1"); - } else { - orc_program_append_str (p, opcode->name, "d1", "s1", "c1"); - } + orc_program_append_2 (p, opcode->name, 0, args[0], args[1], + args[2], args[3]); return p; } @@ -788,26 +811,45 @@ orc_test_get_program_for_opcode_param (OrcStaticOpcode *opcode) { OrcProgram *p; char s[40]; + int args[4] = { -1, -1, -1, -1 }; + int flags; + int n_args = 0; if (opcode->src_size[1] == 0) { return NULL; } + p = orc_program_new (); if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { - p = orc_program_new_as (opcode->dest_size[0], opcode->src_size[0]); + args[n_args++] = + orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); } else { - p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); + args[n_args++] = + orc_program_add_destination (p, opcode->dest_size[0], "d1"); + } + if (opcode->dest_size[1] != 0) { + args[n_args++] = + orc_program_add_destination (p, opcode->dest_size[1], "d2"); + } + args[n_args++] = + orc_program_add_source (p, opcode->src_size[0], "s1"); + args[n_args++] = + orc_program_add_parameter (p, opcode->src_size[1], "p1"); + if (opcode->src_size[2]) { + args[n_args++] = + orc_program_add_parameter (p, opcode->src_size[2], "p2"); } - orc_program_add_parameter (p, opcode->src_size[1], "p1"); - sprintf(s, "test_const_%s", opcode->name); + if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || + (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { + flags = ORC_TEST_FLAGS_FLOAT; + } + + sprintf(s, "test_p_%s", opcode->name); orc_program_set_name (p, s); - if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { - orc_program_append_str (p, opcode->name, "a1", "s1", "p1"); - } else { - orc_program_append_str (p, opcode->name, "d1", "s1", "p1"); - } + orc_program_append_2 (p, opcode->name, 0, args[0], args[1], + args[2], args[3]); return p; } |