Author: zoltan
Date: 2006-09-26 02:47:16 -0400 (Tue, 26 Sep 2006)
New Revision: 65900
Modified:
branches/vargaz/mini-linear-il/mono/mono/mini/ChangeLog
branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c
branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.c
branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.h
branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c
branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.h
Log:
2006-09-26 Zoltan Varga <[EMAIL PROTECTED]>
* method-to-ir.c mini-x86.h mini-x86.c mini-amd64.h mini-amd64.c: Move
the rest of
the Interlocked instrins creation code to mini_emit_inst_for_method ()
as well.
Modified: branches/vargaz/mini-linear-il/mono/mono/mini/ChangeLog
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/ChangeLog 2006-09-26
06:46:32 UTC (rev 65899)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/ChangeLog 2006-09-26
06:47:16 UTC (rev 65900)
@@ -1,5 +1,8 @@
2006-09-26 Zoltan Varga <[EMAIL PROTECTED]>
+ * method-to-ir.c mini-x86.h mini-x86.c mini-amd64.h mini-amd64.c: Move
the rest of
+ the Interlocked instrins creation code to mini_emit_inst_for_method ()
as well.
+
* mini-amd64.c mini-amd64.c mini-x86.c mini-sparc.: Move check for
OP_MEMORY_BARRIER
from mono_arch_emit_inst_for_method () to mini_emit_inst_for_method ().
Modified: branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c
2006-09-26 06:46:32 UTC (rev 65899)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/method-to-ir.c
2006-09-26 06:47:16 UTC (rev 65900)
@@ -3704,6 +3704,8 @@
} else if (cmethod->klass->image == mono_defaults.corlib &&
(strcmp (cmethod->klass->name_space,
"System.Threading") == 0) &&
(strcmp (cmethod->klass->name, "Interlocked") == 0))
{
+ ins = NULL;
+
#if SIZEOF_VOID_P == 8
if (strcmp (cmethod->name, "Read") == 0 && (fsig->params
[0]->type == MONO_TYPE_I8)) {
/* 64 bit reads are already atomic */
@@ -3712,9 +3714,127 @@
ins->inst_basereg = args [0]->dreg;
ins->inst_offset = 0;
MONO_ADD_INS (cfg->cbb, ins);
- return ins;
}
#endif
+
+#ifdef MONO_ARCH_HAVE_ATOMIC_ADD
+ if (strcmp (cmethod->name, "Increment") == 0) {
+ MonoInst *ins_iconst;
+ guint32 opcode;
+
+ if (fsig->params [0]->type == MONO_TYPE_I4)
+ opcode = OP_ATOMIC_ADD_NEW_I4;
+#if SIZEOF_VOID_P == 8
+ else if (fsig->params [0]->type == MONO_TYPE_I8)
+ opcode = OP_ATOMIC_ADD_NEW_I8;
+#endif
+ else
+ g_assert_not_reached ();
+
+ MONO_INST_NEW (cfg, ins_iconst, OP_ICONST);
+ ins_iconst->inst_c0 = 1;
+ ins_iconst->dreg = mono_alloc_ireg (cfg);
+ MONO_ADD_INS (cfg->cbb, ins_iconst);
+
+ MONO_INST_NEW (cfg, ins, opcode);
+ ins->dreg = mono_alloc_ireg (cfg);
+ ins->inst_basereg = args [0]->dreg;
+ ins->inst_offset = 0;
+ ins->sreg2 = ins_iconst->dreg;
+ ins->type = (opcode == OP_ATOMIC_ADD_NEW_I4) ? STACK_I4
: STACK_I8;
+ MONO_ADD_INS (cfg->cbb, ins);
+ } else if (strcmp (cmethod->name, "Decrement") == 0) {
+ MonoInst *ins_iconst;
+ guint32 opcode;
+
+ if (fsig->params [0]->type == MONO_TYPE_I4)
+ opcode = OP_ATOMIC_ADD_NEW_I4;
+#if SIZEOF_VOID_P == 8
+ else if (fsig->params [0]->type == MONO_TYPE_I8)
+ opcode = OP_ATOMIC_ADD_NEW_I8;
+#endif
+ else
+ g_assert_not_reached ();
+
+ MONO_INST_NEW (cfg, ins_iconst, OP_ICONST);
+ ins_iconst->inst_c0 = -1;
+ ins_iconst->dreg = mono_alloc_ireg (cfg);
+ MONO_ADD_INS (cfg->cbb, ins_iconst);
+
+ MONO_INST_NEW (cfg, ins, opcode);
+ ins->dreg = mono_alloc_ireg (cfg);
+ ins->inst_basereg = args [0]->dreg;
+ ins->inst_offset = 0;
+ ins->sreg2 = ins_iconst->dreg;
+ ins->type = (opcode == OP_ATOMIC_ADD_NEW_I4) ? STACK_I4
: STACK_I8;
+ MONO_ADD_INS (cfg->cbb, ins);
+ } else if (strcmp (cmethod->name, "Add") == 0) {
+ guint32 opcode;
+
+ if (fsig->params [0]->type == MONO_TYPE_I4)
+ opcode = OP_ATOMIC_ADD_NEW_I4;
+#if SIZEOF_VOID_P == 8
+ else if (fsig->params [0]->type == MONO_TYPE_I8)
+ opcode = OP_ATOMIC_ADD_NEW_I8;
+#endif
+ else
+ g_assert_not_reached ();
+
+ MONO_INST_NEW (cfg, ins, opcode);
+ ins->dreg = mono_alloc_ireg (cfg);
+ ins->inst_basereg = args [0]->dreg;
+ ins->inst_offset = 0;
+ ins->sreg2 = args [1]->dreg;
+ ins->type = (opcode == OP_ATOMIC_ADD_I4) ? STACK_I4 :
STACK_I8;
+ MONO_ADD_INS (cfg->cbb, ins);
+ }
+#endif /* MONO_ARCH_HAVE_ATOMIC_ADD */
+
+#ifdef MONO_ARCH_HAVE_ATOMIC_EXCHANGE
+ if (strcmp (cmethod->name, "Exchange") == 0) {
+ guint32 opcode;
+
+ if (fsig->params [0]->type == MONO_TYPE_I4)
+ opcode = OP_ATOMIC_EXCHANGE_I4;
+#if SIZEOF_VOID_P == 8
+ else if ((fsig->params [0]->type == MONO_TYPE_I8) ||
+ (fsig->params [0]->type ==
MONO_TYPE_I) ||
+ (fsig->params [0]->type ==
MONO_TYPE_OBJECT))
+ opcode = OP_ATOMIC_EXCHANGE_I8;
+#else
+ else if ((fsig->params [0]->type == MONO_TYPE_I) ||
+ (fsig->params [0]->type ==
MONO_TYPE_OBJECT))
+ opcode = OP_ATOMIC_EXCHANGE_I4;
+#endif
+ else
+ return NULL;
+
+ MONO_INST_NEW (cfg, ins, opcode);
+ ins->dreg = mono_alloc_ireg (cfg);
+ ins->inst_basereg = args [0]->dreg;
+ ins->inst_offset = 0;
+ ins->sreg2 = args [1]->dreg;
+ MONO_ADD_INS (cfg->cbb, ins);
+
+ switch (fsig->params [0]->type) {
+ case MONO_TYPE_I4:
+ ins->type = STACK_I4;
+ break;
+ case MONO_TYPE_I8:
+ case MONO_TYPE_I:
+ ins->type = STACK_I8;
+ break;
+ case MONO_TYPE_OBJECT:
+ ins->type = STACK_OBJ;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+#endif /* MONO_ARCH_HAVE_ATOMIC_EXCHANGE */
+
+ if (ins)
+ return ins;
}
return mono_arch_emit_inst_for_method (cfg, cmethod, fsig, args);
Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.c 2006-09-26
06:46:32 UTC (rev 65899)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.c 2006-09-26
06:47:16 UTC (rev 65900)
@@ -6040,114 +6040,13 @@
ins->inst_i1 = args [1];
}
#endif
- } else if(cmethod->klass->image == mono_defaults.corlib &&
- (strcmp (cmethod->klass->name_space,
"System.Threading") == 0) &&
- (strcmp (cmethod->klass->name, "Interlocked") == 0))
{
-
- if (strcmp (cmethod->name, "Increment") == 0) {
- MonoInst *ins_iconst;
- guint32 opcode;
-
- if (fsig->params [0]->type == MONO_TYPE_I4)
- opcode = OP_ATOMIC_ADD_NEW_I4;
- else if (fsig->params [0]->type == MONO_TYPE_I8)
- opcode = OP_ATOMIC_ADD_NEW_I8;
- else
- g_assert_not_reached ();
-
- MONO_INST_NEW (cfg, ins_iconst, OP_ICONST);
- ins_iconst->inst_c0 = 1;
- ins_iconst->dreg = mono_alloc_ireg (cfg);
- MONO_ADD_INS (cfg->cbb, ins_iconst);
-
- MONO_INST_NEW (cfg, ins, opcode);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = ins_iconst->dreg;
- ins->type = (opcode == OP_ATOMIC_ADD_NEW_I4) ? STACK_I4
: STACK_I8;
- MONO_ADD_INS (cfg->cbb, ins);
- } else if (strcmp (cmethod->name, "Decrement") == 0) {
- MonoInst *ins_iconst;
- guint32 opcode;
-
- if (fsig->params [0]->type == MONO_TYPE_I4)
- opcode = OP_ATOMIC_ADD_NEW_I4;
- else if (fsig->params [0]->type == MONO_TYPE_I8)
- opcode = OP_ATOMIC_ADD_NEW_I8;
- else
- g_assert_not_reached ();
-
- MONO_INST_NEW (cfg, ins_iconst, OP_ICONST);
- ins_iconst->inst_c0 = -1;
- ins_iconst->dreg = mono_alloc_ireg (cfg);
- MONO_ADD_INS (cfg->cbb, ins_iconst);
-
- MONO_INST_NEW (cfg, ins, opcode);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = ins_iconst->dreg;
- ins->type = (opcode == OP_ATOMIC_ADD_NEW_I4) ? STACK_I4
: STACK_I8;
- MONO_ADD_INS (cfg->cbb, ins);
- } else if (strcmp (cmethod->name, "Add") == 0) {
- guint32 opcode;
-
- if (fsig->params [0]->type == MONO_TYPE_I4)
- opcode = OP_ATOMIC_ADD_NEW_I4;
- else if (fsig->params [0]->type == MONO_TYPE_I8)
- opcode = OP_ATOMIC_ADD_NEW_I8;
- else
- g_assert_not_reached ();
-
- MONO_INST_NEW (cfg, ins, opcode);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = args [1]->dreg;
- ins->type = (opcode == OP_ATOMIC_ADD_I4) ? STACK_I4 :
STACK_I8;
- MONO_ADD_INS (cfg->cbb, ins);
- } else if (strcmp (cmethod->name, "Exchange") == 0) {
- guint32 opcode;
-
- if (fsig->params [0]->type == MONO_TYPE_I4)
- opcode = OP_ATOMIC_EXCHANGE_I4;
- else if ((fsig->params [0]->type == MONO_TYPE_I8) ||
- (fsig->params [0]->type ==
MONO_TYPE_I) ||
- (fsig->params [0]->type ==
MONO_TYPE_OBJECT))
- opcode = OP_ATOMIC_EXCHANGE_I8;
- else
- return NULL;
-
- MONO_INST_NEW (cfg, ins, opcode);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = args [1]->dreg;
- MONO_ADD_INS (cfg->cbb, ins);
-
- switch (fsig->params [0]->type) {
- case MONO_TYPE_I4:
- ins->type = STACK_I4;
- break;
- case MONO_TYPE_I8:
- case MONO_TYPE_I:
- ins->type = STACK_I8;
- break;
- case MONO_TYPE_OBJECT:
- ins->type = STACK_OBJ;
- break;
- default:
- g_assert_not_reached ();
- }
- }
-
- /*
- * Can't implement CompareExchange methods this way since they
have
- * three arguments.
- */
}
+ /*
+ * Can't implement CompareExchange methods this way since they have
+ * three arguments.
+ */
+
return ins;
}
Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.h
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.h 2006-09-26
06:46:32 UTC (rev 65899)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini-amd64.h 2006-09-26
06:47:16 UTC (rev 65900)
@@ -237,6 +237,8 @@
#define MONO_ARCH_HAVE_CREATE_SPECIFIC_TRAMPOLINE 1
#define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE 1
#define MONO_ARCH_HAVE_CREATE_VARS 1
+#define MONO_ARCH_HAVE_ATOMIC_ADD 1
+#define MONO_ARCH_HAVE_ATOMIC_EXCHANGE 1
/* Used for optimization, not complete */
#define MONO_ARCH_IS_OP_MEMBASE(opcode) ((opcode) == OP_X86_PUSH_MEMBASE)
Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c 2006-09-26
06:46:32 UTC (rev 65899)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.c 2006-09-26
06:47:16 UTC (rev 65900)
@@ -4746,57 +4746,6 @@
ins->inst_i1 = args [1];
}
#endif
- } else if(cmethod->klass->image == mono_defaults.corlib &&
- (strcmp (cmethod->klass->name_space,
"System.Threading") == 0) &&
- (strcmp (cmethod->klass->name, "Interlocked") == 0))
{
- /* FIXME: Fuse these with ldaddr */
- if (strcmp (cmethod->name, "Increment") == 0 && fsig->params
[0]->type == MONO_TYPE_I4) {
- MonoInst *ins_iconst;
-
- MONO_INST_NEW (cfg, ins_iconst, OP_ICONST);
- ins_iconst->inst_c0 = 1;
- ins_iconst->dreg = mono_alloc_ireg (cfg);
- MONO_ADD_INS (cfg->cbb, ins_iconst);
-
- MONO_INST_NEW (cfg, ins, OP_ATOMIC_ADD_NEW_I4);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = ins_iconst->dreg;
- ins->type = STACK_I4;
- MONO_ADD_INS (cfg->cbb, ins);
- } else if (strcmp (cmethod->name, "Decrement") == 0 &&
fsig->params [0]->type == MONO_TYPE_I4) {
- MonoInst *ins_iconst;
-
- MONO_INST_NEW (cfg, ins_iconst, OP_ICONST);
- ins_iconst->inst_c0 = -1;
- ins_iconst->dreg = mono_alloc_ireg (cfg);
- MONO_ADD_INS (cfg->cbb, ins_iconst);
-
- MONO_INST_NEW (cfg, ins, OP_ATOMIC_ADD_NEW_I4);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = ins_iconst->dreg;
- ins->type = STACK_I4;
- MONO_ADD_INS (cfg->cbb, ins);
- } else if (strcmp (cmethod->name, "Exchange") == 0 &&
fsig->params [0]->type == MONO_TYPE_I4) {
- MONO_INST_NEW (cfg, ins, OP_ATOMIC_EXCHANGE_I4);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = args [1]->dreg;
- ins->type = STACK_I4;
- MONO_ADD_INS (cfg->cbb, ins);
- } else if (strcmp (cmethod->name, "Add") == 0 && fsig->params
[0]->type == MONO_TYPE_I4) {
- MONO_INST_NEW (cfg, ins, OP_ATOMIC_ADD_NEW_I4);
- ins->dreg = mono_alloc_ireg (cfg);
- ins->inst_basereg = args [0]->dreg;
- ins->inst_offset = 0;
- ins->sreg2 = args [1]->dreg;
- ins->type = STACK_I4;
- MONO_ADD_INS (cfg->cbb, ins);
- }
}
return ins;
Modified: branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.h
===================================================================
--- branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.h 2006-09-26
06:46:32 UTC (rev 65899)
+++ branches/vargaz/mini-linear-il/mono/mono/mini/mini-x86.h 2006-09-26
06:47:16 UTC (rev 65900)
@@ -204,6 +204,8 @@
#define MONO_ARCH_HAVE_CREATE_SPECIFIC_TRAMPOLINE 1
#define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE 1
#define MONO_ARCH_HAVE_CREATE_VARS 1
+#define MONO_ARCH_HAVE_ATOMIC_ADD 1
+#define MONO_ARCH_HAVE_ATOMIC_EXCHANGE 1
/* Used for optimization, not complete */
#define MONO_ARCH_IS_OP_MEMBASE(opcode) ((opcode) == OP_X86_PUSH_MEMBASE)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches