| 1 | /* |
| 2 | * Internal declarations for 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 | |
| 25 | #ifndef TCG_INTERNAL_H |
| 26 | #define TCG_INTERNAL_H |
| 27 | |
| 28 | #include "tcg/helper-info.h" |
| 29 | |
| 30 | #define TCG_HIGHWATER 1024 |
| 31 | |
| 32 | extern TCGContext tcg_init_ctx; |
| 33 | extern TCGContext **tcg_ctxs; |
| 34 | extern unsigned int tcg_cur_ctxs; |
| 35 | extern unsigned int tcg_max_ctxs; |
| 36 | |
| 37 | #ifdef CONFIG_USER_ONLY |
| 38 | #define tcg_use_softmmu false |
| 39 | #else |
| 40 | #define tcg_use_softmmu true |
| 41 | #endif |
| 42 | |
| 43 | void tcg_region_init(size_t tb_size, int splitwx, unsigned max_threads); |
| 44 | bool tcg_region_alloc(TCGContext *s); |
| 45 | void tcg_region_thread_initial_alloc(TCGContext *s); |
| 46 | void tcg_region_prologue_set(TCGContext *s); |
| 47 | |
| 48 | static inline void *tcg_call_func(TCGOp *op) |
| 49 | { |
| 50 | return (void *)(uintptr_t)op->args[TCGOP_CALLO(op) + TCGOP_CALLI(op)]; |
| 51 | } |
| 52 | |
| 53 | static inline const TCGHelperInfo *tcg_call_info(TCGOp *op) |
| 54 | { |
| 55 | return (void *)(uintptr_t)op->args[TCGOP_CALLO(op) + TCGOP_CALLI(op) + 1]; |
| 56 | } |
| 57 | |
| 58 | static inline unsigned tcg_call_flags(TCGOp *op) |
| 59 | { |
| 60 | return tcg_call_info(op)->flags; |
| 61 | } |
| 62 | |
| 63 | static inline TCGv_i64 TCGV128_LOW(TCGv_i128 t) |
| 64 | { |
| 65 | return temp_tcgv_i64(tcgv_i128_temp(t) + HOST_BIG_ENDIAN); |
| 66 | } |
| 67 | |
| 68 | static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t) |
| 69 | { |
| 70 | return temp_tcgv_i64(tcgv_i128_temp(t) + !HOST_BIG_ENDIAN); |
| 71 | } |
| 72 | |
| 73 | bool tcg_target_has_memory_bswap(MemOp memop); |
| 74 | |
| 75 | TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind); |
| 76 | |
| 77 | /* |
| 78 | * Locate or create a read-only temporary that is a constant. |
| 79 | * This kind of temporary need not be freed, but for convenience |
| 80 | * will be silently ignored by tcg_temp_free_*. |
| 81 | */ |
| 82 | TCGTemp *tcg_constant_internal(TCGType type, int64_t val); |
| 83 | |
| 84 | TCGOp *tcg_gen_op1(TCGOpcode, TCGType, TCGArg); |
| 85 | TCGOp *tcg_gen_op2(TCGOpcode, TCGType, TCGArg, TCGArg); |
| 86 | TCGOp *tcg_gen_op3(TCGOpcode, TCGType, TCGArg, TCGArg, TCGArg); |
| 87 | TCGOp *tcg_gen_op4(TCGOpcode, TCGType, TCGArg, TCGArg, TCGArg, TCGArg); |
| 88 | TCGOp *tcg_gen_op5(TCGOpcode, TCGType, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg); |
| 89 | TCGOp *tcg_gen_op6(TCGOpcode, TCGType, TCGArg, TCGArg, |
| 90 | TCGArg, TCGArg, TCGArg, TCGArg); |
| 91 | |
| 92 | void vec_gen_2(TCGOpcode, TCGType, unsigned, TCGArg, TCGArg); |
| 93 | void vec_gen_3(TCGOpcode, TCGType, unsigned, TCGArg, TCGArg, TCGArg); |
| 94 | void vec_gen_4(TCGOpcode, TCGType, unsigned, TCGArg, TCGArg, TCGArg, TCGArg); |
| 95 | void vec_gen_6(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r, |
| 96 | TCGArg a, TCGArg b, TCGArg c, TCGArg d, TCGArg e); |
| 97 | |
| 98 | TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, |
| 99 | TCGOpcode, TCGType, unsigned nargs); |
| 100 | TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, |
| 101 | TCGOpcode, TCGType, unsigned nargs); |
| 102 | |
| 103 | /* |
| 104 | * For a binary opcode OP, return true if the second input operand allows IMM. |
| 105 | */ |
| 106 | bool tcg_op_imm_match(TCGOpcode op, TCGType type, tcg_target_ulong imm); |
| 107 | |
| 108 | #endif /* TCG_INTERNAL_H */ |