From 03271524b66dfc979cc0412bdb5d8d617426b644 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 14 Aug 2013 14:35:56 -0700 Subject: tcg: Add muluh and mulsh opcodes Use them in places where mulu2 and muls2 are used. Optimize mulx2 with dead low part to mulxh. Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tcg/mips') diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index a438950bc1..6cb7c2f3c4 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -89,6 +89,8 @@ typedef enum { #define TCG_TARGET_HAS_eqv_i32 0 #define TCG_TARGET_HAS_nand_i32 0 #define TCG_TARGET_HAS_muls2_i32 1 +#define TCG_TARGET_HAS_muluh_i32 0 +#define TCG_TARGET_HAS_mulsh_i32 0 /* optional instructions only implemented on MIPS4, MIPS32 and Loongson 2 */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >= 1)) || \ -- cgit v1.2.1 From 3c9a8f17560794ad23889318cc42894c6e592cc3 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 14 Aug 2013 14:41:43 -0700 Subject: tcg-mips: Implement mulsh, muluh With the optimization in tcg_liveness_analysis, we can avoid the MFLO when it is unused. Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 10 ++++++++++ tcg/mips/tcg-target.h | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'tcg/mips') diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 793532ec95..31cd514167 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -1423,6 +1423,14 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_reg(s, OPC_MFLO, args[0], 0, 0); tcg_out_opc_reg(s, OPC_MFHI, args[1], 0, 0); break; + case INDEX_op_mulsh_i32: + tcg_out_opc_reg(s, OPC_MULT, 0, args[1], args[2]); + tcg_out_opc_reg(s, OPC_MFHI, args[0], 0, 0); + break; + case INDEX_op_muluh_i32: + tcg_out_opc_reg(s, OPC_MULTU, 0, args[1], args[2]); + tcg_out_opc_reg(s, OPC_MFHI, args[0], 0, 0); + break; case INDEX_op_div_i32: tcg_out_opc_reg(s, OPC_DIV, 0, args[1], args[2]); tcg_out_opc_reg(s, OPC_MFLO, args[0], 0, 0); @@ -1602,6 +1610,8 @@ static const TCGTargetOpDef mips_op_defs[] = { { INDEX_op_mul_i32, { "r", "rZ", "rZ" } }, { INDEX_op_muls2_i32, { "r", "r", "rZ", "rZ" } }, { INDEX_op_mulu2_i32, { "r", "r", "rZ", "rZ" } }, + { INDEX_op_mulsh_i32, { "r", "rZ", "rZ" } }, + { INDEX_op_muluh_i32, { "r", "rZ", "rZ" } }, { INDEX_op_div_i32, { "r", "rZ", "rZ" } }, { INDEX_op_divu_i32, { "r", "rZ", "rZ" } }, { INDEX_op_rem_i32, { "r", "rZ", "rZ" } }, diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 6cb7c2f3c4..7ef79e0879 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -89,8 +89,8 @@ typedef enum { #define TCG_TARGET_HAS_eqv_i32 0 #define TCG_TARGET_HAS_nand_i32 0 #define TCG_TARGET_HAS_muls2_i32 1 -#define TCG_TARGET_HAS_muluh_i32 0 -#define TCG_TARGET_HAS_mulsh_i32 0 +#define TCG_TARGET_HAS_muluh_i32 1 +#define TCG_TARGET_HAS_mulsh_i32 1 /* optional instructions only implemented on MIPS4, MIPS32 and Loongson 2 */ #if (defined(__mips_isa_rev) && (__mips_isa_rev >= 1)) || \ -- cgit v1.2.1 From b93949ef6a5dea2b22987f2aa3028068e751a7e4 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 20 Aug 2013 14:22:50 -0700 Subject: tcg: Change flush_icache_range arguments to uintptr_t Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tcg/mips') diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 7ef79e0879..a820328093 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -127,8 +127,7 @@ typedef enum { #include #endif -static inline void flush_icache_range(tcg_target_ulong start, - tcg_target_ulong stop) +static inline void flush_icache_range(uintptr_t start, uintptr_t stop) { cacheflush ((void *)start, stop-start, ICACHE); } -- cgit v1.2.1 From 2ba7fae29ec63acf2ce77d20d4146fa224bf2338 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 20 Aug 2013 15:30:10 -0700 Subject: tcg: Change relocation offsets to intptr_t Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tcg/mips') diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 31cd514167..f7ea140177 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -108,33 +108,33 @@ static const TCGReg tcg_target_call_oarg_regs[2] = { static uint8_t *tb_ret_addr; -static inline uint32_t reloc_lo16_val (void *pc, tcg_target_long target) +static inline uint32_t reloc_lo16_val(void *pc, intptr_t target) { return target & 0xffff; } -static inline void reloc_lo16 (void *pc, tcg_target_long target) +static inline void reloc_lo16(void *pc, intptr_t target) { *(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff) | reloc_lo16_val(pc, target); } -static inline uint32_t reloc_hi16_val (void *pc, tcg_target_long target) +static inline uint32_t reloc_hi16_val(void *pc, intptr_t target) { return (target >> 16) & 0xffff; } -static inline void reloc_hi16 (void *pc, tcg_target_long target) +static inline void reloc_hi16(void *pc, intptr_t target) { *(uint32_t *) pc = (*(uint32_t *) pc & ~0xffff) | reloc_hi16_val(pc, target); } -static inline uint32_t reloc_pc16_val (void *pc, tcg_target_long target) +static inline uint32_t reloc_pc16_val(void *pc, intptr_t target) { int32_t disp; - disp = target - (tcg_target_long) pc - 4; + disp = target - (intptr_t)pc - 4; if (disp != (disp << 14) >> 14) { tcg_abort (); } @@ -157,14 +157,14 @@ static inline uint32_t reloc_26_val (void *pc, tcg_target_long target) return (target >> 2) & 0x3ffffff; } -static inline void reloc_pc26 (void *pc, tcg_target_long target) +static inline void reloc_pc26(void *pc, intptr_t target) { *(uint32_t *) pc = (*(uint32_t *) pc & ~0x3ffffff) | reloc_26_val(pc, target); } static void patch_reloc(uint8_t *code_ptr, int type, - tcg_target_long value, tcg_target_long addend) + intptr_t value, intptr_t addend) { value += addend; switch(type) { -- cgit v1.2.1 From a05b5b9be0fec96c89e00abaa964be7ce9e661ac Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 20 Aug 2013 17:07:26 -0700 Subject: tcg: Change tcg_out_ld/st offset to intptr_t Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tcg/mips') diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index f7ea140177..6bf7dba82d 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -514,13 +514,13 @@ static inline void tcg_out_ldst(TCGContext *s, int opc, TCGArg arg, } static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, - TCGReg arg1, tcg_target_long arg2) + TCGReg arg1, intptr_t arg2) { tcg_out_ldst(s, OPC_LW, arg, arg1, arg2); } static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, - TCGReg arg1, tcg_target_long arg2) + TCGReg arg1, intptr_t arg2) { tcg_out_ldst(s, OPC_SW, arg, arg1, arg2); } -- cgit v1.2.1 From e58eb534133f8ccaa957a33a06ccdb9129f2c842 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 27 Aug 2013 13:13:44 -0700 Subject: exec: Split softmmu_defs.h The _cmmu helpers can be moved to exec-all.h. The helpers that are used from TCG will shortly need access to tcg_target_long so move their declarations into tcg.h. This requires minor include adjustments to all TCG backends. Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'tcg/mips') diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 6bf7dba82d..3c2b394753 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -919,9 +919,6 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, } #if defined(CONFIG_SOFTMMU) - -#include "exec/softmmu_defs.h" - /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ static const void * const qemu_ld_helpers[4] = { -- cgit v1.2.1