[llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp SparcV9InstrSelection.cpp SparcV9PreSelection.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Tue Jul 27 10:43:33 PDT 2004
Changes in directory llvm/lib/Target/SparcV9:
SparcV9InstrInfo.cpp updated: 1.69 -> 1.70
SparcV9InstrSelection.cpp updated: 1.144 -> 1.145
SparcV9PreSelection.cpp updated: 1.36 -> 1.37
---
Log message:
Convert many of the virtual TargetInstrInfo methods used as helper
functions in SparcV9InstrSelection and SparcV9PreSelection into regular
old global functions. As it happens, none of them really have anything
to do with TargetInstrInfo.
---
Diffs of the changes: (+46 -54)
Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp
diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.69 llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.70
--- llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.69 Mon Jul 19 08:25:02 2004
+++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp Tue Jul 27 12:43:23 2004
@@ -45,10 +45,10 @@
//---------------------------------------------------------------------------
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;
@@ -426,10 +426,7 @@
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;
@@ -457,12 +454,12 @@
// 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");
@@ -541,7 +538,6 @@
}
}
-
// 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.
@@ -550,12 +546,12 @@
// 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");
@@ -611,12 +607,12 @@
// 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();
@@ -662,12 +658,12 @@
// 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;
@@ -697,8 +693,7 @@
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
@@ -756,14 +751,14 @@
// 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);
@@ -778,14 +773,14 @@
// 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);
Index: llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp
diff -u llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp:1.144 llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp:1.145
--- llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp:1.144 Thu Jun 17 13:17:08 2004
+++ llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp Tue Jul 27 12:43:23 2004
@@ -592,14 +592,13 @@
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);
}
@@ -793,9 +792,8 @@
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);
}
}
@@ -826,8 +824,9 @@
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;
@@ -897,7 +896,7 @@
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);
@@ -980,8 +979,9 @@
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) {
@@ -1089,7 +1089,7 @@
// 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!");
@@ -1567,7 +1567,7 @@
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);
}
@@ -1637,7 +1637,7 @@
if ((constVal->getType()->isInteger()
|| isa<PointerType>(constVal->getType()))
- && target.getInstrInfo()->ConvertConstantToIntType(target,
+ && ConvertConstantToIntType(target,
constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
@@ -1889,15 +1889,15 @@
? 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
@@ -1955,7 +1955,7 @@
MachineCodeForInstruction::get(dest);
srcForCast = new TmpInstruction(destMCFI, tmpTypeToUse, dest);
- target.getInstrInfo()->CreateCodeToCopyIntToFloat(target,
+ CreateCodeToCopyIntToFloat(target,
dest->getParent()->getParent(),
leftVal, cast<Instruction>(srcForCast),
mvec, destMCFI);
@@ -2067,13 +2067,11 @@
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);
@@ -2109,8 +2107,7 @@
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);
@@ -2251,7 +2248,7 @@
if ((constVal->getType()->isInteger()
|| isa<PointerType>(constVal->getType()))
- && target.getInstrInfo()->ConvertConstantToIntType(target,
+ && ConvertConstantToIntType(target,
constVal, constVal->getType(), isValidConst) == 0
&& isValidConst)
{
@@ -2328,10 +2325,10 @@
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);
}
@@ -2506,7 +2503,7 @@
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);
@@ -2826,8 +2823,7 @@
else {
std::vector<MachineInstr*> minstrVec;
Instruction* instr = subtreeRoot->getInstruction();
- target.getInstrInfo()->
- CreateCopyInstructionsByType(target,
+ CreateCopyInstructionsByType(target,
instr->getParent()->getParent(),
instr->getOperand(forwardOperandNum),
instr, minstrVec,
Index: llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp
diff -u llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.36 llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.37
--- llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.36 Sat Jul 17 19:38:32 2004
+++ llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp Tue Jul 27 12:43:23 2004
@@ -16,6 +16,7 @@
//===----------------------------------------------------------------------===//
#include "SparcV9Internals.h"
+#include "SparcV9InstrSelectionSupport.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/iMemory.h"
@@ -180,7 +181,7 @@
// load address of constant into a register, then load the constant
// this is now done during instruction selection
// the constant will live in the MachineConstantPool later on
- } else if (instrInfo.ConstantMayNotFitInImmedField(CV, &I)) {
+ } else if (ConstantMayNotFitInImmedField(CV, &I)) {
// put the constant into a virtual register using a cast
CastInst* castI = new CastInst(CV, CV->getType(), "copyConst",
&insertBefore);
More information about the llvm-commits
mailing list