The old getIndices has been deprecated, because it no longer works. It now
[oota-llvm.git] / lib / Target / SparcV9 / InstrSelection / InstrSelectionSupport.cpp
index 400d5948d4f8335957ec943156ac1c94a10dc6d4..d43e688dd762f7cdf9eabecf5326a9aade7a3335 100644 (file)
@@ -117,8 +117,8 @@ FoldGetElemChain(const InstructionNode* getElemInstrNode,
     getElemInstrNode->getInstruction();
   
   // Initialize return values from the incoming instruction
-  Value* ptrVal = getElemInst->getPtrOperand();
-  chainIdxVec = getElemInst->getIndexVec(); // copies index vector values
+  Value* ptrVal = getElemInst->getPointerOperand();
+  chainIdxVec = getElemInst->getIndicesBROKEN(); // copies index vector values
   
   // Now chase the chain of getElementInstr instructions, if any
   InstrTreeNode* ptrChild = getElemInstrNode->leftChild();
@@ -128,10 +128,10 @@ FoldGetElemChain(const InstructionNode* getElemInstrNode,
       // Child is a GetElemPtr instruction
       getElemInst = (MemAccessInst*)
        ((InstructionNode*) ptrChild)->getInstruction();
-      const vector<ConstPoolVal*>& idxVec = getElemInst->getIndexVec();
+      const vector<ConstPoolVal*>& idxVec = getElemInst->getIndicesBROKEN();
       
       // Get the pointer value out of ptrChild and *prepend* its index vector
-      ptrVal = getElemInst->getPtrOperand();
+      ptrVal = getElemInst->getPointerOperand();
       chainIdxVec.insert(chainIdxVec.begin(), idxVec.begin(), idxVec.end());
       
       ptrChild = ptrChild->leftChild();
@@ -241,15 +241,23 @@ ChooseRegOrImmed(Value* val,
       return MachineOperand::MO_SignExtendedImmed;
     }
   
-  if (!CPV->getType()->isIntegral()) return opType;
-
+  // Otherwise it needs to be an integer or a NULL pointer
+  if (! CPV->getType()->isIntegral() &&
+      ! (CPV->getType()->isPointerType() &&
+         CPV->isNullValue()))
+    return opType;
+  
   // Now get the constant value and check if it fits in the IMMED field.
   // Take advantage of the fact that the max unsigned value will rarely
   // fit into any IMMED field and ignore that case (i.e., cast smaller
   // unsigned constants to signed).
   // 
   int64_t intValue;
-  if (CPV->getType()->isSigned())
+  if (CPV->getType()->isPointerType())
+    {
+      intValue = 0;
+    }
+  else if (CPV->getType()->isSigned())
     {
       intValue = ((ConstPoolSInt*)CPV)->getValue();
     }
@@ -325,9 +333,9 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
           int64_t immedValue;
           MachineOperand::MachineOperandType opType =
             ChooseRegOrImmed(opValue, minstr->getOpCode(), target,
-                             /*canUseImmed*/ (op == 1),
+                             (target.getInstrInfo().getImmmedConstantPos(minstr->getOpCode()) == (int) op),
                              machineRegNum, immedValue);
-              
+          
           if (opType == MachineOperand::MO_MachineRegister)
             minstr->SetMachineOperand(op, machineRegNum);
           else if (opType == MachineOperand::MO_VirtualRegister)
@@ -337,7 +345,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
 
           if (constantThatMustBeLoaded)
             { // register the value so it is emitted in the assembly
-              method->getMachineCode().addToConstantPool(
+              MachineCodeForMethod::get(method).addToConstantPool(
                                                  cast<ConstPoolVal>(opValue));
             }
         }
@@ -372,7 +380,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
         
         if (isa<ConstPoolVal>(oldVal))
           { // register the value so it is emitted in the assembly
-            method->getMachineCode().addToConstantPool(
+            MachineCodeForMethod::get(method).addToConstantPool(
                                                cast<ConstPoolVal>(oldVal));
           }
       }