diff options
author | Wim Taymans <wtaymans@redhat.com> | 2014-09-18 12:27:01 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-09-18 12:27:01 +0200 |
commit | f6697e30681f46f6f3f632ddbbcab98107eec7e0 (patch) | |
tree | 8f88a847087fe7c905799fa27cceb7161b2bb9bf | |
parent | e65d2007f2a9fb8a6ac0e2b2527636d7afa8e914 (diff) | |
download | orc-f6697e30681f46f6f3f632ddbbcab98107eec7e0.tar.gz |
compiler: generate only 1 temp for constants
Generate only 1 temp variable for constants. We do this by keeping track
of what variable we used to replace the constant.
Previously, orc would allocate a new temp variable every time a constant
was used, this wastes registers and is not needed.
-rw-r--r-- | orc/orccompiler.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/orc/orccompiler.c b/orc/orccompiler.c index 1b403f5..575775b 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -582,6 +582,13 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) OrcInstruction *cinsn; int multiplier; + if (var->vartype == ORC_VAR_TYPE_CONST) { + if (var->replaced) { + insn.src_args[i] = var->replacement; + continue; + } + } + cinsn = compiler->insns + compiler->n_insns; compiler->n_insns++; @@ -598,13 +605,16 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler) cinsn->opcode = get_loadp_opcode_for_size (opcode->src_size[i]); cinsn->dest_args[0] = orc_compiler_new_temporary (compiler, opcode->src_size[i] * multiplier); + if (var->vartype == ORC_VAR_TYPE_CONST) { + var->replaced = TRUE; + var->replacement = cinsn->dest_args[0]; + compiler->vars[cinsn->dest_args[0]].flags |= ORC_VAR_FLAG_VOLATILE_WORKAROUND; } cinsn->src_args[0] = insn.src_args[i]; insn.src_args[i] = cinsn->dest_args[0]; - } } } |