-#if defined(ENABLE_SSA)
-void codegen_insert_phi_moves(jitdata *jd, basicblock *bptr) {
- /* look for phi moves */
- int t_a,s_a,i, type;
- int t_lt, s_lt; /* lifetime indices of phi_moves */
- s4 t_regoff, s_regoff, s_flags, t_flags;
- codegendata *cd;
- lsradata *ls;
-
- MCODECHECK(512);
-
- ls = jd->ls;
- cd = jd->cd;
-
- /* Moves from phi functions with highest indices have to be */
- /* inserted first, since this is the order as is used for */
- /* conflict resolution */
- for(i = ls->num_phi_moves[bptr->nr] - 1; i >= 0 ; i--) {
- t_a = ls->phi_moves[bptr->nr][i][0];
- s_a = ls->phi_moves[bptr->nr][i][1];
-#if defined(SSA_DEBUG_VERBOSE)
- if (compileverbose)
- printf("BB %3i Move %3i <- %3i ", bptr->nr, t_a, s_a);
-#endif
- if (t_a >= 0) {
- /* local var lifetimes */
- t_lt = ls->maxlifetimes + t_a;
- type = ls->lifetime[t_lt].type;
- }
- else {
- t_lt = -t_a-1;
- type = ls->lifetime[t_lt].local_ss->s->type;
- /* stackslot lifetime */
- }
-
- if (type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
- if (compileverbose)
- printf("...returning - phi lifetimes where joined\n");
-#endif
- return;
- }
-
- if (s_a >= 0) {
- /* local var lifetimes */
- s_lt = ls->maxlifetimes + s_a;
- type = ls->lifetime[s_lt].type;
- }
- else {
- s_lt = -s_a-1;
- type = ls->lifetime[s_lt].type;
- /* stackslot lifetime */
- }
-
- if (type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
- if (compileverbose)
- printf("...returning - phi lifetimes where joined\n");
-#endif
- return;
- }
-
- if (t_a >= 0) {
- t_flags = VAR(t_a)->flags;
- t_regoff = VAR(t_a)->vv.regoff;
-
- }
- else {
- t_flags = ls->lifetime[t_lt].local_ss->s->flags;
- t_regoff = ls->lifetime[t_lt].local_ss->s->regoff;
- }
-
- if (s_a >= 0) {
- /* local var move */
- s_flags = VAR(s_a)->flags;
- s_regoff = VAR(s_a)->vv.regoff;
- } else {
- /* stackslot lifetime */
- s_flags = ls->lifetime[s_lt].local_ss->s->flags;
- s_regoff = ls->lifetime[s_lt].local_ss->s->regoff;
- }
-
- if (type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
- if (compileverbose)
- printf("...returning - phi lifetimes where joined\n");
-#endif
- return;
- }
-
- cg_move(cd, type, s_regoff, s_flags, t_regoff, t_flags);
-
-#if defined(SSA_DEBUG_VERBOSE)
- if (compileverbose) {
- if (IS_INMEMORY(t_flags) && IS_INMEMORY(s_flags)) {
- /* mem -> mem */
- printf("M%3i <- M%3i",t_regoff,s_regoff);
- }
- else if (IS_INMEMORY(s_flags)) {
- /* mem -> reg */
- printf("R%3i <- M%3i",t_regoff,s_regoff);
- }
- else if (IS_INMEMORY(t_flags)) {
- /* reg -> mem */
- printf("M%3i <- R%3i",t_regoff,s_regoff);
- }
- else {
- /* reg -> reg */
- printf("R%3i <- R%3i",t_regoff,s_regoff);
- }
- printf("\n");
- }
-#endif /* defined(SSA_DEBUG_VERBOSE) */
- }
-}
-
-void cg_move(codegendata *cd, s4 type, s4 src_regoff, s4 src_flags,
- s4 dst_regoff, s4 dst_flags) {
- if ((IS_INMEMORY(dst_flags)) && (IS_INMEMORY(src_flags))) {
- /* mem -> mem */
- if (dst_regoff != src_regoff) {
- if (!IS_2_WORD_TYPE(type)) {
- if (IS_FLT_DBL_TYPE(type)) {
- emit_flds_membase(cd, REG_SP, src_regoff * 4);
- emit_fstps_membase(cd, REG_SP, dst_regoff * 4);
- } else{
- emit_mov_membase_reg(cd, REG_SP, src_regoff * 4,
- REG_ITMP1);
- emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, dst_regoff * 4);
- }
- } else { /* LONG OR DOUBLE */
- if (IS_FLT_DBL_TYPE(type)) {
- emit_fldl_membase( cd, REG_SP, src_regoff * 4);
- emit_fstpl_membase(cd, REG_SP, dst_regoff * 4);
- } else {
- emit_mov_membase_reg(cd, REG_SP, src_regoff * 4,
- REG_ITMP1);
- emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, dst_regoff * 4);
- emit_mov_membase_reg(cd, REG_SP, src_regoff * 4 + 4,
- REG_ITMP1);
- emit_mov_reg_membase(cd, REG_ITMP1, REG_SP,
- dst_regoff * 4 + 4);
- }
- }
- }
- } else {
- if (IS_FLT_DBL_TYPE(type)) {
- log_text("cg_move: flt/dbl type have to be in memory\n");
-/* assert(0); */
- }
- if (IS_2_WORD_TYPE(type)) {
- log_text("cg_move: longs have to be in memory\n");
-/* assert(0); */
- }
- if (IS_INMEMORY(src_flags)) {
- /* mem -> reg */
- emit_mov_membase_reg(cd, REG_SP, src_regoff * 4, dst_regoff);
- } else if (IS_INMEMORY(dst_flags)) {
- /* reg -> mem */
- emit_mov_reg_membase(cd, src_regoff, REG_SP, dst_regoff * 4);
- } else {
- /* reg -> reg */
- /* only ints can be in regs on i386 */
- M_INTMOVE(src_regoff,dst_regoff);
- }
- }
-}
-#endif /* defined(ENABLE_SSA) */
-
-
-/* codegen_emit_stub_compiler **************************************************
-
- Emit a stub routine which calls the compiler.
-
-*******************************************************************************/
-
-void codegen_emit_stub_compiler(jitdata *jd)
-{
- methodinfo *m;
- codegendata *cd;
-
- /* get required compiler data */
-
- m = jd->m;
- cd = jd->cd;
-
- /* code for the stub */
-
- M_MOV_IMM(m, REG_ITMP1);
- M_MOV_IMM(asm_call_jit_compiler, REG_ITMP3);
- M_JMP(REG_ITMP3);
-}
-