Skip to contentSkip to conversation

tcg-next patch queue

GIT PULL Richard Henderson 2 participants 5 messages Jul 26, 2013

lore
Share & tools
lore
#0 lore raw

This is ping 3 for this pull request. Re-sending with more tags in the subject, and rebased vs today's master, just to be sure.

r~

The following changes since commit 003e26bc9f7c4f5cd90e046ae112c1d09363b8d1:

Merge remote-tracking branch 'mdroth/qga-pull-2013-7-25' into staging (2013-07-25 15:58:29 -0500)

are available in the git repository at:

git://github.com/rth7680/qemu.git tcg-next

for you to fetch changes up to 2038b3f9f9d1eca12048de88d705ec5827bc02b3:

tcg: Remove temp_buf (2013-07-26 08:36:34 -1000)

----------------------------------------------------------------
Claudio Fontana (1):
tcg/aarch64: implement ldst 12bit scaled uimm offset

Jani Kokkonen (1):
tcg/aarch64: Implement tlb lookup fast path

Richard Henderson (1):
tcg: Remove temp_buf

 configure                |   2 +-
 include/exec/cpu-defs.h  |   2 -
 include/exec/exec-all.h  |  14 +++
 tcg/aarch64/tcg-target.c | 256 +++++++++++++++++++++++++++++++++++++----------
 4 files changed, 218 insertions(+), 56 deletions(-)
#1 lore raw

[Qemu-devel] [PULL v2 for-1.6 1/3] tcg/aarch64: implement ldst 12bit scaled uimm offset

From: Claudio Fontana <[email protected]>

implement the 12bit scaled unsigned immediate offset variant of LDR/STR. This improves code size by avoiding the movi + ldst_r for naturally aligned offsets in range.

---
 tcg/aarch64/tcg-target.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
tcg/aarch64/tcg-target.c +29 -3
index 562a549..cfd4081 100644
@@ -315,6 +315,17 @@ static inline void tcg_out_ldst_9(TCGContext *s,
     tcg_out32(s, op_data << 24 | mod << 20 | off << 12 | rn << 5 | rd);
 }
 
+/* tcg_out_ldst_12 expects a scaled unsigned immediate offset */
+static inline void tcg_out_ldst_12(TCGContext *s,
+                                   enum aarch64_ldst_op_data op_data,
+                                   enum aarch64_ldst_op_type op_type,
+                                   TCGReg rd, TCGReg rn,
+                                   tcg_target_ulong scaled_uimm)
+{
+    tcg_out32(s, (op_data | 1) << 24
+              | op_type << 20 | scaled_uimm << 10 | rn << 5 | rd);
+}
+
 static inline void tcg_out_movr(TCGContext *s, int ext, TCGReg rd, TCGReg src)
 {
     /* register to register move using MOV (shifted register with no shift) */
@@ -374,10 +385,25 @@ static inline void tcg_out_ldst(TCGContext *s, enum aarch64_ldst_op_data data,
 {
     if (offset >= -256 && offset < 256) {
         tcg_out_ldst_9(s, data, type, rd, rn, offset);
-    } else {
-        tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, offset);
-        tcg_out_ldst_r(s, data, type, rd, rn, TCG_REG_TMP);
+        return;
     }
+
+    if (offset >= 256) {
+        /* if the offset is naturally aligned and in range,
+           then we can use the scaled uimm12 encoding */
+        unsigned int s_bits = data >> 6;
+        if (!(offset & ((1 << s_bits) - 1))) {
+            tcg_target_ulong scaled_uimm = offset >> s_bits;
+            if (scaled_uimm <= 0xfff) {
+                tcg_out_ldst_12(s, data, type, rd, rn, scaled_uimm);
+                return;
+            }
+        }
+    }
+
+    /* worst-case scenario, move offset to temp register, use reg offset */
+    tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, offset);
+    tcg_out_ldst_r(s, data, type, rd, rn, TCG_REG_TMP);
 }
 
 /* mov alias implemented with add immediate, useful to move to/from SP */
Signature · 1 line
1.8.3.1
#2 lore raw

[Qemu-devel] [PULL v2 for-1.6 2/3] tcg/aarch64: Implement tlb lookup fast path

In reply to Richard Henderson

From: Jani Kokkonen <[email protected]>

