}
}
+int
+orc_compiler_get_temp_reg (OrcCompiler *compiler)
+{
+ int j;
+
+ for(j=0;j<ORC_N_REGS;j++){
+ compiler->alloc_regs[j] = 0;
+ }
+ for(j=0;j<ORC_N_COMPILER_VARIABLES;j++){
+ if (!compiler->vars[j].alloc) continue;
+
+ ORC_DEBUG("var %d: %d %d %d", j, compiler->vars[j].alloc,
+ compiler->vars[j].first_use,
+ compiler->vars[j].last_use);
+
+ if (compiler->vars[j].first_use == -1) {
+ compiler->alloc_regs[compiler->vars[j].alloc] = 1;
+ } else if (compiler->vars[j].first_use <= compiler->insn_index &&
+ compiler->vars[j].last_use >= compiler->insn_index) {
+ compiler->alloc_regs[compiler->vars[j].alloc] = 1;
+ }
+ }
+
+ ORC_DEBUG("at insn %d", compiler->insn_index);
+ for(j=0;j<8;j++){
+ ORC_DEBUG("xmm%d: %d %d", j, compiler->valid_regs[ORC_VEC_REG_BASE + j],
+ compiler->alloc_regs[ORC_VEC_REG_BASE + j]);
+ }
+
+ for(j=compiler->min_temp_reg;j<ORC_VEC_REG_BASE+16;j++){
+ if (compiler->valid_regs[j] && !compiler->alloc_regs[j]) {
+ compiler->min_temp_reg = j+1;
+ return j;
+ }
+ }
+
+ return 0;
+}
+
void
orc_compiler_rewrite_vars (OrcCompiler *compiler)
{
orc_compiler_get_constant (OrcCompiler *compiler, int size, int value)
{
int i;
+ int tmp;
if (size < 4) {
if (size < 2) {
if (compiler->constants[i].alloc_reg != 0) {;
return compiler->constants[i].alloc_reg;
}
- orc_compiler_load_constant (compiler, compiler->tmpreg, size, value);
- return compiler->tmpreg;
+ tmp = orc_compiler_get_temp_reg (compiler);
+ orc_compiler_load_constant (compiler, tmp, size, value);
+ return tmp;
}
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
#ifndef MMX
- int tmp2 = X86_XMM7;
+ int tmp2 = orc_compiler_get_temp_reg (p);
if (p->loop_shift <= 2) {
orc_sse_emit_movdqa (p, src1, tmp);
int type = ORC_PTR_TO_INT(user);
int tmpc;
+ tmpc = orc_compiler_get_constant (p, 1<<type, 1);
if (src == dest) {
- tmpc = orc_compiler_get_constant (p, 1<<type, 1);
orc_sse_emit_660f (p, names[type], codes[type], src, tmpc);
orc_sse_emit_movdqa (p, tmpc, dest);
} else {
- tmpc = orc_compiler_get_constant (p, 1<<type, 1);
orc_sse_emit_movdqa (p, tmpc, dest);
orc_sse_emit_660f (p, names[type], codes[type], src, dest);
}
/* About 5.6 cycles per array member on ginger */
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
- int a = X86_XMM7;
- int j = X86_XMM6;
- int j2 = X86_XMM5;
- int l = X86_XMM4;
- int divisor = X86_XMM3;
+ int a = orc_compiler_get_temp_reg (p);
+ int j = orc_compiler_get_temp_reg (p);
+ int j2 = orc_compiler_get_temp_reg (p);
+ int l = orc_compiler_get_temp_reg (p);
+ int divisor = orc_compiler_get_temp_reg (p);
int tmp;
int i;
/* About 8.4 cycles per array member on ginger */
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
- int b = X86_XMM7;
- int a = X86_XMM6;
- int k = X86_XMM5;
- int j = X86_XMM4;
+ int b = orc_compiler_get_temp_reg (p);
+ int a = orc_compiler_get_temp_reg (p);
+ int k = orc_compiler_get_temp_reg (p);
+ int j = orc_compiler_get_temp_reg (p);
int tmp;
int i;
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
- int tmp2 = X86_XMM7;
+ int tmp2 = orc_compiler_get_temp_reg (p);
orc_sse_emit_movdqa (p, dest, tmp);
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
- int tmp2 = X86_XMM7;
+ int tmp2 = orc_compiler_get_temp_reg (p);
orc_sse_emit_movdqa (p, src, tmp);
orc_sse_emit_movdqa (p, dest, tmp2);
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
- int tmp2 = X86_XMM7;
+ int tmp2 = orc_compiler_get_temp_reg (p);
orc_sse_emit_movdqa (p, src, tmp);
orc_sse_emit_movdqa (p, dest, tmp2);
{
int tmp = p->tmpreg;
int gptmp = p->gp_tmpreg;
- int tmp2 = X86_XMM7;
+ int tmp2 = orc_compiler_get_temp_reg (p);
orc_x86_emit_mov_imm_reg (p, 4, mask1, gptmp);
orc_x86_emit_mov_reg_sse (p, gptmp, tmp);
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
#if 0
- int tmp2 = X86_XMM7;
- int tmp3 = X86_XMM6;
+ int tmp2 = orc_compiler_get_temp_reg (p);
+ int tmp3 = orc_compiler_get_temp_reg (p);
orc_sse_emit_movdqa (p, src, tmp);
orc_sse_emit_pand (p, dest, tmp);
orc_sse_emit_por (p, tmp2, dest);
#endif
- int s = X86_XMM7;
- int t = X86_XMM6;
+ int s = orc_compiler_get_temp_reg (p);
+ int t = orc_compiler_get_temp_reg (p);
/*
From Tim Terriberry: (slightly faster than above)
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
- int tmp2 = X86_XMM7;
- int tmp3 = X86_XMM6;
+ int tmp2 = orc_compiler_get_temp_reg (p);
+ int tmp3 = orc_compiler_get_temp_reg (p);
tmp = orc_compiler_get_constant (p, 4, 0xffffffff);
orc_sse_emit_pxor (p, src, tmp);
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
- int tmp2 = X86_XMM7;
+ int tmp2 = orc_compiler_get_temp_reg (p);
#if 0
/* an alternate version. slower. */
int src = p->vars[insn->src_args[1]].alloc;
int dest = p->vars[insn->dest_args[0]].alloc;
int tmp = p->tmpreg;
- int tmp2 = X86_XMM7;
+ int tmp2 = orc_compiler_get_temp_reg (p);
orc_sse_emit_movdqa (p, src, tmp2);
orc_sse_emit_psrld (p, 1, tmp2);