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