Supports CONFIG_QEMU_LDST_OPTIMIZATION

---
 configure                |   2 +-
 include/exec/exec-all.h  |  14 +++
 tcg/aarch64/tcg-target.c | 224 ++++++++++++++++++++++++++++++++++++-----------
 3 files changed, 189 insertions(+), 51 deletions(-)
configure +1 -1
index 3d83e16..f5e299a 100755
@@ -3645,7 +3645,7 @@ echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
 echo "ARCH=$ARCH" >> $config_host_mak
 
 case "$cpu" in
-  arm|i386|x86_64|ppc)
+  arm|i386|x86_64|ppc|aarch64)
     # The TCG interpreter currently does not support ld/st optimization.
     if test "$tcg_interpreter" = "no" ; then
         echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_host_mak
include/exec/exec-all.h +14 -0
index b2162a4..5920f73 100644
@@ -358,6 +358,20 @@ static inline uintptr_t tcg_getpc_ldst(uintptr_t ra)
                                    not the start of the next opcode  */
     return ra;
 }
+#elif defined(__aarch64__)
+#  define GETRA()       ((uintptr_t)__builtin_return_address(0))
+#  define GETPC_LDST()  tcg_getpc_ldst(GETRA())
+static inline uintptr_t tcg_getpc_ldst(uintptr_t ra)
+{
+    int32_t b;
+    ra += 4;                    /* skip one instruction */
+    b = *(int32_t *)ra;         /* load the branch insn */
+    b = (b << 6) >> (6 - 2);    /* extract the displacement */
+    ra += b;                    /* apply the displacement  */
+    ra -= 4;                    /* return a pointer into the current opcode,
+                                   not the start of the next opcode  */
+    return ra;
+}
 # else
 #  error "CONFIG_QEMU_LDST_OPTIMIZATION needs GETPC_LDST() implementation!"
 # endif
tcg/aarch64/tcg-target.c +174 -50

272 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#3 lore raw

[Qemu-devel] [PULL v2 for-1.6 3/3] tcg: Remove temp_buf

In reply to Richard Henderson

All targets have been converted to allocating space for temporaries on the stack. No need to allocate space within the CPU_COMMON block.

---
 include/exec/cpu-defs.h | 2 --
 1 file changed, 2 deletions(-)
include/exec/cpu-defs.h +0 -2
index b5b93db..a5c028c 100644
@@ -154,8 +154,6 @@ typedef struct CPUWatchpoint {
                                      memory was accessed */             \
     CPU_COMMON_TLB                                                      \
     struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE];           \
-    /* buffer for temporaries in the code generator */                  \
-    long temp_buf[CPU_TEMP_BUF_NLONGS];                                 \
                                                                         \
     int64_t icount_extra; /* Instructions until next timer event.  */   \
     /* Number of cycles left, with interrupt flag in high bit.          \
Signature · 1 line
1.8.3.1
#4 lore raw
In reply to Richard Henderson

Had just applied the previous one FWIW.

Sorry for the delay.

Regards,

Anthony Liguori

Quoted 37 lines · Richard Henderson

This is ping 3 for this pull request. Re-sending with more tags in the subject, and rebased vs today's master, just to be sure.

r~

The following changes since commit 003e26bc9f7c4f5cd90e046ae112c1d09363b8d1:

Merge remote-tracking branch 'mdroth/qga-pull-2013-7-25' into staging (2013-07-25 15:58:29 -0500)

are available in the git repository at:

git://github.com/rth7680/qemu.git tcg-next

for you to fetch changes up to 2038b3f9f9d1eca12048de88d705ec5827bc02b3:

tcg: Remove temp_buf (2013-07-26 08:36:34 -1000)

----------------------------------------------------------------
Claudio Fontana (1):
tcg/aarch64: implement ldst 12bit scaled uimm offset

Jani Kokkonen (1):
tcg/aarch64: Implement tlb lookup fast path

Richard Henderson (1):
tcg: Remove temp_buf

 configure                |   2 +-
 include/exec/cpu-defs.h  |   2 -
 include/exec/exec-all.h  |  14 +++
 tcg/aarch64/tcg-target.c | 256 +++++++++++++++++++++++++++++++++++++----------
 4 files changed, 218 insertions(+), 56 deletions(-)