When converting virtual registers to immediate constants, change the opcode.
authorMisha Brukman <brukman+llvm@gmail.com>
Fri, 30 May 2003 20:36:27 +0000 (20:36 +0000)
committerMisha Brukman <brukman+llvm@gmail.com>
Fri, 30 May 2003 20:36:27 +0000 (20:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6452 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp

index 187da269c9c876429b79232fd74487e92df495f6..a5a3662e937c062dcb7896b169be1012d4c2984f 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/DerivedTypes.h"
+#include "../../Target/Sparc/SparcInstrSelectionSupport.h"
 using std::vector;
 
 //*************************** Local Functions ******************************/
@@ -186,6 +187,12 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
                                       immedValue);
             if (opType == MachineOperand::MO_VirtualRegister)
               constantThatMustBeLoaded = true;
+            else {
+              // The optype has changed from being a register to an immediate
+              // This means we need to change the opcode, e.g. ADDr -> ADDi
+              unsigned newOpcode = convertOpcodeFromRegToImm(opCode);
+              minstr->setOpcode(newOpcode);
+            }
           }
         }
       else
@@ -213,6 +220,13 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
                 ? (Value*)ConstantSInt::get(Type::LongTy, immedValue)
                 : (Value*)ConstantUInt::get(Type::ULongTy,(uint64_t)immedValue);
             }
+          else 
+            {
+              // The optype has changed from being a register to an immediate
+              // This means we need to change the opcode, e.g. ADDr -> ADDi
+              unsigned newOpcode = convertOpcodeFromRegToImm(opCode);
+              minstr->setOpcode(newOpcode);
+            }
         }
 
       if (opType == MachineOperand::MO_MachineRegister)
index 187da269c9c876429b79232fd74487e92df495f6..a5a3662e937c062dcb7896b169be1012d4c2984f 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/DerivedTypes.h"
+#include "../../Target/Sparc/SparcInstrSelectionSupport.h"
 using std::vector;
 
 //*************************** Local Functions ******************************/
@@ -186,6 +187,12 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
                                       immedValue);
             if (opType == MachineOperand::MO_VirtualRegister)
               constantThatMustBeLoaded = true;
+            else {
+              // The optype has changed from being a register to an immediate
+              // This means we need to change the opcode, e.g. ADDr -> ADDi
+              unsigned newOpcode = convertOpcodeFromRegToImm(opCode);
+              minstr->setOpcode(newOpcode);
+            }
           }
         }
       else
@@ -213,6 +220,13 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
                 ? (Value*)ConstantSInt::get(Type::LongTy, immedValue)
                 : (Value*)ConstantUInt::get(Type::ULongTy,(uint64_t)immedValue);
             }
+          else 
+            {
+              // The optype has changed from being a register to an immediate
+              // This means we need to change the opcode, e.g. ADDr -> ADDi
+              unsigned newOpcode = convertOpcodeFromRegToImm(opCode);
+              minstr->setOpcode(newOpcode);
+            }
         }
 
       if (opType == MachineOperand::MO_MachineRegister)