Moved register defines into arch.h
[cacao.git] / src / vm / jit / mips / machine-instr.h
1 #ifndef _MACHINE_INSTR_H
2 #define _MACHINE_INSTR_H
3
4 #if 0
5
6 /* If anyone wants to compile with gcc, use this section.
7  * It is not usable with the MIPSPro compiler.
8  *
9  * It is outdated, too.
10  */ 
11
12 static inline long
13 __attribute__ ((unused))
14 atomic_swap (volatile long *p, long val)
15 {
16   long ret, temp;
17
18   __asm__ __volatile__
19     ("1:\n\t"
20      ".set  push\n\t"
21      ".set  mips2\n\t"
22      "lld   %2,%4\n\t"
23      "move  %0,%3\n\t"
24      "scd   %0,%1\n\t"
25      ".set  pop\n\t"
26      "beqz  %0,1b\n"
27      : "=&r" (temp), "=m" (*p), "=&r" (ret)
28      : "r" (val), "m" (*p)
29      : "memory");
30
31   return ret;
32 }
33 static inline int
34 __attribute__ ((unused))
35 compare_and_swap (volatile long *p, long oldval, long newval)
36 {
37   long ret, temp;
38
39   __asm__ __volatile__
40     ("1:\n\t"
41      ".set  push\n\t"
42      ".set  mips2\n\t"
43      "lld   %1,%5\n\t"
44      "move  %0,$0\n\t"
45      "bne   %1,%3,2f\n\t"
46      "move  %0,%4\n\t"
47      "scd   %0,%2\n\t"
48      ".set  pop\n\t"
49      "beqz  %0,1b\n"
50      "2:\n\t"
51      : "=&r" (ret), "=&r" (temp), "=m" (*p)
52      : "r" (oldval), "r" (newval), "m" (*p)
53      : "memory");
54
55   return ret;
56 }
57
58 #else
59
60 static inline void
61 atomic_add(int *mem, int val)
62 {
63         *mem += val;
64 }
65
66 long compare_and_swap (long *p, long oldval, long newval);
67
68 #define STORE_ORDER_BARRIER()
69 #define MEMORY_BARRIER_BEFORE_ATOMIC()
70 #define MEMORY_BARRIER_AFTER_ATOMIC()
71 #define MEMORY_BARRIER()
72
73 #endif
74 #endif