Implement mono_memory_barrier () and OP_MEMORY_BARRIER for ARM.
authorZoltan Varga <vargaz@gmail.com>
Sun, 20 Feb 2011 02:22:52 +0000 (03:22 +0100)
committerZoltan Varga <vargaz@gmail.com>
Sun, 20 Feb 2011 02:22:52 +0000 (03:22 +0100)
mono/arch/arm/arm-codegen.h
mono/mini/cpu-arm.md
mono/mini/mini-arm.c
mono/utils/mono-membar.h

index e7dc99f9316e9b404809e5ce8e8c6ea057146a17..2460fc449819e547a64c2e07c0f5810210d02120 100644 (file)
@@ -1084,6 +1084,16 @@ typedef union {
 #define ARM_MOVT_REG_IMM_COND(p, rd, imm16, cond) ARM_EMIT(p, (((cond) << 28) | (3 << 24) | (4 << 20) | ((((guint32)(imm16)) >> 12) << 16) | ((rd) << 12) | (((guint32)(imm16)) & 0xfff)))
 #define ARM_MOVT_REG_IMM(p, rd, imm16) ARM_MOVT_REG_IMM_COND ((p), (rd), (imm16), ARMCOND_AL)
 
+/* MCR */
+#define ARM_DEF_MCR_COND(coproc, opc1, rt, crn, crm, opc2, cond)       \
+       ARM_DEF_COND ((cond)) | ((0xe << 24) | (((opc1) & 0x7) << 21) | (0 << 20) | (((crn) & 0xf) << 16) | (((rt) & 0xf) << 12) | (((coproc) & 0xf) << 8) | (((opc2) & 0x7) << 5) | (1 << 4) | (((crm) & 0xf) << 0))
+
+#define ARM_MCR_COND(p, coproc, opc1, rt, crn, crm, opc2, cond)        \
+       ARM_EMIT(p, ARM_DEF_MCR_COND ((coproc), (opc1), (rt), (crn), (crm), (opc2), (cond)))
+
+#define ARM_MCR(p, coproc, opc1, rt, crn, crm, opc2) \
+       ARM_MCR_COND ((p), (coproc), (opc1), (rt), (crn), (crm), (opc2), ARMCOND_AL)
+
 #ifdef __cplusplus
 }
 #endif
index 1b253dd8fe8023d6c269082a1e74d91870597f30..3894753c82cf2338dbb605ca40be5650d59d62af 100644 (file)
@@ -46,7 +46,7 @@
 #
 # See the code in mini-x86.c for more details on how the specifiers are used.
 #
-memory_barrier: len:4
+memory_barrier: len:8 clob:a
 nop: len:4
 relaxed_nop: len:4
 break: len:4
index ef8a7de81859cdd940080d2fe5ae7782b3758cf6..a9fed328da0787b73614f64387e7b77b71966566 100644 (file)
@@ -3261,6 +3261,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
 
                switch (ins->opcode) {
                case OP_MEMORY_BARRIER:
+                       ARM_MOV_REG_IMM8 (code, ARMREG_R0, 0);
+                       ARM_MCR (code, 15, 0, ARMREG_R0, 7, 10, 5);
                        break;
                case OP_TLS_GET:
 #ifdef HAVE_AEABI_READ_TP
index 13ed6e72823d9b2cb9f516ec68989ed840c7a777..1c343b0d454fb10ed0bf4dfb4cf239818ceacc27 100644 (file)
@@ -129,7 +129,7 @@ static inline void mono_memory_write_barrier (void)
 #elif defined(__arm__)
 static inline void mono_memory_barrier (void)
 {
-       __asm__ __volatile__ ("" : : : "memory");
+       __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory");
 }
 
 static inline void mono_memory_read_barrier (void)