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