2 * Routines common to user and system emulation of load/store.
4 * Copyright (c) 2003 Fabrice Bellard
6 * SPDX-License-Identifier: GPL-2.0-or-later
8 * This work is licensed under the terms of the GNU GPL, version 2 or later.
9 * See the COPYING file in the top-level directory.
12 uint32_t cpu_ldub_mmuidx_ra(CPUArchState *env, abi_ptr addr,
13 int mmu_idx, uintptr_t ra)
15 MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
16 return cpu_ldb_mmu(env, addr, oi, ra);
19 int cpu_ldsb_mmuidx_ra(CPUArchState *env, abi_ptr addr,
20 int mmu_idx, uintptr_t ra)
22 return (int8_t)cpu_ldub_mmuidx_ra(env, addr, mmu_idx, ra);
25 uint32_t cpu_lduw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,
26 int mmu_idx, uintptr_t ra)
28 MemOpIdx oi = make_memop_idx(MO_BEUW | MO_UNALN, mmu_idx);
29 return cpu_ldw_be_mmu(env, addr, oi, ra);
32 int cpu_ldsw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,
33 int mmu_idx, uintptr_t ra)
35 return (int16_t)cpu_lduw_be_mmuidx_ra(env, addr, mmu_idx, ra);
38 uint32_t cpu_ldl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,
39 int mmu_idx, uintptr_t ra)
41 MemOpIdx oi = make_memop_idx(MO_BEUL | MO_UNALN, mmu_idx);
42 return cpu_ldl_be_mmu(env, addr, oi, ra);
45 uint64_t cpu_ldq_be_mmuidx_ra(CPUArchState *env, abi_ptr addr,
46 int mmu_idx, uintptr_t ra)
48 MemOpIdx oi = make_memop_idx(MO_BEUQ | MO_UNALN, mmu_idx);
49 return cpu_ldq_be_mmu(env, addr, oi, ra);
52 uint32_t cpu_lduw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,
53 int mmu_idx, uintptr_t ra)
55 MemOpIdx oi = make_memop_idx(MO_LEUW | MO_UNALN, mmu_idx);
56 return cpu_ldw_le_mmu(env, addr, oi, ra);
59 int cpu_ldsw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,
60 int mmu_idx, uintptr_t ra)
62 return (int16_t)cpu_lduw_le_mmuidx_ra(env, addr, mmu_idx, ra);
65 uint32_t cpu_ldl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,
66 int mmu_idx, uintptr_t ra)
68 MemOpIdx oi = make_memop_idx(MO_LEUL | MO_UNALN, mmu_idx);
69 return cpu_ldl_le_mmu(env, addr, oi, ra);
72 uint64_t cpu_ldq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr,
73 int mmu_idx, uintptr_t ra)
75 MemOpIdx oi = make_memop_idx(MO_LEUQ | MO_UNALN, mmu_idx);
76 return cpu_ldq_le_mmu(env, addr, oi, ra);
79 void cpu_stb_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
80 int mmu_idx, uintptr_t ra)
82 MemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
83 cpu_stb_mmu(env, addr, val, oi, ra);
86 void cpu_stw_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
87 int mmu_idx, uintptr_t ra)
89 MemOpIdx oi = make_memop_idx(MO_BEUW | MO_UNALN, mmu_idx);
90 cpu_stw_be_mmu(env, addr, val, oi, ra);
93 void cpu_stl_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
94 int mmu_idx, uintptr_t ra)
96 MemOpIdx oi = make_memop_idx(MO_BEUL | MO_UNALN, mmu_idx);
97 cpu_stl_be_mmu(env, addr, val, oi, ra);
100 void cpu_stq_be_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
101 int mmu_idx, uintptr_t ra)
103 MemOpIdx oi = make_memop_idx(MO_BEUQ | MO_UNALN, mmu_idx);
104 cpu_stq_be_mmu(env, addr, val, oi, ra);
107 void cpu_stw_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
108 int mmu_idx, uintptr_t ra)
110 MemOpIdx oi = make_memop_idx(MO_LEUW | MO_UNALN, mmu_idx);
111 cpu_stw_le_mmu(env, addr, val, oi, ra);
114 void cpu_stl_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint32_t val,
115 int mmu_idx, uintptr_t ra)
117 MemOpIdx oi = make_memop_idx(MO_LEUL | MO_UNALN, mmu_idx);
118 cpu_stl_le_mmu(env, addr, val, oi, ra);
121 void cpu_stq_le_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val,
122 int mmu_idx, uintptr_t ra)
124 MemOpIdx oi = make_memop_idx(MO_LEUQ | MO_UNALN, mmu_idx);
125 cpu_stq_le_mmu(env, addr, val, oi, ra);
128 /*--------------------------*/
130 uint32_t cpu_ldub_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
132 return cpu_ldub_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
135 int cpu_ldsb_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
137 return (int8_t)cpu_ldub_data_ra(env, addr, ra);
140 uint32_t cpu_lduw_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
142 return cpu_lduw_be_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
145 int cpu_ldsw_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
147 return (int16_t)cpu_lduw_be_data_ra(env, addr, ra);
150 uint32_t cpu_ldl_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
152 return cpu_ldl_be_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
155 uint64_t cpu_ldq_be_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
157 return cpu_ldq_be_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
160 uint32_t cpu_lduw_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
162 return cpu_lduw_le_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
165 int cpu_ldsw_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
167 return (int16_t)cpu_lduw_le_data_ra(env, addr, ra);
170 uint32_t cpu_ldl_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
172 return cpu_ldl_le_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
175 uint64_t cpu_ldq_le_data_ra(CPUArchState *env, abi_ptr addr, uintptr_t ra)
177 return cpu_ldq_le_mmuidx_ra(env, addr, cpu_mmu_index(env, false), ra);
180 void cpu_stb_data_ra(CPUArchState *env, abi_ptr addr,
181 uint32_t val, uintptr_t ra)
183 cpu_stb_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
186 void cpu_stw_be_data_ra(CPUArchState *env, abi_ptr addr,
187 uint32_t val, uintptr_t ra)
189 cpu_stw_be_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
192 void cpu_stl_be_data_ra(CPUArchState *env, abi_ptr addr,
193 uint32_t val, uintptr_t ra)
195 cpu_stl_be_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
198 void cpu_stq_be_data_ra(CPUArchState *env, abi_ptr addr,
199 uint64_t val, uintptr_t ra)
201 cpu_stq_be_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
204 void cpu_stw_le_data_ra(CPUArchState *env, abi_ptr addr,
205 uint32_t val, uintptr_t ra)
207 cpu_stw_le_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
210 void cpu_stl_le_data_ra(CPUArchState *env, abi_ptr addr,
211 uint32_t val, uintptr_t ra)
213 cpu_stl_le_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
216 void cpu_stq_le_data_ra(CPUArchState *env, abi_ptr addr,
217 uint64_t val, uintptr_t ra)
219 cpu_stq_le_mmuidx_ra(env, addr, val, cpu_mmu_index(env, false), ra);
222 /*--------------------------*/
224 uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr addr)
226 return cpu_ldub_data_ra(env, addr, 0);
229 int cpu_ldsb_data(CPUArchState *env, abi_ptr addr)
231 return (int8_t)cpu_ldub_data(env, addr);
234 uint32_t cpu_lduw_be_data(CPUArchState *env, abi_ptr addr)
236 return cpu_lduw_be_data_ra(env, addr, 0);
239 int cpu_ldsw_be_data(CPUArchState *env, abi_ptr addr)
241 return (int16_t)cpu_lduw_be_data(env, addr);
244 uint32_t cpu_ldl_be_data(CPUArchState *env, abi_ptr addr)
246 return cpu_ldl_be_data_ra(env, addr, 0);
249 uint64_t cpu_ldq_be_data(CPUArchState *env, abi_ptr addr)
251 return cpu_ldq_be_data_ra(env, addr, 0);
254 uint32_t cpu_lduw_le_data(CPUArchState *env, abi_ptr addr)
256 return cpu_lduw_le_data_ra(env, addr, 0);
259 int cpu_ldsw_le_data(CPUArchState *env, abi_ptr addr)
261 return (int16_t)cpu_lduw_le_data(env, addr);
264 uint32_t cpu_ldl_le_data(CPUArchState *env, abi_ptr addr)
266 return cpu_ldl_le_data_ra(env, addr, 0);
269 uint64_t cpu_ldq_le_data(CPUArchState *env, abi_ptr addr)
271 return cpu_ldq_le_data_ra(env, addr, 0);
274 void cpu_stb_data(CPUArchState *env, abi_ptr addr, uint32_t val)
276 cpu_stb_data_ra(env, addr, val, 0);
279 void cpu_stw_be_data(CPUArchState *env, abi_ptr addr, uint32_t val)
281 cpu_stw_be_data_ra(env, addr, val, 0);
284 void cpu_stl_be_data(CPUArchState *env, abi_ptr addr, uint32_t val)
286 cpu_stl_be_data_ra(env, addr, val, 0);
289 void cpu_stq_be_data(CPUArchState *env, abi_ptr addr, uint64_t val)
291 cpu_stq_be_data_ra(env, addr, val, 0);
294 void cpu_stw_le_data(CPUArchState *env, abi_ptr addr, uint32_t val)
296 cpu_stw_le_data_ra(env, addr, val, 0);
299 void cpu_stl_le_data(CPUArchState *env, abi_ptr addr, uint32_t val)
301 cpu_stl_le_data_ra(env, addr, val, 0);
304 void cpu_stq_le_data(CPUArchState *env, abi_ptr addr, uint64_t val)
306 cpu_stq_le_data_ra(env, addr, val, 0);