//---------------------------------------------------------------------------
uint64_t
-SparcV9InstrInfo::ConvertConstantToIntType(const TargetMachine &target,
+ConvertConstantToIntType(const TargetMachine &target,
const Value *V,
const Type *destType,
- bool &isValidConstant) const
+ bool &isValidConstant)
{
isValidConstant = false;
uint64_t C = 0;
InitializeMaxConstantsTable();
}
-bool
-SparcV9InstrInfo::ConstantMayNotFitInImmedField(const Constant* CV,
- const Instruction* I) const
-{
+bool ConstantMayNotFitInImmedField(const Constant* CV, const Instruction* I) {
if (I->getOpcode() >= MaxConstantsTable.size()) // user-defined op (or bug!)
return true;
// Any stack space required is allocated via MachineFunction.
//
void
-SparcV9InstrInfo::CreateCodeToLoadConst(const TargetMachine& target,
+CreateCodeToLoadConst(const TargetMachine& target,
Function* F,
Value* val,
Instruction* dest,
std::vector<MachineInstr*>& mvec,
- MachineCodeForInstruction& mcfi) const
+ MachineCodeForInstruction& mcfi)
{
assert(isa<Constant>(val) &&
"I only know about constant values and global addresses");
}
}
-
// Create an instruction sequence to copy an integer register `val'
// to a floating point register `dest' by copying to memory and back.
// val must be an integral type. dest must be a Float or Double.
// Any stack space required is allocated via MachineFunction.
//
void
-SparcV9InstrInfo::CreateCodeToCopyIntToFloat(const TargetMachine& target,
+CreateCodeToCopyIntToFloat(const TargetMachine& target,
Function* F,
Value* val,
Instruction* dest,
std::vector<MachineInstr*>& mvec,
- MachineCodeForInstruction& mcfi) const
+ MachineCodeForInstruction& mcfi)
{
assert((val->getType()->isIntegral() || isa<PointerType>(val->getType()))
&& "Source type must be integral (integer or bool) or pointer");
// Temporary stack space required is allocated via MachineFunction.
//
void
-SparcV9InstrInfo::CreateCodeToCopyFloatToInt(const TargetMachine& target,
+CreateCodeToCopyFloatToInt(const TargetMachine& target,
Function* F,
Value* val,
Instruction* dest,
std::vector<MachineInstr*>& mvec,
- MachineCodeForInstruction& mcfi) const
+ MachineCodeForInstruction& mcfi)
{
const Type* opTy = val->getType();
const Type* destTy = dest->getType();
// Any stack space required is allocated via MachineFunction.
//
void
-SparcV9InstrInfo::CreateCopyInstructionsByType(const TargetMachine& target,
+CreateCopyInstructionsByType(const TargetMachine& target,
Function *F,
Value* src,
Instruction* dest,
std::vector<MachineInstr*>& mvec,
- MachineCodeForInstruction& mcfi) const
+ MachineCodeForInstruction& mcfi)
{
bool loadConstantToReg = false;
if (loadConstantToReg) {
// `src' is constant and cannot fit in immed field for the ADD
// Insert instructions to "load" the constant into a register
- target.getInstrInfo()->CreateCodeToLoadConst(target, F, src, dest,
- mvec, mcfi);
+ CreateCodeToLoadConst(target, F, src, dest, mvec, mcfi);
} else {
// Create a reg-to-reg copy instruction for the given type:
// -- For FP values, create a FMOVS or FMOVD instruction
// Any stack space required is allocated via MachineFunction.
//
void
-SparcV9InstrInfo::CreateSignExtensionInstructions(
+CreateSignExtensionInstructions(
const TargetMachine& target,
Function* F,
Value* srcVal,
Value* destVal,
unsigned int numLowBits,
std::vector<MachineInstr*>& mvec,
- MachineCodeForInstruction& mcfi) const
+ MachineCodeForInstruction& mcfi)
{
CreateBitExtensionInstructions(/*signExtend*/ true, target, F, srcVal,
destVal, numLowBits, mvec, mcfi);
// Any stack space required is allocated via MachineFunction.
//
void
-SparcV9InstrInfo::CreateZeroExtensionInstructions(
+CreateZeroExtensionInstructions(
const TargetMachine& target,
Function* F,
Value* srcVal,
Value* destVal,
unsigned int numLowBits,
std::vector<MachineInstr*>& mvec,
- MachineCodeForInstruction& mcfi) const
+ MachineCodeForInstruction& mcfi)
{
CreateBitExtensionInstructions(/*signExtend*/ false, target, F, srcVal,
destVal, numLowBits, mvec, mcfi);
castDestType));
// Create the fpreg-to-intreg copy code
- target.getInstrInfo()->CreateCodeToCopyFloatToInt(target, F, destForCast,
- fpToIntCopyDest, mvec, mcfi);
+ CreateCodeToCopyFloatToInt(target, F, destForCast, fpToIntCopyDest, mvec,
+ mcfi);
// Create the uint64_t to uint32_t conversion, if needed
if (destI->getType() == Type::UIntTy)
- target.getInstrInfo()->
- CreateZeroExtensionInstructions(target, F, fpToIntCopyDest, destI,
- /*numLowBits*/ 32, mvec, mcfi);
+ CreateZeroExtensionInstructions(target, F, fpToIntCopyDest, destI,
+ /*numLowBits*/ 32, mvec, mcfi);
}
if (shiftDest != destVal) {
// extend the sign-bit of the result into all upper bits of dest
assert(8*opSize <= 32 && "Unexpected type size > 4 and < IntRegSize?");
- target.getInstrInfo()->
- CreateSignExtensionInstructions(target, F, shiftDest, destVal,
- 8*opSize, mvec, mcfi);
+ CreateSignExtensionInstructions(target, F, shiftDest, destVal, 8*opSize,
+ mvec, mcfi);
}
}
if (resultType->isInteger() || isa<PointerType>(resultType)) {
bool isValidConst;
- int64_t C = (int64_t) target.getInstrInfo()->ConvertConstantToIntType(target,
- constOp, constOp->getType(), isValidConst);
+ int64_t C = (int64_t) ConvertConstantToIntType(target, constOp,
+ constOp->getType(),
+ isValidConst);
if (isValidConst) {
unsigned pow;
bool needNeg = false;
Constant* P = ConstantExpr::get(Instruction::Mul,
cast<Constant>(lval),
cast<Constant>(rval));
- target.getInstrInfo()->CreateCodeToLoadConst(target,F,P,destVal,mvec,mcfi);
+ CreateCodeToLoadConst (target, F, P, destVal, mvec, mcfi);
}
else if (isa<Constant>(rval)) // rval is constant, but not lval
CreateMulConstInstruction(target, F, lval, rval, destVal, mvec, mcfi);
if (resultType->isInteger()) {
unsigned pow;
bool isValidConst;
- int64_t C = (int64_t) target.getInstrInfo()->ConvertConstantToIntType(target,
- constOp, constOp->getType(), isValidConst);
+ int64_t C = (int64_t) ConvertConstantToIntType(target, constOp,
+ constOp->getType(),
+ isValidConst);
if (isValidConst) {
bool needNeg = false;
if (C < 0) {
// compile time if the total size is a known constant.
if (isa<Constant>(numElementsVal)) {
bool isValid;
- int64_t numElem = (int64_t) target.getInstrInfo()->
+ int64_t numElem = (int64_t)
ConvertConstantToIntType(target, numElementsVal,
numElementsVal->getType(), isValid);
assert(isValid && "Unexpectedly large array dimension in alloca!");
retValToUse = new TmpInstruction(mcfi, retVal);
// sign-extend retVal and put the result in the temporary reg.
- target.getInstrInfo()->CreateSignExtensionInstructions
+ CreateSignExtensionInstructions
(target, returnInstr->getParent()->getParent(),
retVal, retValToUse, 8*retSize, mvec, mcfi);
}
if ((constVal->getType()->isInteger()
|| isa<PointerType>(constVal->getType()))
- && target.getInstrInfo()->ConvertConstantToIntType(target,
+ && ConvertConstantToIntType(target,
constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
? new TmpInstruction(mcfi, destType, opVal)
: destI);
- target.getInstrInfo()->CreateSignExtensionInstructions
+ CreateSignExtensionInstructions
(target, currentFunc,opVal,signExtDest,extSourceInBits,mvec,mcfi);
if (signAndZeroExtend)
- target.getInstrInfo()->CreateZeroExtensionInstructions
+ CreateZeroExtensionInstructions
(target, currentFunc, signExtDest, destI, 8*destSize, mvec, mcfi);
}
else if (zeroExtendOnly) {
- target.getInstrInfo()->CreateZeroExtensionInstructions
+ CreateZeroExtensionInstructions
(target, currentFunc, opVal, destI, extSourceInBits, mvec, mcfi);
}
else
MachineCodeForInstruction::get(dest);
srcForCast = new TmpInstruction(destMCFI, tmpTypeToUse, dest);
- target.getInstrInfo()->CreateCodeToCopyIntToFloat(target,
+ CreateCodeToCopyIntToFloat(target,
dest->getParent()->getParent(),
leftVal, cast<Instruction>(srcForCast),
mvec, destMCFI);
MachineCodeForInstruction& mcfi=MachineCodeForInstruction::get(divI);
divOp1ToUse = new TmpInstruction(mcfi, divOp1);
divOp2ToUse = new TmpInstruction(mcfi, divOp2);
- target.getInstrInfo()->
- CreateSignExtensionInstructions(target,
+ CreateSignExtensionInstructions(target,
divI->getParent()->getParent(),
divOp1, divOp1ToUse,
8*opSize, mvec, mcfi);
- target.getInstrInfo()->
- CreateSignExtensionInstructions(target,
+ CreateSignExtensionInstructions(target,
divI->getParent()->getParent(),
divOp2, divOp2ToUse,
8*opSize, mvec, mcfi);
unsigned opSize=target.getTargetData().getTypeSize(divOp2->getType());
if (opSize < 8) {
divOpToUse = new TmpInstruction(mcfi, divOp2);
- target.getInstrInfo()->
- CreateSignExtensionInstructions(target,
+ CreateSignExtensionInstructions(target,
remI->getParent()->getParent(),
divOp2, divOpToUse,
8*opSize, mvec, mcfi);
if ((constVal->getType()->isInteger()
|| isa<PointerType>(constVal->getType()))
- && target.getInstrInfo()->ConvertConstantToIntType(target,
+ && ConvertConstantToIntType(target,
constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
rightOpToUse = new TmpInstruction(mcfi, rightVal);
// sign-extend each operand and put the result in the temporary reg.
- target.getInstrInfo()->CreateSignExtensionInstructions
+ CreateSignExtensionInstructions
(target, setCCInstr->getParent()->getParent(),
leftVal, leftOpToUse, 8*opSize, mvec, mcfi);
- target.getInstrInfo()->CreateSignExtensionInstructions
+ CreateSignExtensionInstructions
(target, setCCInstr->getParent()->getParent(),
rightVal, rightOpToUse, 8*opSize, mvec, mcfi);
}
TmpInstruction* argExtend = new TmpInstruction(mcfi, argVal);
// sign-extend argVal and put the result in the temporary reg.
- target.getInstrInfo()->CreateSignExtensionInstructions
+ CreateSignExtensionInstructions
(target, currentFunc, argVal, argExtend,
8*argSize, mvec, mcfi);
else {
std::vector<MachineInstr*> minstrVec;
Instruction* instr = subtreeRoot->getInstruction();
- target.getInstrInfo()->
- CreateCopyInstructionsByType(target,
+ CreateCopyInstructionsByType(target,
instr->getParent()->getParent(),
instr->getOperand(forwardOperandNum),
instr, minstrVec,