[docs] Enable documentation for mini.
[mono.git] / mono / mini / mini-mips.c
index 8af84338759ecf8629b8b541dfb679058df08b2e..86885203a9e8efcd1f275b357f0ddad7ecc982fd 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * mini-mips.c: MIPS backend for the Mono code generator
+/**
+ * \file
+ * MIPS backend for the Mono code generator
  *
  * Authors:
  *   Mark Mason (mason@broadcom.com)
@@ -62,9 +63,6 @@ enum {
 static mono_mutex_t mini_arch_mutex;
 
 int mono_exc_esp_offset = 0;
-static int tls_mode = TLS_MODE_DETECT;
-static int lmf_pthread_key = -1;
-static int monothread_key = -1;
 
 /* Whenever the host is little-endian */
 static int little_endian;
@@ -98,23 +96,6 @@ static gpointer bp_trigger_page;
                cfg->bb_exit->max_offset += 16;                         \
        } while (0) 
 
-
-#define emit_linuxthreads_tls(code,dreg,key) do {\
-               int off1, off2; \
-               off1 = offsets_from_pthread_key ((key), &off2); \
-               g_assert_not_reached ();                \
-               ppc_lwz ((code), (dreg), off1, ppc_r2); \
-               ppc_lwz ((code), (dreg), off2, (dreg)); \
-       } while (0);
-
-
-#define emit_tls_access(code,dreg,key) do {    \
-               switch (tls_mode) {     \
-               case TLS_MODE_LTHREADS: emit_linuxthreads_tls(code,dreg,key); break;    \
-               default: g_assert_not_reached ();       \
-               }       \
-       } while (0)
-
 #define MONO_EMIT_NEW_LOAD_R8(cfg,dr,addr) do { \
                MonoInst *inst;                            \
                MONO_INST_NEW ((cfg), (inst), OP_R8CONST); \
@@ -409,17 +390,6 @@ mips_patch (guint32 *code, guint32 target)
        }
 }
 
-#if 0
-static int
-offsets_from_pthread_key (guint32 key, int *offset2)
-{
-       int idx1 = key / 32;
-       int idx2 = key % 32;
-       *offset2 = idx2 * sizeof (gpointer);
-       return 284 + idx1 * sizeof (gpointer);
-}
-#endif
-
 static void mono_arch_compute_omit_fp (MonoCompile *cfg);
 
 const char*
@@ -728,6 +698,12 @@ mono_arch_cleanup (void)
        mono_os_mutex_destroy (&mini_arch_mutex);
 }
 
+gboolean
+mono_arch_have_fast_tls (void)
+{
+       return FALSE;
+}
+
 /*
  * This function returns the optimizations supported on this cpu.
  */
@@ -2175,12 +2151,6 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
        int tmp5 = -1;
 
        switch (ins->opcode) {
-#if 0
-       case OP_LCOMPARE:
-       case OP_LCOMPARE_IMM:
-               mono_print_ins (ins);
-               g_assert_not_reached ();
-#endif
        case OP_LADD:
                tmp1 = mono_alloc_ireg (cfg);
                MONO_EMIT_NEW_BIALU (cfg, OP_IADD, ins->dreg+1, ins->sreg1+1, ins->sreg2+1);
@@ -2217,17 +2187,6 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
                NULLIFY_INS(ins);
                break;
 
-       case OP_LMUL:
-       case OP_LDIV:
-       case OP_LDIV_UN:
-       case OP_LREM:
-       case OP_LREM_UN:
-       case OP_LSHL:
-       case OP_LSHR:
-       case OP_LSHR_UN:
-               mono_print_ins (ins);
-               g_assert_not_reached ();
-
        case OP_LNEG:
                tmp1 = mono_alloc_ireg (cfg);
                MONO_EMIT_NEW_BIALU (cfg, OP_ISUB, ins->dreg+1, mips_zero, ins->sreg1+1);
@@ -2237,27 +2196,6 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
                NULLIFY_INS(ins);
                break;
 
-#if 0
-       case OP_LNOT:
-#endif
-#if 0
-       case OP_LCONV_TO_I1:
-       case OP_LCONV_TO_I2:
-       case OP_LCONV_TO_I4:
-       case OP_LCONV_TO_I8:
-       case OP_LCONV_TO_R4:
-       case OP_LCONV_TO_R8:
-       case OP_LCONV_TO_U4:
-       case OP_LCONV_TO_U8:
-       case OP_LCONV_TO_U2:
-       case OP_LCONV_TO_U1:
-       case OP_LCONV_TO_I:
-       case OP_LCONV_TO_OVF_I:
-       case OP_LCONV_TO_OVF_U:
-#endif
-               mono_print_ins (ins);
-               g_assert_not_reached ();
-
        case OP_LADD_OVF:
                tmp1 = mono_alloc_ireg (cfg);
                tmp2 = mono_alloc_ireg (cfg);
@@ -2310,11 +2248,6 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
                NULLIFY_INS(ins);
                break;
 
-       case OP_LMUL_OVF:
-       case OP_LMUL_OVF_UN:
-               mono_print_ins (ins);
-               g_assert_not_reached ();
-
        case OP_LSUB_OVF:
                tmp1 = mono_alloc_ireg (cfg);
                tmp2 = mono_alloc_ireg (cfg);
@@ -2361,60 +2294,6 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
                MONO_EMIT_NEW_COMPARE_EXC (cfg, NE_UN, tmp2, mips_zero, "OverflowException");
                NULLIFY_INS(ins);
                break;
-#if 0
-       case OP_LCONV_TO_OVF_I1_UN:
-       case OP_LCONV_TO_OVF_I2_UN:
-       case OP_LCONV_TO_OVF_I4_UN:
-       case OP_LCONV_TO_OVF_I8_UN:
-       case OP_LCONV_TO_OVF_U1_UN:
-       case OP_LCONV_TO_OVF_U2_UN:
-       case OP_LCONV_TO_OVF_U4_UN:
-       case OP_LCONV_TO_OVF_U8_UN:
-       case OP_LCONV_TO_OVF_I_UN:
-       case OP_LCONV_TO_OVF_U_UN:
-       case OP_LCONV_TO_OVF_I1:
-       case OP_LCONV_TO_OVF_U1:
-       case OP_LCONV_TO_OVF_I2:
-       case OP_LCONV_TO_OVF_U2:
-       case OP_LCONV_TO_OVF_I4:
-       case OP_LCONV_TO_OVF_U4:
-       case OP_LCONV_TO_OVF_I8:
-       case OP_LCONV_TO_OVF_U8:
-#endif
-       case OP_LCEQ:
-       case OP_LCGT:
-       case OP_LCGT_UN:
-       case OP_LCLT:
-       case OP_LCLT_UN:
-#if 0
-       case OP_LCONV_TO_R_UN:
-       case OP_LCONV_TO_U:
-#endif
-       case OP_LMUL_IMM:
-       case OP_LSHL_IMM:
-       case OP_LSHR_IMM:
-       case OP_LSHR_UN_IMM:
-       case OP_LDIV_IMM:
-       case OP_LDIV_UN_IMM:
-       case OP_LREM_IMM:
-       case OP_LREM_UN_IMM:
-       case OP_LBEQ:
-       case OP_LBGE:
-       case OP_LBGT:
-       case OP_LBLE:
-       case OP_LBLT:
-       case OP_LBNE_UN:
-       case OP_LBGE_UN:
-       case OP_LBGT_UN:
-       case OP_LBLE_UN:
-       case OP_LBLT_UN:
-               mono_print_ins (ins);
-               g_assert_not_reached ();
-#if 0
-       case OP_LCONV_TO_R8_2:
-       case OP_LCONV_TO_R4_2:
-       case OP_LCONV_TO_R_UN_2:
-#endif
        case OP_LCONV_TO_OVF_I4_2:
                tmp1 = mono_alloc_ireg (cfg);
 
@@ -2424,14 +2303,6 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
                MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, ins->dreg, ins->sreg1);
                NULLIFY_INS(ins);
                break;
-
-       case OP_LMIN_UN:
-       case OP_LMAX_UN:
-       case OP_LMIN:
-       case OP_LMAX:
-               mono_print_ins (ins);
-               g_assert_not_reached ();
-
        default:
                break;
        }
@@ -3423,12 +3294,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        mips_nop (code);
                        break;
                }
-               case OP_TLS_GET:
-                       g_assert_not_reached();
-#if 0
-                       emit_tls_access (code, ins->dreg, ins->inst_offset);
-#endif
-                       break;
                case OP_BIGMUL:
                        mips_mult (code, ins->sreg1, ins->sreg2);
                        mips_mflo (code, ins->dreg);
