2011-10-05 22:03:02 +04:00
|
|
|
/*
|
|
|
|
* Tiny Code Generator for QEMU
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009, 2011 Stefan Weil
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
#include "../tcg-pool.c.inc"
|
2011-10-05 22:03:02 +04:00
|
|
|
|
2020-10-17 21:35:13 +03:00
|
|
|
static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
|
|
|
|
{
|
|
|
|
switch (op) {
|
2021-02-02 22:40:22 +03:00
|
|
|
case INDEX_op_goto_ptr:
|
|
|
|
return C_O0_I1(r);
|
|
|
|
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_ld8u_i32:
|
|
|
|
case INDEX_op_ld8s_i32:
|
|
|
|
case INDEX_op_ld16u_i32:
|
|
|
|
case INDEX_op_ld16s_i32:
|
|
|
|
case INDEX_op_ld_i32:
|
|
|
|
case INDEX_op_ld8u_i64:
|
|
|
|
case INDEX_op_ld8s_i64:
|
|
|
|
case INDEX_op_ld16u_i64:
|
|
|
|
case INDEX_op_ld16s_i64:
|
|
|
|
case INDEX_op_ld32u_i64:
|
|
|
|
case INDEX_op_ld32s_i64:
|
|
|
|
case INDEX_op_ld_i64:
|
|
|
|
case INDEX_op_not_i32:
|
|
|
|
case INDEX_op_not_i64:
|
|
|
|
case INDEX_op_neg_i32:
|
|
|
|
case INDEX_op_neg_i64:
|
|
|
|
case INDEX_op_ext8s_i32:
|
|
|
|
case INDEX_op_ext8s_i64:
|
|
|
|
case INDEX_op_ext16s_i32:
|
|
|
|
case INDEX_op_ext16s_i64:
|
|
|
|
case INDEX_op_ext8u_i32:
|
|
|
|
case INDEX_op_ext8u_i64:
|
|
|
|
case INDEX_op_ext16u_i32:
|
|
|
|
case INDEX_op_ext16u_i64:
|
|
|
|
case INDEX_op_ext32s_i64:
|
|
|
|
case INDEX_op_ext32u_i64:
|
|
|
|
case INDEX_op_ext_i32_i64:
|
|
|
|
case INDEX_op_extu_i32_i64:
|
|
|
|
case INDEX_op_bswap16_i32:
|
|
|
|
case INDEX_op_bswap16_i64:
|
|
|
|
case INDEX_op_bswap32_i32:
|
|
|
|
case INDEX_op_bswap32_i64:
|
|
|
|
case INDEX_op_bswap64_i64:
|
2021-02-03 03:48:48 +03:00
|
|
|
case INDEX_op_extract_i32:
|
|
|
|
case INDEX_op_extract_i64:
|
|
|
|
case INDEX_op_sextract_i32:
|
|
|
|
case INDEX_op_sextract_i64:
|
2021-02-03 04:01:57 +03:00
|
|
|
case INDEX_op_ctpop_i32:
|
|
|
|
case INDEX_op_ctpop_i64:
|
2020-10-17 21:35:13 +03:00
|
|
|
return C_O1_I1(r, r);
|
|
|
|
|
|
|
|
case INDEX_op_st8_i32:
|
|
|
|
case INDEX_op_st16_i32:
|
|
|
|
case INDEX_op_st_i32:
|
|
|
|
case INDEX_op_st8_i64:
|
|
|
|
case INDEX_op_st16_i64:
|
|
|
|
case INDEX_op_st32_i64:
|
|
|
|
case INDEX_op_st_i64:
|
|
|
|
return C_O0_I2(r, r);
|
|
|
|
|
|
|
|
case INDEX_op_div_i32:
|
|
|
|
case INDEX_op_div_i64:
|
|
|
|
case INDEX_op_divu_i32:
|
|
|
|
case INDEX_op_divu_i64:
|
|
|
|
case INDEX_op_rem_i32:
|
|
|
|
case INDEX_op_rem_i64:
|
|
|
|
case INDEX_op_remu_i32:
|
|
|
|
case INDEX_op_remu_i64:
|
|
|
|
case INDEX_op_add_i32:
|
|
|
|
case INDEX_op_add_i64:
|
|
|
|
case INDEX_op_sub_i32:
|
|
|
|
case INDEX_op_sub_i64:
|
|
|
|
case INDEX_op_mul_i32:
|
|
|
|
case INDEX_op_mul_i64:
|
|
|
|
case INDEX_op_and_i32:
|
|
|
|
case INDEX_op_and_i64:
|
|
|
|
case INDEX_op_andc_i32:
|
|
|
|
case INDEX_op_andc_i64:
|
|
|
|
case INDEX_op_eqv_i32:
|
|
|
|
case INDEX_op_eqv_i64:
|
|
|
|
case INDEX_op_nand_i32:
|
|
|
|
case INDEX_op_nand_i64:
|
|
|
|
case INDEX_op_nor_i32:
|
|
|
|
case INDEX_op_nor_i64:
|
|
|
|
case INDEX_op_or_i32:
|
|
|
|
case INDEX_op_or_i64:
|
|
|
|
case INDEX_op_orc_i32:
|
|
|
|
case INDEX_op_orc_i64:
|
|
|
|
case INDEX_op_xor_i32:
|
|
|
|
case INDEX_op_xor_i64:
|
|
|
|
case INDEX_op_shl_i32:
|
|
|
|
case INDEX_op_shl_i64:
|
|
|
|
case INDEX_op_shr_i32:
|
|
|
|
case INDEX_op_shr_i64:
|
|
|
|
case INDEX_op_sar_i32:
|
|
|
|
case INDEX_op_sar_i64:
|
|
|
|
case INDEX_op_rotl_i32:
|
|
|
|
case INDEX_op_rotl_i64:
|
|
|
|
case INDEX_op_rotr_i32:
|
|
|
|
case INDEX_op_rotr_i64:
|
2021-01-29 04:07:41 +03:00
|
|
|
case INDEX_op_setcond_i32:
|
|
|
|
case INDEX_op_setcond_i64:
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_deposit_i32:
|
|
|
|
case INDEX_op_deposit_i64:
|
2021-02-03 04:01:57 +03:00
|
|
|
case INDEX_op_clz_i32:
|
|
|
|
case INDEX_op_clz_i64:
|
|
|
|
case INDEX_op_ctz_i32:
|
|
|
|
case INDEX_op_ctz_i64:
|
2021-01-30 11:36:40 +03:00
|
|
|
return C_O1_I2(r, r, r);
|
2020-10-17 21:35:13 +03:00
|
|
|
|
|
|
|
case INDEX_op_brcond_i32:
|
|
|
|
case INDEX_op_brcond_i64:
|
2021-01-29 04:07:41 +03:00
|
|
|
return C_O0_I2(r, r);
|
2011-10-05 22:03:02 +04:00
|
|
|
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_add2_i32:
|
2021-02-03 04:40:12 +03:00
|
|
|
case INDEX_op_add2_i64:
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_sub2_i32:
|
2021-02-03 04:40:12 +03:00
|
|
|
case INDEX_op_sub2_i64:
|
2020-10-17 21:35:13 +03:00
|
|
|
return C_O2_I4(r, r, r, r, r, r);
|
2021-02-03 04:40:12 +03:00
|
|
|
|
|
|
|
#if TCG_TARGET_REG_BITS == 32
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_brcond2_i32:
|
2021-01-29 04:07:41 +03:00
|
|
|
return C_O0_I4(r, r, r, r);
|
2021-02-03 04:21:27 +03:00
|
|
|
#endif
|
|
|
|
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_mulu2_i32:
|
2021-02-03 04:21:27 +03:00
|
|
|
case INDEX_op_mulu2_i64:
|
|
|
|
case INDEX_op_muls2_i32:
|
|
|
|
case INDEX_op_muls2_i64:
|
2020-10-17 21:35:13 +03:00
|
|
|
return C_O2_I2(r, r, r, r);
|
2021-02-03 03:15:45 +03:00
|
|
|
|
|
|
|
case INDEX_op_movcond_i32:
|
|
|
|
case INDEX_op_movcond_i64:
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_setcond2_i32:
|
2021-01-29 04:07:41 +03:00
|
|
|
return C_O1_I4(r, r, r, r, r);
|
2016-11-18 11:31:40 +03:00
|
|
|
|
2020-10-17 21:35:13 +03:00
|
|
|
case INDEX_op_qemu_ld_i32:
|
|
|
|
return (TARGET_LONG_BITS <= TCG_TARGET_REG_BITS
|
|
|
|
? C_O1_I1(r, r)
|
|
|
|
: C_O1_I2(r, r, r));
|
|
|
|
case INDEX_op_qemu_ld_i64:
|
|
|
|
return (TCG_TARGET_REG_BITS == 64 ? C_O1_I1(r, r)
|
|
|
|
: TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? C_O2_I1(r, r, r)
|
|
|
|
: C_O2_I2(r, r, r, r));
|
|
|
|
case INDEX_op_qemu_st_i32:
|
|
|
|
return (TARGET_LONG_BITS <= TCG_TARGET_REG_BITS
|
|
|
|
? C_O0_I2(r, r)
|
|
|
|
: C_O0_I3(r, r, r));
|
|
|
|
case INDEX_op_qemu_st_i64:
|
|
|
|
return (TCG_TARGET_REG_BITS == 64 ? C_O0_I2(r, r)
|
|
|
|
: TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? C_O0_I3(r, r, r)
|
|
|
|
: C_O0_I4(r, r, r, r));
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2016-11-18 11:31:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-05 22:03:02 +04:00
|
|
|
static const int tcg_target_reg_alloc_order[] = {
|
|
|
|
TCG_REG_R2,
|
|
|
|
TCG_REG_R3,
|
|
|
|
TCG_REG_R4,
|
|
|
|
TCG_REG_R5,
|
|
|
|
TCG_REG_R6,
|
|
|
|
TCG_REG_R7,
|
|
|
|
TCG_REG_R8,
|
|
|
|
TCG_REG_R9,
|
|
|
|
TCG_REG_R10,
|
|
|
|
TCG_REG_R11,
|
|
|
|
TCG_REG_R12,
|
|
|
|
TCG_REG_R13,
|
|
|
|
TCG_REG_R14,
|
|
|
|
TCG_REG_R15,
|
2021-02-01 12:23:07 +03:00
|
|
|
TCG_REG_R1,
|
|
|
|
TCG_REG_R0,
|
2011-10-05 22:03:02 +04:00
|
|
|
};
|
|
|
|
|
2021-01-31 01:24:25 +03:00
|
|
|
/* No call arguments via registers. All will be stored on the "stack". */
|
|
|
|
static const int tcg_target_call_iarg_regs[] = { };
|
2011-10-05 22:03:02 +04:00
|
|
|
|
2022-10-19 17:55:36 +03:00
|
|
|
static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(kind == TCG_CALL_RET_NORMAL);
|
2022-10-21 03:47:54 +03:00
|
|
|
tcg_debug_assert(slot >= 0 && slot < 128 / TCG_TARGET_REG_BITS);
|
2022-10-19 17:55:36 +03:00
|
|
|
return TCG_REG_R0 + slot;
|
|
|
|
}
|
2011-10-05 22:03:02 +04:00
|
|
|
|
2016-04-21 11:48:50 +03:00
|
|
|
#ifdef CONFIG_DEBUG_TCG
|
2011-10-05 22:03:02 +04:00
|
|
|
static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
|
|
|
|
"r00",
|
|
|
|
"r01",
|
|
|
|
"r02",
|
|
|
|
"r03",
|
|
|
|
"r04",
|
|
|
|
"r05",
|
|
|
|
"r06",
|
|
|
|
"r07",
|
|
|
|
"r08",
|
|
|
|
"r09",
|
|
|
|
"r10",
|
|
|
|
"r11",
|
|
|
|
"r12",
|
|
|
|
"r13",
|
|
|
|
"r14",
|
|
|
|
"r15",
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-11-30 22:52:48 +03:00
|
|
|
static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
|
2013-08-21 02:30:10 +04:00
|
|
|
intptr_t value, intptr_t addend)
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
intptr_t diff = value - (intptr_t)(code_ptr + 1);
|
2011-10-05 22:03:02 +04:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_debug_assert(addend == 0);
|
|
|
|
tcg_debug_assert(type == 20);
|
2011-10-05 22:03:02 +04:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
if (diff == sextract32(diff, 0, type)) {
|
|
|
|
tcg_patch32(code_ptr, deposit32(*code_ptr, 32 - type, type, diff));
|
|
|
|
return true;
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
return false;
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
|
2021-01-28 09:04:43 +03:00
|
|
|
static void stack_bounds_check(TCGReg base, target_long offset)
|
|
|
|
{
|
|
|
|
if (base == TCG_REG_CALL_STACK) {
|
2021-01-31 01:24:25 +03:00
|
|
|
tcg_debug_assert(offset >= 0);
|
|
|
|
tcg_debug_assert(offset < (TCG_STATIC_CALL_ARGS_SIZE +
|
|
|
|
TCG_STATIC_FRAME_SIZE));
|
2021-01-28 09:04:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-01 21:36:39 +03:00
|
|
|
static void tcg_out_op_l(TCGContext *s, TCGOpcode op, TCGLabel *l0)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 21:36:39 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_out_reloc(s, s->code_ptr, 20, l0, 0);
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 21:36:39 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 21:40:59 +03:00
|
|
|
static void tcg_out_op_p(TCGContext *s, TCGOpcode op, void *p0)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
|
|
|
intptr_t diff;
|
2021-02-01 21:40:59 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
/* Special case for exit_tb: map null -> 0. */
|
|
|
|
if (p0 == NULL) {
|
|
|
|
diff = 0;
|
|
|
|
} else {
|
|
|
|
diff = p0 - (void *)(s->code_ptr + 1);
|
|
|
|
tcg_debug_assert(diff != 0);
|
|
|
|
if (diff != sextract32(diff, 0, 20)) {
|
|
|
|
tcg_raise_tb_overflow(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 12, 20, diff);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 21:40:59 +03:00
|
|
|
}
|
|
|
|
|
2021-02-02 22:40:22 +03:00
|
|
|
static void tcg_out_op_r(TCGContext *s, TCGOpcode op, TCGReg r0)
|
|
|
|
{
|
|
|
|
tcg_insn_unit insn = 0;
|
|
|
|
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
tcg_out32(s, insn);
|
|
|
|
}
|
|
|
|
|
2021-02-01 22:20:19 +03:00
|
|
|
static void tcg_out_op_v(TCGContext *s, TCGOpcode op)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_out32(s, (uint8_t)op);
|
2021-02-01 22:20:19 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 22:57:43 +03:00
|
|
|
static void tcg_out_op_ri(TCGContext *s, TCGOpcode op, TCGReg r0, int32_t i1)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 22:57:43 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_debug_assert(i1 == sextract32(i1, 0, 20));
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 20, i1);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 22:57:43 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 22:41:20 +03:00
|
|
|
static void tcg_out_op_rl(TCGContext *s, TCGOpcode op, TCGReg r0, TCGLabel *l1)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 22:41:20 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_out_reloc(s, s->code_ptr, 20, l1, 0);
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 22:41:20 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 21:45:41 +03:00
|
|
|
static void tcg_out_op_rr(TCGContext *s, TCGOpcode op, TCGReg r0, TCGReg r1)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 21:45:41 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 21:45:41 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 22:16:33 +03:00
|
|
|
static void tcg_out_op_rrm(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, TCGArg m2)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 22:16:33 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_debug_assert(m2 == extract32(m2, 0, 12));
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 20, 12, m2);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 22:16:33 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 21:49:18 +03:00
|
|
|
static void tcg_out_op_rrr(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, TCGReg r2)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 21:49:18 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 21:49:18 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 20:58:02 +03:00
|
|
|
static void tcg_out_op_rrs(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, intptr_t i2)
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 20:58:02 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_debug_assert(i2 == sextract32(i2, 0, 16));
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 16, i2);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 20:58:02 +03:00
|
|
|
}
|
|
|
|
|
2021-02-03 03:48:48 +03:00
|
|
|
static void tcg_out_op_rrbb(TCGContext *s, TCGOpcode op, TCGReg r0,
|
|
|
|
TCGReg r1, uint8_t b2, uint8_t b3)
|
|
|
|
{
|
|
|
|
tcg_insn_unit insn = 0;
|
|
|
|
|
|
|
|
tcg_debug_assert(b2 == extract32(b2, 0, 6));
|
|
|
|
tcg_debug_assert(b3 == extract32(b3, 0, 6));
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 6, b2);
|
|
|
|
insn = deposit32(insn, 22, 6, b3);
|
|
|
|
tcg_out32(s, insn);
|
|
|
|
}
|
|
|
|
|
2021-02-01 21:52:20 +03:00
|
|
|
static void tcg_out_op_rrrc(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, TCGReg r2, TCGCond c3)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 21:52:20 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
insn = deposit32(insn, 20, 4, c3);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 21:52:20 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 22:16:33 +03:00
|
|
|
static void tcg_out_op_rrrm(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, TCGReg r2, TCGArg m3)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 22:16:33 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_debug_assert(m3 == extract32(m3, 0, 12));
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
insn = deposit32(insn, 20, 12, m3);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 22:16:33 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 21:59:56 +03:00
|
|
|
static void tcg_out_op_rrrbb(TCGContext *s, TCGOpcode op, TCGReg r0,
|
|
|
|
TCGReg r1, TCGReg r2, uint8_t b3, uint8_t b4)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 21:59:56 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_debug_assert(b3 == extract32(b3, 0, 6));
|
|
|
|
tcg_debug_assert(b4 == extract32(b4, 0, 6));
|
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
insn = deposit32(insn, 20, 6, b3);
|
|
|
|
insn = deposit32(insn, 26, 6, b4);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 21:59:56 +03:00
|
|
|
}
|
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
static void tcg_out_op_rrrrr(TCGContext *s, TCGOpcode op, TCGReg r0,
|
|
|
|
TCGReg r1, TCGReg r2, TCGReg r3, TCGReg r4)
|
2021-02-01 22:16:33 +03:00
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 22:16:33 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
insn = deposit32(insn, 20, 4, r3);
|
|
|
|
insn = deposit32(insn, 24, 4, r4);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 22:16:33 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 22:07:31 +03:00
|
|
|
static void tcg_out_op_rrrr(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, TCGReg r2, TCGReg r3)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 22:07:31 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
insn = deposit32(insn, 20, 4, r3);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 22:07:31 +03:00
|
|
|
}
|
|
|
|
|
2021-02-01 21:54:54 +03:00
|
|
|
static void tcg_out_op_rrrrrc(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, TCGReg r2,
|
|
|
|
TCGReg r3, TCGReg r4, TCGCond c5)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 21:54:54 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
insn = deposit32(insn, 20, 4, r3);
|
|
|
|
insn = deposit32(insn, 24, 4, r4);
|
|
|
|
insn = deposit32(insn, 28, 4, c5);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 21:54:54 +03:00
|
|
|
}
|
2021-02-01 22:06:06 +03:00
|
|
|
|
|
|
|
static void tcg_out_op_rrrrrr(TCGContext *s, TCGOpcode op,
|
|
|
|
TCGReg r0, TCGReg r1, TCGReg r2,
|
|
|
|
TCGReg r3, TCGReg r4, TCGReg r5)
|
|
|
|
{
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-02-01 22:06:06 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
insn = deposit32(insn, 0, 8, op);
|
|
|
|
insn = deposit32(insn, 8, 4, r0);
|
|
|
|
insn = deposit32(insn, 12, 4, r1);
|
|
|
|
insn = deposit32(insn, 16, 4, r2);
|
|
|
|
insn = deposit32(insn, 20, 4, r3);
|
|
|
|
insn = deposit32(insn, 24, 4, r4);
|
|
|
|
insn = deposit32(insn, 28, 4, r5);
|
|
|
|
tcg_out32(s, insn);
|
2021-02-01 22:06:06 +03:00
|
|
|
}
|
2021-02-01 21:54:54 +03:00
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
static void tcg_out_ldst(TCGContext *s, TCGOpcode op, TCGReg val,
|
|
|
|
TCGReg base, intptr_t offset)
|
|
|
|
{
|
|
|
|
stack_bounds_check(base, offset);
|
|
|
|
if (offset != sextract32(offset, 0, 16)) {
|
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, offset);
|
|
|
|
tcg_out_op_rrr(s, (TCG_TARGET_REG_BITS == 32
|
|
|
|
? INDEX_op_add_i32 : INDEX_op_add_i64),
|
|
|
|
TCG_REG_TMP, TCG_REG_TMP, base);
|
|
|
|
base = TCG_REG_TMP;
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
tcg_out_op_rrs(s, op, val, base, offset);
|
|
|
|
}
|
|
|
|
|
2021-02-01 20:58:02 +03:00
|
|
|
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg val, TCGReg base,
|
|
|
|
intptr_t offset)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_out_ldst(s, INDEX_op_ld_i32, val, base, offset);
|
2021-02-01 20:58:02 +03:00
|
|
|
break;
|
2011-10-05 22:03:02 +04:00
|
|
|
#if TCG_TARGET_REG_BITS == 64
|
2021-02-01 20:58:02 +03:00
|
|
|
case TCG_TYPE_I64:
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_out_ldst(s, INDEX_op_ld_i64, val, base, offset);
|
2021-02-01 20:58:02 +03:00
|
|
|
break;
|
2011-10-05 22:03:02 +04:00
|
|
|
#endif
|
2021-02-01 20:58:02 +03:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-16 20:48:18 +03:00
|
|
|
static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
2021-02-01 21:45:41 +03:00
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
|
|
|
tcg_out_op_rr(s, INDEX_op_mov_i32, ret, arg);
|
|
|
|
break;
|
|
|
|
#if TCG_TARGET_REG_BITS == 64
|
|
|
|
case TCG_TYPE_I64:
|
|
|
|
tcg_out_op_rr(s, INDEX_op_mov_i64, ret, arg);
|
|
|
|
break;
|
2011-10-05 22:03:02 +04:00
|
|
|
#endif
|
2021-02-01 21:45:41 +03:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2019-03-16 20:48:18 +03:00
|
|
|
return true;
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_movi(TCGContext *s, TCGType type,
|
2021-02-01 22:57:43 +03:00
|
|
|
TCGReg ret, tcg_target_long arg)
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
2021-02-01 22:57:43 +03:00
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
2011-10-05 22:03:02 +04:00
|
|
|
#if TCG_TARGET_REG_BITS == 64
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
arg = (int32_t)arg;
|
|
|
|
/* fall through */
|
2021-02-01 22:57:43 +03:00
|
|
|
case TCG_TYPE_I64:
|
2011-10-05 22:03:02 +04:00
|
|
|
#endif
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
break;
|
2021-02-01 22:57:43 +03:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
|
|
|
|
if (arg == sextract32(arg, 0, 20)) {
|
|
|
|
tcg_out_op_ri(s, INDEX_op_tci_movi, ret, arg);
|
|
|
|
} else {
|
|
|
|
tcg_insn_unit insn = 0;
|
|
|
|
|
|
|
|
new_pool_label(s, arg, 20, s->code_ptr, 0);
|
|
|
|
insn = deposit32(insn, 0, 8, INDEX_op_tci_movl);
|
|
|
|
insn = deposit32(insn, 8, 4, ret);
|
|
|
|
tcg_out32(s, insn);
|
|
|
|
}
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
|
2023-04-05 21:17:01 +03:00
|
|
|
static void tcg_out_ext8s(TCGContext *s, TCGType type, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext8s_i32);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext8s_i32, rd, rs);
|
|
|
|
break;
|
|
|
|
#if TCG_TARGET_REG_BITS == 64
|
|
|
|
case TCG_TYPE_I64:
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext8s_i64);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext8s_i64, rd, rs);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-05 23:26:51 +03:00
|
|
|
static void tcg_out_ext8u(TCGContext *s, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
if (TCG_TARGET_REG_BITS == 64) {
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext8u_i64);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext8u_i64, rd, rs);
|
|
|
|
} else {
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext8u_i32);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext8u_i32, rd, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-06 00:49:59 +03:00
|
|
|
static void tcg_out_ext16s(TCGContext *s, TCGType type, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext16s_i32);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext16s_i32, rd, rs);
|
|
|
|
break;
|
|
|
|
#if TCG_TARGET_REG_BITS == 64
|
|
|
|
case TCG_TYPE_I64:
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext16s_i64);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext16s_i64, rd, rs);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-06 02:25:22 +03:00
|
|
|
static void tcg_out_ext16u(TCGContext *s, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
if (TCG_TARGET_REG_BITS == 64) {
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext16u_i64);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext16u_i64, rd, rs);
|
|
|
|
} else {
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext16u_i32);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext16u_i32, rd, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-06 03:50:09 +03:00
|
|
|
static void tcg_out_ext32s(TCGContext *s, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(TCG_TARGET_REG_BITS == 64);
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext32s_i64);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext32s_i64, rd, rs);
|
|
|
|
}
|
|
|
|
|
2023-04-06 04:07:05 +03:00
|
|
|
static void tcg_out_ext32u(TCGContext *s, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(TCG_TARGET_REG_BITS == 64);
|
|
|
|
tcg_debug_assert(TCG_TARGET_HAS_ext32u_i64);
|
|
|
|
tcg_out_op_rr(s, INDEX_op_ext32u_i64, rd, rs);
|
|
|
|
}
|
|
|
|
|
2023-04-06 04:30:56 +03:00
|
|
|
static void tcg_out_exts_i32_i64(TCGContext *s, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
tcg_out_ext32s(s, rd, rs);
|
|
|
|
}
|
|
|
|
|
2023-04-06 04:56:28 +03:00
|
|
|
static void tcg_out_extu_i32_i64(TCGContext *s, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
tcg_out_ext32u(s, rd, rs);
|
|
|
|
}
|
|
|
|
|
2023-04-06 05:58:35 +03:00
|
|
|
static void tcg_out_extrl_i64_i32(TCGContext *s, TCGReg rd, TCGReg rs)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(TCG_TARGET_REG_BITS == 64);
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, rd, rs);
|
|
|
|
}
|
|
|
|
|
2023-04-06 07:39:54 +03:00
|
|
|
static bool tcg_out_xchg(TCGContext *s, TCGType type, TCGReg r1, TCGReg r2)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:28:04 +03:00
|
|
|
static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs,
|
|
|
|
tcg_target_long imm)
|
|
|
|
{
|
|
|
|
/* This function is only used for passing structs by reference. */
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
2021-01-31 01:24:25 +03:00
|
|
|
static void tcg_out_call(TCGContext *s, const tcg_insn_unit *func,
|
2022-10-18 10:51:41 +03:00
|
|
|
const TCGHelperInfo *info)
|
2014-04-29 00:21:25 +04:00
|
|
|
{
|
2022-10-18 10:51:41 +03:00
|
|
|
ffi_cif *cif = info->cif;
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_insn_unit insn = 0;
|
2021-01-31 01:24:25 +03:00
|
|
|
uint8_t which;
|
|
|
|
|
|
|
|
if (cif->rtype == &ffi_type_void) {
|
|
|
|
which = 0;
|
|
|
|
} else {
|
2022-10-21 03:47:54 +03:00
|
|
|
tcg_debug_assert(cif->rtype->size == 4 ||
|
|
|
|
cif->rtype->size == 8 ||
|
|
|
|
cif->rtype->size == 16);
|
|
|
|
which = ctz32(cif->rtype->size) - 1;
|
2021-01-31 01:24:25 +03:00
|
|
|
}
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
new_pool_l2(s, 20, s->code_ptr, 0, (uintptr_t)func, (uintptr_t)cif);
|
|
|
|
insn = deposit32(insn, 0, 8, INDEX_op_call);
|
|
|
|
insn = deposit32(insn, 8, 4, which);
|
|
|
|
tcg_out32(s, insn);
|
2014-04-29 00:21:25 +04:00
|
|
|
}
|
|
|
|
|
2021-02-19 02:28:36 +03:00
|
|
|
#if TCG_TARGET_REG_BITS == 64
|
|
|
|
# define CASE_32_64(x) \
|
|
|
|
case glue(glue(INDEX_op_, x), _i64): \
|
|
|
|
case glue(glue(INDEX_op_, x), _i32):
|
|
|
|
# define CASE_64(x) \
|
|
|
|
case glue(glue(INDEX_op_, x), _i64):
|
|
|
|
#else
|
|
|
|
# define CASE_32_64(x) \
|
|
|
|
case glue(glue(INDEX_op_, x), _i32):
|
|
|
|
# define CASE_64(x)
|
|
|
|
#endif
|
|
|
|
|
2022-11-26 23:42:06 +03:00
|
|
|
static void tcg_out_exit_tb(TCGContext *s, uintptr_t arg)
|
|
|
|
{
|
|
|
|
tcg_out_op_p(s, INDEX_op_exit_tb, (void *)arg);
|
|
|
|
}
|
|
|
|
|
2022-11-27 04:14:05 +03:00
|
|
|
static void tcg_out_goto_tb(TCGContext *s, int which)
|
|
|
|
{
|
|
|
|
/* indirect jump method. */
|
|
|
|
tcg_out_op_p(s, INDEX_op_goto_tb, (void *)get_jmp_target_addr(s, which));
|
|
|
|
set_jmp_reset_offset(s, which);
|
|
|
|
}
|
|
|
|
|
2022-12-06 01:43:18 +03:00
|
|
|
void tb_target_set_jmp_target(const TranslationBlock *tb, int n,
|
|
|
|
uintptr_t jmp_rx, uintptr_t jmp_rw)
|
|
|
|
{
|
|
|
|
/* Always indirect, nothing to do */
|
|
|
|
}
|
|
|
|
|
2021-03-12 15:14:18 +03:00
|
|
|
static void tcg_out_op(TCGContext *s, TCGOpcode opc,
|
|
|
|
const TCGArg args[TCG_MAX_OP_ARGS],
|
|
|
|
const int const_args[TCG_MAX_OP_ARGS])
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
2021-06-13 22:34:30 +03:00
|
|
|
TCGOpcode exts;
|
|
|
|
|
2011-10-05 22:03:02 +04:00
|
|
|
switch (opc) {
|
2021-02-02 22:40:22 +03:00
|
|
|
case INDEX_op_goto_ptr:
|
|
|
|
tcg_out_op_r(s, opc, args[0]);
|
|
|
|
break;
|
|
|
|
|
2011-10-05 22:03:02 +04:00
|
|
|
case INDEX_op_br:
|
2021-02-01 21:36:39 +03:00
|
|
|
tcg_out_op_l(s, opc, arg_label(args[0]));
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:39 +03:00
|
|
|
|
|
|
|
CASE_32_64(setcond)
|
2021-02-01 21:52:20 +03:00
|
|
|
tcg_out_op_rrrc(s, opc, args[0], args[1], args[2], args[3]);
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:39 +03:00
|
|
|
|
2021-02-03 03:15:45 +03:00
|
|
|
CASE_32_64(movcond)
|
2011-10-05 22:03:02 +04:00
|
|
|
case INDEX_op_setcond2_i32:
|
2021-02-01 21:54:54 +03:00
|
|
|
tcg_out_op_rrrrrc(s, opc, args[0], args[1], args[2],
|
|
|
|
args[3], args[4], args[5]);
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:40 +03:00
|
|
|
|
|
|
|
CASE_32_64(ld8u)
|
|
|
|
CASE_32_64(ld8s)
|
|
|
|
CASE_32_64(ld16u)
|
|
|
|
CASE_32_64(ld16s)
|
2011-10-05 22:03:02 +04:00
|
|
|
case INDEX_op_ld_i32:
|
2021-02-19 02:28:40 +03:00
|
|
|
CASE_64(ld32u)
|
|
|
|
CASE_64(ld32s)
|
|
|
|
CASE_64(ld)
|
|
|
|
CASE_32_64(st8)
|
|
|
|
CASE_32_64(st16)
|
2011-10-05 22:03:02 +04:00
|
|
|
case INDEX_op_st_i32:
|
2021-02-19 02:28:40 +03:00
|
|
|
CASE_64(st32)
|
|
|
|
CASE_64(st)
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_out_ldst(s, opc, args[0], args[1], args[2]);
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:36 +03:00
|
|
|
|
|
|
|
CASE_32_64(add)
|
|
|
|
CASE_32_64(sub)
|
|
|
|
CASE_32_64(mul)
|
|
|
|
CASE_32_64(and)
|
|
|
|
CASE_32_64(or)
|
|
|
|
CASE_32_64(xor)
|
|
|
|
CASE_32_64(andc) /* Optional (TCG_TARGET_HAS_andc_*). */
|
|
|
|
CASE_32_64(orc) /* Optional (TCG_TARGET_HAS_orc_*). */
|
|
|
|
CASE_32_64(eqv) /* Optional (TCG_TARGET_HAS_eqv_*). */
|
|
|
|
CASE_32_64(nand) /* Optional (TCG_TARGET_HAS_nand_*). */
|
|
|
|
CASE_32_64(nor) /* Optional (TCG_TARGET_HAS_nor_*). */
|
|
|
|
CASE_32_64(shl)
|
|
|
|
CASE_32_64(shr)
|
|
|
|
CASE_32_64(sar)
|
|
|
|
CASE_32_64(rotl) /* Optional (TCG_TARGET_HAS_rot_*). */
|
|
|
|
CASE_32_64(rotr) /* Optional (TCG_TARGET_HAS_rot_*). */
|
|
|
|
CASE_32_64(div) /* Optional (TCG_TARGET_HAS_div_*). */
|
|
|
|
CASE_32_64(divu) /* Optional (TCG_TARGET_HAS_div_*). */
|
|
|
|
CASE_32_64(rem) /* Optional (TCG_TARGET_HAS_div_*). */
|
|
|
|
CASE_32_64(remu) /* Optional (TCG_TARGET_HAS_div_*). */
|
2021-02-03 04:01:57 +03:00
|
|
|
CASE_32_64(clz) /* Optional (TCG_TARGET_HAS_clz_*). */
|
|
|
|
CASE_32_64(ctz) /* Optional (TCG_TARGET_HAS_ctz_*). */
|
2021-02-01 21:49:18 +03:00
|
|
|
tcg_out_op_rrr(s, opc, args[0], args[1], args[2]);
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:38 +03:00
|
|
|
|
|
|
|
CASE_32_64(deposit) /* Optional (TCG_TARGET_HAS_deposit_*). */
|
2021-01-30 11:36:40 +03:00
|
|
|
{
|
|
|
|
TCGArg pos = args[3], len = args[4];
|
|
|
|
TCGArg max = opc == INDEX_op_deposit_i32 ? 32 : 64;
|
|
|
|
|
|
|
|
tcg_debug_assert(pos < max);
|
|
|
|
tcg_debug_assert(pos + len <= max);
|
|
|
|
|
2021-02-01 21:59:56 +03:00
|
|
|
tcg_out_op_rrrbb(s, opc, args[0], args[1], args[2], pos, len);
|
2021-01-30 11:36:40 +03:00
|
|
|
}
|
2021-02-03 03:48:48 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
CASE_32_64(extract) /* Optional (TCG_TARGET_HAS_extract_*). */
|
|
|
|
CASE_32_64(sextract) /* Optional (TCG_TARGET_HAS_sextract_*). */
|
|
|
|
{
|
|
|
|
TCGArg pos = args[2], len = args[3];
|
|
|
|
TCGArg max = tcg_op_defs[opc].flags & TCG_OPF_64BIT ? 64 : 32;
|
|
|
|
|
|
|
|
tcg_debug_assert(pos < max);
|
|
|
|
tcg_debug_assert(pos + len <= max);
|
|
|
|
|
|
|
|
tcg_out_op_rrbb(s, opc, args[0], args[1], pos, len);
|
|
|
|
}
|
2012-09-19 00:52:14 +04:00
|
|
|
break;
|
2011-10-05 22:03:02 +04:00
|
|
|
|
2021-02-19 02:28:39 +03:00
|
|
|
CASE_32_64(brcond)
|
2021-02-01 22:41:20 +03:00
|
|
|
tcg_out_op_rrrc(s, (opc == INDEX_op_brcond_i32
|
|
|
|
? INDEX_op_setcond_i32 : INDEX_op_setcond_i64),
|
|
|
|
TCG_REG_TMP, args[0], args[1], args[2]);
|
|
|
|
tcg_out_op_rl(s, opc, TCG_REG_TMP, arg_label(args[3]));
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:37 +03:00
|
|
|
|
|
|
|
CASE_32_64(neg) /* Optional (TCG_TARGET_HAS_neg_*). */
|
|
|
|
CASE_32_64(not) /* Optional (TCG_TARGET_HAS_not_*). */
|
2021-02-03 04:01:57 +03:00
|
|
|
CASE_32_64(ctpop) /* Optional (TCG_TARGET_HAS_ctpop_*). */
|
2021-06-13 22:34:30 +03:00
|
|
|
case INDEX_op_bswap32_i32: /* Optional (TCG_TARGET_HAS_bswap32_i32). */
|
|
|
|
case INDEX_op_bswap64_i64: /* Optional (TCG_TARGET_HAS_bswap64_i64). */
|
2021-02-01 21:45:41 +03:00
|
|
|
tcg_out_op_rr(s, opc, args[0], args[1]);
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:36 +03:00
|
|
|
|
2021-06-13 22:34:30 +03:00
|
|
|
case INDEX_op_bswap16_i32: /* Optional (TCG_TARGET_HAS_bswap16_i32). */
|
|
|
|
exts = INDEX_op_ext16s_i32;
|
|
|
|
goto do_bswap;
|
|
|
|
case INDEX_op_bswap16_i64: /* Optional (TCG_TARGET_HAS_bswap16_i64). */
|
|
|
|
exts = INDEX_op_ext16s_i64;
|
|
|
|
goto do_bswap;
|
|
|
|
case INDEX_op_bswap32_i64: /* Optional (TCG_TARGET_HAS_bswap32_i64). */
|
|
|
|
exts = INDEX_op_ext32s_i64;
|
|
|
|
do_bswap:
|
|
|
|
/* The base tci bswaps zero-extend, and ignore high bits. */
|
|
|
|
tcg_out_op_rr(s, opc, args[0], args[1]);
|
|
|
|
if (args[2] & TCG_BSWAP_OS) {
|
|
|
|
tcg_out_op_rr(s, exts, args[0], args[0]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-02-03 04:40:12 +03:00
|
|
|
CASE_32_64(add2)
|
|
|
|
CASE_32_64(sub2)
|
2021-02-01 22:06:06 +03:00
|
|
|
tcg_out_op_rrrrrr(s, opc, args[0], args[1], args[2],
|
|
|
|
args[3], args[4], args[5]);
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-03 04:40:12 +03:00
|
|
|
|
|
|
|
#if TCG_TARGET_REG_BITS == 32
|
2011-10-05 22:03:02 +04:00
|
|
|
case INDEX_op_brcond2_i32:
|
2021-02-01 22:41:20 +03:00
|
|
|
tcg_out_op_rrrrrc(s, INDEX_op_setcond2_i32, TCG_REG_TMP,
|
|
|
|
args[0], args[1], args[2], args[3], args[4]);
|
|
|
|
tcg_out_op_rl(s, INDEX_op_brcond_i32, TCG_REG_TMP, arg_label(args[5]));
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-03 04:21:27 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
CASE_32_64(mulu2)
|
|
|
|
CASE_32_64(muls2)
|
2021-02-01 22:07:31 +03:00
|
|
|
tcg_out_op_rrrr(s, opc, args[0], args[1], args[2], args[3]);
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:39 +03:00
|
|
|
|
2014-05-27 07:59:16 +04:00
|
|
|
case INDEX_op_qemu_ld_i32:
|
|
|
|
case INDEX_op_qemu_st_i32:
|
2021-02-01 22:16:33 +03:00
|
|
|
if (TARGET_LONG_BITS <= TCG_TARGET_REG_BITS) {
|
|
|
|
tcg_out_op_rrm(s, opc, args[0], args[1], args[2]);
|
|
|
|
} else {
|
|
|
|
tcg_out_op_rrrm(s, opc, args[0], args[1], args[2], args[3]);
|
2014-05-27 07:59:16 +04:00
|
|
|
}
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:40 +03:00
|
|
|
|
|
|
|
case INDEX_op_qemu_ld_i64:
|
2014-05-27 07:59:16 +04:00
|
|
|
case INDEX_op_qemu_st_i64:
|
2021-02-01 22:16:33 +03:00
|
|
|
if (TCG_TARGET_REG_BITS == 64) {
|
|
|
|
tcg_out_op_rrm(s, opc, args[0], args[1], args[2]);
|
|
|
|
} else if (TARGET_LONG_BITS <= TCG_TARGET_REG_BITS) {
|
|
|
|
tcg_out_op_rrrm(s, opc, args[0], args[1], args[2], args[3]);
|
|
|
|
} else {
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_TMP, args[4]);
|
|
|
|
tcg_out_op_rrrrr(s, opc, args[0], args[1],
|
|
|
|
args[2], args[3], TCG_REG_TMP);
|
2014-05-27 07:59:16 +04:00
|
|
|
}
|
2011-10-05 22:03:02 +04:00
|
|
|
break;
|
2021-02-19 02:28:36 +03:00
|
|
|
|
2016-07-14 23:20:22 +03:00
|
|
|
case INDEX_op_mb:
|
2021-02-01 22:20:19 +03:00
|
|
|
tcg_out_op_v(s, opc);
|
2016-07-14 23:20:22 +03:00
|
|
|
break;
|
2021-02-19 02:28:36 +03:00
|
|
|
|
2014-04-25 23:19:33 +04:00
|
|
|
case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */
|
|
|
|
case INDEX_op_mov_i64:
|
|
|
|
case INDEX_op_call: /* Always emitted via tcg_out_call. */
|
2022-11-26 23:42:06 +03:00
|
|
|
case INDEX_op_exit_tb: /* Always emitted via tcg_out_exit_tb. */
|
2022-11-27 04:14:05 +03:00
|
|
|
case INDEX_op_goto_tb: /* Always emitted via tcg_out_goto_tb. */
|
2023-04-05 21:17:01 +03:00
|
|
|
case INDEX_op_ext8s_i32: /* Always emitted via tcg_reg_alloc_op. */
|
|
|
|
case INDEX_op_ext8s_i64:
|
2023-04-05 23:26:51 +03:00
|
|
|
case INDEX_op_ext8u_i32:
|
|
|
|
case INDEX_op_ext8u_i64:
|
2023-04-06 00:49:59 +03:00
|
|
|
case INDEX_op_ext16s_i32:
|
|
|
|
case INDEX_op_ext16s_i64:
|
2023-04-06 02:25:22 +03:00
|
|
|
case INDEX_op_ext16u_i32:
|
|
|
|
case INDEX_op_ext16u_i64:
|
2023-04-06 03:50:09 +03:00
|
|
|
case INDEX_op_ext32s_i64:
|
2023-04-06 04:07:05 +03:00
|
|
|
case INDEX_op_ext32u_i64:
|
2023-04-06 04:30:56 +03:00
|
|
|
case INDEX_op_ext_i32_i64:
|
2023-04-06 04:56:28 +03:00
|
|
|
case INDEX_op_extu_i32_i64:
|
2023-04-06 05:58:35 +03:00
|
|
|
case INDEX_op_extrl_i64_i32:
|
2011-10-05 22:03:02 +04:00
|
|
|
default:
|
2023-04-05 22:09:14 +03:00
|
|
|
g_assert_not_reached();
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-01 20:58:02 +03:00
|
|
|
static void tcg_out_st(TCGContext *s, TCGType type, TCGReg val, TCGReg base,
|
|
|
|
intptr_t offset)
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
2021-02-01 20:58:02 +03:00
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
2022-02-26 04:44:55 +03:00
|
|
|
tcg_out_ldst(s, INDEX_op_st_i32, val, base, offset);
|
2021-02-01 20:58:02 +03:00
|
|
|
break;
|
2011-10-05 22:03:02 +04:00
|
|
|
#if TCG_TARGET_REG_BITS == 64
|
2021-02-01 20:58:02 +03:00
|
|
|
case TCG_TYPE_I64:
|
2022-02-26 04:44:55 +03:00
|
|
|
tcg_out_ldst(s, INDEX_op_st_i64, val, base, offset);
|
2021-02-01 20:58:02 +03:00
|
|
|
break;
|
2011-10-05 22:03:02 +04:00
|
|
|
#endif
|
2021-02-01 20:58:02 +03:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 08:59:13 +03:00
|
|
|
static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val,
|
|
|
|
TCGReg base, intptr_t ofs)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-10-05 22:03:02 +04:00
|
|
|
/* Test if a constant matches the constraint. */
|
2021-05-04 02:47:37 +03:00
|
|
|
static bool tcg_target_const_match(int64_t val, TCGType type, int ct)
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
2021-05-04 02:47:37 +03:00
|
|
|
return ct & TCG_CT_CONST;
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
|
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-02-02 10:27:41 +03:00
|
|
|
static void tcg_out_nop_fill(tcg_insn_unit *p, int count)
|
|
|
|
{
|
|
|
|
memset(p, 0, sizeof(*p) * count);
|
|
|
|
}
|
|
|
|
|
2011-10-05 22:03:02 +04:00
|
|
|
static void tcg_target_init(TCGContext *s)
|
|
|
|
{
|
|
|
|
/* The current code uses uint8_t for tcg operations. */
|
2016-04-21 11:48:49 +03:00
|
|
|
tcg_debug_assert(tcg_op_defs_max <= UINT8_MAX);
|
2011-10-05 22:03:02 +04:00
|
|
|
|
|
|
|
/* Registers available for 32 bit operations. */
|
2017-09-11 22:44:30 +03:00
|
|
|
tcg_target_available_regs[TCG_TYPE_I32] = BIT(TCG_TARGET_NB_REGS) - 1;
|
2011-10-05 22:03:02 +04:00
|
|
|
/* Registers available for 64 bit operations. */
|
2017-09-11 22:44:30 +03:00
|
|
|
tcg_target_available_regs[TCG_TYPE_I64] = BIT(TCG_TARGET_NB_REGS) - 1;
|
2021-01-29 23:00:42 +03:00
|
|
|
/*
|
|
|
|
* The interpreter "registers" are in the local stack frame and
|
|
|
|
* cannot be clobbered by the called helper functions. However,
|
|
|
|
* the interpreter assumes a 64-bit return value and assigns to
|
|
|
|
* the return value registers.
|
|
|
|
*/
|
|
|
|
tcg_target_call_clobber_regs =
|
|
|
|
MAKE_64BIT_MASK(TCG_REG_R0, 64 / TCG_TARGET_REG_BITS);
|
2013-03-28 09:37:55 +04:00
|
|
|
|
2017-09-11 21:25:55 +03:00
|
|
|
s->reserved_regs = 0;
|
2021-02-01 12:26:14 +03:00
|
|
|
tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP);
|
2011-10-05 22:03:02 +04:00
|
|
|
tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
|
2013-03-28 09:37:55 +04:00
|
|
|
|
2021-01-31 01:24:25 +03:00
|
|
|
/* The call arguments come first, followed by the temp storage. */
|
|
|
|
tcg_set_frame(s, TCG_REG_CALL_STACK, TCG_STATIC_CALL_ARGS_SIZE,
|
|
|
|
TCG_STATIC_FRAME_SIZE);
|
2011-10-05 22:03:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate global QEMU prologue and epilogue code. */
|
2013-03-28 09:37:54 +04:00
|
|
|
static inline void tcg_target_qemu_prologue(TCGContext *s)
|
2011-10-05 22:03:02 +04:00
|
|
|
{
|
|
|
|
}
|