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();
// 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();
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();
}
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)
if (constantThatMustBeLoaded)
{ // register the value so it is emitted in the assembly
- method->getMachineCode().addToConstantPool(
+ MachineCodeForMethod::get(method).addToConstantPool(
cast<ConstPoolVal>(opValue));
}
}
if (isa<ConstPoolVal>(oldVal))
{ // register the value so it is emitted in the assembly
- method->getMachineCode().addToConstantPool(
+ MachineCodeForMethod::get(method).addToConstantPool(
cast<ConstPoolVal>(oldVal));
}
}