@@ -4675,7 +4540,7 @@ mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain,
 {
        MonoJumpInfo *patch_info;
 
-       mono_error_init (error);
+       error_init (error);
 
        for (patch_info = ji; patch_info; patch_info = patch_info->next) {
                unsigned char *ip = patch_info->ip.i + code;
@@ -5269,20 +5134,8 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                mips_load_const (code, mips_at, MIPS_LMF_MAGIC1);
                mips_sw (code, mips_at, mips_sp, lmf_offset + G_STRUCT_OFFSET(MonoLMF, magic));
 
-               if (lmf_pthread_key != -1) {
-                       g_assert_not_reached();
-#if 0
-                       emit_tls_access (code, mips_temp, lmf_pthread_key);
-#endif
-                       if (G_STRUCT_OFFSET (MonoJitTlsData, lmf)) {
-                               int offset = G_STRUCT_OFFSET (MonoJitTlsData, lmf);
-                               g_assert (mips_is_imm16(offset));
-                               mips_addiu (code, mips_a0, mips_temp, offset);
-                       }
-               } else {
-                       /* This can/will clobber the a0-a3 registers */
-                       mips_call (code, mips_t9, (gpointer)mono_get_lmf_addr);
-               }
+               /* This can/will clobber the a0-a3 registers */
+               mips_call (code, mips_t9, (gpointer)mono_get_lmf_addr);
 
                /* mips_v0 is the result from mono_get_lmf_addr () (MonoLMF **) */
                g_assert (mips_is_imm16(lmf_offset + G_STRUCT_OFFSET(MonoLMF, lmf_addr)));
@@ -5689,128 +5542,9 @@ mono_arch_emit_exceptions (MonoCompile *cfg)
 #endif
 }
 
-/*
- * Thread local storage support
- */
-static void
-setup_tls_access (void)
-{
-       guint32 ptk;
-       //guint32 *ins, *code;
-
-       if (tls_mode == TLS_MODE_FAILED)
-               return;
-
-       if (g_getenv ("MONO_NO_TLS")) {
-               tls_mode = TLS_MODE_FAILED;
-               return;
-       }
-
-       if (tls_mode == TLS_MODE_DETECT) {
-               /* XXX */
-               tls_mode = TLS_MODE_FAILED;
-               return;
-#if 0
-
-               ins = (guint32*)pthread_getspecific;
-               /* uncond branch to the real method */
-               if ((*ins >> 26) == 18) {
-                       gint32 val;
-                       val = (*ins & ~3) << 6;
-                       val >>= 6;
-                       if (*ins & 2) {
-                               /* absolute */
-                               ins = (guint32*)val;
-                       } else {
-                               ins = (guint32*) ((char*)ins + val);
-                       }
-               }
-               code = &cmplwi_1023;
-               ppc_cmpli (code, 0, 0, ppc_r3, 1023);
-               code = &li_0x48;
-               ppc_li (code, ppc_r4, 0x48);
-               code = &blr_ins;
-               ppc_blr (code);
-               if (*ins == cmplwi_1023) {
-                       int found_lwz_284 = 0;
-                       for (ptk = 0; ptk < 20; ++ptk) {
-                               ++ins;
-                               if (!*ins || *ins == blr_ins)
-                                       break;
-                               if ((guint16)*ins == 284 && (*ins >> 26) == 32) {
-                                       found_lwz_284 = 1;
-                                       break;
-                               }
-                       }
-                       if (!found_lwz_284) {
-                               tls_mode = TLS_MODE_FAILED;
-                               return;
-                       }
-                       tls_mode = TLS_MODE_LTHREADS;
-               } else if (*ins == li_0x48) {
-                       ++ins;
-                       /* uncond branch to the real method */
-                       if ((*ins >> 26) == 18) {
-                               gint32 val;
-                               val = (*ins & ~3) << 6;
-                               val >>= 6;
-                               if (*ins & 2) {
-                                       /* absolute */
-                                       ins = (guint32*)val;
-                               } else {
-                                       ins = (guint32*) ((char*)ins + val);
-                               }
-                               code = &val;
-                               ppc_li (code, ppc_r0, 0x7FF2);
-                               if (ins [1] == val) {
-                                       /* Darwin on G4, implement */
-                                       tls_mode = TLS_MODE_FAILED;
-                                       return;
-                               } else {
-                                       code = &val;
-                                       ppc_mfspr (code, ppc_r3, 104);
-                                       if (ins [1] != val) {
-                                               tls_mode = TLS_MODE_FAILED;
-                                               return;
-                                       }
-                                       tls_mode = TLS_MODE_DARWIN_G5;
-                               }
-                       } else {
-                               tls_mode = TLS_MODE_FAILED;
-                               return;
-                       }
-               } else {
-                       tls_mode = TLS_MODE_FAILED;
-                       return;
-               }
-#endif
-       }
-       if (lmf_pthread_key == -1) {
-               ptk = mono_jit_tls_id;
-               if (ptk < 1024) {
-                       /*g_print ("MonoLMF at: %d\n", ptk);*/
-                       /*if (!try_offset_access (mono_get_lmf_addr (), ptk)) {
-                               init_tls_failed = 1;
-                               return;
-                       }*/
-                       lmf_pthread_key = ptk;
-               }
-       }
-       if (monothread_key == -1) {
-               ptk = mono_thread_get_tls_key ();
-               if (ptk < 1024) {
-                       monothread_key = ptk;
-                       /*g_print ("thread inited: %d\n", ptk);*/
-               } else {
-                       /*g_print ("thread not inited yet %d\n", ptk);*/
-               }
-       }
-}
-
 void
 mono_arch_finish_init (void)
 {
-       setup_tls_access ();
 }
 
 void