diff options
author | David Schleef <ds@schleef.org> | 2010-08-30 05:09:20 +0400 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2010-08-30 05:13:48 +0400 |
commit | c3501e2ad006a979be15a55cb429a1f0f803b056 (patch) | |
tree | 96b236ca94f6a37109120dd248506b7465192fa3 | |
parent | b13c02370aa6e85e42f70d5c28c84685c54a91c4 (diff) |
orcc: Fix code generation of test
-rw-r--r-- | tools/orcc.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/orcc.c b/tools/orcc.c index 1f6c189..099c180 100644 --- a/tools/orcc.c +++ b/tools/orcc.c @@ -1058,15 +1058,29 @@ output_code_test (OrcProgram *p, FILE *output) enumnames[insn->src_args[0]]); } } else { - if (p->vars[insn->src_args[1]].size != 0) { - fprintf(output, " orc_program_append_2 (p, \"%s\", %d, %s, %s, %s, -1);\n", - insn->opcode->name, insn->flags, enumnames[insn->dest_args[0]], - enumnames[insn->src_args[0]], enumnames[insn->src_args[1]]); - } else { - fprintf(output, " orc_program_append_2 (p, \"%s\", %d, %s, %s, -1, -1);\n", - insn->opcode->name, insn->flags, enumnames[insn->dest_args[0]], - enumnames[insn->src_args[0]]); + int args[4] = { 0, 0, 0, 0 }; + int n_args = 0; + + if (insn->opcode->dest_size[0] != 0) { + args[n_args++] = insn->dest_args[0]; + } + if (insn->opcode->dest_size[1] != 0) { + args[n_args++] = insn->dest_args[1]; + } + if (insn->opcode->src_size[0] != 0) { + args[n_args++] = insn->src_args[0]; } + if (insn->opcode->src_size[1] != 0) { + args[n_args++] = insn->src_args[1]; + } + if (insn->opcode->src_size[2] != 0) { + args[n_args++] = insn->src_args[2]; + } + + fprintf(output, " orc_program_append_2 (p, \"%s\", %d, %s, %s, %s, %s);\n", + insn->opcode->name, insn->flags, enumnames[args[0]], + enumnames[args[1]], enumnames[args[2]], + enumnames[args[3]]); } } |