diff options
author | Wim Taymans <wtaymans@redhat.com> | 2015-06-22 13:13:36 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2015-06-22 13:13:36 +0200 |
commit | 4c81fbf198184e2ee986ac88d73ba81382bcff7a (patch) | |
tree | 361bbf813bbc435e460122e99123b748dc83679b | |
parent | 8f6487540d28b47c47cd5b93d21cad2c3c5d6e34 (diff) |
program: only reuse constants of the same size and value
When reusing an existing constant, make sure not only the value but also
the size is the same. We then also need to make a name based on the size
and value so that we can store the same value for different sizes.
Fixes problem with the bayer functions that used 255 as a 16 and 8 bit
constant. This was not detected in the unit test because both the backup
and asm functions do the same error, but it could be seen when a new
backup function was checked against a older ORC.
-rw-r--r-- | orc/orccompiler.c | 2 | ||||
-rw-r--r-- | orc/orcparse.c | 15 | ||||
-rw-r--r-- | orc/orcprogram.c | 3 |
3 files changed, 15 insertions, 5 deletions
diff --git a/orc/orccompiler.c b/orc/orccompiler.c index 3618f5b..352ec6e 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -565,7 +565,7 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) if (var->vartype == ORC_VAR_TYPE_SRC || var->vartype == ORC_VAR_TYPE_DEST) { OrcInstruction *cinsn; - + cinsn = compiler->insns + compiler->n_insns; compiler->n_insns++; diff --git a/orc/orcparse.c b/orc/orcparse.c index f4d0a28..8d6be4c 100644 --- a/orc/orcparse.c +++ b/orc/orcparse.c @@ -307,13 +307,22 @@ orc_parse_full (const char *code, OrcProgram ***programs, char **log) for(i=offset+1,j=0;i<n_tokens;i++,j++){ char *end; double unused ORC_GNUC_UNUSED; + char varname[20]; + + args[j] = token[i]; unused = strtod (token[i], &end); if (end != token[i]) { - orc_program_add_constant_str (parser->program, opcode_arg_size(o, j), - token[i], token[i]); + int id; + + /* make a unique name based on value and size */ + sprintf (varname, "_%d.%s", opcode_arg_size(o, j), token[i]); + id = orc_program_add_constant_str (parser->program, opcode_arg_size(o, j), + token[i], varname); + /* it's possible we reused an existing variable, get its name so + * that we can refer to it in the opcode */ + args[j] = parser->program->vars[id].name; } - args[j] = token[i]; } orc_program_append_str_2 (parser->program, token[offset], flags, diff --git a/orc/orcprogram.c b/orc/orcprogram.c index 1d749c0..c8e3d47 100644 --- a/orc/orcprogram.c +++ b/orc/orcprogram.c @@ -585,7 +585,8 @@ orc_program_add_constant_str (OrcProgram *program, int size, } for(j=0;j<program->n_const_vars;j++){ - if (program->vars[ORC_VAR_C1 + j].value.i == program->vars[i].value.i) { + if (program->vars[ORC_VAR_C1 + j].value.i == program->vars[i].value.i && + program->vars[ORC_VAR_C1 + j].size == size) { return ORC_VAR_C1 + j; } } |