Fix preprocessor guard condition
[qemu/mini2440.git] / target-alpha / op_mem.h
blob5bf73afca04523b157dcd9221cdc0e9c56aeda11
1 /*
2 * Alpha emulation cpu micro-operations for memory accesses for qemu.
4 * Copyright (c) 2007 Jocelyn Mayer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //#define DEBUG_MEM_ACCESSES
22 #if defined (DEBUG_MEM_ACCESSES)
23 void helper_print_mem_EA (target_ulong EA);
24 #define print_mem_EA(EA) do { helper_print_mem_EA(EA); } while (0)
25 #else
26 #define print_mem_EA(EA) do { } while (0)
27 #endif
29 static always_inline uint32_t glue(ldl_l, MEMSUFFIX) (target_ulong EA)
31 env->lock = EA;
33 return glue(ldl, MEMSUFFIX)(EA);
36 static always_inline uint32_t glue(ldq_l, MEMSUFFIX) (target_ulong EA)
38 env->lock = EA;
40 return glue(ldq, MEMSUFFIX)(EA);
43 static always_inline void glue(stl_c, MEMSUFFIX) (target_ulong EA,
44 uint32_t data)
46 if (EA == env->lock) {
47 glue(stl, MEMSUFFIX)(EA, data);
48 T0 = 0;
49 } else {
50 T0 = 1;
52 env->lock = -1;
55 static always_inline void glue(stq_c, MEMSUFFIX) (target_ulong EA,
56 uint64_t data)
58 if (EA == env->lock) {
59 glue(stq, MEMSUFFIX)(EA, data);
60 T0 = 0;
61 } else {
62 T0 = 1;
64 env->lock = -1;
67 #define ALPHA_LD_OP(name, op) \
68 void OPPROTO glue(glue(op_ld, name), MEMSUFFIX) (void) \
69 { \
70 print_mem_EA(T0); \
71 T1 = glue(op, MEMSUFFIX)(T0); \
72 RETURN(); \
75 #define ALPHA_ST_OP(name, op) \
76 void OPPROTO glue(glue(op_st, name), MEMSUFFIX) (void) \
77 { \
78 print_mem_EA(T0); \
79 glue(op, MEMSUFFIX)(T0, T1); \
80 RETURN(); \
83 ALPHA_LD_OP(bu, ldub);
84 ALPHA_ST_OP(b, stb);
85 ALPHA_LD_OP(wu, lduw);
86 ALPHA_ST_OP(w, stw);
87 ALPHA_LD_OP(l, ldl);
88 ALPHA_ST_OP(l, stl);
89 ALPHA_LD_OP(q, ldq);
90 ALPHA_ST_OP(q, stq);
92 ALPHA_LD_OP(q_u, ldq);
93 ALPHA_ST_OP(q_u, stq);
95 ALPHA_LD_OP(l_l, ldl_l);
96 ALPHA_LD_OP(q_l, ldq_l);
97 ALPHA_ST_OP(l_c, stl_c);
98 ALPHA_ST_OP(q_c, stq_c);
100 #define ALPHA_LDF_OP(name, op) \
101 void OPPROTO glue(glue(op_ld, name), MEMSUFFIX) (void) \
103 print_mem_EA(T0); \
104 FT1 = glue(op, MEMSUFFIX)(T0); \
105 RETURN(); \
108 #define ALPHA_STF_OP(name, op) \
109 void OPPROTO glue(glue(op_st, name), MEMSUFFIX) (void) \
111 print_mem_EA(T0); \
112 glue(op, MEMSUFFIX)(T0, FT1); \
113 RETURN(); \
116 ALPHA_LDF_OP(t, ldfq);
117 ALPHA_STF_OP(t, stfq);
118 ALPHA_LDF_OP(s, ldfl);
119 ALPHA_STF_OP(s, stfl);
121 /* VAX floating point */
122 ALPHA_LDF_OP(f, helper_ldff);
123 ALPHA_STF_OP(f, helper_stff);
124 ALPHA_LDF_OP(g, helper_ldfg);
125 ALPHA_STF_OP(g, helper_stfg);
127 #undef MEMSUFFIX