From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH 08/16] tcg-hppa: Use TCGMemOp within qemu_ldst routines
Date: Wed, 4 Sep 2013 14:04:57 -0700 [thread overview]
Message-ID: <1378328705-23006-9-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1378328705-23006-1-git-send-email-rth@twiddle.net>
Untested.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
tcg/hppa/tcg-target.c | 110 ++++++++++++++++++++++++--------------------------
1 file changed, 53 insertions(+), 57 deletions(-)
diff --git a/tcg/hppa/tcg-target.c b/tcg/hppa/tcg-target.c
index 236b39c..b13c2d8 100644
--- a/tcg/hppa/tcg-target.c
+++ b/tcg/hppa/tcg-target.c
@@ -935,7 +935,8 @@ static const void * const qemu_st_helpers[4] = {
return value is 0, R1 is not used. */
static int tcg_out_tlb_read(TCGContext *s, int r0, int r1, int addrlo,
- int addrhi, int s_bits, int lab_miss, int offset)
+ int addrhi, TCGMemOp s_bits, int lab_miss,
+ int offset)
{
int ret;
@@ -1020,30 +1021,27 @@ static int tcg_out_arg_reg64(TCGContext *s, int argno, TCGArg vl, TCGArg vh)
}
#endif
-static void tcg_out_qemu_ld_direct(TCGContext *s, int datalo_reg, int datahi_reg,
- int addr_reg, int addend_reg, int opc)
+static void tcg_out_qemu_ld_direct(TCGContext *s, int datalo_reg,
+ int datahi_reg, int addr_reg,
+ int addend_reg, TCGMemOp opc)
{
-#ifdef TARGET_WORDS_BIGENDIAN
- const int bswap = 0;
-#else
- const int bswap = 1;
-#endif
+ const TCGMemOp bswap = opc & MO_BSWAP;
- switch (opc) {
- case 0:
+ switch (opc & MO_SSIZE) {
+ case MO_UB:
tcg_out_ldst_index(s, datalo_reg, addr_reg, addend_reg, INSN_LDBX);
break;
- case 0 | 4:
+ case MO_SB:
tcg_out_ldst_index(s, datalo_reg, addr_reg, addend_reg, INSN_LDBX);
tcg_out_ext8s(s, datalo_reg, datalo_reg);
break;
- case 1:
+ case MO_UW:
tcg_out_ldst_index(s, datalo_reg, addr_reg, addend_reg, INSN_LDHX);
if (bswap) {
tcg_out_bswap16(s, datalo_reg, datalo_reg, 0);
}
break;
- case 1 | 4:
+ case MO_SW:
tcg_out_ldst_index(s, datalo_reg, addr_reg, addend_reg, INSN_LDHX);
if (bswap) {
tcg_out_bswap16(s, datalo_reg, datalo_reg, 1);
@@ -1051,13 +1049,13 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, int datalo_reg, int datahi_reg
tcg_out_ext16s(s, datalo_reg, datalo_reg);
}
break;
- case 2:
+ case MO_UL:
tcg_out_ldst_index(s, datalo_reg, addr_reg, addend_reg, INSN_LDWX);
if (bswap) {
tcg_out_bswap32(s, datalo_reg, datalo_reg, TCG_REG_R20);
}
break;
- case 3:
+ case MO_Q:
if (bswap) {
int t = datahi_reg;
datahi_reg = datalo_reg;
@@ -1087,11 +1085,12 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, int datalo_reg, int datahi_reg
}
}
-static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
+static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, TCGMemOp opc)
{
+ TCGMemOp s_bits = opc & MO_SIZE;
int datalo_reg = *args++;
/* Note that datahi_reg is only used for 64-bit loads. */
- int datahi_reg = (opc == 3 ? *args++ : TCG_REG_R0);
+ int datahi_reg = (s_bits == MO_64 ? *args++ : TCG_REG_R0);
int addrlo_reg = *args++;
#if defined(CONFIG_SOFTMMU)
@@ -1105,7 +1104,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
offset = offsetof(CPUArchState, tlb_table[mem_index][0].addr_read);
offset = tcg_out_tlb_read(s, TCG_REG_R26, TCG_REG_R25, addrlo_reg,
- addrhi_reg, opc & 3, lab1, offset);
+ addrhi_reg, s_bits, lab1, offset);
/* TLB Hit. */
tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R20,
@@ -1128,26 +1127,26 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
}
argno = tcg_out_arg_reg32(s, argno, mem_index, true);
- tcg_out_call(s, qemu_ld_helpers[opc & 3]);
+ tcg_out_call(s, qemu_ld_helpers[s_bits]);
- switch (opc) {
- case 0:
+ switch (opc & MO_SSIZE) {
+ case MO_UB:
tcg_out_andi(s, datalo_reg, TCG_REG_RET0, 0xff);
break;
- case 0 | 4:
+ case MO_SB:
tcg_out_ext8s(s, datalo_reg, TCG_REG_RET0);
break;
- case 1:
+ case MO_UW:
tcg_out_andi(s, datalo_reg, TCG_REG_RET0, 0xffff);
break;
- case 1 | 4:
+ case MO_SW:
tcg_out_ext16s(s, datalo_reg, TCG_REG_RET0);
break;
- case 2:
- case 2 | 4:
+ case MO_UL:
+ case MO_SL:
tcg_out_mov(s, TCG_TYPE_I32, datalo_reg, TCG_REG_RET0);
break;
- case 3:
+ case MO_Q:
tcg_out_mov(s, TCG_TYPE_I32, datahi_reg, TCG_REG_RET0);
tcg_out_mov(s, TCG_TYPE_I32, datalo_reg, TCG_REG_RET1);
break;
@@ -1164,33 +1163,29 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
}
static void tcg_out_qemu_st_direct(TCGContext *s, int datalo_reg,
- int datahi_reg, int addr_reg, int opc)
+ int datahi_reg, int addr_reg, TCGMemOp opc)
{
-#ifdef TARGET_WORDS_BIGENDIAN
- const int bswap = 0;
-#else
- const int bswap = 1;
-#endif
+ const TCGMemOp bswap = opc & MO_BSWAP;
- switch (opc) {
- case 0:
+ switch (opc & MO_SIZE) {
+ case MO_8:
tcg_out_ldst(s, datalo_reg, addr_reg, 0, INSN_STB);
break;
- case 1:
+ case MO_16:
if (bswap) {
tcg_out_bswap16(s, TCG_REG_R20, datalo_reg, 0);
datalo_reg = TCG_REG_R20;
}
tcg_out_ldst(s, datalo_reg, addr_reg, 0, INSN_STH);
break;
- case 2:
+ case MO_32:
if (bswap) {
tcg_out_bswap32(s, TCG_REG_R20, datalo_reg, TCG_REG_R20);
datalo_reg = TCG_REG_R20;
}
tcg_out_ldst(s, datalo_reg, addr_reg, 0, INSN_STW);
break;
- case 3:
+ case MO_64:
if (bswap) {
tcg_out_bswap32(s, TCG_REG_R20, datalo_reg, TCG_REG_R20);
tcg_out_bswap32(s, TCG_REG_R23, datahi_reg, TCG_REG_R23);
@@ -1206,11 +1201,12 @@ static void tcg_out_qemu_st_direct(TCGContext *s, int datalo_reg,
}
-static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
+static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, TCGMemOp opc)
{
+ TCGMemOp s_bits = opc & MO_SIZE;
int datalo_reg = *args++;
/* Note that datahi_reg is only used for 64-bit loads. */
- int datahi_reg = (opc == 3 ? *args++ : TCG_REG_R0);
+ int datahi_reg = (s_bits == MO_64 ? *args++ : TCG_REG_R0);
int addrlo_reg = *args++;
#if defined(CONFIG_SOFTMMU)
@@ -1224,7 +1220,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
offset = offsetof(CPUArchState, tlb_table[mem_index][0].addr_write);
offset = tcg_out_tlb_read(s, TCG_REG_R26, TCG_REG_R25, addrlo_reg,
- addrhi_reg, opc, lab1, offset);
+ addrhi_reg, s_bits, lab1, offset);
/* TLB Hit. */
tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R20,
@@ -1250,19 +1246,19 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
}
next = (argno < 4 ? tcg_target_call_iarg_regs[argno] : TCG_REG_R20);
- switch(opc) {
- case 0:
+ switch (s_bits) {
+ case MO_8:
tcg_out_andi(s, next, datalo_reg, 0xff);
argno = tcg_out_arg_reg32(s, argno, next, false);
break;
- case 1:
+ case MO_16:
tcg_out_andi(s, next, datalo_reg, 0xffff);
argno = tcg_out_arg_reg32(s, argno, next, false);
break;
- case 2:
+ case MO_32:
argno = tcg_out_arg_reg32(s, argno, datalo_reg, false);
break;
- case 3:
+ case MO_64:
argno = tcg_out_arg_reg64(s, argno, datalo_reg, datahi_reg);
break;
default:
@@ -1270,7 +1266,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
}
argno = tcg_out_arg_reg32(s, argno, mem_index, true);
- tcg_out_call(s, qemu_st_helpers[opc]);
+ tcg_out_call(s, qemu_st_helpers[s_bits]);
/* label2: */
tcg_out_label(s, lab2, s->code_ptr);
@@ -1534,35 +1530,35 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
break;
case INDEX_op_qemu_ld8u:
- tcg_out_qemu_ld(s, args, 0);
+ tcg_out_qemu_ld(s, args, MO_UB);
break;
case INDEX_op_qemu_ld8s:
- tcg_out_qemu_ld(s, args, 0 | 4);
+ tcg_out_qemu_ld(s, args, MO_SB);
break;
case INDEX_op_qemu_ld16u:
- tcg_out_qemu_ld(s, args, 1);
+ tcg_out_qemu_ld(s, args, MO_TEUW);
break;
case INDEX_op_qemu_ld16s:
- tcg_out_qemu_ld(s, args, 1 | 4);
+ tcg_out_qemu_ld(s, args, MO_TESW);
break;
case INDEX_op_qemu_ld32:
- tcg_out_qemu_ld(s, args, 2);
+ tcg_out_qemu_ld(s, args, MO_TEUL);
break;
case INDEX_op_qemu_ld64:
- tcg_out_qemu_ld(s, args, 3);
+ tcg_out_qemu_ld(s, args, MO_TEQ);
break;
case INDEX_op_qemu_st8:
- tcg_out_qemu_st(s, args, 0);
+ tcg_out_qemu_st(s, args, MO_UB);
break;
case INDEX_op_qemu_st16:
- tcg_out_qemu_st(s, args, 1);
+ tcg_out_qemu_st(s, args, MO_TEUW);
break;
case INDEX_op_qemu_st32:
- tcg_out_qemu_st(s, args, 2);
+ tcg_out_qemu_st(s, args, MO_TEUL);
break;
case INDEX_op_qemu_st64:
- tcg_out_qemu_st(s, args, 3);
+ tcg_out_qemu_st(s, args, MO_TEQ);
break;
default:
--
1.8.1.4
next prev parent reply other threads:[~2013-09-04 21:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-04 21:04 [Qemu-devel] [PATCH 00/16] Streamlining endian handling in TCG Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 01/16] tcg: Add TCGMemOp Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 02/16] tcg-i386: Use TCGMemOp within qemu_ldst routines Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 03/16] tcg-aarch64: " Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 04/16] tcg-arm: " Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 05/16] tcg-s390: " Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 06/16] tcg-ppc: " Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 07/16] tcg-ppc64: " Richard Henderson
2013-09-04 21:04 ` Richard Henderson [this message]
2013-09-04 21:04 ` [Qemu-devel] [PATCH 09/16] tcg-mips: " Richard Henderson
2013-09-04 21:04 ` [Qemu-devel] [PATCH 10/16] tcg-sparc: " Richard Henderson
2013-09-04 21:05 ` [Qemu-devel] [PATCH 11/16] tcg: Add qemu_ld_st_i32/64 Richard Henderson
2013-09-04 21:05 ` [Qemu-devel] [PATCH 12/16] exec: Add both big- and little-endian memory helpers Richard Henderson
2013-09-04 21:05 ` [Qemu-devel] [PATCH 13/16] tcg-i386: Tidy softmmu routines Richard Henderson
2013-09-04 21:05 ` [Qemu-devel] [PATCH 14/16] tcg-i386: Remove "cb" output restriction from qemu_st8 for i386 Richard Henderson
2013-09-04 21:05 ` [Qemu-devel] [PATCH 15/16] tcg-i386: Support new ldst opcodes Richard Henderson
2013-09-04 21:05 ` [Qemu-devel] [PATCH 16/16] target-ppc: Convert to " Richard Henderson
2013-09-05 9:08 ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
2013-09-05 11:40 ` Benjamin Herrenschmidt
2013-09-05 12:59 ` Alexander Graf
2013-09-05 13:37 ` Benjamin Herrenschmidt
2013-09-05 15:35 ` Richard Henderson
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=1378328705-23006-9-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=aurelien@aurel32.net \
--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).