Skip to contentSkip to conversation

target-tilegx: Check zero dest register for ld instructions

PATCH In review [email protected] 3 participants 3 messages Sep 28, 2015 – Oct 1, 2015 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-tilegx: Check zero dest register for ld instructions

From: Chen Gang <[email protected]>

At present, qemu x86_64 host backend can not remove the related dummy instructions. Even the worse, sometimes, it will generate the incorrect instructions which will cause segment fault for prefetch_l3 instruction.

---
 target-tilegx/translate.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
target-tilegx/translate.c +7 -3
index 86da6b5..7232361 100644
@@ -620,7 +620,9 @@ static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
         memop = MO_TEQ;
         mnemonic = "ld";
     do_load:
-        tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
+        if (dest != TILEGX_R_ZERO) {
+            tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
+        }
         break;
     case OE_RR_X1(LDNA):
         tcg_gen_andi_tl(tdest, tsrca, ~7);
@@ -1987,8 +1989,10 @@ static TileExcp decode_y2(DisasContext *dc, tilegx_bundle_bits bundle)
         memop = MO_TEQ;
         mnemonic = "ld";
     do_load:
-        tcg_gen_qemu_ld_tl(dest_gr(dc, srcbdest), load_gr(dc, srca),
-                           dc->mmuidx, memop);
+        if (srcbdest != TILEGX_R_ZERO) {
+            tcg_gen_qemu_ld_tl(dest_gr(dc, srcbdest), load_gr(dc, srca),
+                               dc->mmuidx, memop);
+        }
         qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s, %s", mnemonic,
                       reg_names[srcbdest], reg_names[srca]);
         return TILEGX_EXCP_NONE;
Signature · 1 line
1.9.3
#1 lore raw
Quoted 16 lines · On 09/28/2015 11:51 PM, [email protected] wrote:

From: Chen Gang <[email protected]>

At present, qemu x86_64 host backend can not remove the related dummy instructions. Even the worse, sometimes, it will generate the incorrect instructions which will cause segment fault for prefetch_l3 instruction.

---
  target-tilegx/translate.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
target-tilegx/translate.c +0 -0
index 86da6b5..7232361 100644

target-tilegx/translate.c static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext, · line 625

Quoted 7 lines
target-tilegx/translate.c +3 -1
@@ -620,7 +620,9 @@ static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
          memop = MO_TEQ;
          mnemonic = "ld";
      do_load:
-        tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
+        if (dest != TILEGX_R_ZERO) {
+            tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
+        }

This isn't right. Not all load instructions are nofault prefetches.

r~

Quoted 17 lines
target-tilegx/translate.c +4 -2
          break;
      case OE_RR_X1(LDNA):
          tcg_gen_andi_tl(tdest, tsrca, ~7);
@@ -1987,8 +1989,10 @@ static TileExcp decode_y2(DisasContext *dc, tilegx_bundle_bits bundle)
          memop = MO_TEQ;
          mnemonic = "ld";
      do_load:
-        tcg_gen_qemu_ld_tl(dest_gr(dc, srcbdest), load_gr(dc, srca),
-                           dc->mmuidx, memop);
+        if (srcbdest != TILEGX_R_ZERO) {
+            tcg_gen_qemu_ld_tl(dest_gr(dc, srcbdest), load_gr(dc, srca),
+                               dc->mmuidx, memop);
+        }
          qemu_log_mask(CPU_LOG_TB_IN_ASM, "%s %s, %s", mnemonic,
                        reg_names[srcbdest], reg_names[srca]);
          return TILEGX_EXCP_NONE;

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 12 lines · Richard Henderson
Quoted 11 lines · On 09/28/2015 11:51 PM, [email protected] wrote:

From: Chen Gang <[email protected]>

At present, qemu x86_64 host backend can not remove the related dummy instructions. Even the worse, sometimes, it will generate the incorrect instructions which will cause segment fault for prefetch_l3 instruction.

---
target-tilegx/translate.c | 10 +++++++---

1 file changed, 7 insertions(+), 3 deletions(-)
Quoted 15 lines
Quoted 7 lines
target-tilegx/translate.c +0 -0
index 86da6b5..7232361 100644
@@ -620,7 +620,9 @@ static TileExcp gen_rr_opcode(DisasContext *dc, unsigned opext,
 memop = MO_TEQ;
 mnemonic = "ld";
Quoted 5 lines

do_load:
- tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
+ if (dest != TILEGX_R_ZERO) {
+ tcg_gen_qemu_ld_tl(tdest, tsrca, dc->mmuidx, memop);
+ }

This isn't right. Not all load instructions are nofault prefetches.

OK, thanks.

--
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed