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