Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 1 | /* |
| 2 | * Optimizations for Tiny Code Generator for QEMU |
| 3 | * |
| 4 | * Copyright (c) 2010 Samsung Electronics. |
| 5 | * Contributed by Kirill Batuzov <batuzovk@ispras.ru> |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | * of this software and associated documentation files (the "Software"), to deal |
| 9 | * in the Software without restriction, including without limitation the rights |
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | * copies of the Software, and to permit persons to whom the Software is |
| 12 | * furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | * THE SOFTWARE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | |
| 28 | #include <stdlib.h> |
| 29 | #include <stdio.h> |
| 30 | |
| 31 | #include "qemu-common.h" |
| 32 | #include "tcg-op.h" |
| 33 | |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 34 | #define CASE_OP_32_64(x) \ |
| 35 | glue(glue(case INDEX_op_, x), _i32): \ |
| 36 | glue(glue(case INDEX_op_, x), _i64) |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 37 | |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 38 | typedef enum { |
| 39 | TCG_TEMP_UNDEF = 0, |
| 40 | TCG_TEMP_CONST, |
| 41 | TCG_TEMP_COPY, |
| 42 | TCG_TEMP_HAS_COPY, |
| 43 | TCG_TEMP_ANY |
| 44 | } tcg_temp_state; |
| 45 | |
| 46 | struct tcg_temp_info { |
| 47 | tcg_temp_state state; |
| 48 | uint16_t prev_copy; |
| 49 | uint16_t next_copy; |
| 50 | tcg_target_ulong val; |
| 51 | }; |
| 52 | |
| 53 | static struct tcg_temp_info temps[TCG_MAX_TEMPS]; |
| 54 | |
| 55 | /* Reset TEMP's state to TCG_TEMP_ANY. If TEMP was a representative of some |
| 56 | class of equivalent temp's, a new representative should be chosen in this |
| 57 | class. */ |
| 58 | static void reset_temp(TCGArg temp, int nb_temps, int nb_globals) |
| 59 | { |
| 60 | int i; |
| 61 | TCGArg new_base = (TCGArg)-1; |
| 62 | if (temps[temp].state == TCG_TEMP_HAS_COPY) { |
| 63 | for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) { |
| 64 | if (i >= nb_globals) { |
| 65 | temps[i].state = TCG_TEMP_HAS_COPY; |
| 66 | new_base = i; |
| 67 | break; |
| 68 | } |
| 69 | } |
| 70 | for (i = temps[temp].next_copy; i != temp; i = temps[i].next_copy) { |
| 71 | if (new_base == (TCGArg)-1) { |
| 72 | temps[i].state = TCG_TEMP_ANY; |
| 73 | } else { |
| 74 | temps[i].val = new_base; |
| 75 | } |
| 76 | } |
| 77 | temps[temps[temp].next_copy].prev_copy = temps[temp].prev_copy; |
| 78 | temps[temps[temp].prev_copy].next_copy = temps[temp].next_copy; |
| 79 | } else if (temps[temp].state == TCG_TEMP_COPY) { |
| 80 | temps[temps[temp].next_copy].prev_copy = temps[temp].prev_copy; |
| 81 | temps[temps[temp].prev_copy].next_copy = temps[temp].next_copy; |
| 82 | new_base = temps[temp].val; |
| 83 | } |
| 84 | temps[temp].state = TCG_TEMP_ANY; |
| 85 | if (new_base != (TCGArg)-1 && temps[new_base].next_copy == new_base) { |
| 86 | temps[new_base].state = TCG_TEMP_ANY; |
| 87 | } |
| 88 | } |
| 89 | |
Blue Swirl | fe0de7a | 2011-07-30 19:18:32 +0000 | [diff] [blame] | 90 | static int op_bits(TCGOpcode op) |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 91 | { |
Richard Henderson | 8399ad5 | 2011-08-17 14:11:45 -0700 | [diff] [blame] | 92 | const TCGOpDef *def = &tcg_op_defs[op]; |
| 93 | return def->flags & TCG_OPF_64BIT ? 64 : 32; |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 94 | } |
| 95 | |
Blue Swirl | fe0de7a | 2011-07-30 19:18:32 +0000 | [diff] [blame] | 96 | static TCGOpcode op_to_movi(TCGOpcode op) |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 97 | { |
| 98 | switch (op_bits(op)) { |
| 99 | case 32: |
| 100 | return INDEX_op_movi_i32; |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 101 | case 64: |
| 102 | return INDEX_op_movi_i64; |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 103 | default: |
| 104 | fprintf(stderr, "op_to_movi: unexpected return value of " |
| 105 | "function op_bits.\n"); |
| 106 | tcg_abort(); |
| 107 | } |
| 108 | } |
| 109 | |
Aurelien Jarno | d104beb | 2012-09-10 13:14:12 +0200 | [diff] [blame] | 110 | static void tcg_opt_gen_mov(TCGArg *gen_args, TCGArg dst, TCGArg src, |
| 111 | int nb_temps, int nb_globals) |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 112 | { |
| 113 | reset_temp(dst, nb_temps, nb_globals); |
| 114 | assert(temps[src].state != TCG_TEMP_COPY); |
Aurelien Jarno | d104beb | 2012-09-10 13:14:12 +0200 | [diff] [blame] | 115 | if (src >= nb_globals) { |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 116 | assert(temps[src].state != TCG_TEMP_CONST); |
| 117 | if (temps[src].state != TCG_TEMP_HAS_COPY) { |
| 118 | temps[src].state = TCG_TEMP_HAS_COPY; |
| 119 | temps[src].next_copy = src; |
| 120 | temps[src].prev_copy = src; |
| 121 | } |
| 122 | temps[dst].state = TCG_TEMP_COPY; |
| 123 | temps[dst].val = src; |
| 124 | temps[dst].next_copy = temps[src].next_copy; |
| 125 | temps[dst].prev_copy = src; |
| 126 | temps[temps[dst].next_copy].prev_copy = dst; |
| 127 | temps[src].next_copy = dst; |
| 128 | } |
| 129 | gen_args[0] = dst; |
| 130 | gen_args[1] = src; |
| 131 | } |
| 132 | |
| 133 | static void tcg_opt_gen_movi(TCGArg *gen_args, TCGArg dst, TCGArg val, |
| 134 | int nb_temps, int nb_globals) |
| 135 | { |
| 136 | reset_temp(dst, nb_temps, nb_globals); |
| 137 | temps[dst].state = TCG_TEMP_CONST; |
| 138 | temps[dst].val = val; |
| 139 | gen_args[0] = dst; |
| 140 | gen_args[1] = val; |
| 141 | } |
| 142 | |
Blue Swirl | fe0de7a | 2011-07-30 19:18:32 +0000 | [diff] [blame] | 143 | static TCGOpcode op_to_mov(TCGOpcode op) |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 144 | { |
| 145 | switch (op_bits(op)) { |
| 146 | case 32: |
| 147 | return INDEX_op_mov_i32; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 148 | case 64: |
| 149 | return INDEX_op_mov_i64; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 150 | default: |
| 151 | fprintf(stderr, "op_to_mov: unexpected return value of " |
| 152 | "function op_bits.\n"); |
| 153 | tcg_abort(); |
| 154 | } |
| 155 | } |
| 156 | |
Blue Swirl | fe0de7a | 2011-07-30 19:18:32 +0000 | [diff] [blame] | 157 | static TCGArg do_constant_folding_2(TCGOpcode op, TCGArg x, TCGArg y) |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 158 | { |
| 159 | switch (op) { |
| 160 | CASE_OP_32_64(add): |
| 161 | return x + y; |
| 162 | |
| 163 | CASE_OP_32_64(sub): |
| 164 | return x - y; |
| 165 | |
| 166 | CASE_OP_32_64(mul): |
| 167 | return x * y; |
| 168 | |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 169 | CASE_OP_32_64(and): |
| 170 | return x & y; |
| 171 | |
| 172 | CASE_OP_32_64(or): |
| 173 | return x | y; |
| 174 | |
| 175 | CASE_OP_32_64(xor): |
| 176 | return x ^ y; |
| 177 | |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 178 | case INDEX_op_shl_i32: |
| 179 | return (uint32_t)x << (uint32_t)y; |
| 180 | |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 181 | case INDEX_op_shl_i64: |
| 182 | return (uint64_t)x << (uint64_t)y; |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 183 | |
| 184 | case INDEX_op_shr_i32: |
| 185 | return (uint32_t)x >> (uint32_t)y; |
| 186 | |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 187 | case INDEX_op_shr_i64: |
| 188 | return (uint64_t)x >> (uint64_t)y; |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 189 | |
| 190 | case INDEX_op_sar_i32: |
| 191 | return (int32_t)x >> (int32_t)y; |
| 192 | |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 193 | case INDEX_op_sar_i64: |
| 194 | return (int64_t)x >> (int64_t)y; |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 195 | |
| 196 | case INDEX_op_rotr_i32: |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 197 | x = ((uint32_t)x << (32 - y)) | ((uint32_t)x >> y); |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 198 | return x; |
| 199 | |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 200 | case INDEX_op_rotr_i64: |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 201 | x = ((uint64_t)x << (64 - y)) | ((uint64_t)x >> y); |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 202 | return x; |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 203 | |
| 204 | case INDEX_op_rotl_i32: |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 205 | x = ((uint32_t)x << y) | ((uint32_t)x >> (32 - y)); |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 206 | return x; |
| 207 | |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 208 | case INDEX_op_rotl_i64: |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 209 | x = ((uint64_t)x << y) | ((uint64_t)x >> (64 - y)); |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 210 | return x; |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 211 | |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 212 | CASE_OP_32_64(not): |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 213 | return ~x; |
| 214 | |
Richard Henderson | cb25c80 | 2011-08-17 14:11:47 -0700 | [diff] [blame] | 215 | CASE_OP_32_64(neg): |
| 216 | return -x; |
| 217 | |
| 218 | CASE_OP_32_64(andc): |
| 219 | return x & ~y; |
| 220 | |
| 221 | CASE_OP_32_64(orc): |
| 222 | return x | ~y; |
| 223 | |
| 224 | CASE_OP_32_64(eqv): |
| 225 | return ~(x ^ y); |
| 226 | |
| 227 | CASE_OP_32_64(nand): |
| 228 | return ~(x & y); |
| 229 | |
| 230 | CASE_OP_32_64(nor): |
| 231 | return ~(x | y); |
| 232 | |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 233 | CASE_OP_32_64(ext8s): |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 234 | return (int8_t)x; |
| 235 | |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 236 | CASE_OP_32_64(ext16s): |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 237 | return (int16_t)x; |
| 238 | |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 239 | CASE_OP_32_64(ext8u): |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 240 | return (uint8_t)x; |
| 241 | |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 242 | CASE_OP_32_64(ext16u): |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 243 | return (uint16_t)x; |
| 244 | |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 245 | case INDEX_op_ext32s_i64: |
| 246 | return (int32_t)x; |
| 247 | |
| 248 | case INDEX_op_ext32u_i64: |
| 249 | return (uint32_t)x; |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 250 | |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 251 | default: |
| 252 | fprintf(stderr, |
| 253 | "Unrecognized operation %d in do_constant_folding.\n", op); |
| 254 | tcg_abort(); |
| 255 | } |
| 256 | } |
| 257 | |
Blue Swirl | fe0de7a | 2011-07-30 19:18:32 +0000 | [diff] [blame] | 258 | static TCGArg do_constant_folding(TCGOpcode op, TCGArg x, TCGArg y) |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 259 | { |
| 260 | TCGArg res = do_constant_folding_2(op, x, y); |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 261 | if (op_bits(op) == 32) { |
| 262 | res &= 0xffffffff; |
| 263 | } |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 264 | return res; |
| 265 | } |
| 266 | |
Aurelien Jarno | f8dd19e | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 267 | static TCGArg do_constant_folding_cond(TCGOpcode op, TCGArg x, |
| 268 | TCGArg y, TCGCond c) |
| 269 | { |
| 270 | switch (op_bits(op)) { |
| 271 | case 32: |
| 272 | switch (c) { |
| 273 | case TCG_COND_EQ: |
| 274 | return (uint32_t)x == (uint32_t)y; |
| 275 | case TCG_COND_NE: |
| 276 | return (uint32_t)x != (uint32_t)y; |
| 277 | case TCG_COND_LT: |
| 278 | return (int32_t)x < (int32_t)y; |
| 279 | case TCG_COND_GE: |
| 280 | return (int32_t)x >= (int32_t)y; |
| 281 | case TCG_COND_LE: |
| 282 | return (int32_t)x <= (int32_t)y; |
| 283 | case TCG_COND_GT: |
| 284 | return (int32_t)x > (int32_t)y; |
| 285 | case TCG_COND_LTU: |
| 286 | return (uint32_t)x < (uint32_t)y; |
| 287 | case TCG_COND_GEU: |
| 288 | return (uint32_t)x >= (uint32_t)y; |
| 289 | case TCG_COND_LEU: |
| 290 | return (uint32_t)x <= (uint32_t)y; |
| 291 | case TCG_COND_GTU: |
| 292 | return (uint32_t)x > (uint32_t)y; |
| 293 | } |
| 294 | break; |
| 295 | case 64: |
| 296 | switch (c) { |
| 297 | case TCG_COND_EQ: |
| 298 | return (uint64_t)x == (uint64_t)y; |
| 299 | case TCG_COND_NE: |
| 300 | return (uint64_t)x != (uint64_t)y; |
| 301 | case TCG_COND_LT: |
| 302 | return (int64_t)x < (int64_t)y; |
| 303 | case TCG_COND_GE: |
| 304 | return (int64_t)x >= (int64_t)y; |
| 305 | case TCG_COND_LE: |
| 306 | return (int64_t)x <= (int64_t)y; |
| 307 | case TCG_COND_GT: |
| 308 | return (int64_t)x > (int64_t)y; |
| 309 | case TCG_COND_LTU: |
| 310 | return (uint64_t)x < (uint64_t)y; |
| 311 | case TCG_COND_GEU: |
| 312 | return (uint64_t)x >= (uint64_t)y; |
| 313 | case TCG_COND_LEU: |
| 314 | return (uint64_t)x <= (uint64_t)y; |
| 315 | case TCG_COND_GTU: |
| 316 | return (uint64_t)x > (uint64_t)y; |
| 317 | } |
| 318 | break; |
| 319 | } |
| 320 | |
| 321 | fprintf(stderr, |
| 322 | "Unrecognized bitness %d or condition %d in " |
| 323 | "do_constant_folding_cond.\n", op_bits(op), c); |
| 324 | tcg_abort(); |
| 325 | } |
| 326 | |
| 327 | |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 328 | /* Propagate constants and copies, fold constant expressions. */ |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 329 | static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, |
| 330 | TCGArg *args, TCGOpDef *tcg_op_defs) |
| 331 | { |
Blue Swirl | fe0de7a | 2011-07-30 19:18:32 +0000 | [diff] [blame] | 332 | int i, nb_ops, op_index, nb_temps, nb_globals, nb_call_args; |
| 333 | TCGOpcode op; |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 334 | const TCGOpDef *def; |
| 335 | TCGArg *gen_args; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 336 | TCGArg tmp; |
Richard Henderson | 5d8f536 | 2012-09-21 10:13:38 -0700 | [diff] [blame] | 337 | TCGCond cond; |
| 338 | |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 339 | /* Array VALS has an element for each temp. |
| 340 | If this temp holds a constant then its value is kept in VALS' element. |
| 341 | If this temp is a copy of other ones then this equivalence class' |
| 342 | representative is kept in VALS' element. |
| 343 | If this temp is neither copy nor constant then corresponding VALS' |
| 344 | element is unused. */ |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 345 | |
| 346 | nb_temps = s->nb_temps; |
| 347 | nb_globals = s->nb_globals; |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 348 | memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 349 | |
| 350 | nb_ops = tcg_opc_ptr - gen_opc_buf; |
| 351 | gen_args = args; |
| 352 | for (op_index = 0; op_index < nb_ops; op_index++) { |
| 353 | op = gen_opc_buf[op_index]; |
| 354 | def = &tcg_op_defs[op]; |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 355 | /* Do copy propagation */ |
| 356 | if (!(def->flags & (TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS))) { |
| 357 | assert(op != INDEX_op_call); |
| 358 | for (i = def->nb_oargs; i < def->nb_oargs + def->nb_iargs; i++) { |
| 359 | if (temps[args[i]].state == TCG_TEMP_COPY) { |
| 360 | args[i] = temps[args[i]].val; |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 365 | /* For commutative operations make constant second argument */ |
| 366 | switch (op) { |
| 367 | CASE_OP_32_64(add): |
| 368 | CASE_OP_32_64(mul): |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 369 | CASE_OP_32_64(and): |
| 370 | CASE_OP_32_64(or): |
| 371 | CASE_OP_32_64(xor): |
Richard Henderson | cb25c80 | 2011-08-17 14:11:47 -0700 | [diff] [blame] | 372 | CASE_OP_32_64(eqv): |
| 373 | CASE_OP_32_64(nand): |
| 374 | CASE_OP_32_64(nor): |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 375 | if (temps[args[1]].state == TCG_TEMP_CONST) { |
| 376 | tmp = args[1]; |
| 377 | args[1] = args[2]; |
| 378 | args[2] = tmp; |
| 379 | } |
| 380 | break; |
Aurelien Jarno | 65a7cce | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 381 | CASE_OP_32_64(brcond): |
| 382 | if (temps[args[0]].state == TCG_TEMP_CONST |
| 383 | && temps[args[1]].state != TCG_TEMP_CONST) { |
| 384 | tmp = args[0]; |
| 385 | args[0] = args[1]; |
| 386 | args[1] = tmp; |
| 387 | args[2] = tcg_swap_cond(args[2]); |
| 388 | } |
| 389 | break; |
| 390 | CASE_OP_32_64(setcond): |
| 391 | if (temps[args[1]].state == TCG_TEMP_CONST |
| 392 | && temps[args[2]].state != TCG_TEMP_CONST) { |
| 393 | tmp = args[1]; |
| 394 | args[1] = args[2]; |
| 395 | args[2] = tmp; |
| 396 | args[3] = tcg_swap_cond(args[3]); |
| 397 | } |
| 398 | break; |
Richard Henderson | fa01a20 | 2012-09-21 10:13:37 -0700 | [diff] [blame] | 399 | CASE_OP_32_64(movcond): |
Richard Henderson | 5d8f536 | 2012-09-21 10:13:38 -0700 | [diff] [blame] | 400 | cond = args[5]; |
Richard Henderson | fa01a20 | 2012-09-21 10:13:37 -0700 | [diff] [blame] | 401 | if (temps[args[1]].state == TCG_TEMP_CONST |
| 402 | && temps[args[2]].state != TCG_TEMP_CONST) { |
| 403 | tmp = args[1]; |
| 404 | args[1] = args[2]; |
| 405 | args[2] = tmp; |
Richard Henderson | 5d8f536 | 2012-09-21 10:13:38 -0700 | [diff] [blame] | 406 | cond = tcg_swap_cond(cond); |
Richard Henderson | fa01a20 | 2012-09-21 10:13:37 -0700 | [diff] [blame] | 407 | } |
Richard Henderson | 5d8f536 | 2012-09-21 10:13:38 -0700 | [diff] [blame] | 408 | /* For movcond, we canonicalize the "false" input reg to match |
| 409 | the destination reg so that the tcg backend can implement |
| 410 | a "move if true" operation. */ |
| 411 | if (args[0] == args[3]) { |
| 412 | tmp = args[3]; |
| 413 | args[3] = args[4]; |
| 414 | args[4] = tmp; |
| 415 | cond = tcg_invert_cond(cond); |
| 416 | } |
| 417 | args[5] = cond; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 418 | default: |
| 419 | break; |
| 420 | } |
| 421 | |
Aurelien Jarno | 01ee528 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 422 | /* Simplify expressions for "shift/rot r, 0, a => movi r, 0" */ |
| 423 | switch (op) { |
| 424 | CASE_OP_32_64(shl): |
| 425 | CASE_OP_32_64(shr): |
| 426 | CASE_OP_32_64(sar): |
| 427 | CASE_OP_32_64(rotl): |
| 428 | CASE_OP_32_64(rotr): |
| 429 | if (temps[args[1]].state == TCG_TEMP_CONST |
| 430 | && temps[args[1]].val == 0) { |
| 431 | gen_opc_buf[op_index] = op_to_movi(op); |
| 432 | tcg_opt_gen_movi(gen_args, args[0], 0, nb_temps, nb_globals); |
| 433 | args += 3; |
| 434 | gen_args += 2; |
| 435 | continue; |
| 436 | } |
| 437 | break; |
| 438 | default: |
| 439 | break; |
| 440 | } |
| 441 | |
Aurelien Jarno | 56e4943 | 2012-09-06 16:47:13 +0200 | [diff] [blame] | 442 | /* Simplify expression for "op r, a, 0 => mov r, a" cases */ |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 443 | switch (op) { |
| 444 | CASE_OP_32_64(add): |
| 445 | CASE_OP_32_64(sub): |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 446 | CASE_OP_32_64(shl): |
| 447 | CASE_OP_32_64(shr): |
| 448 | CASE_OP_32_64(sar): |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 449 | CASE_OP_32_64(rotl): |
| 450 | CASE_OP_32_64(rotr): |
Aurelien Jarno | 38ee188 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 451 | CASE_OP_32_64(or): |
| 452 | CASE_OP_32_64(xor): |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 453 | if (temps[args[1]].state == TCG_TEMP_CONST) { |
| 454 | /* Proceed with possible constant folding. */ |
| 455 | break; |
| 456 | } |
| 457 | if (temps[args[2]].state == TCG_TEMP_CONST |
| 458 | && temps[args[2]].val == 0) { |
| 459 | if ((temps[args[0]].state == TCG_TEMP_COPY |
| 460 | && temps[args[0]].val == args[1]) |
| 461 | || args[0] == args[1]) { |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 462 | gen_opc_buf[op_index] = INDEX_op_nop; |
| 463 | } else { |
| 464 | gen_opc_buf[op_index] = op_to_mov(op); |
Aurelien Jarno | d104beb | 2012-09-10 13:14:12 +0200 | [diff] [blame] | 465 | tcg_opt_gen_mov(gen_args, args[0], args[1], |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 466 | nb_temps, nb_globals); |
| 467 | gen_args += 2; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 468 | } |
Aurelien Jarno | fedc0da | 2012-09-07 12:24:32 +0200 | [diff] [blame] | 469 | args += 3; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 470 | continue; |
| 471 | } |
| 472 | break; |
Aurelien Jarno | 56e4943 | 2012-09-06 16:47:13 +0200 | [diff] [blame] | 473 | default: |
| 474 | break; |
| 475 | } |
| 476 | |
| 477 | /* Simplify expression for "op r, a, 0 => movi r, 0" cases */ |
| 478 | switch (op) { |
Aurelien Jarno | 61251c0 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 479 | CASE_OP_32_64(and): |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 480 | CASE_OP_32_64(mul): |
| 481 | if ((temps[args[2]].state == TCG_TEMP_CONST |
| 482 | && temps[args[2]].val == 0)) { |
| 483 | gen_opc_buf[op_index] = op_to_movi(op); |
| 484 | tcg_opt_gen_movi(gen_args, args[0], 0, nb_temps, nb_globals); |
| 485 | args += 3; |
| 486 | gen_args += 2; |
| 487 | continue; |
| 488 | } |
| 489 | break; |
Aurelien Jarno | 56e4943 | 2012-09-06 16:47:13 +0200 | [diff] [blame] | 490 | default: |
| 491 | break; |
| 492 | } |
| 493 | |
| 494 | /* Simplify expression for "op r, a, a => mov r, a" cases */ |
| 495 | switch (op) { |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 496 | CASE_OP_32_64(or): |
| 497 | CASE_OP_32_64(and): |
| 498 | if (args[1] == args[2]) { |
| 499 | if (args[1] == args[0]) { |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 500 | gen_opc_buf[op_index] = INDEX_op_nop; |
| 501 | } else { |
| 502 | gen_opc_buf[op_index] = op_to_mov(op); |
Aurelien Jarno | d104beb | 2012-09-10 13:14:12 +0200 | [diff] [blame] | 503 | tcg_opt_gen_mov(gen_args, args[0], args[1], nb_temps, |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 504 | nb_globals); |
| 505 | gen_args += 2; |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 506 | } |
Aurelien Jarno | fedc0da | 2012-09-07 12:24:32 +0200 | [diff] [blame] | 507 | args += 3; |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 508 | continue; |
| 509 | } |
| 510 | break; |
Blue Swirl | fe0de7a | 2011-07-30 19:18:32 +0000 | [diff] [blame] | 511 | default: |
| 512 | break; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 513 | } |
| 514 | |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 515 | /* Propagate constants through copy operations and do constant |
| 516 | folding. Constants will be substituted to arguments by register |
| 517 | allocator where needed and possible. Also detect copies. */ |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 518 | switch (op) { |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 519 | CASE_OP_32_64(mov): |
| 520 | if ((temps[args[1]].state == TCG_TEMP_COPY |
| 521 | && temps[args[1]].val == args[0]) |
| 522 | || args[0] == args[1]) { |
| 523 | args += 2; |
| 524 | gen_opc_buf[op_index] = INDEX_op_nop; |
| 525 | break; |
| 526 | } |
| 527 | if (temps[args[1]].state != TCG_TEMP_CONST) { |
Aurelien Jarno | d104beb | 2012-09-10 13:14:12 +0200 | [diff] [blame] | 528 | tcg_opt_gen_mov(gen_args, args[0], args[1], |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 529 | nb_temps, nb_globals); |
| 530 | gen_args += 2; |
| 531 | args += 2; |
| 532 | break; |
| 533 | } |
| 534 | /* Source argument is constant. Rewrite the operation and |
| 535 | let movi case handle it. */ |
| 536 | op = op_to_movi(op); |
| 537 | gen_opc_buf[op_index] = op; |
| 538 | args[1] = temps[args[1]].val; |
| 539 | /* fallthrough */ |
| 540 | CASE_OP_32_64(movi): |
| 541 | tcg_opt_gen_movi(gen_args, args[0], args[1], nb_temps, nb_globals); |
| 542 | gen_args += 2; |
| 543 | args += 2; |
| 544 | break; |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 545 | CASE_OP_32_64(not): |
Richard Henderson | cb25c80 | 2011-08-17 14:11:47 -0700 | [diff] [blame] | 546 | CASE_OP_32_64(neg): |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 547 | CASE_OP_32_64(ext8s): |
| 548 | CASE_OP_32_64(ext8u): |
| 549 | CASE_OP_32_64(ext16s): |
| 550 | CASE_OP_32_64(ext16u): |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 551 | case INDEX_op_ext32s_i64: |
| 552 | case INDEX_op_ext32u_i64: |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 553 | if (temps[args[1]].state == TCG_TEMP_CONST) { |
| 554 | gen_opc_buf[op_index] = op_to_movi(op); |
| 555 | tmp = do_constant_folding(op, temps[args[1]].val, 0); |
| 556 | tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals); |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 557 | } else { |
| 558 | reset_temp(args[0], nb_temps, nb_globals); |
| 559 | gen_args[0] = args[0]; |
| 560 | gen_args[1] = args[1]; |
Kirill Batuzov | a640f03 | 2011-07-07 16:37:17 +0400 | [diff] [blame] | 561 | } |
Aurelien Jarno | fedc0da | 2012-09-07 12:24:32 +0200 | [diff] [blame] | 562 | gen_args += 2; |
| 563 | args += 2; |
| 564 | break; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 565 | CASE_OP_32_64(add): |
| 566 | CASE_OP_32_64(sub): |
| 567 | CASE_OP_32_64(mul): |
Kirill Batuzov | 9a81090 | 2011-07-07 16:37:15 +0400 | [diff] [blame] | 568 | CASE_OP_32_64(or): |
| 569 | CASE_OP_32_64(and): |
| 570 | CASE_OP_32_64(xor): |
Kirill Batuzov | 55c0975 | 2011-07-07 16:37:16 +0400 | [diff] [blame] | 571 | CASE_OP_32_64(shl): |
| 572 | CASE_OP_32_64(shr): |
| 573 | CASE_OP_32_64(sar): |
Richard Henderson | 25c4d9c | 2011-08-17 14:11:46 -0700 | [diff] [blame] | 574 | CASE_OP_32_64(rotl): |
| 575 | CASE_OP_32_64(rotr): |
Richard Henderson | cb25c80 | 2011-08-17 14:11:47 -0700 | [diff] [blame] | 576 | CASE_OP_32_64(andc): |
| 577 | CASE_OP_32_64(orc): |
| 578 | CASE_OP_32_64(eqv): |
| 579 | CASE_OP_32_64(nand): |
| 580 | CASE_OP_32_64(nor): |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 581 | if (temps[args[1]].state == TCG_TEMP_CONST |
| 582 | && temps[args[2]].state == TCG_TEMP_CONST) { |
| 583 | gen_opc_buf[op_index] = op_to_movi(op); |
| 584 | tmp = do_constant_folding(op, temps[args[1]].val, |
| 585 | temps[args[2]].val); |
| 586 | tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals); |
| 587 | gen_args += 2; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 588 | } else { |
| 589 | reset_temp(args[0], nb_temps, nb_globals); |
| 590 | gen_args[0] = args[0]; |
| 591 | gen_args[1] = args[1]; |
| 592 | gen_args[2] = args[2]; |
| 593 | gen_args += 3; |
Kirill Batuzov | 53108fb | 2011-07-07 16:37:14 +0400 | [diff] [blame] | 594 | } |
Aurelien Jarno | fedc0da | 2012-09-07 12:24:32 +0200 | [diff] [blame] | 595 | args += 3; |
| 596 | break; |
Aurelien Jarno | f8dd19e | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 597 | CASE_OP_32_64(setcond): |
| 598 | if (temps[args[1]].state == TCG_TEMP_CONST |
| 599 | && temps[args[2]].state == TCG_TEMP_CONST) { |
| 600 | gen_opc_buf[op_index] = op_to_movi(op); |
| 601 | tmp = do_constant_folding_cond(op, temps[args[1]].val, |
| 602 | temps[args[2]].val, args[3]); |
| 603 | tcg_opt_gen_movi(gen_args, args[0], tmp, nb_temps, nb_globals); |
| 604 | gen_args += 2; |
Aurelien Jarno | f8dd19e | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 605 | } else { |
| 606 | reset_temp(args[0], nb_temps, nb_globals); |
| 607 | gen_args[0] = args[0]; |
| 608 | gen_args[1] = args[1]; |
| 609 | gen_args[2] = args[2]; |
| 610 | gen_args[3] = args[3]; |
| 611 | gen_args += 4; |
Aurelien Jarno | f8dd19e | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 612 | } |
Aurelien Jarno | fedc0da | 2012-09-07 12:24:32 +0200 | [diff] [blame] | 613 | args += 4; |
| 614 | break; |
Aurelien Jarno | fbeaa26 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 615 | CASE_OP_32_64(brcond): |
| 616 | if (temps[args[0]].state == TCG_TEMP_CONST |
| 617 | && temps[args[1]].state == TCG_TEMP_CONST) { |
| 618 | if (do_constant_folding_cond(op, temps[args[0]].val, |
| 619 | temps[args[1]].val, args[2])) { |
| 620 | memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); |
| 621 | gen_opc_buf[op_index] = INDEX_op_br; |
| 622 | gen_args[0] = args[3]; |
| 623 | gen_args += 1; |
Aurelien Jarno | fbeaa26 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 624 | } else { |
| 625 | gen_opc_buf[op_index] = INDEX_op_nop; |
Aurelien Jarno | fbeaa26 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 626 | } |
Aurelien Jarno | fbeaa26 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 627 | } else { |
| 628 | memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); |
| 629 | reset_temp(args[0], nb_temps, nb_globals); |
| 630 | gen_args[0] = args[0]; |
| 631 | gen_args[1] = args[1]; |
| 632 | gen_args[2] = args[2]; |
| 633 | gen_args[3] = args[3]; |
| 634 | gen_args += 4; |
Aurelien Jarno | fbeaa26 | 2012-09-06 16:47:14 +0200 | [diff] [blame] | 635 | } |
Aurelien Jarno | fedc0da | 2012-09-07 12:24:32 +0200 | [diff] [blame] | 636 | args += 4; |
| 637 | break; |
Richard Henderson | fa01a20 | 2012-09-21 10:13:37 -0700 | [diff] [blame] | 638 | CASE_OP_32_64(movcond): |
| 639 | if (temps[args[1]].state == TCG_TEMP_CONST |
| 640 | && temps[args[2]].state == TCG_TEMP_CONST) { |
| 641 | tmp = do_constant_folding_cond(op, temps[args[1]].val, |
| 642 | temps[args[2]].val, args[5]); |
| 643 | if (args[0] == args[4-tmp] |
| 644 | || (temps[args[4-tmp]].state == TCG_TEMP_COPY |
| 645 | && temps[args[4-tmp]].val == args[0])) { |
| 646 | gen_opc_buf[op_index] = INDEX_op_nop; |
| 647 | } else if (temps[args[4-tmp]].state == TCG_TEMP_CONST) { |
| 648 | gen_opc_buf[op_index] = op_to_movi(op); |
| 649 | tcg_opt_gen_movi(gen_args, args[0], temps[args[4-tmp]].val, |
| 650 | nb_temps, nb_globals); |
| 651 | gen_args += 2; |
| 652 | } else { |
| 653 | gen_opc_buf[op_index] = op_to_mov(op); |
| 654 | tcg_opt_gen_mov(gen_args, args[0], args[4-tmp], |
| 655 | nb_temps, nb_globals); |
| 656 | gen_args += 2; |
| 657 | } |
| 658 | } else { |
| 659 | reset_temp(args[0], nb_temps, nb_globals); |
| 660 | gen_args[0] = args[0]; |
| 661 | gen_args[1] = args[1]; |
| 662 | gen_args[2] = args[2]; |
| 663 | gen_args[3] = args[3]; |
| 664 | gen_args[4] = args[4]; |
| 665 | gen_args[5] = args[5]; |
| 666 | gen_args += 6; |
| 667 | } |
| 668 | args += 6; |
| 669 | break; |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 670 | case INDEX_op_call: |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 671 | nb_call_args = (args[0] >> 16) + (args[0] & 0xffff); |
| 672 | if (!(args[nb_call_args + 1] & (TCG_CALL_CONST | TCG_CALL_PURE))) { |
| 673 | for (i = 0; i < nb_globals; i++) { |
| 674 | reset_temp(i, nb_temps, nb_globals); |
| 675 | } |
| 676 | } |
| 677 | for (i = 0; i < (args[0] >> 16); i++) { |
| 678 | reset_temp(args[i + 1], nb_temps, nb_globals); |
| 679 | } |
| 680 | i = nb_call_args + 3; |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 681 | while (i) { |
| 682 | *gen_args = *args; |
| 683 | args++; |
| 684 | gen_args++; |
| 685 | i--; |
| 686 | } |
| 687 | break; |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 688 | default: |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 689 | /* Default case: we do know nothing about operation so no |
Aurelien Jarno | a255066 | 2012-09-19 21:40:30 +0200 | [diff] [blame] | 690 | propagation is done. We trash everything if the operation |
| 691 | is the end of a basic block, otherwise we only trash the |
| 692 | output args. */ |
| 693 | if (def->flags & TCG_OPF_BB_END) { |
| 694 | memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); |
| 695 | } else { |
| 696 | for (i = 0; i < def->nb_oargs; i++) { |
| 697 | reset_temp(args[i], nb_temps, nb_globals); |
| 698 | } |
Kirill Batuzov | 22613af | 2011-07-07 16:37:13 +0400 | [diff] [blame] | 699 | } |
Kirill Batuzov | 8f2e8c0 | 2011-07-07 16:37:12 +0400 | [diff] [blame] | 700 | for (i = 0; i < def->nb_args; i++) { |
| 701 | gen_args[i] = args[i]; |
| 702 | } |
| 703 | args += def->nb_args; |
| 704 | gen_args += def->nb_args; |
| 705 | break; |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | return gen_args; |
| 710 | } |
| 711 | |
| 712 | TCGArg *tcg_optimize(TCGContext *s, uint16_t *tcg_opc_ptr, |
| 713 | TCGArg *args, TCGOpDef *tcg_op_defs) |
| 714 | { |
| 715 | TCGArg *res; |
| 716 | res = tcg_constant_folding(s, tcg_opc_ptr, args, tcg_op_defs); |
| 717 | return res; |
| 718 | } |