bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Tiny Code Generator for QEMU |
| 3 | * |
| 4 | * Copyright (c) 2008 Fabrice Bellard |
| 5 | * |
| 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: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 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. |
| 23 | */ |
| 24 | #include "tcg.h" |
| 25 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 26 | int gen_new_label(void); |
| 27 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 28 | static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 arg1) |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 29 | { |
| 30 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 31 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 32 | } |
| 33 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 34 | static inline void tcg_gen_op1_i64(TCGOpcode opc, TCGv_i64 arg1) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 35 | { |
| 36 | *gen_opc_ptr++ = opc; |
| 37 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 40 | static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg arg1) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 41 | { |
| 42 | *gen_opc_ptr++ = opc; |
| 43 | *gen_opparam_ptr++ = arg1; |
| 44 | } |
| 45 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 46 | static inline void tcg_gen_op2_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 47 | { |
| 48 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 49 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 50 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 53 | static inline void tcg_gen_op2_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2) |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 54 | { |
| 55 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 56 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 57 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 58 | } |
| 59 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 60 | static inline void tcg_gen_op2i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGArg arg2) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 61 | { |
| 62 | *gen_opc_ptr++ = opc; |
| 63 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 64 | *gen_opparam_ptr++ = arg2; |
| 65 | } |
| 66 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 67 | static inline void tcg_gen_op2i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGArg arg2) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 68 | { |
| 69 | *gen_opc_ptr++ = opc; |
| 70 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 71 | *gen_opparam_ptr++ = arg2; |
| 72 | } |
| 73 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 74 | static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg arg1, TCGArg arg2) |
pbrook | bcb0126 | 2008-05-24 02:24:25 +0000 | [diff] [blame] | 75 | { |
| 76 | *gen_opc_ptr++ = opc; |
| 77 | *gen_opparam_ptr++ = arg1; |
| 78 | *gen_opparam_ptr++ = arg2; |
| 79 | } |
| 80 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 81 | static inline void tcg_gen_op3_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 82 | TCGv_i32 arg3) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 83 | { |
| 84 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 85 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 86 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 87 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 90 | static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 91 | TCGv_i64 arg3) |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 92 | { |
| 93 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 94 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 95 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 96 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 97 | } |
| 98 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 99 | static inline void tcg_gen_op3i_i32(TCGOpcode opc, TCGv_i32 arg1, |
| 100 | TCGv_i32 arg2, TCGArg arg3) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 101 | { |
| 102 | *gen_opc_ptr++ = opc; |
| 103 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 104 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 105 | *gen_opparam_ptr++ = arg3; |
| 106 | } |
| 107 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 108 | static inline void tcg_gen_op3i_i64(TCGOpcode opc, TCGv_i64 arg1, |
| 109 | TCGv_i64 arg2, TCGArg arg3) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 110 | { |
| 111 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 112 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 113 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 114 | *gen_opparam_ptr++ = arg3; |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 115 | } |
| 116 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 117 | static inline void tcg_gen_ldst_op_i32(TCGOpcode opc, TCGv_i32 val, |
| 118 | TCGv_ptr base, TCGArg offset) |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 119 | { |
| 120 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 121 | *gen_opparam_ptr++ = GET_TCGV_I32(val); |
| 122 | *gen_opparam_ptr++ = GET_TCGV_PTR(base); |
| 123 | *gen_opparam_ptr++ = offset; |
| 124 | } |
| 125 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 126 | static inline void tcg_gen_ldst_op_i64(TCGOpcode opc, TCGv_i64 val, |
| 127 | TCGv_ptr base, TCGArg offset) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 128 | { |
| 129 | *gen_opc_ptr++ = opc; |
blueswir1 | a810a2d | 2008-12-07 17:16:42 +0000 | [diff] [blame] | 130 | *gen_opparam_ptr++ = GET_TCGV_I64(val); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 131 | *gen_opparam_ptr++ = GET_TCGV_PTR(base); |
| 132 | *gen_opparam_ptr++ = offset; |
| 133 | } |
| 134 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 135 | static inline void tcg_gen_qemu_ldst_op_i64_i32(TCGOpcode opc, TCGv_i64 val, |
| 136 | TCGv_i32 addr, TCGArg mem_index) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 137 | { |
| 138 | *gen_opc_ptr++ = opc; |
| 139 | *gen_opparam_ptr++ = GET_TCGV_I64(val); |
| 140 | *gen_opparam_ptr++ = GET_TCGV_I32(addr); |
| 141 | *gen_opparam_ptr++ = mem_index; |
| 142 | } |
| 143 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 144 | static inline void tcg_gen_qemu_ldst_op_i64_i64(TCGOpcode opc, TCGv_i64 val, |
| 145 | TCGv_i64 addr, TCGArg mem_index) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 146 | { |
| 147 | *gen_opc_ptr++ = opc; |
| 148 | *gen_opparam_ptr++ = GET_TCGV_I64(val); |
| 149 | *gen_opparam_ptr++ = GET_TCGV_I64(addr); |
| 150 | *gen_opparam_ptr++ = mem_index; |
| 151 | } |
| 152 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 153 | static inline void tcg_gen_op4_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 154 | TCGv_i32 arg3, TCGv_i32 arg4) |
| 155 | { |
| 156 | *gen_opc_ptr++ = opc; |
| 157 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 158 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 159 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
| 160 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); |
| 161 | } |
| 162 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 163 | static inline void tcg_gen_op4_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
blueswir1 | a810a2d | 2008-12-07 17:16:42 +0000 | [diff] [blame] | 164 | TCGv_i64 arg3, TCGv_i64 arg4) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 165 | { |
| 166 | *gen_opc_ptr++ = opc; |
| 167 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 168 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 169 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 170 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); |
| 171 | } |
| 172 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 173 | static inline void tcg_gen_op4i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 174 | TCGv_i32 arg3, TCGArg arg4) |
| 175 | { |
| 176 | *gen_opc_ptr++ = opc; |
| 177 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 178 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 179 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 180 | *gen_opparam_ptr++ = arg4; |
| 181 | } |
| 182 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 183 | static inline void tcg_gen_op4i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 184 | TCGv_i64 arg3, TCGArg arg4) |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 185 | { |
| 186 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 187 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 188 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 189 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 190 | *gen_opparam_ptr++ = arg4; |
| 191 | } |
| 192 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 193 | static inline void tcg_gen_op4ii_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 194 | TCGArg arg3, TCGArg arg4) |
| 195 | { |
| 196 | *gen_opc_ptr++ = opc; |
| 197 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 198 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 199 | *gen_opparam_ptr++ = arg3; |
| 200 | *gen_opparam_ptr++ = arg4; |
| 201 | } |
| 202 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 203 | static inline void tcg_gen_op4ii_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 204 | TCGArg arg3, TCGArg arg4) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 205 | { |
| 206 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 207 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 208 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 209 | *gen_opparam_ptr++ = arg3; |
| 210 | *gen_opparam_ptr++ = arg4; |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 213 | static inline void tcg_gen_op5_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 214 | TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5) |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 215 | { |
| 216 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 217 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 218 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 219 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
| 220 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); |
| 221 | *gen_opparam_ptr++ = GET_TCGV_I32(arg5); |
| 222 | } |
| 223 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 224 | static inline void tcg_gen_op5_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 225 | TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5) |
| 226 | { |
| 227 | *gen_opc_ptr++ = opc; |
| 228 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 229 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 230 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 231 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); |
| 232 | *gen_opparam_ptr++ = GET_TCGV_I64(arg5); |
| 233 | } |
| 234 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 235 | static inline void tcg_gen_op5i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 236 | TCGv_i32 arg3, TCGv_i32 arg4, TCGArg arg5) |
| 237 | { |
| 238 | *gen_opc_ptr++ = opc; |
| 239 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 240 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 241 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
| 242 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 243 | *gen_opparam_ptr++ = arg5; |
| 244 | } |
| 245 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 246 | static inline void tcg_gen_op5i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 247 | TCGv_i64 arg3, TCGv_i64 arg4, TCGArg arg5) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 248 | { |
| 249 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 250 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 251 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 252 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 253 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); |
| 254 | *gen_opparam_ptr++ = arg5; |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 257 | static inline void tcg_gen_op6_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 258 | TCGv_i32 arg3, TCGv_i32 arg4, TCGv_i32 arg5, |
| 259 | TCGv_i32 arg6) |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 260 | { |
| 261 | *gen_opc_ptr++ = opc; |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 262 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 263 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 264 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
| 265 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); |
| 266 | *gen_opparam_ptr++ = GET_TCGV_I32(arg5); |
| 267 | *gen_opparam_ptr++ = GET_TCGV_I32(arg6); |
| 268 | } |
| 269 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 270 | static inline void tcg_gen_op6_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 271 | TCGv_i64 arg3, TCGv_i64 arg4, TCGv_i64 arg5, |
| 272 | TCGv_i64 arg6) |
| 273 | { |
| 274 | *gen_opc_ptr++ = opc; |
| 275 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 276 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 277 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 278 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); |
| 279 | *gen_opparam_ptr++ = GET_TCGV_I64(arg5); |
| 280 | *gen_opparam_ptr++ = GET_TCGV_I64(arg6); |
| 281 | } |
| 282 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 283 | static inline void tcg_gen_op6i_i32(TCGOpcode opc, TCGv_i32 arg1, TCGv_i32 arg2, |
Richard Henderson | be210ac | 2010-01-07 10:13:31 -0800 | [diff] [blame] | 284 | TCGv_i32 arg3, TCGv_i32 arg4, |
| 285 | TCGv_i32 arg5, TCGArg arg6) |
| 286 | { |
| 287 | *gen_opc_ptr++ = opc; |
| 288 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 289 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 290 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
| 291 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); |
| 292 | *gen_opparam_ptr++ = GET_TCGV_I32(arg5); |
| 293 | *gen_opparam_ptr++ = arg6; |
| 294 | } |
| 295 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 296 | static inline void tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 arg1, TCGv_i64 arg2, |
Richard Henderson | be210ac | 2010-01-07 10:13:31 -0800 | [diff] [blame] | 297 | TCGv_i64 arg3, TCGv_i64 arg4, |
| 298 | TCGv_i64 arg5, TCGArg arg6) |
| 299 | { |
| 300 | *gen_opc_ptr++ = opc; |
| 301 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 302 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 303 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 304 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); |
| 305 | *gen_opparam_ptr++ = GET_TCGV_I64(arg5); |
| 306 | *gen_opparam_ptr++ = arg6; |
| 307 | } |
| 308 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 309 | static inline void tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 arg1, |
| 310 | TCGv_i32 arg2, TCGv_i32 arg3, |
| 311 | TCGv_i32 arg4, TCGArg arg5, TCGArg arg6) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 312 | { |
| 313 | *gen_opc_ptr++ = opc; |
| 314 | *gen_opparam_ptr++ = GET_TCGV_I32(arg1); |
| 315 | *gen_opparam_ptr++ = GET_TCGV_I32(arg2); |
| 316 | *gen_opparam_ptr++ = GET_TCGV_I32(arg3); |
| 317 | *gen_opparam_ptr++ = GET_TCGV_I32(arg4); |
| 318 | *gen_opparam_ptr++ = arg5; |
| 319 | *gen_opparam_ptr++ = arg6; |
| 320 | } |
| 321 | |
Richard Henderson | a975160 | 2010-03-19 11:12:29 -0700 | [diff] [blame] | 322 | static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 arg1, |
| 323 | TCGv_i64 arg2, TCGv_i64 arg3, |
| 324 | TCGv_i64 arg4, TCGArg arg5, TCGArg arg6) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 325 | { |
| 326 | *gen_opc_ptr++ = opc; |
| 327 | *gen_opparam_ptr++ = GET_TCGV_I64(arg1); |
| 328 | *gen_opparam_ptr++ = GET_TCGV_I64(arg2); |
| 329 | *gen_opparam_ptr++ = GET_TCGV_I64(arg3); |
| 330 | *gen_opparam_ptr++ = GET_TCGV_I64(arg4); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 331 | *gen_opparam_ptr++ = arg5; |
| 332 | *gen_opparam_ptr++ = arg6; |
| 333 | } |
| 334 | |
| 335 | static inline void gen_set_label(int n) |
| 336 | { |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 337 | tcg_gen_op1i(INDEX_op_set_label, n); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 338 | } |
| 339 | |
blueswir1 | fb50d41 | 2008-03-21 17:58:45 +0000 | [diff] [blame] | 340 | static inline void tcg_gen_br(int label) |
| 341 | { |
| 342 | tcg_gen_op1i(INDEX_op_br, label); |
| 343 | } |
| 344 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 345 | static inline void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 346 | { |
aurel32 | fe75bcf | 2009-03-10 08:57:16 +0000 | [diff] [blame] | 347 | if (!TCGV_EQUAL_I32(ret, arg)) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 348 | tcg_gen_op2_i32(INDEX_op_mov_i32, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 349 | } |
| 350 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 351 | static inline void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 352 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 353 | tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 354 | } |
| 355 | |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 356 | /* A version of dh_sizemask from def-helper.h that doesn't rely on |
| 357 | preprocessor magic. */ |
| 358 | static inline int tcg_gen_sizemask(int n, int is_64bit, int is_signed) |
| 359 | { |
| 360 | return (is_64bit << n*2) | (is_signed << (n*2 + 1)); |
| 361 | } |
| 362 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 363 | /* helper calls */ |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 364 | static inline void tcg_gen_helperN(void *func, int flags, int sizemask, |
| 365 | TCGArg ret, int nargs, TCGArg *args) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 366 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 367 | TCGv_ptr fn; |
| 368 | fn = tcg_const_ptr((tcg_target_long)func); |
| 369 | tcg_gen_callN(&tcg_ctx, fn, flags, sizemask, ret, |
| 370 | nargs, args); |
| 371 | tcg_temp_free_ptr(fn); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Aurelien Jarno | dbfff4d | 2010-03-14 23:01:01 +0100 | [diff] [blame] | 374 | /* Note: Both tcg_gen_helper32() and tcg_gen_helper64() are currently |
| 375 | reserved for helpers in tcg-runtime.c. These helpers are all const |
| 376 | and pure, hence the call to tcg_gen_callN() with TCG_CALL_CONST | |
| 377 | TCG_CALL_PURE. This may need to be adjusted if these functions |
| 378 | start to be used with other helpers. */ |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 379 | static inline void tcg_gen_helper32(void *func, int sizemask, TCGv_i32 ret, |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 380 | TCGv_i32 a, TCGv_i32 b) |
| 381 | { |
| 382 | TCGv_ptr fn; |
| 383 | TCGArg args[2]; |
| 384 | fn = tcg_const_ptr((tcg_target_long)func); |
| 385 | args[0] = GET_TCGV_I32(a); |
| 386 | args[1] = GET_TCGV_I32(b); |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 387 | tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask, |
| 388 | GET_TCGV_I32(ret), 2, args); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 389 | tcg_temp_free_ptr(fn); |
| 390 | } |
| 391 | |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 392 | static inline void tcg_gen_helper64(void *func, int sizemask, TCGv_i64 ret, |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 393 | TCGv_i64 a, TCGv_i64 b) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 394 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 395 | TCGv_ptr fn; |
| 396 | TCGArg args[2]; |
| 397 | fn = tcg_const_ptr((tcg_target_long)func); |
| 398 | args[0] = GET_TCGV_I64(a); |
| 399 | args[1] = GET_TCGV_I64(b); |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 400 | tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask, |
| 401 | GET_TCGV_I64(ret), 2, args); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 402 | tcg_temp_free_ptr(fn); |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 403 | } |
| 404 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 405 | /* 32 bit ops */ |
| 406 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 407 | static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 408 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 409 | tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 410 | } |
| 411 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 412 | static inline void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 413 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 414 | tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 415 | } |
| 416 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 417 | static inline void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 418 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 419 | tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 420 | } |
| 421 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 422 | static inline void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 423 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 424 | tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 425 | } |
| 426 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 427 | static inline void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 428 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 429 | tcg_gen_ldst_op_i32(INDEX_op_ld_i32, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 430 | } |
| 431 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 432 | static inline void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 433 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 434 | tcg_gen_ldst_op_i32(INDEX_op_st8_i32, arg1, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 435 | } |
| 436 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 437 | static inline void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 438 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 439 | tcg_gen_ldst_op_i32(INDEX_op_st16_i32, arg1, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 440 | } |
| 441 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 442 | static inline void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 443 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 444 | tcg_gen_ldst_op_i32(INDEX_op_st_i32, arg1, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 445 | } |
| 446 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 447 | static inline void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 448 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 449 | tcg_gen_op3_i32(INDEX_op_add_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 450 | } |
| 451 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 452 | static inline void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 453 | { |
blueswir1 | 7089442 | 2008-02-20 18:01:23 +0000 | [diff] [blame] | 454 | /* some cases can be optimized here */ |
| 455 | if (arg2 == 0) { |
| 456 | tcg_gen_mov_i32(ret, arg1); |
| 457 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 458 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 459 | tcg_gen_add_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 460 | tcg_temp_free_i32(t0); |
blueswir1 | 7089442 | 2008-02-20 18:01:23 +0000 | [diff] [blame] | 461 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 462 | } |
| 463 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 464 | static inline void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 465 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 466 | tcg_gen_op3_i32(INDEX_op_sub_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 467 | } |
| 468 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 469 | static inline void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2) |
aurel32 | 0045734 | 2008-11-02 08:23:04 +0000 | [diff] [blame] | 470 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 471 | TCGv_i32 t0 = tcg_const_i32(arg1); |
aurel32 | 0045734 | 2008-11-02 08:23:04 +0000 | [diff] [blame] | 472 | tcg_gen_sub_i32(ret, t0, arg2); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 473 | tcg_temp_free_i32(t0); |
aurel32 | 0045734 | 2008-11-02 08:23:04 +0000 | [diff] [blame] | 474 | } |
| 475 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 476 | static inline void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 477 | { |
blueswir1 | 7089442 | 2008-02-20 18:01:23 +0000 | [diff] [blame] | 478 | /* some cases can be optimized here */ |
| 479 | if (arg2 == 0) { |
| 480 | tcg_gen_mov_i32(ret, arg1); |
| 481 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 482 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 483 | tcg_gen_sub_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 484 | tcg_temp_free_i32(t0); |
blueswir1 | 7089442 | 2008-02-20 18:01:23 +0000 | [diff] [blame] | 485 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 486 | } |
| 487 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 488 | static inline void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 489 | { |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 490 | if (TCGV_EQUAL_I32(arg1, arg2)) { |
| 491 | tcg_gen_mov_i32(ret, arg1); |
| 492 | } else { |
| 493 | tcg_gen_op3_i32(INDEX_op_and_i32, ret, arg1, arg2); |
| 494 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 495 | } |
| 496 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 497 | static inline void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 498 | { |
| 499 | /* some cases can be optimized here */ |
| 500 | if (arg2 == 0) { |
| 501 | tcg_gen_movi_i32(ret, 0); |
| 502 | } else if (arg2 == 0xffffffff) { |
| 503 | tcg_gen_mov_i32(ret, arg1); |
| 504 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 505 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 506 | tcg_gen_and_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 507 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 511 | static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 512 | { |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 513 | if (TCGV_EQUAL_I32(arg1, arg2)) { |
| 514 | tcg_gen_mov_i32(ret, arg1); |
| 515 | } else { |
| 516 | tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2); |
| 517 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 518 | } |
| 519 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 520 | static inline void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 521 | { |
| 522 | /* some cases can be optimized here */ |
| 523 | if (arg2 == 0xffffffff) { |
blueswir1 | 7089442 | 2008-02-20 18:01:23 +0000 | [diff] [blame] | 524 | tcg_gen_movi_i32(ret, 0xffffffff); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 525 | } else if (arg2 == 0) { |
| 526 | tcg_gen_mov_i32(ret, arg1); |
| 527 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 528 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 529 | tcg_gen_or_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 530 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 534 | static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 535 | { |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 536 | if (TCGV_EQUAL_I32(arg1, arg2)) { |
| 537 | tcg_gen_movi_i32(ret, 0); |
| 538 | } else { |
| 539 | tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2); |
| 540 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 541 | } |
| 542 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 543 | static inline void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 544 | { |
| 545 | /* some cases can be optimized here */ |
| 546 | if (arg2 == 0) { |
| 547 | tcg_gen_mov_i32(ret, arg1); |
| 548 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 549 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 550 | tcg_gen_xor_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 551 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 552 | } |
| 553 | } |
| 554 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 555 | static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 556 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 557 | tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 558 | } |
| 559 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 560 | static inline void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 561 | { |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 562 | if (arg2 == 0) { |
| 563 | tcg_gen_mov_i32(ret, arg1); |
| 564 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 565 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 566 | tcg_gen_shl_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 567 | tcg_temp_free_i32(t0); |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 568 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 569 | } |
| 570 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 571 | static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 572 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 573 | tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 574 | } |
| 575 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 576 | static inline void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 577 | { |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 578 | if (arg2 == 0) { |
| 579 | tcg_gen_mov_i32(ret, arg1); |
| 580 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 581 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 582 | tcg_gen_shr_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 583 | tcg_temp_free_i32(t0); |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 584 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 585 | } |
| 586 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 587 | static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 588 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 589 | tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 590 | } |
| 591 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 592 | static inline void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 593 | { |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 594 | if (arg2 == 0) { |
| 595 | tcg_gen_mov_i32(ret, arg1); |
| 596 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 597 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 598 | tcg_gen_sar_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 599 | tcg_temp_free_i32(t0); |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 600 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 601 | } |
| 602 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 603 | static inline void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1, |
| 604 | TCGv_i32 arg2, int label_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 605 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 606 | tcg_gen_op4ii_i32(INDEX_op_brcond_i32, arg1, arg2, cond, label_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 607 | } |
| 608 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 609 | static inline void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1, |
| 610 | int32_t arg2, int label_index) |
pbrook | cb63669 | 2008-05-24 02:22:00 +0000 | [diff] [blame] | 611 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 612 | TCGv_i32 t0 = tcg_const_i32(arg2); |
pbrook | cb63669 | 2008-05-24 02:22:00 +0000 | [diff] [blame] | 613 | tcg_gen_brcond_i32(cond, arg1, t0, label_index); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 614 | tcg_temp_free_i32(t0); |
pbrook | cb63669 | 2008-05-24 02:22:00 +0000 | [diff] [blame] | 615 | } |
| 616 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 617 | static inline void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret, |
Aurelien Jarno | 5105c55 | 2010-02-08 12:10:15 +0100 | [diff] [blame] | 618 | TCGv_i32 arg1, TCGv_i32 arg2) |
| 619 | { |
| 620 | tcg_gen_op4i_i32(INDEX_op_setcond_i32, ret, arg1, arg2, cond); |
| 621 | } |
| 622 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 623 | static inline void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret, |
| 624 | TCGv_i32 arg1, int32_t arg2) |
Aurelien Jarno | 5105c55 | 2010-02-08 12:10:15 +0100 | [diff] [blame] | 625 | { |
| 626 | TCGv_i32 t0 = tcg_const_i32(arg2); |
| 627 | tcg_gen_setcond_i32(cond, ret, arg1, t0); |
| 628 | tcg_temp_free_i32(t0); |
| 629 | } |
| 630 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 631 | static inline void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 632 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 633 | tcg_gen_op3_i32(INDEX_op_mul_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 634 | } |
| 635 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 636 | static inline void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
ths | f730fd2 | 2008-05-04 08:14:08 +0000 | [diff] [blame] | 637 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 638 | TCGv_i32 t0 = tcg_const_i32(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 639 | tcg_gen_mul_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 640 | tcg_temp_free_i32(t0); |
ths | f730fd2 | 2008-05-04 08:14:08 +0000 | [diff] [blame] | 641 | } |
| 642 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 643 | #ifdef TCG_TARGET_HAS_div_i32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 644 | static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 645 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 646 | tcg_gen_op3_i32(INDEX_op_div_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 647 | } |
| 648 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 649 | static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 650 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 651 | tcg_gen_op3_i32(INDEX_op_rem_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 652 | } |
| 653 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 654 | static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 655 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 656 | tcg_gen_op3_i32(INDEX_op_divu_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 657 | } |
| 658 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 659 | static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 660 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 661 | tcg_gen_op3_i32(INDEX_op_remu_i32, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 662 | } |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 663 | #elif defined(TCG_TARGET_HAS_div2_i32) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 664 | static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 665 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 666 | TCGv_i32 t0; |
| 667 | t0 = tcg_temp_new_i32(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 668 | tcg_gen_sari_i32(t0, arg1, 31); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 669 | tcg_gen_op5_i32(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2); |
| 670 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 671 | } |
| 672 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 673 | static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 674 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 675 | TCGv_i32 t0; |
| 676 | t0 = tcg_temp_new_i32(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 677 | tcg_gen_sari_i32(t0, arg1, 31); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 678 | tcg_gen_op5_i32(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2); |
| 679 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 680 | } |
| 681 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 682 | static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 683 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 684 | TCGv_i32 t0; |
| 685 | t0 = tcg_temp_new_i32(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 686 | tcg_gen_movi_i32(t0, 0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 687 | tcg_gen_op5_i32(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2); |
| 688 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 689 | } |
| 690 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 691 | static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 692 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 693 | TCGv_i32 t0; |
| 694 | t0 = tcg_temp_new_i32(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 695 | tcg_gen_movi_i32(t0, 0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 696 | tcg_gen_op5_i32(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2); |
| 697 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 698 | } |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 699 | #else |
| 700 | static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
| 701 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 702 | int sizemask = 0; |
| 703 | /* Return value and both arguments are 32-bit and signed. */ |
| 704 | sizemask |= tcg_gen_sizemask(0, 0, 1); |
| 705 | sizemask |= tcg_gen_sizemask(1, 0, 1); |
| 706 | sizemask |= tcg_gen_sizemask(2, 0, 1); |
| 707 | |
| 708 | tcg_gen_helper32(tcg_helper_div_i32, sizemask, ret, arg1, arg2); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
| 712 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 713 | int sizemask = 0; |
| 714 | /* Return value and both arguments are 32-bit and signed. */ |
| 715 | sizemask |= tcg_gen_sizemask(0, 0, 1); |
| 716 | sizemask |= tcg_gen_sizemask(1, 0, 1); |
| 717 | sizemask |= tcg_gen_sizemask(2, 0, 1); |
| 718 | |
| 719 | tcg_gen_helper32(tcg_helper_rem_i32, sizemask, ret, arg1, arg2); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
| 723 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 724 | int sizemask = 0; |
| 725 | /* Return value and both arguments are 32-bit and unsigned. */ |
| 726 | sizemask |= tcg_gen_sizemask(0, 0, 0); |
| 727 | sizemask |= tcg_gen_sizemask(1, 0, 0); |
| 728 | sizemask |= tcg_gen_sizemask(2, 0, 0); |
| 729 | |
| 730 | tcg_gen_helper32(tcg_helper_divu_i32, ret, arg1, arg2, 0); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
| 734 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 735 | int sizemask = 0; |
| 736 | /* Return value and both arguments are 32-bit and unsigned. */ |
| 737 | sizemask |= tcg_gen_sizemask(0, 0, 0); |
| 738 | sizemask |= tcg_gen_sizemask(1, 0, 0); |
| 739 | sizemask |= tcg_gen_sizemask(2, 0, 0); |
| 740 | |
| 741 | tcg_gen_helper32(tcg_helper_remu_i32, ret, arg1, arg2, 0); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 742 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 743 | #endif |
| 744 | |
| 745 | #if TCG_TARGET_REG_BITS == 32 |
| 746 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 747 | static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 748 | { |
aurel32 | fe75bcf | 2009-03-10 08:57:16 +0000 | [diff] [blame] | 749 | if (!TCGV_EQUAL_I64(ret, arg)) { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 750 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
blueswir1 | 4d07272 | 2008-05-03 20:52:26 +0000 | [diff] [blame] | 751 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); |
| 752 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 753 | } |
| 754 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 755 | static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 756 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 757 | tcg_gen_movi_i32(TCGV_LOW(ret), arg); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 758 | tcg_gen_movi_i32(TCGV_HIGH(ret), arg >> 32); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 759 | } |
| 760 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 761 | static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
| 762 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 763 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 764 | tcg_gen_ld8u_i32(TCGV_LOW(ret), arg2, offset); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 765 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 766 | } |
| 767 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 768 | static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
| 769 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 770 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 771 | tcg_gen_ld8s_i32(TCGV_LOW(ret), arg2, offset); |
| 772 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_HIGH(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 773 | } |
| 774 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 775 | static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
| 776 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 777 | { |
aurel32 | a747723 | 2009-02-09 20:43:53 +0000 | [diff] [blame] | 778 | tcg_gen_ld16u_i32(TCGV_LOW(ret), arg2, offset); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 779 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 780 | } |
| 781 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 782 | static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
| 783 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 784 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 785 | tcg_gen_ld16s_i32(TCGV_LOW(ret), arg2, offset); |
| 786 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 787 | } |
| 788 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 789 | static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2, |
| 790 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 791 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 792 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 793 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 794 | } |
| 795 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 796 | static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2, |
| 797 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 798 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 799 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
| 800 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 801 | } |
| 802 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 803 | static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, |
| 804 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 805 | { |
| 806 | /* since arg2 and ret have different types, they cannot be the |
| 807 | same temporary */ |
| 808 | #ifdef TCG_TARGET_WORDS_BIGENDIAN |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 809 | tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 810 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset + 4); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 811 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 812 | tcg_gen_ld_i32(TCGV_LOW(ret), arg2, offset); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 813 | tcg_gen_ld_i32(TCGV_HIGH(ret), arg2, offset + 4); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 814 | #endif |
| 815 | } |
| 816 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 817 | static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
| 818 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 819 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 820 | tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 821 | } |
| 822 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 823 | static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
| 824 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 825 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 826 | tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 827 | } |
| 828 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 829 | static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
| 830 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 831 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 832 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 833 | } |
| 834 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 835 | static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, |
| 836 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 837 | { |
| 838 | #ifdef TCG_TARGET_WORDS_BIGENDIAN |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 839 | tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 840 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset + 4); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 841 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 842 | tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 843 | tcg_gen_st_i32(TCGV_HIGH(arg1), arg2, offset + 4); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 844 | #endif |
| 845 | } |
| 846 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 847 | static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 848 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 849 | tcg_gen_op6_i32(INDEX_op_add2_i32, TCGV_LOW(ret), TCGV_HIGH(ret), |
| 850 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), |
| 851 | TCGV_HIGH(arg2)); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 852 | } |
| 853 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 854 | static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 855 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 856 | tcg_gen_op6_i32(INDEX_op_sub2_i32, TCGV_LOW(ret), TCGV_HIGH(ret), |
| 857 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), |
| 858 | TCGV_HIGH(arg2)); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 859 | } |
| 860 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 861 | static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 862 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 863 | tcg_gen_and_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 864 | tcg_gen_and_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 865 | } |
| 866 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 867 | static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 868 | { |
aurel32 | e510508 | 2009-03-11 02:57:30 +0000 | [diff] [blame] | 869 | tcg_gen_andi_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
| 870 | tcg_gen_andi_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 871 | } |
| 872 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 873 | static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 874 | { |
aurel32 | e510508 | 2009-03-11 02:57:30 +0000 | [diff] [blame] | 875 | tcg_gen_or_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 876 | tcg_gen_or_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 877 | } |
| 878 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 879 | static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 880 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 881 | tcg_gen_ori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 882 | tcg_gen_ori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 883 | } |
| 884 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 885 | static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 886 | { |
aurel32 | e510508 | 2009-03-11 02:57:30 +0000 | [diff] [blame] | 887 | tcg_gen_xor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 888 | tcg_gen_xor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 889 | } |
| 890 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 891 | static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 892 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 893 | tcg_gen_xori_i32(TCGV_LOW(ret), TCGV_LOW(arg1), arg2); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 894 | tcg_gen_xori_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), arg2 >> 32); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 895 | } |
| 896 | |
| 897 | /* XXX: use generic code when basic block handling is OK or CPU |
| 898 | specific code (x86) */ |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 899 | static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 900 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 901 | int sizemask = 0; |
| 902 | /* Return value and both arguments are 64-bit and signed. */ |
| 903 | sizemask |= tcg_gen_sizemask(0, 1, 1); |
| 904 | sizemask |= tcg_gen_sizemask(1, 1, 1); |
| 905 | sizemask |= tcg_gen_sizemask(2, 1, 1); |
| 906 | |
| 907 | tcg_gen_helper64(tcg_helper_shl_i64, sizemask, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 908 | } |
| 909 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 910 | static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 911 | { |
| 912 | tcg_gen_shifti_i64(ret, arg1, arg2, 0, 0); |
| 913 | } |
| 914 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 915 | static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 916 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 917 | int sizemask = 0; |
| 918 | /* Return value and both arguments are 64-bit and signed. */ |
| 919 | sizemask |= tcg_gen_sizemask(0, 1, 1); |
| 920 | sizemask |= tcg_gen_sizemask(1, 1, 1); |
| 921 | sizemask |= tcg_gen_sizemask(2, 1, 1); |
| 922 | |
| 923 | tcg_gen_helper64(tcg_helper_shr_i64, sizemask, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 924 | } |
| 925 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 926 | static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 927 | { |
| 928 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 0); |
| 929 | } |
| 930 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 931 | static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 932 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 933 | int sizemask = 0; |
| 934 | /* Return value and both arguments are 64-bit and signed. */ |
| 935 | sizemask |= tcg_gen_sizemask(0, 1, 1); |
| 936 | sizemask |= tcg_gen_sizemask(1, 1, 1); |
| 937 | sizemask |= tcg_gen_sizemask(2, 1, 1); |
| 938 | |
| 939 | tcg_gen_helper64(tcg_helper_sar_i64, sizemask, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 940 | } |
| 941 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 942 | static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 943 | { |
| 944 | tcg_gen_shifti_i64(ret, arg1, arg2, 1, 1); |
| 945 | } |
| 946 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 947 | static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, |
| 948 | TCGv_i64 arg2, int label_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 949 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 950 | tcg_gen_op6ii_i32(INDEX_op_brcond2_i32, |
| 951 | TCGV_LOW(arg1), TCGV_HIGH(arg1), TCGV_LOW(arg2), |
| 952 | TCGV_HIGH(arg2), cond, label_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 953 | } |
| 954 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 955 | static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret, |
Aurelien Jarno | 5105c55 | 2010-02-08 12:10:15 +0100 | [diff] [blame] | 956 | TCGv_i64 arg1, TCGv_i64 arg2) |
| 957 | { |
| 958 | tcg_gen_op6i_i32(INDEX_op_setcond2_i32, TCGV_LOW(ret), |
| 959 | TCGV_LOW(arg1), TCGV_HIGH(arg1), |
| 960 | TCGV_LOW(arg2), TCGV_HIGH(arg2), cond); |
| 961 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
| 962 | } |
| 963 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 964 | static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 965 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 966 | TCGv_i64 t0; |
| 967 | TCGv_i32 t1; |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 968 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 969 | t0 = tcg_temp_new_i64(); |
| 970 | t1 = tcg_temp_new_i32(); |
| 971 | |
| 972 | tcg_gen_op4_i32(INDEX_op_mulu2_i32, TCGV_LOW(t0), TCGV_HIGH(t0), |
| 973 | TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 974 | |
| 975 | tcg_gen_mul_i32(t1, TCGV_LOW(arg1), TCGV_HIGH(arg2)); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 976 | tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 977 | tcg_gen_mul_i32(t1, TCGV_HIGH(arg1), TCGV_LOW(arg2)); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 978 | tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 979 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 980 | tcg_gen_mov_i64(ret, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 981 | tcg_temp_free_i64(t0); |
| 982 | tcg_temp_free_i32(t1); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 983 | } |
| 984 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 985 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 986 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 987 | int sizemask = 0; |
| 988 | /* Return value and both arguments are 64-bit and signed. */ |
| 989 | sizemask |= tcg_gen_sizemask(0, 1, 1); |
| 990 | sizemask |= tcg_gen_sizemask(1, 1, 1); |
| 991 | sizemask |= tcg_gen_sizemask(2, 1, 1); |
| 992 | |
| 993 | tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 994 | } |
| 995 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 996 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 997 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 998 | int sizemask = 0; |
| 999 | /* Return value and both arguments are 64-bit and signed. */ |
| 1000 | sizemask |= tcg_gen_sizemask(0, 1, 1); |
| 1001 | sizemask |= tcg_gen_sizemask(1, 1, 1); |
| 1002 | sizemask |= tcg_gen_sizemask(2, 1, 1); |
| 1003 | |
| 1004 | tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1005 | } |
| 1006 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1007 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1008 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 1009 | int sizemask = 0; |
| 1010 | /* Return value and both arguments are 64-bit and unsigned. */ |
| 1011 | sizemask |= tcg_gen_sizemask(0, 1, 0); |
| 1012 | sizemask |= tcg_gen_sizemask(1, 1, 0); |
| 1013 | sizemask |= tcg_gen_sizemask(2, 1, 0); |
| 1014 | |
| 1015 | tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1016 | } |
| 1017 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1018 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1019 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 1020 | int sizemask = 0; |
| 1021 | /* Return value and both arguments are 64-bit and unsigned. */ |
| 1022 | sizemask |= tcg_gen_sizemask(0, 1, 0); |
| 1023 | sizemask |= tcg_gen_sizemask(1, 1, 0); |
| 1024 | sizemask |= tcg_gen_sizemask(2, 1, 0); |
| 1025 | |
| 1026 | tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | #else |
| 1030 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1031 | static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1032 | { |
aurel32 | fe75bcf | 2009-03-10 08:57:16 +0000 | [diff] [blame] | 1033 | if (!TCGV_EQUAL_I64(ret, arg)) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1034 | tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1035 | } |
| 1036 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1037 | static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1038 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1039 | tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1040 | } |
| 1041 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1042 | static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1043 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1044 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1045 | tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1046 | } |
| 1047 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1048 | static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1049 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1050 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1051 | tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1054 | static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1055 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1056 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1057 | tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1058 | } |
| 1059 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1060 | static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1061 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1062 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1063 | tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1066 | static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1067 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1068 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1069 | tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1070 | } |
| 1071 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1072 | static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1073 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1074 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1075 | tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1076 | } |
| 1077 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1078 | static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_i64 arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1079 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1080 | tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1083 | static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1084 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1085 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1086 | tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1087 | } |
| 1088 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1089 | static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1090 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1091 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1092 | tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1095 | static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_i64 arg2, |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1096 | tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1097 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1098 | tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1099 | } |
| 1100 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1101 | static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_i64 arg2, tcg_target_long offset) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1102 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1103 | tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1104 | } |
| 1105 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1106 | static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1107 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1108 | tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1109 | } |
| 1110 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1111 | static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1112 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1113 | tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1116 | static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1117 | { |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1118 | if (TCGV_EQUAL_I64(arg1, arg2)) { |
| 1119 | tcg_gen_mov_i64(ret, arg1); |
| 1120 | } else { |
| 1121 | tcg_gen_op3_i64(INDEX_op_and_i64, ret, arg1, arg2); |
| 1122 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1123 | } |
| 1124 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1125 | static inline void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1126 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1127 | TCGv_i64 t0 = tcg_const_i64(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1128 | tcg_gen_and_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1129 | tcg_temp_free_i64(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1132 | static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1133 | { |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1134 | if (TCGV_EQUAL_I64(arg1, arg2)) { |
| 1135 | tcg_gen_mov_i64(ret, arg1); |
| 1136 | } else { |
| 1137 | tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2); |
| 1138 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1141 | static inline void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1142 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1143 | TCGv_i64 t0 = tcg_const_i64(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1144 | tcg_gen_or_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1145 | tcg_temp_free_i64(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1146 | } |
| 1147 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1148 | static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1149 | { |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1150 | if (TCGV_EQUAL_I64(arg1, arg2)) { |
| 1151 | tcg_gen_movi_i64(ret, 0); |
| 1152 | } else { |
| 1153 | tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2); |
| 1154 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1155 | } |
| 1156 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1157 | static inline void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1158 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1159 | TCGv_i64 t0 = tcg_const_i64(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1160 | tcg_gen_xor_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1161 | tcg_temp_free_i64(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1162 | } |
| 1163 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1164 | static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1165 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1166 | tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1167 | } |
| 1168 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1169 | static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1170 | { |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 1171 | if (arg2 == 0) { |
| 1172 | tcg_gen_mov_i64(ret, arg1); |
| 1173 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1174 | TCGv_i64 t0 = tcg_const_i64(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1175 | tcg_gen_shl_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1176 | tcg_temp_free_i64(t0); |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 1177 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1178 | } |
| 1179 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1180 | static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1181 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1182 | tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1185 | static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1186 | { |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 1187 | if (arg2 == 0) { |
| 1188 | tcg_gen_mov_i64(ret, arg1); |
| 1189 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1190 | TCGv_i64 t0 = tcg_const_i64(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1191 | tcg_gen_shr_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1192 | tcg_temp_free_i64(t0); |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 1193 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1194 | } |
| 1195 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1196 | static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1197 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1198 | tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1201 | static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1202 | { |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 1203 | if (arg2 == 0) { |
| 1204 | tcg_gen_mov_i64(ret, arg1); |
| 1205 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1206 | TCGv_i64 t0 = tcg_const_i64(arg2); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1207 | tcg_gen_sar_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1208 | tcg_temp_free_i64(t0); |
bellard | 34151a2 | 2008-05-22 13:25:14 +0000 | [diff] [blame] | 1209 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1210 | } |
| 1211 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 1212 | static inline void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, |
| 1213 | TCGv_i64 arg2, int label_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1214 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1215 | tcg_gen_op4ii_i64(INDEX_op_brcond_i64, arg1, arg2, cond, label_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1216 | } |
| 1217 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 1218 | static inline void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret, |
Aurelien Jarno | 5105c55 | 2010-02-08 12:10:15 +0100 | [diff] [blame] | 1219 | TCGv_i64 arg1, TCGv_i64 arg2) |
| 1220 | { |
| 1221 | tcg_gen_op4i_i64(INDEX_op_setcond_i64, ret, arg1, arg2, cond); |
| 1222 | } |
| 1223 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1224 | static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1225 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1226 | tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | #ifdef TCG_TARGET_HAS_div_i64 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1230 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1231 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1232 | tcg_gen_op3_i64(INDEX_op_div_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1233 | } |
| 1234 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1235 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1236 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1237 | tcg_gen_op3_i64(INDEX_op_rem_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1238 | } |
| 1239 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1240 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1241 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1242 | tcg_gen_op3_i64(INDEX_op_divu_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1245 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1246 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1247 | tcg_gen_op3_i64(INDEX_op_remu_i64, ret, arg1, arg2); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1248 | } |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 1249 | #elif defined(TCG_TARGET_HAS_div2_i64) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1250 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1251 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1252 | TCGv_i64 t0; |
| 1253 | t0 = tcg_temp_new_i64(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1254 | tcg_gen_sari_i64(t0, arg1, 63); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1255 | tcg_gen_op5_i64(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2); |
| 1256 | tcg_temp_free_i64(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1259 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1260 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1261 | TCGv_i64 t0; |
| 1262 | t0 = tcg_temp_new_i64(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1263 | tcg_gen_sari_i64(t0, arg1, 63); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1264 | tcg_gen_op5_i64(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2); |
| 1265 | tcg_temp_free_i64(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1266 | } |
| 1267 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1268 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1269 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1270 | TCGv_i64 t0; |
| 1271 | t0 = tcg_temp_new_i64(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1272 | tcg_gen_movi_i64(t0, 0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1273 | tcg_gen_op5_i64(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2); |
| 1274 | tcg_temp_free_i64(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1275 | } |
| 1276 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1277 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1278 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1279 | TCGv_i64 t0; |
| 1280 | t0 = tcg_temp_new_i64(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1281 | tcg_gen_movi_i64(t0, 0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1282 | tcg_gen_op5_i64(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2); |
| 1283 | tcg_temp_free_i64(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1284 | } |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 1285 | #else |
| 1286 | static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
| 1287 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 1288 | int sizemask = 0; |
| 1289 | /* Return value and both arguments are 64-bit and signed. */ |
| 1290 | sizemask |= tcg_gen_sizemask(0, 1, 1); |
| 1291 | sizemask |= tcg_gen_sizemask(1, 1, 1); |
| 1292 | sizemask |= tcg_gen_sizemask(2, 1, 1); |
| 1293 | |
| 1294 | tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
| 1298 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 1299 | int sizemask = 0; |
| 1300 | /* Return value and both arguments are 64-bit and signed. */ |
| 1301 | sizemask |= tcg_gen_sizemask(0, 1, 1); |
| 1302 | sizemask |= tcg_gen_sizemask(1, 1, 1); |
| 1303 | sizemask |= tcg_gen_sizemask(2, 1, 1); |
| 1304 | |
| 1305 | tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 1306 | } |
| 1307 | |
| 1308 | static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
| 1309 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 1310 | int sizemask = 0; |
| 1311 | /* Return value and both arguments are 64-bit and unsigned. */ |
| 1312 | sizemask |= tcg_gen_sizemask(0, 1, 0); |
| 1313 | sizemask |= tcg_gen_sizemask(1, 1, 0); |
| 1314 | sizemask |= tcg_gen_sizemask(2, 1, 0); |
| 1315 | |
| 1316 | tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
| 1320 | { |
Richard Henderson | 2bece2c | 2010-06-14 17:35:27 -0700 | [diff] [blame] | 1321 | int sizemask = 0; |
| 1322 | /* Return value and both arguments are 64-bit and unsigned. */ |
| 1323 | sizemask |= tcg_gen_sizemask(0, 1, 0); |
| 1324 | sizemask |= tcg_gen_sizemask(1, 1, 0); |
| 1325 | sizemask |= tcg_gen_sizemask(2, 1, 0); |
| 1326 | |
| 1327 | tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2); |
Aurelien Jarno | 31d6655 | 2010-03-02 23:16:36 +0100 | [diff] [blame] | 1328 | } |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1329 | #endif |
| 1330 | |
| 1331 | #endif |
| 1332 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1333 | static inline void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
aurel32 | 6359706 | 2008-11-02 08:22:54 +0000 | [diff] [blame] | 1334 | { |
| 1335 | /* some cases can be optimized here */ |
| 1336 | if (arg2 == 0) { |
| 1337 | tcg_gen_mov_i64(ret, arg1); |
| 1338 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1339 | TCGv_i64 t0 = tcg_const_i64(arg2); |
aurel32 | 6359706 | 2008-11-02 08:22:54 +0000 | [diff] [blame] | 1340 | tcg_gen_add_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1341 | tcg_temp_free_i64(t0); |
aurel32 | 6359706 | 2008-11-02 08:22:54 +0000 | [diff] [blame] | 1342 | } |
| 1343 | } |
| 1344 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1345 | static inline void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2) |
aurel32 | 0045734 | 2008-11-02 08:23:04 +0000 | [diff] [blame] | 1346 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1347 | TCGv_i64 t0 = tcg_const_i64(arg1); |
aurel32 | 0045734 | 2008-11-02 08:23:04 +0000 | [diff] [blame] | 1348 | tcg_gen_sub_i64(ret, t0, arg2); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1349 | tcg_temp_free_i64(t0); |
aurel32 | 0045734 | 2008-11-02 08:23:04 +0000 | [diff] [blame] | 1350 | } |
| 1351 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1352 | static inline void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
aurel32 | 6359706 | 2008-11-02 08:22:54 +0000 | [diff] [blame] | 1353 | { |
| 1354 | /* some cases can be optimized here */ |
| 1355 | if (arg2 == 0) { |
| 1356 | tcg_gen_mov_i64(ret, arg1); |
| 1357 | } else { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1358 | TCGv_i64 t0 = tcg_const_i64(arg2); |
aurel32 | 6359706 | 2008-11-02 08:22:54 +0000 | [diff] [blame] | 1359 | tcg_gen_sub_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1360 | tcg_temp_free_i64(t0); |
aurel32 | 6359706 | 2008-11-02 08:22:54 +0000 | [diff] [blame] | 1361 | } |
| 1362 | } |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 1363 | static inline void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, |
| 1364 | int64_t arg2, int label_index) |
aurel32 | f02bb95 | 2008-11-03 07:08:26 +0000 | [diff] [blame] | 1365 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1366 | TCGv_i64 t0 = tcg_const_i64(arg2); |
aurel32 | f02bb95 | 2008-11-03 07:08:26 +0000 | [diff] [blame] | 1367 | tcg_gen_brcond_i64(cond, arg1, t0, label_index); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1368 | tcg_temp_free_i64(t0); |
aurel32 | f02bb95 | 2008-11-03 07:08:26 +0000 | [diff] [blame] | 1369 | } |
| 1370 | |
Richard Henderson | 8a56e84 | 2010-03-19 11:26:05 -0700 | [diff] [blame] | 1371 | static inline void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret, |
| 1372 | TCGv_i64 arg1, int64_t arg2) |
Aurelien Jarno | 5105c55 | 2010-02-08 12:10:15 +0100 | [diff] [blame] | 1373 | { |
| 1374 | TCGv_i64 t0 = tcg_const_i64(arg2); |
| 1375 | tcg_gen_setcond_i64(cond, ret, arg1, t0); |
| 1376 | tcg_temp_free_i64(t0); |
| 1377 | } |
| 1378 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1379 | static inline void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
aurel32 | f02bb95 | 2008-11-03 07:08:26 +0000 | [diff] [blame] | 1380 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1381 | TCGv_i64 t0 = tcg_const_i64(arg2); |
aurel32 | f02bb95 | 2008-11-03 07:08:26 +0000 | [diff] [blame] | 1382 | tcg_gen_mul_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1383 | tcg_temp_free_i64(t0); |
aurel32 | f02bb95 | 2008-11-03 07:08:26 +0000 | [diff] [blame] | 1384 | } |
| 1385 | |
aurel32 | 6359706 | 2008-11-02 08:22:54 +0000 | [diff] [blame] | 1386 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1387 | /***************************************/ |
| 1388 | /* optional operations */ |
| 1389 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1390 | static inline void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1391 | { |
| 1392 | #ifdef TCG_TARGET_HAS_ext8s_i32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1393 | tcg_gen_op2_i32(INDEX_op_ext8s_i32, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1394 | #else |
| 1395 | tcg_gen_shli_i32(ret, arg, 24); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1396 | tcg_gen_sari_i32(ret, ret, 24); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1397 | #endif |
| 1398 | } |
| 1399 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1400 | static inline void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1401 | { |
| 1402 | #ifdef TCG_TARGET_HAS_ext16s_i32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1403 | tcg_gen_op2_i32(INDEX_op_ext16s_i32, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1404 | #else |
| 1405 | tcg_gen_shli_i32(ret, arg, 16); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1406 | tcg_gen_sari_i32(ret, ret, 16); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1407 | #endif |
| 1408 | } |
| 1409 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1410 | static inline void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1411 | { |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1412 | #ifdef TCG_TARGET_HAS_ext8u_i32 |
| 1413 | tcg_gen_op2_i32(INDEX_op_ext8u_i32, ret, arg); |
| 1414 | #else |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1415 | tcg_gen_andi_i32(ret, arg, 0xffu); |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1416 | #endif |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1417 | } |
| 1418 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1419 | static inline void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1420 | { |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1421 | #ifdef TCG_TARGET_HAS_ext16u_i32 |
| 1422 | tcg_gen_op2_i32(INDEX_op_ext16u_i32, ret, arg); |
| 1423 | #else |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1424 | tcg_gen_andi_i32(ret, arg, 0xffffu); |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1425 | #endif |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1426 | } |
| 1427 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1428 | /* Note: we assume the two high bytes are set to zero */ |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1429 | static inline void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1430 | { |
| 1431 | #ifdef TCG_TARGET_HAS_bswap16_i32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1432 | tcg_gen_op2_i32(INDEX_op_bswap16_i32, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1433 | #else |
aurel32 | dfa1a3f | 2009-03-13 09:35:03 +0000 | [diff] [blame] | 1434 | TCGv_i32 t0 = tcg_temp_new_i32(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1435 | |
aurel32 | dfa1a3f | 2009-03-13 09:35:03 +0000 | [diff] [blame] | 1436 | tcg_gen_ext8u_i32(t0, arg); |
| 1437 | tcg_gen_shli_i32(t0, t0, 8); |
| 1438 | tcg_gen_shri_i32(ret, arg, 8); |
| 1439 | tcg_gen_or_i32(ret, ret, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1440 | tcg_temp_free_i32(t0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1441 | #endif |
| 1442 | } |
| 1443 | |
aurel32 | 66896cb | 2009-03-13 09:34:48 +0000 | [diff] [blame] | 1444 | static inline void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1445 | { |
aurel32 | 66896cb | 2009-03-13 09:34:48 +0000 | [diff] [blame] | 1446 | #ifdef TCG_TARGET_HAS_bswap32_i32 |
| 1447 | tcg_gen_op2_i32(INDEX_op_bswap32_i32, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1448 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1449 | TCGv_i32 t0, t1; |
| 1450 | t0 = tcg_temp_new_i32(); |
| 1451 | t1 = tcg_temp_new_i32(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1452 | |
| 1453 | tcg_gen_shli_i32(t0, arg, 24); |
| 1454 | |
| 1455 | tcg_gen_andi_i32(t1, arg, 0x0000ff00); |
| 1456 | tcg_gen_shli_i32(t1, t1, 8); |
| 1457 | tcg_gen_or_i32(t0, t0, t1); |
| 1458 | |
| 1459 | tcg_gen_shri_i32(t1, arg, 8); |
| 1460 | tcg_gen_andi_i32(t1, t1, 0x0000ff00); |
| 1461 | tcg_gen_or_i32(t0, t0, t1); |
| 1462 | |
| 1463 | tcg_gen_shri_i32(t1, arg, 24); |
| 1464 | tcg_gen_or_i32(ret, t0, t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1465 | tcg_temp_free_i32(t0); |
| 1466 | tcg_temp_free_i32(t1); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1467 | #endif |
| 1468 | } |
| 1469 | |
| 1470 | #if TCG_TARGET_REG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1471 | static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1472 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1473 | tcg_gen_ext8s_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
| 1474 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1475 | } |
| 1476 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1477 | static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1478 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1479 | tcg_gen_ext16s_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
| 1480 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1481 | } |
| 1482 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1483 | static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1484 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1485 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
| 1486 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1487 | } |
| 1488 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1489 | static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1490 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1491 | tcg_gen_ext8u_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1492 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
| 1493 | } |
| 1494 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1495 | static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1496 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1497 | tcg_gen_ext16u_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1498 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
| 1499 | } |
| 1500 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1501 | static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1502 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1503 | tcg_gen_mov_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1504 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
| 1505 | } |
| 1506 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1507 | static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1508 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1509 | tcg_gen_mov_i32(ret, TCGV_LOW(arg)); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1510 | } |
| 1511 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1512 | static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1513 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1514 | tcg_gen_mov_i32(TCGV_LOW(ret), arg); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1515 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1516 | } |
| 1517 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1518 | static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1519 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1520 | tcg_gen_mov_i32(TCGV_LOW(ret), arg); |
| 1521 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1522 | } |
| 1523 | |
aurel32 | 9a5c57f | 2009-03-13 09:35:12 +0000 | [diff] [blame] | 1524 | /* Note: we assume the six high bytes are set to zero */ |
| 1525 | static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg) |
| 1526 | { |
| 1527 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); |
| 1528 | tcg_gen_bswap16_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
| 1529 | } |
| 1530 | |
| 1531 | /* Note: we assume the four high bytes are set to zero */ |
| 1532 | static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) |
| 1533 | { |
| 1534 | tcg_gen_mov_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); |
| 1535 | tcg_gen_bswap32_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
| 1536 | } |
| 1537 | |
aurel32 | 66896cb | 2009-03-13 09:34:48 +0000 | [diff] [blame] | 1538 | static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1539 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1540 | TCGv_i32 t0, t1; |
| 1541 | t0 = tcg_temp_new_i32(); |
| 1542 | t1 = tcg_temp_new_i32(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1543 | |
aurel32 | 66896cb | 2009-03-13 09:34:48 +0000 | [diff] [blame] | 1544 | tcg_gen_bswap32_i32(t0, TCGV_LOW(arg)); |
| 1545 | tcg_gen_bswap32_i32(t1, TCGV_HIGH(arg)); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1546 | tcg_gen_mov_i32(TCGV_LOW(ret), t1); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1547 | tcg_gen_mov_i32(TCGV_HIGH(ret), t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1548 | tcg_temp_free_i32(t0); |
| 1549 | tcg_temp_free_i32(t1); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1550 | } |
| 1551 | #else |
| 1552 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1553 | static inline void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1554 | { |
| 1555 | #ifdef TCG_TARGET_HAS_ext8s_i64 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1556 | tcg_gen_op2_i64(INDEX_op_ext8s_i64, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1557 | #else |
| 1558 | tcg_gen_shli_i64(ret, arg, 56); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1559 | tcg_gen_sari_i64(ret, ret, 56); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1560 | #endif |
| 1561 | } |
| 1562 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1563 | static inline void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1564 | { |
| 1565 | #ifdef TCG_TARGET_HAS_ext16s_i64 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1566 | tcg_gen_op2_i64(INDEX_op_ext16s_i64, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1567 | #else |
| 1568 | tcg_gen_shli_i64(ret, arg, 48); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1569 | tcg_gen_sari_i64(ret, ret, 48); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1570 | #endif |
| 1571 | } |
| 1572 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1573 | static inline void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1574 | { |
| 1575 | #ifdef TCG_TARGET_HAS_ext32s_i64 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1576 | tcg_gen_op2_i64(INDEX_op_ext32s_i64, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1577 | #else |
| 1578 | tcg_gen_shli_i64(ret, arg, 32); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1579 | tcg_gen_sari_i64(ret, ret, 32); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1580 | #endif |
| 1581 | } |
| 1582 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1583 | static inline void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1584 | { |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1585 | #ifdef TCG_TARGET_HAS_ext8u_i64 |
| 1586 | tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg); |
| 1587 | #else |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1588 | tcg_gen_andi_i64(ret, arg, 0xffu); |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1589 | #endif |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1590 | } |
| 1591 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1592 | static inline void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1593 | { |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1594 | #ifdef TCG_TARGET_HAS_ext16u_i64 |
| 1595 | tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg); |
| 1596 | #else |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1597 | tcg_gen_andi_i64(ret, arg, 0xffffu); |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1598 | #endif |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1599 | } |
| 1600 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1601 | static inline void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg) |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1602 | { |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1603 | #ifdef TCG_TARGET_HAS_ext32u_i64 |
| 1604 | tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg); |
| 1605 | #else |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1606 | tcg_gen_andi_i64(ret, arg, 0xffffffffu); |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1607 | #endif |
pbrook | 8683143 | 2008-05-11 12:22:01 +0000 | [diff] [blame] | 1608 | } |
| 1609 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1610 | /* Note: we assume the target supports move between 32 and 64 bit |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 1611 | registers. This will probably break MIPS64 targets. */ |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1612 | static inline void tcg_gen_trunc_i64_i32(TCGv_i32 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1613 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1614 | tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg))); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1615 | } |
| 1616 | |
| 1617 | /* Note: we assume the target supports move between 32 and 64 bit |
| 1618 | registers */ |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1619 | static inline void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1620 | { |
Aurelien Jarno | cfc8698 | 2009-09-30 23:09:35 +0200 | [diff] [blame] | 1621 | tcg_gen_ext32u_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg))); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1622 | } |
| 1623 | |
| 1624 | /* Note: we assume the target supports move between 32 and 64 bit |
| 1625 | registers */ |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1626 | static inline void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1627 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1628 | tcg_gen_ext32s_i64(ret, MAKE_TCGV_I64(GET_TCGV_I32(arg))); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1629 | } |
| 1630 | |
aurel32 | 9a5c57f | 2009-03-13 09:35:12 +0000 | [diff] [blame] | 1631 | /* Note: we assume the six high bytes are set to zero */ |
| 1632 | static inline void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg) |
| 1633 | { |
| 1634 | #ifdef TCG_TARGET_HAS_bswap16_i64 |
| 1635 | tcg_gen_op2_i64(INDEX_op_bswap16_i64, ret, arg); |
| 1636 | #else |
| 1637 | TCGv_i64 t0 = tcg_temp_new_i64(); |
| 1638 | |
| 1639 | tcg_gen_ext8u_i64(t0, arg); |
| 1640 | tcg_gen_shli_i64(t0, t0, 8); |
| 1641 | tcg_gen_shri_i64(ret, arg, 8); |
| 1642 | tcg_gen_or_i64(ret, ret, t0); |
| 1643 | tcg_temp_free_i64(t0); |
| 1644 | #endif |
| 1645 | } |
| 1646 | |
| 1647 | /* Note: we assume the four high bytes are set to zero */ |
| 1648 | static inline void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg) |
| 1649 | { |
| 1650 | #ifdef TCG_TARGET_HAS_bswap32_i64 |
| 1651 | tcg_gen_op2_i64(INDEX_op_bswap32_i64, ret, arg); |
| 1652 | #else |
| 1653 | TCGv_i64 t0, t1; |
| 1654 | t0 = tcg_temp_new_i64(); |
| 1655 | t1 = tcg_temp_new_i64(); |
| 1656 | |
| 1657 | tcg_gen_shli_i64(t0, arg, 24); |
| 1658 | tcg_gen_ext32u_i64(t0, t0); |
| 1659 | |
| 1660 | tcg_gen_andi_i64(t1, arg, 0x0000ff00); |
| 1661 | tcg_gen_shli_i64(t1, t1, 8); |
| 1662 | tcg_gen_or_i64(t0, t0, t1); |
| 1663 | |
| 1664 | tcg_gen_shri_i64(t1, arg, 8); |
| 1665 | tcg_gen_andi_i64(t1, t1, 0x0000ff00); |
| 1666 | tcg_gen_or_i64(t0, t0, t1); |
| 1667 | |
| 1668 | tcg_gen_shri_i64(t1, arg, 24); |
| 1669 | tcg_gen_or_i64(ret, t0, t1); |
| 1670 | tcg_temp_free_i64(t0); |
| 1671 | tcg_temp_free_i64(t1); |
| 1672 | #endif |
| 1673 | } |
| 1674 | |
aurel32 | 66896cb | 2009-03-13 09:34:48 +0000 | [diff] [blame] | 1675 | static inline void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1676 | { |
aurel32 | 66896cb | 2009-03-13 09:34:48 +0000 | [diff] [blame] | 1677 | #ifdef TCG_TARGET_HAS_bswap64_i64 |
| 1678 | tcg_gen_op2_i64(INDEX_op_bswap64_i64, ret, arg); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1679 | #else |
Stefan Weil | b348113 | 2009-09-05 18:54:10 +0200 | [diff] [blame] | 1680 | TCGv_i64 t0 = tcg_temp_new_i64(); |
| 1681 | TCGv_i64 t1 = tcg_temp_new_i64(); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1682 | |
| 1683 | tcg_gen_shli_i64(t0, arg, 56); |
| 1684 | |
| 1685 | tcg_gen_andi_i64(t1, arg, 0x0000ff00); |
| 1686 | tcg_gen_shli_i64(t1, t1, 40); |
| 1687 | tcg_gen_or_i64(t0, t0, t1); |
| 1688 | |
| 1689 | tcg_gen_andi_i64(t1, arg, 0x00ff0000); |
| 1690 | tcg_gen_shli_i64(t1, t1, 24); |
| 1691 | tcg_gen_or_i64(t0, t0, t1); |
| 1692 | |
| 1693 | tcg_gen_andi_i64(t1, arg, 0xff000000); |
| 1694 | tcg_gen_shli_i64(t1, t1, 8); |
| 1695 | tcg_gen_or_i64(t0, t0, t1); |
| 1696 | |
| 1697 | tcg_gen_shri_i64(t1, arg, 8); |
| 1698 | tcg_gen_andi_i64(t1, t1, 0xff000000); |
| 1699 | tcg_gen_or_i64(t0, t0, t1); |
| 1700 | |
| 1701 | tcg_gen_shri_i64(t1, arg, 24); |
| 1702 | tcg_gen_andi_i64(t1, t1, 0x00ff0000); |
| 1703 | tcg_gen_or_i64(t0, t0, t1); |
| 1704 | |
| 1705 | tcg_gen_shri_i64(t1, arg, 40); |
| 1706 | tcg_gen_andi_i64(t1, t1, 0x0000ff00); |
| 1707 | tcg_gen_or_i64(t0, t0, t1); |
| 1708 | |
| 1709 | tcg_gen_shri_i64(t1, arg, 56); |
| 1710 | tcg_gen_or_i64(ret, t0, t1); |
Stefan Weil | b348113 | 2009-09-05 18:54:10 +0200 | [diff] [blame] | 1711 | tcg_temp_free_i64(t0); |
| 1712 | tcg_temp_free_i64(t1); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 1713 | #endif |
| 1714 | } |
| 1715 | |
| 1716 | #endif |
| 1717 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1718 | static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg) |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 1719 | { |
| 1720 | #ifdef TCG_TARGET_HAS_neg_i32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1721 | tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg); |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 1722 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1723 | TCGv_i32 t0 = tcg_const_i32(0); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1724 | tcg_gen_sub_i32(ret, t0, arg); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1725 | tcg_temp_free_i32(t0); |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 1726 | #endif |
| 1727 | } |
| 1728 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1729 | static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg) |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 1730 | { |
| 1731 | #ifdef TCG_TARGET_HAS_neg_i64 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1732 | tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg); |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 1733 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1734 | TCGv_i64 t0 = tcg_const_i64(0); |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1735 | tcg_gen_sub_i64(ret, t0, arg); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1736 | tcg_temp_free_i64(t0); |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 1737 | #endif |
| 1738 | } |
| 1739 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1740 | static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg) |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 1741 | { |
aurel32 | d260428 | 2009-03-09 22:35:13 +0000 | [diff] [blame] | 1742 | #ifdef TCG_TARGET_HAS_not_i32 |
| 1743 | tcg_gen_op2_i32(INDEX_op_not_i32, ret, arg); |
| 1744 | #else |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1745 | tcg_gen_xori_i32(ret, arg, -1); |
aurel32 | d260428 | 2009-03-09 22:35:13 +0000 | [diff] [blame] | 1746 | #endif |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 1747 | } |
| 1748 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1749 | static inline void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg) |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 1750 | { |
aurel32 | d260428 | 2009-03-09 22:35:13 +0000 | [diff] [blame] | 1751 | #ifdef TCG_TARGET_HAS_not_i64 |
aurel32 | 43e860e | 2009-03-10 10:29:45 +0000 | [diff] [blame] | 1752 | tcg_gen_op2_i64(INDEX_op_not_i64, ret, arg); |
Richard Henderson | a10f9f4 | 2010-03-19 12:44:47 -0700 | [diff] [blame] | 1753 | #elif defined(TCG_TARGET_HAS_not_i32) && TCG_TARGET_REG_BITS == 32 |
| 1754 | tcg_gen_not_i32(TCGV_LOW(ret), TCGV_LOW(arg)); |
| 1755 | tcg_gen_not_i32(TCGV_HIGH(ret), TCGV_HIGH(arg)); |
aurel32 | d260428 | 2009-03-09 22:35:13 +0000 | [diff] [blame] | 1756 | #else |
bellard | e8996ee | 2008-05-23 17:33:39 +0000 | [diff] [blame] | 1757 | tcg_gen_xori_i64(ret, arg, -1); |
aurel32 | d260428 | 2009-03-09 22:35:13 +0000 | [diff] [blame] | 1758 | #endif |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 1759 | } |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1760 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1761 | static inline void tcg_gen_discard_i32(TCGv_i32 arg) |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1762 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1763 | tcg_gen_op1_i32(INDEX_op_discard, arg); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1764 | } |
| 1765 | |
| 1766 | #if TCG_TARGET_REG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1767 | static inline void tcg_gen_discard_i64(TCGv_i64 arg) |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1768 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1769 | tcg_gen_discard_i32(TCGV_LOW(arg)); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1770 | tcg_gen_discard_i32(TCGV_HIGH(arg)); |
| 1771 | } |
| 1772 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1773 | static inline void tcg_gen_discard_i64(TCGv_i64 arg) |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1774 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1775 | tcg_gen_op1_i64(INDEX_op_discard, arg); |
bellard | 5ff9d6a | 2008-02-04 00:37:54 +0000 | [diff] [blame] | 1776 | } |
| 1777 | #endif |
| 1778 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1779 | static inline void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high) |
pbrook | 36aa55d | 2008-09-21 13:48:32 +0000 | [diff] [blame] | 1780 | { |
| 1781 | #if TCG_TARGET_REG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1782 | tcg_gen_mov_i32(TCGV_LOW(dest), low); |
pbrook | 36aa55d | 2008-09-21 13:48:32 +0000 | [diff] [blame] | 1783 | tcg_gen_mov_i32(TCGV_HIGH(dest), high); |
| 1784 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1785 | TCGv_i64 tmp = tcg_temp_new_i64(); |
pbrook | 36aa55d | 2008-09-21 13:48:32 +0000 | [diff] [blame] | 1786 | /* This extension is only needed for type correctness. |
| 1787 | We may be able to do better given target specific information. */ |
| 1788 | tcg_gen_extu_i32_i64(tmp, high); |
| 1789 | tcg_gen_shli_i64(tmp, tmp, 32); |
| 1790 | tcg_gen_extu_i32_i64(dest, low); |
| 1791 | tcg_gen_or_i64(dest, dest, tmp); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1792 | tcg_temp_free_i64(tmp); |
pbrook | 36aa55d | 2008-09-21 13:48:32 +0000 | [diff] [blame] | 1793 | #endif |
| 1794 | } |
| 1795 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1796 | static inline void tcg_gen_concat32_i64(TCGv_i64 dest, TCGv_i64 low, TCGv_i64 high) |
blueswir1 | 945ca82 | 2008-09-21 18:32:28 +0000 | [diff] [blame] | 1797 | { |
| 1798 | #if TCG_TARGET_REG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1799 | tcg_gen_concat_i32_i64(dest, TCGV_LOW(low), TCGV_LOW(high)); |
blueswir1 | 945ca82 | 2008-09-21 18:32:28 +0000 | [diff] [blame] | 1800 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1801 | TCGv_i64 tmp = tcg_temp_new_i64(); |
pbrook | 88422e2 | 2008-09-23 22:31:10 +0000 | [diff] [blame] | 1802 | tcg_gen_ext32u_i64(dest, low); |
blueswir1 | 945ca82 | 2008-09-21 18:32:28 +0000 | [diff] [blame] | 1803 | tcg_gen_shli_i64(tmp, high, 32); |
pbrook | 88422e2 | 2008-09-23 22:31:10 +0000 | [diff] [blame] | 1804 | tcg_gen_or_i64(dest, dest, tmp); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1805 | tcg_temp_free_i64(tmp); |
blueswir1 | 945ca82 | 2008-09-21 18:32:28 +0000 | [diff] [blame] | 1806 | #endif |
| 1807 | } |
| 1808 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1809 | static inline void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1810 | { |
Richard Henderson | 241cbed | 2010-02-16 14:10:13 -0800 | [diff] [blame] | 1811 | #ifdef TCG_TARGET_HAS_andc_i32 |
| 1812 | tcg_gen_op3_i32(INDEX_op_andc_i32, ret, arg1, arg2); |
| 1813 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1814 | TCGv_i32 t0; |
| 1815 | t0 = tcg_temp_new_i32(); |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1816 | tcg_gen_not_i32(t0, arg2); |
| 1817 | tcg_gen_and_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1818 | tcg_temp_free_i32(t0); |
Richard Henderson | 241cbed | 2010-02-16 14:10:13 -0800 | [diff] [blame] | 1819 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1820 | } |
| 1821 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1822 | static inline void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1823 | { |
Richard Henderson | 241cbed | 2010-02-16 14:10:13 -0800 | [diff] [blame] | 1824 | #ifdef TCG_TARGET_HAS_andc_i64 |
| 1825 | tcg_gen_op3_i64(INDEX_op_andc_i64, ret, arg1, arg2); |
| 1826 | #elif defined(TCG_TARGET_HAS_andc_i32) && TCG_TARGET_REG_BITS == 32 |
| 1827 | tcg_gen_andc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 1828 | tcg_gen_andc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
| 1829 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1830 | TCGv_i64 t0; |
| 1831 | t0 = tcg_temp_new_i64(); |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1832 | tcg_gen_not_i64(t0, arg2); |
| 1833 | tcg_gen_and_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1834 | tcg_temp_free_i64(t0); |
Richard Henderson | 241cbed | 2010-02-16 14:10:13 -0800 | [diff] [blame] | 1835 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1836 | } |
| 1837 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1838 | static inline void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1839 | { |
Richard Henderson | 8d625cf | 2010-03-19 13:02:02 -0700 | [diff] [blame] | 1840 | #ifdef TCG_TARGET_HAS_eqv_i32 |
| 1841 | tcg_gen_op3_i32(INDEX_op_eqv_i32, ret, arg1, arg2); |
| 1842 | #else |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1843 | tcg_gen_xor_i32(ret, arg1, arg2); |
| 1844 | tcg_gen_not_i32(ret, ret); |
Richard Henderson | 8d625cf | 2010-03-19 13:02:02 -0700 | [diff] [blame] | 1845 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1846 | } |
| 1847 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1848 | static inline void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1849 | { |
Richard Henderson | 8d625cf | 2010-03-19 13:02:02 -0700 | [diff] [blame] | 1850 | #ifdef TCG_TARGET_HAS_eqv_i64 |
| 1851 | tcg_gen_op3_i64(INDEX_op_eqv_i64, ret, arg1, arg2); |
| 1852 | #elif defined(TCG_TARGET_HAS_eqv_i32) && TCG_TARGET_REG_BITS == 32 |
| 1853 | tcg_gen_eqv_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 1854 | tcg_gen_eqv_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
| 1855 | #else |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1856 | tcg_gen_xor_i64(ret, arg1, arg2); |
| 1857 | tcg_gen_not_i64(ret, ret); |
Richard Henderson | 8d625cf | 2010-03-19 13:02:02 -0700 | [diff] [blame] | 1858 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1859 | } |
| 1860 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1861 | static inline void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1862 | { |
Richard Henderson | 9940a96 | 2010-03-19 13:03:58 -0700 | [diff] [blame] | 1863 | #ifdef TCG_TARGET_HAS_nand_i32 |
| 1864 | tcg_gen_op3_i32(INDEX_op_nand_i32, ret, arg1, arg2); |
| 1865 | #else |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1866 | tcg_gen_and_i32(ret, arg1, arg2); |
| 1867 | tcg_gen_not_i32(ret, ret); |
Richard Henderson | 9940a96 | 2010-03-19 13:03:58 -0700 | [diff] [blame] | 1868 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1869 | } |
| 1870 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1871 | static inline void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1872 | { |
Richard Henderson | 9940a96 | 2010-03-19 13:03:58 -0700 | [diff] [blame] | 1873 | #ifdef TCG_TARGET_HAS_nand_i64 |
| 1874 | tcg_gen_op3_i64(INDEX_op_nand_i64, ret, arg1, arg2); |
| 1875 | #elif defined(TCG_TARGET_HAS_nand_i32) && TCG_TARGET_REG_BITS == 32 |
| 1876 | tcg_gen_nand_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 1877 | tcg_gen_nand_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
| 1878 | #else |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1879 | tcg_gen_and_i64(ret, arg1, arg2); |
| 1880 | tcg_gen_not_i64(ret, ret); |
Richard Henderson | 9940a96 | 2010-03-19 13:03:58 -0700 | [diff] [blame] | 1881 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1882 | } |
| 1883 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1884 | static inline void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1885 | { |
Richard Henderson | 32d98fb | 2010-03-19 13:08:56 -0700 | [diff] [blame] | 1886 | #ifdef TCG_TARGET_HAS_nor_i32 |
| 1887 | tcg_gen_op3_i32(INDEX_op_nor_i32, ret, arg1, arg2); |
| 1888 | #else |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1889 | tcg_gen_or_i32(ret, arg1, arg2); |
| 1890 | tcg_gen_not_i32(ret, ret); |
Richard Henderson | 32d98fb | 2010-03-19 13:08:56 -0700 | [diff] [blame] | 1891 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1892 | } |
| 1893 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1894 | static inline void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1895 | { |
Richard Henderson | 32d98fb | 2010-03-19 13:08:56 -0700 | [diff] [blame] | 1896 | #ifdef TCG_TARGET_HAS_nor_i64 |
| 1897 | tcg_gen_op3_i64(INDEX_op_nor_i64, ret, arg1, arg2); |
| 1898 | #elif defined(TCG_TARGET_HAS_nor_i32) && TCG_TARGET_REG_BITS == 32 |
| 1899 | tcg_gen_nor_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 1900 | tcg_gen_nor_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
| 1901 | #else |
aurel32 | 7fc8105 | 2009-03-10 19:37:39 +0000 | [diff] [blame] | 1902 | tcg_gen_or_i64(ret, arg1, arg2); |
| 1903 | tcg_gen_not_i64(ret, ret); |
Richard Henderson | 32d98fb | 2010-03-19 13:08:56 -0700 | [diff] [blame] | 1904 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1905 | } |
| 1906 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1907 | static inline void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1908 | { |
Richard Henderson | 791d126 | 2010-02-16 14:15:28 -0800 | [diff] [blame] | 1909 | #ifdef TCG_TARGET_HAS_orc_i32 |
| 1910 | tcg_gen_op3_i32(INDEX_op_orc_i32, ret, arg1, arg2); |
| 1911 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1912 | TCGv_i32 t0; |
| 1913 | t0 = tcg_temp_new_i32(); |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1914 | tcg_gen_not_i32(t0, arg2); |
| 1915 | tcg_gen_or_i32(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1916 | tcg_temp_free_i32(t0); |
Richard Henderson | 791d126 | 2010-02-16 14:15:28 -0800 | [diff] [blame] | 1917 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1918 | } |
| 1919 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1920 | static inline void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1921 | { |
Richard Henderson | 791d126 | 2010-02-16 14:15:28 -0800 | [diff] [blame] | 1922 | #ifdef TCG_TARGET_HAS_orc_i64 |
| 1923 | tcg_gen_op3_i64(INDEX_op_orc_i64, ret, arg1, arg2); |
| 1924 | #elif defined(TCG_TARGET_HAS_orc_i32) && TCG_TARGET_REG_BITS == 32 |
| 1925 | tcg_gen_orc_i32(TCGV_LOW(ret), TCGV_LOW(arg1), TCGV_LOW(arg2)); |
| 1926 | tcg_gen_orc_i32(TCGV_HIGH(ret), TCGV_HIGH(arg1), TCGV_HIGH(arg2)); |
| 1927 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1928 | TCGv_i64 t0; |
| 1929 | t0 = tcg_temp_new_i64(); |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1930 | tcg_gen_not_i64(t0, arg2); |
| 1931 | tcg_gen_or_i64(ret, arg1, t0); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1932 | tcg_temp_free_i64(t0); |
Richard Henderson | 791d126 | 2010-02-16 14:15:28 -0800 | [diff] [blame] | 1933 | #endif |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 1934 | } |
| 1935 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1936 | static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1937 | { |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 1938 | #ifdef TCG_TARGET_HAS_rot_i32 |
| 1939 | tcg_gen_op3_i32(INDEX_op_rotl_i32, ret, arg1, arg2); |
| 1940 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1941 | TCGv_i32 t0, t1; |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1942 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1943 | t0 = tcg_temp_new_i32(); |
| 1944 | t1 = tcg_temp_new_i32(); |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1945 | tcg_gen_shl_i32(t0, arg1, arg2); |
| 1946 | tcg_gen_subfi_i32(t1, 32, arg2); |
| 1947 | tcg_gen_shr_i32(t1, arg1, t1); |
| 1948 | tcg_gen_or_i32(ret, t0, t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1949 | tcg_temp_free_i32(t0); |
| 1950 | tcg_temp_free_i32(t1); |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 1951 | #endif |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1952 | } |
| 1953 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1954 | static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1955 | { |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 1956 | #ifdef TCG_TARGET_HAS_rot_i64 |
| 1957 | tcg_gen_op3_i64(INDEX_op_rotl_i64, ret, arg1, arg2); |
| 1958 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1959 | TCGv_i64 t0, t1; |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1960 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1961 | t0 = tcg_temp_new_i64(); |
| 1962 | t1 = tcg_temp_new_i64(); |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1963 | tcg_gen_shl_i64(t0, arg1, arg2); |
| 1964 | tcg_gen_subfi_i64(t1, 64, arg2); |
| 1965 | tcg_gen_shr_i64(t1, arg1, t1); |
| 1966 | tcg_gen_or_i64(ret, t0, t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1967 | tcg_temp_free_i64(t0); |
| 1968 | tcg_temp_free_i64(t1); |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 1969 | #endif |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1970 | } |
| 1971 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1972 | static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1973 | { |
| 1974 | /* some cases can be optimized here */ |
| 1975 | if (arg2 == 0) { |
| 1976 | tcg_gen_mov_i32(ret, arg1); |
| 1977 | } else { |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 1978 | #ifdef TCG_TARGET_HAS_rot_i32 |
| 1979 | TCGv_i32 t0 = tcg_const_i32(arg2); |
| 1980 | tcg_gen_rotl_i32(ret, arg1, t0); |
| 1981 | tcg_temp_free_i32(t0); |
| 1982 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1983 | TCGv_i32 t0, t1; |
| 1984 | t0 = tcg_temp_new_i32(); |
| 1985 | t1 = tcg_temp_new_i32(); |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1986 | tcg_gen_shli_i32(t0, arg1, arg2); |
| 1987 | tcg_gen_shri_i32(t1, arg1, 32 - arg2); |
| 1988 | tcg_gen_or_i32(ret, t0, t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1989 | tcg_temp_free_i32(t0); |
| 1990 | tcg_temp_free_i32(t1); |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 1991 | #endif |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1992 | } |
| 1993 | } |
| 1994 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 1995 | static inline void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 1996 | { |
| 1997 | /* some cases can be optimized here */ |
| 1998 | if (arg2 == 0) { |
| 1999 | tcg_gen_mov_i64(ret, arg1); |
| 2000 | } else { |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 2001 | #ifdef TCG_TARGET_HAS_rot_i64 |
| 2002 | TCGv_i64 t0 = tcg_const_i64(arg2); |
| 2003 | tcg_gen_rotl_i64(ret, arg1, t0); |
| 2004 | tcg_temp_free_i64(t0); |
| 2005 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2006 | TCGv_i64 t0, t1; |
| 2007 | t0 = tcg_temp_new_i64(); |
| 2008 | t1 = tcg_temp_new_i64(); |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2009 | tcg_gen_shli_i64(t0, arg1, arg2); |
| 2010 | tcg_gen_shri_i64(t1, arg1, 64 - arg2); |
| 2011 | tcg_gen_or_i64(ret, t0, t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2012 | tcg_temp_free_i64(t0); |
| 2013 | tcg_temp_free_i64(t1); |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 2014 | #endif |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2015 | } |
| 2016 | } |
| 2017 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2018 | static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2019 | { |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 2020 | #ifdef TCG_TARGET_HAS_rot_i32 |
| 2021 | tcg_gen_op3_i32(INDEX_op_rotr_i32, ret, arg1, arg2); |
| 2022 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2023 | TCGv_i32 t0, t1; |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2024 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2025 | t0 = tcg_temp_new_i32(); |
| 2026 | t1 = tcg_temp_new_i32(); |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2027 | tcg_gen_shr_i32(t0, arg1, arg2); |
| 2028 | tcg_gen_subfi_i32(t1, 32, arg2); |
| 2029 | tcg_gen_shl_i32(t1, arg1, t1); |
| 2030 | tcg_gen_or_i32(ret, t0, t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2031 | tcg_temp_free_i32(t0); |
| 2032 | tcg_temp_free_i32(t1); |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 2033 | #endif |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2034 | } |
| 2035 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2036 | static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2037 | { |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 2038 | #ifdef TCG_TARGET_HAS_rot_i64 |
| 2039 | tcg_gen_op3_i64(INDEX_op_rotr_i64, ret, arg1, arg2); |
| 2040 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2041 | TCGv_i64 t0, t1; |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2042 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2043 | t0 = tcg_temp_new_i64(); |
| 2044 | t1 = tcg_temp_new_i64(); |
Aurelien Jarno | d9885a0 | 2009-07-18 11:15:40 +0200 | [diff] [blame] | 2045 | tcg_gen_shr_i64(t0, arg1, arg2); |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2046 | tcg_gen_subfi_i64(t1, 64, arg2); |
| 2047 | tcg_gen_shl_i64(t1, arg1, t1); |
| 2048 | tcg_gen_or_i64(ret, t0, t1); |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2049 | tcg_temp_free_i64(t0); |
| 2050 | tcg_temp_free_i64(t1); |
aurel32 | d42f183 | 2009-03-09 18:50:53 +0000 | [diff] [blame] | 2051 | #endif |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2052 | } |
| 2053 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2054 | static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2055 | { |
| 2056 | /* some cases can be optimized here */ |
| 2057 | if (arg2 == 0) { |
| 2058 | tcg_gen_mov_i32(ret, arg1); |
| 2059 | } else { |
| 2060 | tcg_gen_rotli_i32(ret, arg1, 32 - arg2); |
| 2061 | } |
| 2062 | } |
| 2063 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2064 | static inline void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2) |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2065 | { |
| 2066 | /* some cases can be optimized here */ |
| 2067 | if (arg2 == 0) { |
pbrook | de3526b | 2008-11-03 13:30:50 +0000 | [diff] [blame] | 2068 | tcg_gen_mov_i64(ret, arg1); |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2069 | } else { |
| 2070 | tcg_gen_rotli_i64(ret, arg1, 64 - arg2); |
| 2071 | } |
| 2072 | } |
| 2073 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2074 | /***************************************/ |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2075 | /* QEMU specific operations. Their type depend on the QEMU CPU |
| 2076 | type. */ |
| 2077 | #ifndef TARGET_LONG_BITS |
| 2078 | #error must include QEMU headers |
| 2079 | #endif |
| 2080 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2081 | #if TARGET_LONG_BITS == 32 |
| 2082 | #define TCGv TCGv_i32 |
| 2083 | #define tcg_temp_new() tcg_temp_new_i32() |
| 2084 | #define tcg_global_reg_new tcg_global_reg_new_i32 |
| 2085 | #define tcg_global_mem_new tcg_global_mem_new_i32 |
aurel32 | df9247b | 2009-01-01 14:09:05 +0000 | [diff] [blame] | 2086 | #define tcg_temp_local_new() tcg_temp_local_new_i32() |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2087 | #define tcg_temp_free tcg_temp_free_i32 |
| 2088 | #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i32 |
| 2089 | #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i32 |
| 2090 | #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x) |
aurel32 | fe75bcf | 2009-03-10 08:57:16 +0000 | [diff] [blame] | 2091 | #define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2092 | #else |
| 2093 | #define TCGv TCGv_i64 |
| 2094 | #define tcg_temp_new() tcg_temp_new_i64() |
| 2095 | #define tcg_global_reg_new tcg_global_reg_new_i64 |
| 2096 | #define tcg_global_mem_new tcg_global_mem_new_i64 |
aurel32 | df9247b | 2009-01-01 14:09:05 +0000 | [diff] [blame] | 2097 | #define tcg_temp_local_new() tcg_temp_local_new_i64() |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2098 | #define tcg_temp_free tcg_temp_free_i64 |
| 2099 | #define tcg_gen_qemu_ldst_op tcg_gen_op3i_i64 |
| 2100 | #define tcg_gen_qemu_ldst_op_i64 tcg_gen_qemu_ldst_op_i64_i64 |
| 2101 | #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x) |
aurel32 | fe75bcf | 2009-03-10 08:57:16 +0000 | [diff] [blame] | 2102 | #define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b) |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2103 | #endif |
| 2104 | |
bellard | 7e4597d | 2008-05-22 16:56:05 +0000 | [diff] [blame] | 2105 | /* debug info: write the PC of the corresponding QEMU CPU instruction */ |
| 2106 | static inline void tcg_gen_debug_insn_start(uint64_t pc) |
| 2107 | { |
| 2108 | /* XXX: must really use a 32 bit size for TCGArg in all cases */ |
| 2109 | #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS |
pbrook | bcb0126 | 2008-05-24 02:24:25 +0000 | [diff] [blame] | 2110 | tcg_gen_op2ii(INDEX_op_debug_insn_start, |
| 2111 | (uint32_t)(pc), (uint32_t)(pc >> 32)); |
bellard | 7e4597d | 2008-05-22 16:56:05 +0000 | [diff] [blame] | 2112 | #else |
| 2113 | tcg_gen_op1i(INDEX_op_debug_insn_start, pc); |
| 2114 | #endif |
| 2115 | } |
| 2116 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2117 | static inline void tcg_gen_exit_tb(tcg_target_long val) |
| 2118 | { |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2119 | tcg_gen_op1i(INDEX_op_exit_tb, val); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2120 | } |
| 2121 | |
| 2122 | static inline void tcg_gen_goto_tb(int idx) |
| 2123 | { |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2124 | tcg_gen_op1i(INDEX_op_goto_tb, idx); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2125 | } |
| 2126 | |
| 2127 | #if TCG_TARGET_REG_BITS == 32 |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2128 | static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2129 | { |
| 2130 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2131 | tcg_gen_op3i_i32(INDEX_op_qemu_ld8u, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2132 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2133 | tcg_gen_op4i_i32(INDEX_op_qemu_ld8u, TCGV_LOW(ret), TCGV_LOW(addr), |
| 2134 | TCGV_HIGH(addr), mem_index); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2135 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2136 | #endif |
| 2137 | } |
| 2138 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2139 | static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2140 | { |
| 2141 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2142 | tcg_gen_op3i_i32(INDEX_op_qemu_ld8s, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2143 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2144 | tcg_gen_op4i_i32(INDEX_op_qemu_ld8s, TCGV_LOW(ret), TCGV_LOW(addr), |
| 2145 | TCGV_HIGH(addr), mem_index); |
| 2146 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2147 | #endif |
| 2148 | } |
| 2149 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2150 | static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2151 | { |
| 2152 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2153 | tcg_gen_op3i_i32(INDEX_op_qemu_ld16u, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2154 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2155 | tcg_gen_op4i_i32(INDEX_op_qemu_ld16u, TCGV_LOW(ret), TCGV_LOW(addr), |
| 2156 | TCGV_HIGH(addr), mem_index); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2157 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2158 | #endif |
| 2159 | } |
| 2160 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2161 | static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2162 | { |
| 2163 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2164 | tcg_gen_op3i_i32(INDEX_op_qemu_ld16s, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2165 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2166 | tcg_gen_op4i_i32(INDEX_op_qemu_ld16s, TCGV_LOW(ret), TCGV_LOW(addr), |
| 2167 | TCGV_HIGH(addr), mem_index); |
| 2168 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2169 | #endif |
| 2170 | } |
| 2171 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2172 | static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2173 | { |
| 2174 | #if TARGET_LONG_BITS == 32 |
Richard Henderson | 86feb1c | 2010-03-19 12:00:26 -0700 | [diff] [blame] | 2175 | tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2176 | #else |
Richard Henderson | 86feb1c | 2010-03-19 12:00:26 -0700 | [diff] [blame] | 2177 | tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr), |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2178 | TCGV_HIGH(addr), mem_index); |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2179 | tcg_gen_movi_i32(TCGV_HIGH(ret), 0); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2180 | #endif |
| 2181 | } |
| 2182 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2183 | static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2184 | { |
| 2185 | #if TARGET_LONG_BITS == 32 |
Richard Henderson | 86feb1c | 2010-03-19 12:00:26 -0700 | [diff] [blame] | 2186 | tcg_gen_op3i_i32(INDEX_op_qemu_ld32, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2187 | #else |
Richard Henderson | 86feb1c | 2010-03-19 12:00:26 -0700 | [diff] [blame] | 2188 | tcg_gen_op4i_i32(INDEX_op_qemu_ld32, TCGV_LOW(ret), TCGV_LOW(addr), |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2189 | TCGV_HIGH(addr), mem_index); |
| 2190 | tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2191 | #endif |
| 2192 | } |
| 2193 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2194 | static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2195 | { |
| 2196 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2197 | tcg_gen_op4i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2198 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2199 | tcg_gen_op5i_i32(INDEX_op_qemu_ld64, TCGV_LOW(ret), TCGV_HIGH(ret), |
| 2200 | TCGV_LOW(addr), TCGV_HIGH(addr), mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2201 | #endif |
| 2202 | } |
| 2203 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2204 | static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2205 | { |
| 2206 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2207 | tcg_gen_op3i_i32(INDEX_op_qemu_st8, arg, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2208 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2209 | tcg_gen_op4i_i32(INDEX_op_qemu_st8, TCGV_LOW(arg), TCGV_LOW(addr), |
| 2210 | TCGV_HIGH(addr), mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2211 | #endif |
| 2212 | } |
| 2213 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2214 | static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2215 | { |
| 2216 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2217 | tcg_gen_op3i_i32(INDEX_op_qemu_st16, arg, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2218 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2219 | tcg_gen_op4i_i32(INDEX_op_qemu_st16, TCGV_LOW(arg), TCGV_LOW(addr), |
| 2220 | TCGV_HIGH(addr), mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2221 | #endif |
| 2222 | } |
| 2223 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2224 | static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2225 | { |
| 2226 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2227 | tcg_gen_op3i_i32(INDEX_op_qemu_st32, arg, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2228 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2229 | tcg_gen_op4i_i32(INDEX_op_qemu_st32, TCGV_LOW(arg), TCGV_LOW(addr), |
| 2230 | TCGV_HIGH(addr), mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2231 | #endif |
| 2232 | } |
| 2233 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2234 | static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2235 | { |
| 2236 | #if TARGET_LONG_BITS == 32 |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2237 | tcg_gen_op4i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), addr, |
| 2238 | mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2239 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2240 | tcg_gen_op5i_i32(INDEX_op_qemu_st64, TCGV_LOW(arg), TCGV_HIGH(arg), |
| 2241 | TCGV_LOW(addr), TCGV_HIGH(addr), mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2242 | #endif |
| 2243 | } |
| 2244 | |
blueswir1 | 56b8f56 | 2008-02-25 18:29:19 +0000 | [diff] [blame] | 2245 | #define tcg_gen_ld_ptr tcg_gen_ld_i32 |
blueswir1 | a768e4b | 2008-03-16 19:16:37 +0000 | [diff] [blame] | 2246 | #define tcg_gen_discard_ptr tcg_gen_discard_i32 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2247 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2248 | #else /* TCG_TARGET_REG_BITS == 32 */ |
| 2249 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2250 | static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2251 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2252 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8u, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2253 | } |
| 2254 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2255 | static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2256 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2257 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld8s, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2258 | } |
| 2259 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2260 | static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2261 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2262 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16u, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2263 | } |
| 2264 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2265 | static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2266 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2267 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld16s, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2268 | } |
| 2269 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2270 | static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2271 | { |
Richard Henderson | 3e1dbad | 2010-05-03 16:30:48 -0700 | [diff] [blame] | 2272 | #if TARGET_LONG_BITS == 32 |
| 2273 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index); |
| 2274 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2275 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32u, ret, addr, mem_index); |
Richard Henderson | 3e1dbad | 2010-05-03 16:30:48 -0700 | [diff] [blame] | 2276 | #endif |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2277 | } |
| 2278 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2279 | static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2280 | { |
Richard Henderson | 3e1dbad | 2010-05-03 16:30:48 -0700 | [diff] [blame] | 2281 | #if TARGET_LONG_BITS == 32 |
| 2282 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32, ret, addr, mem_index); |
| 2283 | #else |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2284 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_ld32s, ret, addr, mem_index); |
Richard Henderson | 3e1dbad | 2010-05-03 16:30:48 -0700 | [diff] [blame] | 2285 | #endif |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2286 | } |
| 2287 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2288 | static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2289 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2290 | tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_ld64, ret, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2291 | } |
| 2292 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2293 | static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2294 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2295 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st8, arg, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2296 | } |
| 2297 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2298 | static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2299 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2300 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st16, arg, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2301 | } |
| 2302 | |
pbrook | ac56dd4 | 2008-02-03 19:56:33 +0000 | [diff] [blame] | 2303 | static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2304 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2305 | tcg_gen_qemu_ldst_op(INDEX_op_qemu_st32, arg, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2306 | } |
| 2307 | |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2308 | static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2309 | { |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 2310 | tcg_gen_qemu_ldst_op_i64(INDEX_op_qemu_st64, arg, addr, mem_index); |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
blueswir1 | 56b8f56 | 2008-02-25 18:29:19 +0000 | [diff] [blame] | 2313 | #define tcg_gen_ld_ptr tcg_gen_ld_i64 |
blueswir1 | a768e4b | 2008-03-16 19:16:37 +0000 | [diff] [blame] | 2314 | #define tcg_gen_discard_ptr tcg_gen_discard_i64 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2315 | |
bellard | c896fe2 | 2008-02-01 10:05:41 +0000 | [diff] [blame] | 2316 | #endif /* TCG_TARGET_REG_BITS != 32 */ |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2317 | |
| 2318 | #if TARGET_LONG_BITS == 64 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2319 | #define tcg_gen_movi_tl tcg_gen_movi_i64 |
| 2320 | #define tcg_gen_mov_tl tcg_gen_mov_i64 |
| 2321 | #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64 |
| 2322 | #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64 |
| 2323 | #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64 |
| 2324 | #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64 |
| 2325 | #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64 |
| 2326 | #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64 |
| 2327 | #define tcg_gen_ld_tl tcg_gen_ld_i64 |
| 2328 | #define tcg_gen_st8_tl tcg_gen_st8_i64 |
| 2329 | #define tcg_gen_st16_tl tcg_gen_st16_i64 |
| 2330 | #define tcg_gen_st32_tl tcg_gen_st32_i64 |
| 2331 | #define tcg_gen_st_tl tcg_gen_st_i64 |
| 2332 | #define tcg_gen_add_tl tcg_gen_add_i64 |
| 2333 | #define tcg_gen_addi_tl tcg_gen_addi_i64 |
| 2334 | #define tcg_gen_sub_tl tcg_gen_sub_i64 |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 2335 | #define tcg_gen_neg_tl tcg_gen_neg_i64 |
pbrook | 10460c8 | 2008-11-02 13:26:16 +0000 | [diff] [blame] | 2336 | #define tcg_gen_subfi_tl tcg_gen_subfi_i64 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2337 | #define tcg_gen_subi_tl tcg_gen_subi_i64 |
| 2338 | #define tcg_gen_and_tl tcg_gen_and_i64 |
| 2339 | #define tcg_gen_andi_tl tcg_gen_andi_i64 |
| 2340 | #define tcg_gen_or_tl tcg_gen_or_i64 |
| 2341 | #define tcg_gen_ori_tl tcg_gen_ori_i64 |
| 2342 | #define tcg_gen_xor_tl tcg_gen_xor_i64 |
| 2343 | #define tcg_gen_xori_tl tcg_gen_xori_i64 |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 2344 | #define tcg_gen_not_tl tcg_gen_not_i64 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2345 | #define tcg_gen_shl_tl tcg_gen_shl_i64 |
| 2346 | #define tcg_gen_shli_tl tcg_gen_shli_i64 |
| 2347 | #define tcg_gen_shr_tl tcg_gen_shr_i64 |
| 2348 | #define tcg_gen_shri_tl tcg_gen_shri_i64 |
| 2349 | #define tcg_gen_sar_tl tcg_gen_sar_i64 |
| 2350 | #define tcg_gen_sari_tl tcg_gen_sari_i64 |
blueswir1 | 0cf767d | 2008-03-02 18:20:59 +0000 | [diff] [blame] | 2351 | #define tcg_gen_brcond_tl tcg_gen_brcond_i64 |
pbrook | cb63669 | 2008-05-24 02:22:00 +0000 | [diff] [blame] | 2352 | #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64 |
Richard Henderson | be210ac | 2010-01-07 10:13:31 -0800 | [diff] [blame] | 2353 | #define tcg_gen_setcond_tl tcg_gen_setcond_i64 |
Aurelien Jarno | add1e7e | 2010-02-08 12:06:05 +0100 | [diff] [blame] | 2354 | #define tcg_gen_setcondi_tl tcg_gen_setcondi_i64 |
ths | f730fd2 | 2008-05-04 08:14:08 +0000 | [diff] [blame] | 2355 | #define tcg_gen_mul_tl tcg_gen_mul_i64 |
| 2356 | #define tcg_gen_muli_tl tcg_gen_muli_i64 |
aurel32 | ab36421 | 2009-03-29 01:19:22 +0000 | [diff] [blame] | 2357 | #define tcg_gen_div_tl tcg_gen_div_i64 |
| 2358 | #define tcg_gen_rem_tl tcg_gen_rem_i64 |
aurel32 | 864951a | 2009-03-29 14:08:54 +0000 | [diff] [blame] | 2359 | #define tcg_gen_divu_tl tcg_gen_divu_i64 |
| 2360 | #define tcg_gen_remu_tl tcg_gen_remu_i64 |
blueswir1 | a768e4b | 2008-03-16 19:16:37 +0000 | [diff] [blame] | 2361 | #define tcg_gen_discard_tl tcg_gen_discard_i64 |
blueswir1 | e429073 | 2008-03-22 08:39:04 +0000 | [diff] [blame] | 2362 | #define tcg_gen_trunc_tl_i32 tcg_gen_trunc_i64_i32 |
| 2363 | #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64 |
| 2364 | #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64 |
| 2365 | #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64 |
| 2366 | #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64 |
| 2367 | #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64 |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 2368 | #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64 |
| 2369 | #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64 |
| 2370 | #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64 |
| 2371 | #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64 |
| 2372 | #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64 |
| 2373 | #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64 |
aurel32 | 911d79b | 2009-03-13 09:35:19 +0000 | [diff] [blame] | 2374 | #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64 |
| 2375 | #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64 |
| 2376 | #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64 |
blueswir1 | 945ca82 | 2008-09-21 18:32:28 +0000 | [diff] [blame] | 2377 | #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64 |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 2378 | #define tcg_gen_andc_tl tcg_gen_andc_i64 |
| 2379 | #define tcg_gen_eqv_tl tcg_gen_eqv_i64 |
| 2380 | #define tcg_gen_nand_tl tcg_gen_nand_i64 |
| 2381 | #define tcg_gen_nor_tl tcg_gen_nor_i64 |
| 2382 | #define tcg_gen_orc_tl tcg_gen_orc_i64 |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2383 | #define tcg_gen_rotl_tl tcg_gen_rotl_i64 |
| 2384 | #define tcg_gen_rotli_tl tcg_gen_rotli_i64 |
| 2385 | #define tcg_gen_rotr_tl tcg_gen_rotr_i64 |
| 2386 | #define tcg_gen_rotri_tl tcg_gen_rotri_i64 |
blueswir1 | a98824a | 2008-03-13 20:46:42 +0000 | [diff] [blame] | 2387 | #define tcg_const_tl tcg_const_i64 |
aurel32 | bdffd4a | 2008-10-21 11:30:45 +0000 | [diff] [blame] | 2388 | #define tcg_const_local_tl tcg_const_local_i64 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2389 | #else |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2390 | #define tcg_gen_movi_tl tcg_gen_movi_i32 |
| 2391 | #define tcg_gen_mov_tl tcg_gen_mov_i32 |
| 2392 | #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32 |
| 2393 | #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32 |
| 2394 | #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32 |
| 2395 | #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32 |
| 2396 | #define tcg_gen_ld32u_tl tcg_gen_ld_i32 |
| 2397 | #define tcg_gen_ld32s_tl tcg_gen_ld_i32 |
| 2398 | #define tcg_gen_ld_tl tcg_gen_ld_i32 |
| 2399 | #define tcg_gen_st8_tl tcg_gen_st8_i32 |
| 2400 | #define tcg_gen_st16_tl tcg_gen_st16_i32 |
| 2401 | #define tcg_gen_st32_tl tcg_gen_st_i32 |
| 2402 | #define tcg_gen_st_tl tcg_gen_st_i32 |
| 2403 | #define tcg_gen_add_tl tcg_gen_add_i32 |
| 2404 | #define tcg_gen_addi_tl tcg_gen_addi_i32 |
| 2405 | #define tcg_gen_sub_tl tcg_gen_sub_i32 |
pbrook | 390efc5 | 2008-05-11 14:35:37 +0000 | [diff] [blame] | 2406 | #define tcg_gen_neg_tl tcg_gen_neg_i32 |
aurel32 | 0045734 | 2008-11-02 08:23:04 +0000 | [diff] [blame] | 2407 | #define tcg_gen_subfi_tl tcg_gen_subfi_i32 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2408 | #define tcg_gen_subi_tl tcg_gen_subi_i32 |
| 2409 | #define tcg_gen_and_tl tcg_gen_and_i32 |
| 2410 | #define tcg_gen_andi_tl tcg_gen_andi_i32 |
| 2411 | #define tcg_gen_or_tl tcg_gen_or_i32 |
| 2412 | #define tcg_gen_ori_tl tcg_gen_ori_i32 |
| 2413 | #define tcg_gen_xor_tl tcg_gen_xor_i32 |
| 2414 | #define tcg_gen_xori_tl tcg_gen_xori_i32 |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 2415 | #define tcg_gen_not_tl tcg_gen_not_i32 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2416 | #define tcg_gen_shl_tl tcg_gen_shl_i32 |
| 2417 | #define tcg_gen_shli_tl tcg_gen_shli_i32 |
| 2418 | #define tcg_gen_shr_tl tcg_gen_shr_i32 |
| 2419 | #define tcg_gen_shri_tl tcg_gen_shri_i32 |
| 2420 | #define tcg_gen_sar_tl tcg_gen_sar_i32 |
| 2421 | #define tcg_gen_sari_tl tcg_gen_sari_i32 |
blueswir1 | 0cf767d | 2008-03-02 18:20:59 +0000 | [diff] [blame] | 2422 | #define tcg_gen_brcond_tl tcg_gen_brcond_i32 |
pbrook | cb63669 | 2008-05-24 02:22:00 +0000 | [diff] [blame] | 2423 | #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32 |
Richard Henderson | be210ac | 2010-01-07 10:13:31 -0800 | [diff] [blame] | 2424 | #define tcg_gen_setcond_tl tcg_gen_setcond_i32 |
Aurelien Jarno | add1e7e | 2010-02-08 12:06:05 +0100 | [diff] [blame] | 2425 | #define tcg_gen_setcondi_tl tcg_gen_setcondi_i32 |
ths | f730fd2 | 2008-05-04 08:14:08 +0000 | [diff] [blame] | 2426 | #define tcg_gen_mul_tl tcg_gen_mul_i32 |
| 2427 | #define tcg_gen_muli_tl tcg_gen_muli_i32 |
aurel32 | ab36421 | 2009-03-29 01:19:22 +0000 | [diff] [blame] | 2428 | #define tcg_gen_div_tl tcg_gen_div_i32 |
| 2429 | #define tcg_gen_rem_tl tcg_gen_rem_i32 |
aurel32 | 864951a | 2009-03-29 14:08:54 +0000 | [diff] [blame] | 2430 | #define tcg_gen_divu_tl tcg_gen_divu_i32 |
| 2431 | #define tcg_gen_remu_tl tcg_gen_remu_i32 |
blueswir1 | a768e4b | 2008-03-16 19:16:37 +0000 | [diff] [blame] | 2432 | #define tcg_gen_discard_tl tcg_gen_discard_i32 |
blueswir1 | e429073 | 2008-03-22 08:39:04 +0000 | [diff] [blame] | 2433 | #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32 |
| 2434 | #define tcg_gen_trunc_i64_tl tcg_gen_trunc_i64_i32 |
| 2435 | #define tcg_gen_extu_i32_tl tcg_gen_mov_i32 |
| 2436 | #define tcg_gen_ext_i32_tl tcg_gen_mov_i32 |
| 2437 | #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64 |
| 2438 | #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64 |
bellard | 0b6ce4c | 2008-05-17 12:40:44 +0000 | [diff] [blame] | 2439 | #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32 |
| 2440 | #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32 |
| 2441 | #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32 |
| 2442 | #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32 |
| 2443 | #define tcg_gen_ext32u_tl tcg_gen_mov_i32 |
| 2444 | #define tcg_gen_ext32s_tl tcg_gen_mov_i32 |
aurel32 | 911d79b | 2009-03-13 09:35:19 +0000 | [diff] [blame] | 2445 | #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32 |
| 2446 | #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32 |
blueswir1 | 945ca82 | 2008-09-21 18:32:28 +0000 | [diff] [blame] | 2447 | #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64 |
aurel32 | f24cb33 | 2008-10-21 11:28:59 +0000 | [diff] [blame] | 2448 | #define tcg_gen_andc_tl tcg_gen_andc_i32 |
| 2449 | #define tcg_gen_eqv_tl tcg_gen_eqv_i32 |
| 2450 | #define tcg_gen_nand_tl tcg_gen_nand_i32 |
| 2451 | #define tcg_gen_nor_tl tcg_gen_nor_i32 |
| 2452 | #define tcg_gen_orc_tl tcg_gen_orc_i32 |
aurel32 | 1582457 | 2008-11-03 07:08:36 +0000 | [diff] [blame] | 2453 | #define tcg_gen_rotl_tl tcg_gen_rotl_i32 |
| 2454 | #define tcg_gen_rotli_tl tcg_gen_rotli_i32 |
| 2455 | #define tcg_gen_rotr_tl tcg_gen_rotr_i32 |
| 2456 | #define tcg_gen_rotri_tl tcg_gen_rotri_i32 |
blueswir1 | a98824a | 2008-03-13 20:46:42 +0000 | [diff] [blame] | 2457 | #define tcg_const_tl tcg_const_i32 |
aurel32 | bdffd4a | 2008-10-21 11:30:45 +0000 | [diff] [blame] | 2458 | #define tcg_const_local_tl tcg_const_local_i32 |
blueswir1 | f8422f5 | 2008-02-24 07:45:43 +0000 | [diff] [blame] | 2459 | #endif |
pbrook | 6ddbc6e | 2008-03-31 03:46:33 +0000 | [diff] [blame] | 2460 | |
| 2461 | #if TCG_TARGET_REG_BITS == 32 |
ths | 48d38ca | 2008-05-18 22:50:49 +0000 | [diff] [blame] | 2462 | #define tcg_gen_add_ptr tcg_gen_add_i32 |
pbrook | 6ddbc6e | 2008-03-31 03:46:33 +0000 | [diff] [blame] | 2463 | #define tcg_gen_addi_ptr tcg_gen_addi_i32 |
ths | 48d38ca | 2008-05-18 22:50:49 +0000 | [diff] [blame] | 2464 | #define tcg_gen_ext_i32_ptr tcg_gen_mov_i32 |
pbrook | 6ddbc6e | 2008-03-31 03:46:33 +0000 | [diff] [blame] | 2465 | #else /* TCG_TARGET_REG_BITS == 32 */ |
ths | 48d38ca | 2008-05-18 22:50:49 +0000 | [diff] [blame] | 2466 | #define tcg_gen_add_ptr tcg_gen_add_i64 |
pbrook | 6ddbc6e | 2008-03-31 03:46:33 +0000 | [diff] [blame] | 2467 | #define tcg_gen_addi_ptr tcg_gen_addi_i64 |
ths | 48d38ca | 2008-05-18 22:50:49 +0000 | [diff] [blame] | 2468 | #define tcg_gen_ext_i32_ptr tcg_gen_ext_i32_i64 |
pbrook | 6ddbc6e | 2008-03-31 03:46:33 +0000 | [diff] [blame] | 2469 | #endif /* TCG_TARGET_REG_BITS != 32 */ |