Skip to contentSkip to conversation

Fix Alpha ret instruction

PATCH Applied Vince Weaver 2 participants 2 messages Nov 5, 2008 – Nov 6, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix Alpha ret instruction

Hopefully pine doesn't corrupt this patch, I've had problems recently.

For an alpha "ret" instruction, of the type

    ret $26

The return was being ignored. This is because in translate.c
register $26 (the return address) was being over-written with the current PC before it could be jumped to. Thus the ret was ignored.

This patch just re-orders things so the return address is processed before it is over-written with the current PC.

translate.c +3 -2
Index: target-alpha/translate.c
===================================================================
@@ -1634,12 +1634,13 @@
         break;
 #endif
     case 0x1A:
-        if (ra != 31)
-            tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
         if (rb != 31)
             tcg_gen_andi_i64(cpu_pc, cpu_ir[rb], ~3);
         else
             tcg_gen_movi_i64(cpu_pc, 0);
+        if (ra != 31)
+            tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
+
         /* Those four jumps only differ by the branch prediction hint */
         switch (fn2) {
         case 0x0:
#1 lore raw
Quoted 4 lines · Vince Weaver

Hopefully pine doesn't corrupt this patch, I've had problems recently.

For an alpha "ret" instruction, of the type

Quoted 9 lines
    ret $26

The return was being ignored. This is because in translate.c register $26 (the return address) was being over-written with the current PC before it could be jumped to. Thus the ret was ignored.

This patch just re-orders things so the return address is processed before it is over-written with the current PC.

Thanks, applied.

Quoted 23 lines

Index: target-alpha/translate.c
===================================================================

translate.c +3 -2
@@ -1634,12 +1634,13 @@
         break;
 #endif
     case 0x1A:
-        if (ra != 31)
-            tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
         if (rb != 31)
             tcg_gen_andi_i64(cpu_pc, cpu_ir[rb], ~3);
         else
             tcg_gen_movi_i64(cpu_pc, 0);
+        if (ra != 31)
+            tcg_gen_movi_i64(cpu_ir[ra], ctx->pc);
+
         /* Those four jumps only differ by the branch prediction hint */
         switch (fn2) {
         case 0x0:
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net