summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2014-09-19 18:07:10 +0200
committerWim Taymans <wtaymans@redhat.com>2014-09-19 23:05:48 +0200
commita62eefc1dc716046d99aacec208cfdfe42dadb34 (patch)
treef2727cd46128bfcd97161d529cdbe0c249c47af6
parentc368c336b6e618c0edead4023401033d94847e9e (diff)
compiler: keep track of temp variables that contain param/const
Keep track of what const/param is loaded into a temp variable. We can then see if the const is already loaded in a variable and simply reuse it instead of using a new temp. We must also make sure we load constants of different size in different temp variables.
-rw-r--r--orc/orccompiler.c24
-rw-r--r--orc/orcvariable.h3
2 files changed, 22 insertions, 5 deletions
diff --git a/orc/orccompiler.c b/orc/orccompiler.c
index 1b403f5..12c6c11 100644
--- a/orc/orccompiler.c
+++ b/orc/orccompiler.c
@@ -580,10 +580,7 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler)
} else if (var->vartype == ORC_VAR_TYPE_CONST ||
var->vartype == ORC_VAR_TYPE_PARAM) {
OrcInstruction *cinsn;
- int multiplier;
-
- cinsn = compiler->insns + compiler->n_insns;
- compiler->n_insns++;
+ int l, multiplier, loaded;
multiplier = 1;
if (insn.flags & ORC_INSTRUCTION_FLAG_X2) {
@@ -593,6 +590,22 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler)
multiplier = 4;
}
+ loaded = -1;
+ for(l=0;l<ORC_N_COMPILER_VARIABLES;l++){
+ if (compiler->vars[l].name == NULL) continue;
+ if (!compiler->vars[l].has_parameter) continue;
+ if (compiler->vars[l].parameter != insn.src_args[i]) continue;
+ if (compiler->vars[l].size != opcode->src_size[i] * multiplier) continue;
+ loaded = l;
+ break;
+ }
+ if (loaded != -1) {
+ insn.src_args[i] = loaded;
+ continue;
+ }
+ cinsn = compiler->insns + compiler->n_insns;
+ compiler->n_insns++;
+
cinsn->flags = insn.flags;
cinsn->flags |= ORC_INSN_FLAG_ADDED;
cinsn->opcode = get_loadp_opcode_for_size (opcode->src_size[i]);
@@ -602,9 +615,10 @@ orc_compiler_rewrite_insns (OrcCompiler *compiler)
compiler->vars[cinsn->dest_args[0]].flags |=
ORC_VAR_FLAG_VOLATILE_WORKAROUND;
}
+ compiler->vars[cinsn->dest_args[0]].has_parameter = TRUE;
+ compiler->vars[cinsn->dest_args[0]].parameter = insn.src_args[i];
cinsn->src_args[0] = insn.src_args[i];
insn.src_args[i] = cinsn->dest_args[0];
-
}
}
}
diff --git a/orc/orcvariable.h b/orc/orcvariable.h
index 28a7bb4..78226df 100644
--- a/orc/orcvariable.h
+++ b/orc/orcvariable.h
@@ -70,6 +70,9 @@ struct _OrcVariable {
int update_type;
int need_offset_reg;
unsigned int flags;
+
+ int has_parameter;
+ int parameter;
};
ORC_END_DECLS