From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH 5/8] tcg-ppc64: Define TCG_TARGET_ITYPE_SIZE
Date: Fri, 28 Mar 2014 17:27:11 -0700 [thread overview]
Message-ID: <1396052834-26834-6-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1396052834-26834-1-git-send-email-rth@twiddle.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
tcg/ppc64/tcg-target.c | 46 ++++++++++++++++++++++++----------------------
tcg/ppc64/tcg-target.h | 1 +
2 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c
index 06e440f..0920cae 100644
--- a/tcg/ppc64/tcg-target.c
+++ b/tcg/ppc64/tcg-target.c
@@ -31,7 +31,7 @@
#define TCG_CT_CONST_ZERO 0x1000
#define TCG_CT_CONST_MONE 0x2000
-static uint8_t *tb_ret_addr;
+static intptr_t tb_ret_addr;
#if TARGET_LONG_BITS == 32
#define LD_ADDR LWZ
@@ -178,10 +178,9 @@ static uint32_t reloc_pc24_val(void *pc, tcg_target_long target)
return disp & 0x3fffffc;
}
-static void reloc_pc24(void *pc, tcg_target_long target)
+static void reloc_pc24(tcg_itype *pc, tcg_target_long target)
{
- *(uint32_t *)pc = (*(uint32_t *)pc & ~0x3fffffc)
- | reloc_pc24_val(pc, target);
+ *pc = (*pc & ~0x3fffffc) | reloc_pc24_val(pc, target);
}
static uint16_t reloc_pc14_val(void *pc, tcg_target_long target)
@@ -196,24 +195,24 @@ static uint16_t reloc_pc14_val(void *pc, tcg_target_long target)
return disp & 0xfffc;
}
-static void reloc_pc14(void *pc, tcg_target_long target)
+static void reloc_pc14(tcg_itype *pc, tcg_target_long target)
{
- *(uint32_t *)pc = (*(uint32_t *)pc & ~0xfffc) | reloc_pc14_val(pc, target);
+ *pc = (*pc & ~0xfffc) | reloc_pc14_val(pc, target);
}
static inline void tcg_out_b_noaddr(TCGContext *s, int insn)
{
- unsigned retrans = *(uint32_t *)s->code_ptr & 0x3fffffc;
+ unsigned retrans = *s->code_ptr & 0x3fffffc;
tcg_out32(s, insn | retrans);
}
static inline void tcg_out_bc_noaddr(TCGContext *s, int insn)
{
- unsigned retrans = *(uint32_t *)s->code_ptr & 0xfffc;
+ unsigned retrans = *s->code_ptr & 0xfffc;
tcg_out32(s, insn | retrans);
}
-static void patch_reloc(uint8_t *code_ptr, int type,
+static void patch_reloc(tcg_itype *code_ptr, int type,
intptr_t value, intptr_t addend)
{
value += addend;
@@ -938,7 +937,7 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGMemOp s_bits, TCGReg addr_reg,
helper code. */
static void add_qemu_ldst_label(TCGContext *s, bool is_ld, TCGMemOp opc,
int data_reg, int addr_reg, int mem_index,
- uint8_t *raddr, uint8_t *label_ptr)
+ tcg_itype *raddr, tcg_itype *label_ptr)
{
TCGLabelQemuLdst *label = new_ldst_label(s);
@@ -1009,7 +1008,7 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg,
uint32_t insn;
TCGMemOp s_bits = opc & MO_SIZE;
#ifdef CONFIG_SOFTMMU
- void *label_ptr;
+ tcg_itype *label_ptr;
#endif
#ifdef CONFIG_SOFTMMU
@@ -1055,7 +1054,7 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg,
TCGReg rbase;
uint32_t insn;
#ifdef CONFIG_SOFTMMU
- void *label_ptr;
+ tcg_itype *label_ptr;
#endif
#ifdef CONFIG_SOFTMMU
@@ -1115,7 +1114,8 @@ static void tcg_target_qemu_prologue(TCGContext *s)
#ifndef __APPLE__
/* First emit adhoc function descriptor */
tcg_out64(s, (uint64_t)s->code_ptr + 24); /* entry point */
- s->code_ptr += 16; /* skip TOC and environment pointer */
+ tcg_out64(s, 0); /* toc */
+ tcg_out64(s, 0); /* environment pointer */
#endif
/* Prologue */
@@ -1139,7 +1139,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
tcg_out32(s, BCCTR | BO_ALWAYS);
/* Epilogue */
- tb_ret_addr = s->code_ptr;
+ tb_ret_addr = (intptr_t)s->code_ptr;
for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) {
tcg_out32(s, LD | TAI(tcg_target_callee_save_regs[i], TCG_REG_R1,
@@ -1470,14 +1470,14 @@ static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond,
}
}
-void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr)
+void ppc_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr)
{
TCGContext s;
- unsigned long patch_size;
+ uintptr_t patch_size;
- s.code_ptr = (uint8_t *) jmp_addr;
+ s.code_ptr = (tcg_itype *)jmp_addr;
tcg_out_b(&s, 0, addr);
- patch_size = s.code_ptr - (uint8_t *) jmp_addr;
+ patch_size = (uintptr_t)s.code_ptr - jmp_addr;
flush_icache_range(jmp_addr, jmp_addr + patch_size);
}
@@ -1490,18 +1490,20 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
switch (opc) {
case INDEX_op_exit_tb:
tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_R3, args[0]);
- tcg_out_b(s, 0, (tcg_target_long)tb_ret_addr);
+ tcg_out_b(s, 0, tb_ret_addr);
break;
case INDEX_op_goto_tb:
if (s->tb_jmp_offset) {
/* Direct jump method. */
- s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
- s->code_ptr += 28;
+ s->tb_jmp_offset[args[0]]
+ = (uintptr_t)s->code_ptr - (uintptr_t)s->code_buf;
+ s->code_ptr += 7;
} else {
/* Indirect jump method. */
tcg_abort();
}
- s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf;
+ s->tb_next_offset[args[0]]
+ = (uintptr_t)s->code_ptr - (uintptr_t)s->code_buf;
break;
case INDEX_op_br:
{
diff --git a/tcg/ppc64/tcg-target.h b/tcg/ppc64/tcg-target.h
index 7ee50b6..8c55a20 100644
--- a/tcg/ppc64/tcg-target.h
+++ b/tcg/ppc64/tcg-target.h
@@ -26,6 +26,7 @@
#define TCG_TARGET_WORDS_BIGENDIAN
#define TCG_TARGET_NB_REGS 32
+#define TCG_TARGET_ITYPE_SIZE 4
typedef enum {
TCG_REG_R0 = 0,
--
1.9.0
next prev parent reply other threads:[~2014-03-29 0:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-29 0:27 [Qemu-devel] [PATCH 0/8] tcg: tidy the type of code_ptr Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 1/8] exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps Richard Henderson
2014-04-01 12:09 ` [Qemu-devel] [PATCH 1/8] exec-all.h: Use stl_p to avoid undefinedbehaviour patching x86 jumpss Alex Bennée
2014-04-01 12:18 ` Peter Maydell
2014-03-29 0:27 ` [Qemu-devel] [PATCH 2/8] tcg: Avoid stores to unaligned addresses Richard Henderson
2014-04-01 12:12 ` Alex Bennée
2014-03-29 0:27 ` [Qemu-devel] [PATCH 3/8] tcg: Avoid undefined behaviour patching code at " Richard Henderson
2014-04-01 12:13 ` [Qemu-devel] [PATCH 3/8] tcg: Avoid undefined behaviour patchingcode at unaligned addressess Alex Bennée
2014-03-29 0:27 ` [Qemu-devel] [PATCH 4/8] tcg: Define tcg_itype for code pointers Richard Henderson
2014-03-29 0:27 ` Richard Henderson [this message]
2014-03-29 0:27 ` [Qemu-devel] [PATCH 6/8] tcg-ppc: Define TCG_TARGET_ITYPE_SIZE Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 7/8] tcg-aarch64: " Richard Henderson
2014-03-29 0:27 ` [Qemu-devel] [PATCH 8/8] tcg-sparc: " Richard Henderson
2014-03-29 20:26 ` [Qemu-devel] [PATCH 0/8] tcg: tidy the type of code_ptr Peter Maydell
2014-03-30 15:31 ` Richard Henderson
2014-03-31 3:19 ` Richard Henderson
2014-04-01 12:05 ` Alex Bennée
2014-04-01 12:19 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1396052834-26834-6-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=aurelien@aurel32.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).