[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 07/27] tcg-ppc64: Cleanup tcg_out_movi
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v2 07/27] tcg-ppc64: Cleanup tcg_out_movi |
Date: |
Mon, 4 Mar 2013 16:32:50 -0800 |
The test for using movi32 was sub-optimal for TCG_TYPE_I32, comparing
a signed 32-bit quantity against an unsigned 32-bit quantity.
When possible, use addi+oris for 32-bit unsigned constants. Otherwise,
standardize on addi+oris+ori instead of addis+ori+rldicl.
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/ppc64/tcg-target.c | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c
index 82e1da7..a4951c5 100644
--- a/tcg/ppc64/tcg-target.c
+++ b/tcg/ppc64/tcg-target.c
@@ -477,29 +477,25 @@ static void tcg_out_movi32(TCGContext *s, TCGReg ret,
int32_t arg)
}
}
-static void tcg_out_movi (TCGContext *s, TCGType type,
- TCGReg ret, tcg_target_long arg)
+static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret,
+ tcg_target_long arg)
{
- int32_t arg32 = arg;
- arg = type == TCG_TYPE_I32 ? arg & 0xffffffff : arg;
-
- if (arg == arg32) {
- tcg_out_movi32 (s, ret, arg32);
- }
- else {
- if ((uint64_t) arg >> 32) {
- uint16_t h16 = arg >> 16;
- uint16_t l16 = arg;
-
- tcg_out_movi32 (s, ret, arg >> 32);
+ if (type == TCG_TYPE_I32 || arg == (int32_t)arg) {
+ tcg_out_movi32(s, ret, arg);
+ } else if (arg == (uint32_t)arg && !(arg & 0x8000)) {
+ tcg_out32(s, ADDI | RT(ret) | RA(0) | (arg & 0xffff));
+ tcg_out32(s, ORIS | RT(ret) | RA(ret) | ((arg >> 16) & 0xffff));
+ } else {
+ int32_t high = arg >> 32;
+ tcg_out_movi32(s, ret, high);
+ if (high) {
tcg_out_shli64(s, ret, ret, 32);
- if (h16) tcg_out32 (s, ORIS | RS (ret) | RA (ret) | h16);
- if (l16) tcg_out32 (s, ORI | RS (ret) | RA (ret) | l16);
}
- else {
- tcg_out_movi32 (s, ret, arg32);
- if (arg32 < 0)
- tcg_out_ext32u(s, ret, ret);
+ if (arg & 0xffff0000) {
+ tcg_out32(s, ORIS | RS(ret) | RA(ret) | ((arg >> 16) & 0xffff));
+ }
+ if (arg & 0xffff) {
+ tcg_out32(s, ORI | RS(ret) | RA(ret) | (arg & 0xffff));
}
}
}
--
1.8.1.2
- [Qemu-devel] [PATCH v2 00/27] Modernize tcg/ppc64, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 01/27] disas: Disassemble all ppc insns for the host, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 03/27] tcg-ppc64: Introduce and use tcg_out_rlw, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 02/27] tcg-ppc64: Use TCGReg everywhere, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 04/27] tcg-ppc64: Introduce and use tcg_out_ext32u, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 05/27] tcg-ppc64: Introduce and use tcg_out_shli64, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 06/27] tcg-ppc64: Introduce and use tcg_out_shri64, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 07/27] tcg-ppc64: Cleanup tcg_out_movi,
Richard Henderson <=
- [Qemu-devel] [PATCH v2 09/27] tcg-ppc64: Rearrange integer constant constraints, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 10/27] tcg-ppc64: Improve constant add and sub ops., Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 08/27] tcg-ppc64: Introduce and use TAI and SAI, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 11/27] tcg-ppc64: Tidy or and xor patterns., Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 12/27] tcg-ppc64: Improve and_i32 with constant, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 13/27] tcg-ppc64: Improve and_i64 with constant, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 14/27] tcg-ppc64: Streamline qemu_ld/st insn selection, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 15/27] tcg-ppc64: Implement rotates, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 16/27] tcg-ppc64: Implement bswap16 and bswap32, Richard Henderson, 2013/03/04
- [Qemu-devel] [PATCH v2 17/27] tcg-ppc64: Implement bswap64, Richard Henderson, 2013/03/04