[Lldb-commits] [lldb] r273535 - [LLDB][MIPS] Fix Emulation of Compact branch and ADDIU instructions

Sagar Thakur via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 22 23:40:37 PDT 2016


Author: slthakur
Date: Thu Jun 23 01:40:37 2016
New Revision: 273535

URL: http://llvm.org/viewvc/llvm-project?rev=273535&view=rev
Log:
[LLDB][MIPS] Fix Emulation of Compact branch and ADDIU instructions

Patch by Nitesh Jain.

This patch contains 2 changes:

  - Corrected target address calculation of compact branch instructions to reflect changes in disassembler (http://reviews.llvm.org/D17540).
  - Added emulation for (missing) 'Addiu' instruction.

Reviewers :jaydeep, bhushan, clayborg
Differential: http://reviews.llvm.org/D21064

Modified:
    lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
    lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp

Modified: lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp?rev=273535&r1=273534&r2=273535&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp (original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp Thu Jun 23 01:40:37 2016
@@ -1482,56 +1482,56 @@ EmulateInstructionMIPS::Emulate_BXX_3ops
     if (!strcasecmp (op_name, "BEQC"))
     {
         if (rs_val == rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BNEC"))
     {
         if (rs_val != rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BLTC"))
     {
         if (rs_val < rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGEC"))
     {
         if (rs_val >= rt_val)
-            target = pc + 4 + offset;
+            target = pc  + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BLTUC"))
     {
         if (rs_val < rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGEUC"))
     {
         if ((uint32_t)rs_val >= (uint32_t)rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BOVC"))
     {
         if (IsAdd64bitOverflow (rs_val, rt_val))
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BNVC"))
     {
         if (!IsAdd64bitOverflow (rs_val, rt_val))
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
@@ -1773,42 +1773,42 @@ EmulateInstructionMIPS::Emulate_BXX_2ops
     if (!strcasecmp (op_name, "BLTZC"))
     {
         if (rs_val < 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BLEZC"))
     {
         if (rs_val <= 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGEZC"))
     {
         if (rs_val >= 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGTZC"))
     {
         if (rs_val > 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BEQZC"))
     {
         if (rs_val == 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BNEZC"))
     {
         if (rs_val != 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
@@ -2129,7 +2129,7 @@ EmulateInstructionMIPS::Emulate_BALC (ll
     if (!success)
         return false;
 
-    target = pc + 4 + offset;
+    target = pc + offset;
 
     Context context;
 
@@ -2159,7 +2159,7 @@ EmulateInstructionMIPS::Emulate_BC (llvm
     if (!success)
         return false;
 
-    target = pc + 4 + offset;
+    target = pc + offset;
 
     Context context;
 

Modified: lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp?rev=273535&r1=273534&r2=273535&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp (original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp Thu Jun 23 01:40:37 2016
@@ -483,6 +483,7 @@ EmulateInstructionMIPS64::GetOpcodeForIn
         // Prologue/Epilogue instructions
         //----------------------------------------------------------------------
         { "DADDiu",     &EmulateInstructionMIPS64::Emulate_DADDiu,      "DADDIU rt,rs,immediate"    },
+        { "ADDiu",      &EmulateInstructionMIPS64::Emulate_DADDiu,      "ADDIU rt,rs,immediate"     },
         { "SD",         &EmulateInstructionMIPS64::Emulate_SD,          "SD rt,offset(rs)"          },
         { "LD",         &EmulateInstructionMIPS64::Emulate_LD,          "LD rt,offset(base)"        },
 
@@ -1066,7 +1067,7 @@ EmulateInstructionMIPS64::Emulate_BALC (
     if (!success)
         return false;
 
-    target = pc + 4 + offset;
+    target = pc + offset;
 
     Context context;
 
@@ -1240,7 +1241,7 @@ EmulateInstructionMIPS64::Emulate_BC (ll
     if (!success)
         return false;
 
-    target = pc + 4 + offset;
+    target = pc + offset;
 
     Context context;
 
@@ -1289,56 +1290,56 @@ EmulateInstructionMIPS64::Emulate_BXX_3o
     if (!strcasecmp (op_name, "BEQC"))
     {
         if (rs_val == rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BNEC"))
     {
         if (rs_val != rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BLTC"))
     {
         if (rs_val < rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGEC"))
     {
         if (rs_val >= rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BLTUC"))
     {
         if (rs_val < rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGEUC"))
     {
         if ((uint32_t)rs_val >= (uint32_t)rt_val)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BOVC"))
     {
         if (IsAdd64bitOverflow (rs_val, rt_val))
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BNVC"))
     {
         if (!IsAdd64bitOverflow (rs_val, rt_val))
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
@@ -1381,42 +1382,42 @@ EmulateInstructionMIPS64::Emulate_BXX_2o
     if (!strcasecmp (op_name, "BLTZC"))
     {
         if (rs_val < 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BLEZC"))
     {
         if (rs_val <= 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGEZC"))
     {
         if (rs_val >= 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BGTZC"))
     {
         if (rs_val > 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BEQZC"))
     {
         if (rs_val == 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }
     else if (!strcasecmp (op_name, "BNEZC"))
     {
         if (rs_val != 0)
-            target = pc + 4 + offset;
+            target = pc + offset;
         else
             target = pc + 4;
     }




More information about the lldb-commits mailing list