[llvm-commits] CVS: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp

Misha Brukman brukman at cs.uiuc.edu
Tue Jun 3 23:55:01 PDT 2003


Changes in directory llvm/lib/CodeGen/InstrSelection:

InstrSelectionSupport.cpp updated: 1.49 -> 1.50

---
Log message:

I have finally seen the light. The code to change the opcode must live higher in
the loop, and in both cases. In the first case, it is a VReg that is a constant
so it may be actually converted to a constant. In the second case, it is already
a constant, but then if it doesn't change its type (e.g. to become a register
and have the value loaded from memory if it is too large to live in its
instruction field), we must change the opcode BEFORE the 'continue', otherwise
we miss the opportunity.


---
Diffs of the changes:

Index: llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
diff -u llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.49 llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.50
--- llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp:1.49	Mon Jun  2 22:18:20 2003
+++ llvm/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp	Tue Jun  3 23:54:06 2003
@@ -186,6 +186,12 @@
                                       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
@@ -203,6 +209,13 @@
                                     opCode, target, (immedPos == (int)op), 
                                     machineRegNum, immedValue);
 
+          if (opType == MachineOperand::MO_SignExtendedImmed) {
+            // The optype is an immediate value
+            // This means we need to change the opcode, e.g. ADDr -> ADDi
+            unsigned newOpcode = convertOpcodeFromRegToImm(opCode);
+            minstr->setOpcode(newOpcode);
+          }
+
           if (opType == mop.getType()) 
             continue;           // no change: this is the most common case
 
@@ -220,10 +233,6 @@
       else if (opType == MachineOperand::MO_SignExtendedImmed ||
                opType == MachineOperand::MO_UnextendedImmed) {
         minstr->SetMachineOperandConst(op, opType, immedValue);
-        // 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 if (constantThatMustBeLoaded ||
                (opValue && isa<GlobalValue>(opValue)))
         { // opValue is a constant that must be explicitly loaded into a reg





More information about the llvm-commits mailing list