tap-linux: Convert tap_open() to Error
[qemu.git] / tcg / tcg-opc.h
blob13ccb60a5d17528410017f164fcf2bb3f4419ce7
1 /*
2 * Tiny Code Generator for QEMU
4 * Copyright (c) 2008 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
26 * DEF(name, oargs, iargs, cargs, flags)
29 /* predefined ops */
30 DEF(discard, 1, 0, 0, TCG_OPF_NOT_PRESENT)
31 DEF(set_label, 0, 0, 1, TCG_OPF_BB_END | TCG_OPF_NOT_PRESENT)
33 /* variable number of parameters */
34 DEF(call, 0, 0, 3, TCG_OPF_CALL_CLOBBER | TCG_OPF_NOT_PRESENT)
36 DEF(br, 0, 0, 1, TCG_OPF_BB_END)
38 #define IMPL(X) (__builtin_constant_p(X) && !(X) ? TCG_OPF_NOT_PRESENT : 0)
39 #if TCG_TARGET_REG_BITS == 32
40 # define IMPL64 TCG_OPF_64BIT | TCG_OPF_NOT_PRESENT
41 #else
42 # define IMPL64 TCG_OPF_64BIT
43 #endif
45 DEF(mov_i32, 1, 1, 0, TCG_OPF_NOT_PRESENT)
46 DEF(movi_i32, 1, 0, 1, TCG_OPF_NOT_PRESENT)
47 DEF(setcond_i32, 1, 2, 1, 0)
48 DEF(movcond_i32, 1, 4, 1, IMPL(TCG_TARGET_HAS_movcond_i32))
49 /* load/store */
50 DEF(ld8u_i32, 1, 1, 1, 0)
51 DEF(ld8s_i32, 1, 1, 1, 0)
52 DEF(ld16u_i32, 1, 1, 1, 0)
53 DEF(ld16s_i32, 1, 1, 1, 0)
54 DEF(ld_i32, 1, 1, 1, 0)
55 DEF(st8_i32, 0, 2, 1, 0)
56 DEF(st16_i32, 0, 2, 1, 0)
57 DEF(st_i32, 0, 2, 1, 0)
58 /* arith */
59 DEF(add_i32, 1, 2, 0, 0)
60 DEF(sub_i32, 1, 2, 0, 0)
61 DEF(mul_i32, 1, 2, 0, 0)
62 DEF(div_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_div_i32))
63 DEF(divu_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_div_i32))
64 DEF(rem_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_rem_i32))
65 DEF(remu_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_rem_i32))
66 DEF(div2_i32, 2, 3, 0, IMPL(TCG_TARGET_HAS_div2_i32))
67 DEF(divu2_i32, 2, 3, 0, IMPL(TCG_TARGET_HAS_div2_i32))
68 DEF(and_i32, 1, 2, 0, 0)
69 DEF(or_i32, 1, 2, 0, 0)
70 DEF(xor_i32, 1, 2, 0, 0)
71 /* shifts/rotates */
72 DEF(shl_i32, 1, 2, 0, 0)
73 DEF(shr_i32, 1, 2, 0, 0)
74 DEF(sar_i32, 1, 2, 0, 0)
75 DEF(rotl_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_rot_i32))
76 DEF(rotr_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_rot_i32))
77 DEF(deposit_i32, 1, 2, 2, IMPL(TCG_TARGET_HAS_deposit_i32))
79 DEF(brcond_i32, 0, 2, 2, TCG_OPF_BB_END)
81 DEF(add2_i32, 2, 4, 0, IMPL(TCG_TARGET_HAS_add2_i32))
82 DEF(sub2_i32, 2, 4, 0, IMPL(TCG_TARGET_HAS_sub2_i32))
83 DEF(mulu2_i32, 2, 2, 0, IMPL(TCG_TARGET_HAS_mulu2_i32))
84 DEF(muls2_i32, 2, 2, 0, IMPL(TCG_TARGET_HAS_muls2_i32))
85 DEF(muluh_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_muluh_i32))
86 DEF(mulsh_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_mulsh_i32))
87 DEF(brcond2_i32, 0, 4, 2, TCG_OPF_BB_END | IMPL(TCG_TARGET_REG_BITS == 32))
88 DEF(setcond2_i32, 1, 4, 1, IMPL(TCG_TARGET_REG_BITS == 32))
90 DEF(ext8s_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext8s_i32))
91 DEF(ext16s_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext16s_i32))
92 DEF(ext8u_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext8u_i32))
93 DEF(ext16u_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext16u_i32))
94 DEF(bswap16_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_bswap16_i32))
95 DEF(bswap32_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_bswap32_i32))
96 DEF(not_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_not_i32))
97 DEF(neg_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_neg_i32))
98 DEF(andc_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_andc_i32))
99 DEF(orc_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_orc_i32))
100 DEF(eqv_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_eqv_i32))
101 DEF(nand_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_nand_i32))
102 DEF(nor_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_nor_i32))
104 DEF(mov_i64, 1, 1, 0, TCG_OPF_64BIT | TCG_OPF_NOT_PRESENT)
105 DEF(movi_i64, 1, 0, 1, TCG_OPF_64BIT | TCG_OPF_NOT_PRESENT)
106 DEF(setcond_i64, 1, 2, 1, IMPL64)
107 DEF(movcond_i64, 1, 4, 1, IMPL64 | IMPL(TCG_TARGET_HAS_movcond_i64))
108 /* load/store */
109 DEF(ld8u_i64, 1, 1, 1, IMPL64)
110 DEF(ld8s_i64, 1, 1, 1, IMPL64)
111 DEF(ld16u_i64, 1, 1, 1, IMPL64)
112 DEF(ld16s_i64, 1, 1, 1, IMPL64)
113 DEF(ld32u_i64, 1, 1, 1, IMPL64)
114 DEF(ld32s_i64, 1, 1, 1, IMPL64)
115 DEF(ld_i64, 1, 1, 1, IMPL64)
116 DEF(st8_i64, 0, 2, 1, IMPL64)
117 DEF(st16_i64, 0, 2, 1, IMPL64)
118 DEF(st32_i64, 0, 2, 1, IMPL64)
119 DEF(st_i64, 0, 2, 1, IMPL64)
120 /* arith */
121 DEF(add_i64, 1, 2, 0, IMPL64)
122 DEF(sub_i64, 1, 2, 0, IMPL64)
123 DEF(mul_i64, 1, 2, 0, IMPL64)
124 DEF(div_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_div_i64))
125 DEF(divu_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_div_i64))
126 DEF(rem_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_rem_i64))
127 DEF(remu_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_rem_i64))
128 DEF(div2_i64, 2, 3, 0, IMPL64 | IMPL(TCG_TARGET_HAS_div2_i64))
129 DEF(divu2_i64, 2, 3, 0, IMPL64 | IMPL(TCG_TARGET_HAS_div2_i64))
130 DEF(and_i64, 1, 2, 0, IMPL64)
131 DEF(or_i64, 1, 2, 0, IMPL64)
132 DEF(xor_i64, 1, 2, 0, IMPL64)
133 /* shifts/rotates */
134 DEF(shl_i64, 1, 2, 0, IMPL64)
135 DEF(shr_i64, 1, 2, 0, IMPL64)
136 DEF(sar_i64, 1, 2, 0, IMPL64)
137 DEF(rotl_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_rot_i64))
138 DEF(rotr_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_rot_i64))
139 DEF(deposit_i64, 1, 2, 2, IMPL64 | IMPL(TCG_TARGET_HAS_deposit_i64))
141 DEF(trunc_shr_i32, 1, 1, 1,
142 IMPL(TCG_TARGET_HAS_trunc_shr_i32)
143 | (TCG_TARGET_REG_BITS == 32 ? TCG_OPF_NOT_PRESENT : 0))
145 DEF(brcond_i64, 0, 2, 2, TCG_OPF_BB_END | IMPL64)
146 DEF(ext8s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext8s_i64))
147 DEF(ext16s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext16s_i64))
148 DEF(ext32s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext32s_i64))
149 DEF(ext8u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext8u_i64))
150 DEF(ext16u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext16u_i64))
151 DEF(ext32u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext32u_i64))
152 DEF(bswap16_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap16_i64))
153 DEF(bswap32_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap32_i64))
154 DEF(bswap64_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap64_i64))
155 DEF(not_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_not_i64))
156 DEF(neg_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_neg_i64))
157 DEF(andc_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_andc_i64))
158 DEF(orc_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_orc_i64))
159 DEF(eqv_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_eqv_i64))
160 DEF(nand_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_nand_i64))
161 DEF(nor_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_nor_i64))
163 DEF(add2_i64, 2, 4, 0, IMPL64 | IMPL(TCG_TARGET_HAS_add2_i64))
164 DEF(sub2_i64, 2, 4, 0, IMPL64 | IMPL(TCG_TARGET_HAS_sub2_i64))
165 DEF(mulu2_i64, 2, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_mulu2_i64))
166 DEF(muls2_i64, 2, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_muls2_i64))
167 DEF(muluh_i64, 1, 2, 0, IMPL(TCG_TARGET_HAS_muluh_i64))
168 DEF(mulsh_i64, 1, 2, 0, IMPL(TCG_TARGET_HAS_mulsh_i64))
170 /* QEMU specific */
171 #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
172 DEF(debug_insn_start, 0, 0, 2, TCG_OPF_NOT_PRESENT)
173 #else
174 DEF(debug_insn_start, 0, 0, 1, TCG_OPF_NOT_PRESENT)
175 #endif
176 DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_END)
177 DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_END)
179 #define TLADDR_ARGS (TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? 1 : 2)
180 #define DATA64_ARGS (TCG_TARGET_REG_BITS == 64 ? 1 : 2)
182 DEF(qemu_ld_i32, 1, TLADDR_ARGS, 1,
183 TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS)
184 DEF(qemu_st_i32, 0, TLADDR_ARGS + 1, 1,
185 TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS)
186 DEF(qemu_ld_i64, DATA64_ARGS, TLADDR_ARGS, 1,
187 TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS | TCG_OPF_64BIT)
188 DEF(qemu_st_i64, 0, TLADDR_ARGS + DATA64_ARGS, 1,
189 TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS | TCG_OPF_64BIT)
191 #undef TLADDR_ARGS
192 #undef DATA64_ARGS
193 #undef IMPL
194 #undef IMPL64
195 #undef DEF