Add qemu 2.4.0
[kvmfornfv.git] / qemu / include / exec / cpu_ldst_useronly_template.h
1 /*
2  *  User-only accessor function support
3  *
4  * Generate inline load/store functions for one data size.
5  *
6  * Generate a store function as well as signed and unsigned loads.
7  *
8  * Not used directly but included from cpu_ldst.h.
9  *
10  *  Copyright (c) 2015 Linaro Limited
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24  */
25 #if DATA_SIZE == 8
26 #define SUFFIX q
27 #define USUFFIX q
28 #define DATA_TYPE uint64_t
29 #elif DATA_SIZE == 4
30 #define SUFFIX l
31 #define USUFFIX l
32 #define DATA_TYPE uint32_t
33 #elif DATA_SIZE == 2
34 #define SUFFIX w
35 #define USUFFIX uw
36 #define DATA_TYPE uint16_t
37 #define DATA_STYPE int16_t
38 #elif DATA_SIZE == 1
39 #define SUFFIX b
40 #define USUFFIX ub
41 #define DATA_TYPE uint8_t
42 #define DATA_STYPE int8_t
43 #else
44 #error unsupported data size
45 #endif
46
47 #if DATA_SIZE == 8
48 #define RES_TYPE uint64_t
49 #else
50 #define RES_TYPE uint32_t
51 #endif
52
53 static inline RES_TYPE
54 glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
55 {
56     return glue(glue(ld, USUFFIX), _p)(g2h(ptr));
57 }
58
59 #if DATA_SIZE <= 2
60 static inline int
61 glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
62 {
63     return glue(glue(lds, SUFFIX), _p)(g2h(ptr));
64 }
65 #endif
66
67 #ifndef CODE_ACCESS
68 static inline void
69 glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
70                                       RES_TYPE v)
71 {
72     glue(glue(st, SUFFIX), _p)(g2h(ptr), v);
73 }
74 #endif
75
76 #undef RES_TYPE
77 #undef DATA_TYPE
78 #undef DATA_STYPE
79 #undef SUFFIX
80 #undef USUFFIX
81 #undef DATA_SIZE