summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2010-08-14 18:06:34 -0700
committerDavid Schleef <ds@schleef.org>2010-08-14 18:06:34 -0700
commitf684219a4bdc9d663a32a527e3b148a411c4d624 (patch)
tree9276de569a894565c589d1d1dcc902c0d7f63ca5 /tools
parent9853bda6f9d3d21cd028c4bc612c7aaefb5ad72f (diff)
orcc: Fix code generation
Problems with dspp opcodes. Fix a gcc warning about large numbers wrapping around to negative on 32-bit.
Diffstat (limited to 'tools')
-rw-r--r--tools/orcc.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/tools/orcc.c b/tools/orcc.c
index 231096f..b500598 100644
--- a/tools/orcc.c
+++ b/tools/orcc.c
@@ -790,13 +790,8 @@ output_program_generation (OrcProgram *p, FILE *output, int is_inline)
for(i=0;i<8;i++){
var = &p->vars[ORC_VAR_C1 + i];
if (var->size) {
- if (var->value != 0x80000000) {
- fprintf(output, " orc_program_add_constant (p, %d, %u, \"%s\");\n",
- var->size, var->value, varnames[ORC_VAR_C1 + i]);
- } else {
- fprintf(output, " orc_program_add_constant (p, %d, 0x%08x, \"%s\");\n",
- var->size, var->value, varnames[ORC_VAR_C1 + i]);
- }
+ fprintf(output, " orc_program_add_constant (p, %d, 0x%08x, \"%s\");\n",
+ var->size, var->value, varnames[ORC_VAR_C1 + i]);
}
}
for(i=0;i<8;i++){
@@ -837,20 +832,29 @@ output_program_generation (OrcProgram *p, FILE *output, int is_inline)
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, %s);\n",
- insn->opcode->name, insn->flags, enumnames[insn->dest_args[0]],
- enumnames[insn->src_args[0]], enumnames[insn->src_args[1]],
- enumnames[insn->src_args[2]]);
- } 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]]);
}
}
}