Revision | 53c89efd02cef626040165cc8f06b5cf2c15355d (tree) |
---|---|
Time | 2017-09-08 03:57:35 |
Author | Richard Henderson <rth@twid...> |
Commiter | Richard Henderson |
tcg/ppc: Use constant pool for movi
Signed-off-by: Richard Henderson <rth@twiddle.net>
@@ -132,5 +132,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); | ||
132 | 132 | #ifdef CONFIG_SOFTMMU |
133 | 133 | #define TCG_TARGET_NEED_LDST_LABELS |
134 | 134 | #endif |
135 | +#define TCG_TARGET_NEED_POOL_LABELS | |
135 | 136 | |
136 | 137 | #endif |
@@ -22,6 +22,9 @@ | ||
22 | 22 | * THE SOFTWARE. |
23 | 23 | */ |
24 | 24 | |
25 | +#include "elf.h" | |
26 | +#include "tcg-pool.inc.c" | |
27 | + | |
25 | 28 | #if defined _CALL_DARWIN || defined __APPLE__ |
26 | 29 | #define TCG_TARGET_CALL_DARWIN |
27 | 30 | #endif |
@@ -58,8 +61,6 @@ | ||
58 | 61 | |
59 | 62 | static tcg_insn_unit *tb_ret_addr; |
60 | 63 | |
61 | -#include "elf.h" | |
62 | - | |
63 | 64 | bool have_isa_2_06; |
64 | 65 | bool have_isa_3_00; |
65 | 66 |
@@ -224,9 +225,12 @@ static inline void tcg_out_bc_noaddr(TCGContext *s, int insn) | ||
224 | 225 | static void patch_reloc(tcg_insn_unit *code_ptr, int type, |
225 | 226 | intptr_t value, intptr_t addend) |
226 | 227 | { |
227 | - tcg_insn_unit *target = (tcg_insn_unit *)value; | |
228 | + tcg_insn_unit *target; | |
229 | + tcg_insn_unit old; | |
230 | + | |
231 | + value += addend; | |
232 | + target = (tcg_insn_unit *)value; | |
228 | 233 | |
229 | - tcg_debug_assert(addend == 0); | |
230 | 234 | switch (type) { |
231 | 235 | case R_PPC_REL14: |
232 | 236 | reloc_pc14(code_ptr, target); |
@@ -234,6 +238,12 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, | ||
234 | 238 | case R_PPC_REL24: |
235 | 239 | reloc_pc24(code_ptr, target); |
236 | 240 | break; |
241 | + case R_PPC_ADDR16: | |
242 | + assert(value == (int16_t)value); | |
243 | + old = *code_ptr; | |
244 | + old = deposit32(old, 0, 16, value); | |
245 | + *code_ptr = old; | |
246 | + break; | |
237 | 247 | default: |
238 | 248 | tcg_abort(); |
239 | 249 | } |
@@ -676,6 +686,14 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, | ||
676 | 686 | return; |
677 | 687 | } |
678 | 688 | |
689 | + /* Use the constant pool, if possible. */ | |
690 | + if (!in_prologue && USE_REG_TB) { | |
691 | + new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, | |
692 | + -(intptr_t)s->code_gen_ptr); | |
693 | + tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); | |
694 | + return; | |
695 | + } | |
696 | + | |
679 | 697 | tmp = arg >> 31 >> 1; |
680 | 698 | tcg_out_movi(s, TCG_TYPE_I32, ret, tmp); |
681 | 699 | if (tmp) { |
@@ -1858,6 +1876,14 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) | ||
1858 | 1876 | #endif |
1859 | 1877 | } |
1860 | 1878 | |
1879 | +static void tcg_out_nop_fill(tcg_insn_unit *p, int count) | |
1880 | +{ | |
1881 | + int i; | |
1882 | + for (i = 0; i < count; ++i) { | |
1883 | + p[i] = NOP; | |
1884 | + } | |
1885 | +} | |
1886 | + | |
1861 | 1887 | /* Parameters for function call generation, used in tcg.c. */ |
1862 | 1888 | #define TCG_TARGET_STACK_ALIGN 16 |
1863 | 1889 | #define TCG_TARGET_EXTEND_ARGS 1 |