mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-19 01:13:25 +00:00
Renamed inst_const_iterator -> const_inst_iterator
Renamed op_const_iterator -> const_op_iterator Renamed PointerType::getValueType() -> PointerType::getElementType() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1408 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e9bb2df410
commit
7a17675206
@ -16,7 +16,7 @@ class Constant;
|
||||
|
||||
class constant_iterator
|
||||
: public std::forward_iterator<const Constant, ptrdiff_t> {
|
||||
Method::inst_const_iterator InstI; // Method instruction iterator
|
||||
Method::const_inst_iterator InstI; // Method instruction iterator
|
||||
unsigned OpIdx; // Operand index
|
||||
|
||||
typedef constant_iterator _Self;
|
||||
|
@ -267,7 +267,7 @@ private:
|
||||
vector<bool> implicitIsDef; // machine instruction (eg, call args)
|
||||
|
||||
public:
|
||||
typedef ValOpIterator<const MachineInstr, const Value> val_op_const_iterator;
|
||||
typedef ValOpIterator<const MachineInstr, const Value> val_const_op_iterator;
|
||||
typedef ValOpIterator<const MachineInstr, Value> val_op_iterator;
|
||||
|
||||
public:
|
||||
@ -307,7 +307,7 @@ public:
|
||||
|
||||
public:
|
||||
friend ostream& operator<<(ostream& os, const MachineInstr& minstr);
|
||||
friend val_op_const_iterator;
|
||||
friend val_const_op_iterator;
|
||||
friend val_op_iterator;
|
||||
|
||||
public:
|
||||
|
@ -312,7 +312,7 @@ protected:
|
||||
PointerType(const Type *ElType);
|
||||
public:
|
||||
|
||||
inline const Type *getValueType() const { return ValueType; }
|
||||
inline const Type *getElementType() const { return ValueType; }
|
||||
|
||||
virtual const Type *getContainedType(unsigned i) const {
|
||||
return i == 0 ? ValueType.get() : 0;
|
||||
|
@ -114,10 +114,10 @@ public:
|
||||
BasicBlock::iterator, Instruction*> inst_iterator;
|
||||
typedef InstIterator<const BasicBlocksType, const_iterator,
|
||||
BasicBlock::const_iterator,
|
||||
const Instruction*> inst_const_iterator;
|
||||
const Instruction*> const_inst_iterator;
|
||||
|
||||
// This inner class is used to implement inst_begin() & inst_end() for
|
||||
// inst_iterator and inst_const_iterator's.
|
||||
// inst_iterator and const_inst_iterator's.
|
||||
//
|
||||
template <class _BB_t, class _BB_i_t, class _BI_t, class _II_t>
|
||||
class InstIterator {
|
||||
@ -197,8 +197,8 @@ public:
|
||||
|
||||
inline inst_iterator inst_begin() { return inst_iterator(*this); }
|
||||
inline inst_iterator inst_end() { return inst_iterator(*this, true); }
|
||||
inline inst_const_iterator inst_begin() const { return inst_const_iterator(*this); }
|
||||
inline inst_const_iterator inst_end() const { return inst_const_iterator(*this, true); }
|
||||
inline const_inst_iterator inst_begin() const { return const_inst_iterator(*this); }
|
||||
inline const_inst_iterator inst_end() const { return const_inst_iterator(*this, true); }
|
||||
};
|
||||
|
||||
// Provide specializations of GraphTraits to be able to treat a method as a
|
||||
|
@ -40,12 +40,12 @@ public:
|
||||
// Operand Iterator interface...
|
||||
//
|
||||
typedef vector<Use>::iterator op_iterator;
|
||||
typedef vector<Use>::const_iterator op_const_iterator;
|
||||
typedef vector<Use>::const_iterator const_op_iterator;
|
||||
|
||||
inline op_iterator op_begin() { return Operands.begin(); }
|
||||
inline op_const_iterator op_begin() const { return Operands.begin(); }
|
||||
inline const_op_iterator op_begin() const { return Operands.begin(); }
|
||||
inline op_iterator op_end() { return Operands.end(); }
|
||||
inline op_const_iterator op_end() const { return Operands.end(); }
|
||||
inline const_op_iterator op_end() const { return Operands.end(); }
|
||||
|
||||
// dropAllReferences() - This function is in charge of "letting go" of all
|
||||
// objects that this User refers to. This allows one to
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
|
||||
if (ArraySize) {
|
||||
// Make sure they didn't try to specify a size for !(unsized array) type
|
||||
assert(getType()->getValueType()->isArrayType() &&
|
||||
cast<ArrayType>(getType()->getValueType())->isUnsized() &&
|
||||
assert(getType()->getElementType()->isArrayType() &&
|
||||
cast<ArrayType>(getType()->getElementType())->isUnsized() &&
|
||||
"Trying to allocate something other than unsized array, with size!");
|
||||
assert(ArraySize->getType() == Type::UIntTy &&
|
||||
"Malloc/Allocation array size != UIntTy!");
|
||||
@ -37,8 +37,8 @@ public:
|
||||
Operands.push_back(Use(ArraySize, this));
|
||||
} else {
|
||||
// Make sure that the pointer is not to an unsized array!
|
||||
assert(!getType()->getValueType()->isArrayType() ||
|
||||
cast<const ArrayType>(getType()->getValueType())->isSized() &&
|
||||
assert(!getType()->getElementType()->isArrayType() ||
|
||||
cast<const ArrayType>(getType()->getElementType())->isSized() &&
|
||||
"Trying to allocate unsized array without size!");
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ public:
|
||||
// getAllocatedType - Return the type that is being allocated by the
|
||||
// instruction.
|
||||
inline const Type *getAllocatedType() const {
|
||||
return getType()->getValueType();
|
||||
return getType()->getElementType();
|
||||
}
|
||||
|
||||
virtual Instruction *clone() const = 0;
|
||||
@ -183,11 +183,11 @@ public:
|
||||
inline op_iterator idx_begin() {
|
||||
return op_begin()+getFirstIndexOperandNumber();
|
||||
}
|
||||
inline op_const_iterator idx_begin() const {
|
||||
inline const_op_iterator idx_begin() const {
|
||||
return op_begin()+getFirstIndexOperandNumber();
|
||||
}
|
||||
inline op_iterator idx_end() { return op_end(); }
|
||||
inline op_const_iterator idx_end() const { return op_end(); }
|
||||
inline const_op_iterator idx_end() const { return op_end(); }
|
||||
|
||||
|
||||
vector<Value*> copyIndices() const {
|
||||
|
@ -130,7 +130,7 @@ bool IsLeafMethod(const Method* M, const cfg::CallGraph* CG) {
|
||||
return (cgn->begin() == cgn->end());
|
||||
}
|
||||
|
||||
for (Method::inst_const_iterator I = M->inst_begin(), E = M->inst_end();
|
||||
for (Method::const_inst_iterator I = M->inst_begin(), E = M->inst_end();
|
||||
I != E; ++I)
|
||||
if ((*I)->getOpcode() == Instruction::Call)
|
||||
return false;
|
||||
|
@ -51,7 +51,7 @@ static inline bool isSafeInstruction(const Instruction *I) {
|
||||
//
|
||||
bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) {
|
||||
const Method *M = Meth; // We don't need/want write access
|
||||
for (Method::inst_const_iterator I = M->inst_begin(), E = M->inst_end();
|
||||
for (Method::const_inst_iterator I = M->inst_begin(), E = M->inst_end();
|
||||
I != E; ++I) {
|
||||
const Instruction *Inst = *I;
|
||||
const Type *ITy = Inst->getType();
|
||||
|
@ -59,13 +59,13 @@ bool FindUsedTypes::doPerMethodWork(Method *m) {
|
||||
// Loop over all of the instructions in the method, adding their return type
|
||||
// as well as the types of their operands.
|
||||
//
|
||||
for (Method::inst_const_iterator II = M->inst_begin(), IE = M->inst_end();
|
||||
for (Method::const_inst_iterator II = M->inst_begin(), IE = M->inst_end();
|
||||
II != IE; ++II) {
|
||||
const Instruction *I = *II;
|
||||
const Type *Ty = I->getType();
|
||||
|
||||
IncorporateType(Ty); // Incorporate the type of the instruction
|
||||
for (User::op_const_iterator OI = I->op_begin(), OE = I->op_end();
|
||||
for (User::const_op_iterator OI = I->op_begin(), OE = I->op_end();
|
||||
OI != OE; ++OI)
|
||||
if ((*OI)->getType() != Ty) // Avoid set lookup in common case
|
||||
IncorporateType((*OI)->getType()); // Insert inst operand types as well
|
||||
|
@ -39,7 +39,7 @@ void BBLiveVar::calcDefUseSets()
|
||||
}
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
|
||||
if( OpI.isDef() ) // add to Defs only if this operand is a def
|
||||
addDef( *OpI );
|
||||
@ -56,7 +56,7 @@ void BBLiveVar::calcDefUseSets()
|
||||
|
||||
|
||||
// iterate over MI operands to find uses
|
||||
for(MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
const Value *Op = *OpI;
|
||||
|
||||
if ( ((Op)->getType())->isLabelType() )
|
||||
|
@ -12,7 +12,7 @@
|
||||
void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
|
||||
{
|
||||
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
|
||||
if( OpI.isDef() ) // kill only if this operand is a def
|
||||
remove(*OpI); // this definition kills any uses
|
||||
@ -25,7 +25,7 @@ void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
|
||||
}
|
||||
|
||||
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
|
||||
if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
|
||||
|
||||
@ -50,7 +50,7 @@ void LiveVarSet::applyTranferFuncForInst(const Instruction *const Inst)
|
||||
if( Inst->isDefinition() ) { // add to Defs iff this instr is a definition
|
||||
remove(Inst); // this definition kills any uses
|
||||
}
|
||||
Instruction::op_const_iterator OpI = Inst->op_begin(); // get operand iterat
|
||||
Instruction::const_op_iterator OpI = Inst->op_begin(); // get operand iterat
|
||||
|
||||
for( ; OpI != Inst->op_end() ; OpI++) { // iterate over operands
|
||||
if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
|
||||
|
@ -54,7 +54,7 @@ inline bool ModuleAnalyzer::handleType(set<const Type *> &TypeSet,
|
||||
}
|
||||
|
||||
case Type::PointerTyID:
|
||||
if (handleType(TypeSet, ((const PointerType *)T)->getValueType()))
|
||||
if (handleType(TypeSet, cast<const PointerType>(T)->getElementType()))
|
||||
return true;
|
||||
break;
|
||||
|
||||
|
@ -184,8 +184,8 @@ typedef PlaceholderValue<BBPlaceHolderHelper> BBPlaceHolder;
|
||||
static inline ValID &getValIDFromPlaceHolder(const Value *Val) {
|
||||
const Type *Ty = Val->getType();
|
||||
if (isa<PointerType>(Ty) &&
|
||||
isa<MethodType>(cast<PointerType>(Ty)->getValueType()))
|
||||
Ty = cast<PointerType>(Ty)->getValueType();
|
||||
isa<MethodType>(cast<PointerType>(Ty)->getElementType()))
|
||||
Ty = cast<PointerType>(Ty)->getElementType();
|
||||
|
||||
switch (Ty->getPrimitiveID()) {
|
||||
case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getDef();
|
||||
@ -196,8 +196,8 @@ static inline ValID &getValIDFromPlaceHolder(const Value *Val) {
|
||||
static inline int getLineNumFromPlaceHolder(const Value *Val) {
|
||||
const Type *Ty = Val->getType();
|
||||
if (isa<PointerType>(Ty) &&
|
||||
isa<MethodType>(cast<PointerType>(Ty)->getValueType()))
|
||||
Ty = cast<PointerType>(Ty)->getValueType();
|
||||
isa<MethodType>(cast<PointerType>(Ty)->getElementType()))
|
||||
Ty = cast<PointerType>(Ty)->getElementType();
|
||||
|
||||
switch (Ty->getPrimitiveID()) {
|
||||
case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getLineNum();
|
||||
|
@ -983,7 +983,8 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
|
||||
// TODO: GlobalVariable here that includes the said information!
|
||||
|
||||
// Create a placeholder for the global variable reference...
|
||||
GlobalVariable *GV = new GlobalVariable(PT->getValueType(), false,true);
|
||||
GlobalVariable *GV = new GlobalVariable(PT->getElementType(),
|
||||
false, true);
|
||||
// Keep track of the fact that we have a forward ref to recycle it
|
||||
CurModule.GlobalRefs.insert(make_pair(make_pair(PT, $2), GV));
|
||||
|
||||
@ -1351,7 +1352,7 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
|
||||
const MethodType *Ty;
|
||||
|
||||
if (!(PMTy = dyn_cast<PointerType>($2->get())) ||
|
||||
!(Ty = dyn_cast<MethodType>(PMTy->getValueType()))) {
|
||||
!(Ty = dyn_cast<MethodType>(PMTy->getElementType()))) {
|
||||
// Pull out the types of all of the arguments...
|
||||
vector<const Type*> ParamTypes;
|
||||
if ($5) {
|
||||
@ -1487,7 +1488,7 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef {
|
||||
const MethodType *Ty;
|
||||
|
||||
if (!(PMTy = dyn_cast<PointerType>($2->get())) ||
|
||||
!(Ty = dyn_cast<MethodType>(PMTy->getValueType()))) {
|
||||
!(Ty = dyn_cast<MethodType>(PMTy->getElementType()))) {
|
||||
// Pull out the types of all of the arguments...
|
||||
vector<const Type*> ParamTypes;
|
||||
if ($5) {
|
||||
|
@ -305,7 +305,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
|
||||
|
||||
// Create a placeholder for the global variable reference...
|
||||
GlobalVariable *GVar =
|
||||
new GlobalVariable(PT->getValueType(), false, true);
|
||||
new GlobalVariable(PT->getElementType(), false, true);
|
||||
|
||||
// Keep track of the fact that we have a forward ref to recycle it
|
||||
GlobalRefs.insert(make_pair(make_pair(PT, Slot), GVar));
|
||||
|
@ -227,7 +227,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
||||
// Check to make sure we have a pointer to method type
|
||||
PointerType *PTy = dyn_cast<PointerType>(M->getType());
|
||||
if (PTy == 0) return failure(true);
|
||||
MethodType *MTy = dyn_cast<MethodType>(PTy->getValueType());
|
||||
MethodType *MTy = dyn_cast<MethodType>(PTy->getElementType());
|
||||
if (MTy == 0) return failure(true);
|
||||
|
||||
vector<Value *> Params;
|
||||
@ -287,7 +287,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
||||
// Check to make sure we have a pointer to method type
|
||||
PointerType *PTy = dyn_cast<PointerType>(M->getType());
|
||||
if (PTy == 0) return failure(true);
|
||||
MethodType *MTy = dyn_cast<MethodType>(PTy->getValueType());
|
||||
MethodType *MTy = dyn_cast<MethodType>(PTy->getElementType());
|
||||
if (MTy == 0) return failure(true);
|
||||
|
||||
vector<Value *> Params;
|
||||
@ -351,7 +351,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
||||
vector<Value*> Idx;
|
||||
if (!isa<PointerType>(Raw.Ty)) return failure(true);
|
||||
const CompositeType *TopTy =
|
||||
dyn_cast<CompositeType>(cast<PointerType>(Raw.Ty)->getValueType());
|
||||
dyn_cast<CompositeType>(cast<PointerType>(Raw.Ty)->getElementType());
|
||||
|
||||
switch (Raw.NumOperands) {
|
||||
case 0: cerr << "Invalid load encountered!\n"; return failure(true);
|
||||
@ -405,7 +405,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
||||
vector<Value*> Idx;
|
||||
if (!isa<PointerType>(Raw.Ty)) return failure(true);
|
||||
const CompositeType *TopTy =
|
||||
dyn_cast<CompositeType>(cast<PointerType>(Raw.Ty)->getValueType());
|
||||
dyn_cast<CompositeType>(cast<PointerType>(Raw.Ty)->getElementType());
|
||||
|
||||
switch (Raw.NumOperands) {
|
||||
case 0:
|
||||
|
@ -262,7 +262,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
|
||||
}
|
||||
|
||||
const PointerType *PMTy = MethodSignatureList.front().first; // PtrMeth
|
||||
const MethodType *MTy = dyn_cast<const MethodType>(PMTy->getValueType());
|
||||
const MethodType *MTy = dyn_cast<const MethodType>(PMTy->getElementType());
|
||||
if (MTy == 0) return failure(true); // Not ptr to method!
|
||||
|
||||
unsigned isInternal;
|
||||
@ -392,7 +392,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
|
||||
}
|
||||
|
||||
const PointerType *PTy = cast<const PointerType>(Ty);
|
||||
const Type *ElTy = PTy->getValueType();
|
||||
const Type *ElTy = PTy->getElementType();
|
||||
|
||||
Constant *Initializer = 0;
|
||||
if (VarType & 2) { // Does it have an initalizer?
|
||||
@ -430,13 +430,13 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
|
||||
while (MethSignature != Type::VoidTyID) { // List is terminated by Void
|
||||
const Type *Ty = getType(MethSignature);
|
||||
if (!Ty || !isa<PointerType>(Ty) ||
|
||||
!isa<MethodType>(cast<PointerType>(Ty)->getValueType())) {
|
||||
!isa<MethodType>(cast<PointerType>(Ty)->getElementType())) {
|
||||
Error = "Method not ptr to meth type! Ty = " + Ty->getDescription();
|
||||
return failure(true);
|
||||
}
|
||||
|
||||
// We create methods by passing the underlying MethodType to create...
|
||||
Ty = cast<PointerType>(Ty)->getValueType();
|
||||
Ty = cast<PointerType>(Ty)->getElementType();
|
||||
|
||||
// When the ModuleGlobalInfo section is read, we load the type of each
|
||||
// method and the 'ModuleValues' slot that it lands in. We then load a
|
||||
|
@ -74,7 +74,7 @@ void BytecodeWriter::outputType(const Type *T) {
|
||||
|
||||
case Type::PointerTyID: {
|
||||
const PointerType *PT = cast<const PointerType>(T);
|
||||
int Slot = Table.getValSlot(PT->getValueType());
|
||||
int Slot = Table.getValSlot(PT->getElementType());
|
||||
assert(Slot != -1 && "Type used but not available!!");
|
||||
output_vbr((unsigned)Slot, Out);
|
||||
break;
|
||||
|
@ -226,13 +226,13 @@ void BytecodeWriter::processInstruction(const Instruction *I) {
|
||||
NumOperands++;
|
||||
} else if (const CallInst *CI = dyn_cast<CallInst>(I)) {// Handle VarArg calls
|
||||
PointerType *Ty = cast<PointerType>(CI->getCalledValue()->getType());
|
||||
if (cast<MethodType>(Ty->getValueType())->isVarArg()) {
|
||||
if (cast<MethodType>(Ty->getElementType())->isVarArg()) {
|
||||
outputInstrVarArgsCall(I, Table, Type, Out);
|
||||
return;
|
||||
}
|
||||
} else if (const InvokeInst *II = dyn_cast<InvokeInst>(I)) { // ... & Invokes
|
||||
PointerType *Ty = cast<PointerType>(II->getCalledValue()->getType());
|
||||
if (cast<MethodType>(Ty->getValueType())->isVarArg()) {
|
||||
if (cast<MethodType>(Ty->getElementType())->isVarArg()) {
|
||||
outputInstrVarArgsCall(I, Table, Type, Out);
|
||||
return;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ int SlotCalculator::insertValue(const Value *D) {
|
||||
// of const ints), that they are inserted also. Same for global variable
|
||||
// initializers.
|
||||
//
|
||||
for(User::op_const_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
|
||||
for(User::const_op_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
|
||||
if (!isa<GlobalValue>(*I)) // Don't chain insert global values
|
||||
insertValue(*I);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
|
||||
const LiveVarSet* liveVars =
|
||||
methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
|
||||
|
||||
for (MachineInstr::val_op_const_iterator vo(minstr); ! vo.done(); ++vo)
|
||||
for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
|
||||
if (liveVars->find(*vo) == liveVars->end())
|
||||
{
|
||||
hasLastUse = true;
|
||||
|
@ -250,8 +250,7 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
|
||||
|
||||
PHINode *PN = (PHINode *) (*IIt);
|
||||
|
||||
Value *PhiCpRes =
|
||||
new Value(PN->getType(), PN->getValueType() );
|
||||
Value *PhiCpRes = new Value(PN->getType(), PN->getValueType());
|
||||
|
||||
string *Name = new string("PhiCp:");
|
||||
(*Name) += (int) PhiCpRes;
|
||||
|
@ -102,7 +102,7 @@ operator<< (ostream& os, const MachineInstr& minstr)
|
||||
#undef DEBUG_VAL_OP_ITERATOR
|
||||
#ifdef DEBUG_VAL_OP_ITERATOR
|
||||
os << endl << "\tValue operands are: ";
|
||||
for (MachineInstr::val_op_const_iterator vo(&minstr); ! vo.done(); ++vo)
|
||||
for (MachineInstr::val_const_op_iterator vo(&minstr); ! vo.done(); ++vo)
|
||||
{
|
||||
const Value* val = *vo;
|
||||
os << val << (vo.isDef()? "(def), " : ", ");
|
||||
@ -218,7 +218,7 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Method* method)
|
||||
|
||||
unsigned int maxSize = 0;
|
||||
|
||||
for (Method::inst_const_iterator I=method->inst_begin(),E=method->inst_end();
|
||||
for (Method::const_inst_iterator I=method->inst_begin(),E=method->inst_end();
|
||||
I != E; ++I)
|
||||
if ((*I)->getOpcode() == Instruction::Call)
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ void LiveRangeInfo::constructLiveRanges()
|
||||
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
|
||||
if( DEBUG_RA) {
|
||||
MachineOperand::MachineOperandType OpTyp =
|
||||
@ -286,7 +286,7 @@ void LiveRangeInfo::coalesceLRs()
|
||||
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for(MachineInstr::val_op_const_iterator DefI(MInst);!DefI.done();++DefI){
|
||||
for(MachineInstr::val_const_op_iterator DefI(MInst);!DefI.done();++DefI){
|
||||
|
||||
if( DefI.isDef() ) { // iff this operand is a def
|
||||
|
||||
@ -294,7 +294,7 @@ void LiveRangeInfo::coalesceLRs()
|
||||
assert( LROfDef );
|
||||
RegClass *const RCOfDef = LROfDef->getRegClass();
|
||||
|
||||
MachineInstr::val_op_const_iterator UseI(MInst);
|
||||
MachineInstr::val_const_op_iterator UseI(MInst);
|
||||
for( ; !UseI.done(); ++UseI){ // for all uses
|
||||
|
||||
LiveRange *const LROfUse = getLiveRangeForValue( *UseI );
|
||||
|
@ -262,7 +262,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
|
||||
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
|
||||
if( OpI.isDef() ) {
|
||||
// create a new LR iff this operand is a def
|
||||
@ -318,7 +318,7 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
|
||||
bool setInterf = false;
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator It1(MInst);!It1.done(); ++It1) {
|
||||
for( MachineInstr::val_const_op_iterator It1(MInst);!It1.done(); ++It1) {
|
||||
|
||||
const LiveRange *const LROfOp1 = LRI.getLiveRangeForValue( *It1 );
|
||||
|
||||
@ -327,7 +327,7 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
|
||||
|
||||
//if( !LROfOp1 ) continue;
|
||||
|
||||
MachineInstr::val_op_const_iterator It2 = It1;
|
||||
MachineInstr::val_const_op_iterator It2 = It1;
|
||||
++It2;
|
||||
|
||||
for( ; !It2.done(); ++It2) {
|
||||
@ -429,7 +429,7 @@ void PhyRegAlloc::updateMachineCode()
|
||||
//mcInfo.popAllTempValues(TM);
|
||||
// TODO ** : do later
|
||||
|
||||
//for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
//for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
|
||||
|
||||
// Now replace set the registers for operands in the machine instruction
|
||||
@ -928,7 +928,7 @@ void PhyRegAlloc::printMachineCode()
|
||||
cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
|
||||
|
||||
|
||||
//for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
//for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
|
||||
for(unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum) {
|
||||
|
||||
|
@ -237,7 +237,7 @@ Annotation *GlobalAddress::Create(AnnotationID AID, const Annotable *O, void *){
|
||||
GlobalVariable *GV = cast<GlobalVariable>(GVal);
|
||||
|
||||
// First off, we must allocate space for the global variable to point at...
|
||||
const Type *Ty = GV->getType()->getValueType(); // Type to be allocated
|
||||
const Type *Ty = GV->getType()->getElementType(); // Type to be allocated
|
||||
unsigned NumElements = 1;
|
||||
|
||||
if (isa<ArrayType>(Ty) && cast<ArrayType>(Ty)->isUnsized()) {
|
||||
@ -728,7 +728,7 @@ void Interpreter::executeBrInst(BranchInst *I, ExecutionContext &SF) {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void Interpreter::executeAllocInst(AllocationInst *I, ExecutionContext &SF) {
|
||||
const Type *Ty = I->getType()->getValueType(); // Type to be allocated
|
||||
const Type *Ty = I->getType()->getElementType(); // Type to be allocated
|
||||
unsigned NumElements = 1;
|
||||
|
||||
if (I->getNumOperands()) { // Allocating a unsized array type?
|
||||
@ -771,7 +771,7 @@ static PointerTy getElementOffset(MemAccessInst *I, ExecutionContext &SF) {
|
||||
|
||||
PointerTy Total = 0;
|
||||
const Type *Ty =
|
||||
cast<PointerType>(I->getPointerOperand()->getType())->getValueType();
|
||||
cast<PointerType>(I->getPointerOperand()->getType())->getElementType();
|
||||
|
||||
unsigned ArgOff = I->getFirstIndexOperandNumber();
|
||||
while (ArgOff < I->getNumOperands()) {
|
||||
|
@ -130,8 +130,8 @@ GenericValue lle_X_printVal(MethodType *M, const vector<GenericValue> &ArgVal) {
|
||||
|
||||
// Specialize print([ubyte {x N} ] *) and print(sbyte *)
|
||||
if (PointerType *PTy = dyn_cast<PointerType>(M->getParamTypes()[0].get()))
|
||||
if (PTy->getValueType() == Type::SByteTy ||
|
||||
isa<ArrayType>(PTy->getValueType())) {
|
||||
if (PTy->getElementType() == Type::SByteTy ||
|
||||
isa<ArrayType>(PTy->getElementType())) {
|
||||
return lle_VP_printstr(M, ArgVal);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
||||
// later by LinkGlobalInits...
|
||||
//
|
||||
GlobalVariable *DGV =
|
||||
new GlobalVariable(SGV->getType()->getValueType(), SGV->isConstant(),
|
||||
new GlobalVariable(SGV->getType()->getElementType(), SGV->isConstant(),
|
||||
SGV->hasInternalLinkage(), 0, SGV->getName());
|
||||
|
||||
// Add the new global to the dest module
|
||||
|
@ -268,7 +268,7 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
|
||||
const LiveVarSet* liveVars =
|
||||
methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
|
||||
|
||||
for (MachineInstr::val_op_const_iterator vo(minstr); ! vo.done(); ++vo)
|
||||
for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
|
||||
if (liveVars->find(*vo) == liveVars->end())
|
||||
{
|
||||
hasLastUse = true;
|
||||
|
@ -250,8 +250,7 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
|
||||
|
||||
PHINode *PN = (PHINode *) (*IIt);
|
||||
|
||||
Value *PhiCpRes =
|
||||
new Value(PN->getType(), PN->getValueType() );
|
||||
Value *PhiCpRes = new Value(PN->getType(), PN->getValueType());
|
||||
|
||||
string *Name = new string("PhiCp:");
|
||||
(*Name) += (int) PhiCpRes;
|
||||
|
@ -39,7 +39,7 @@ void BBLiveVar::calcDefUseSets()
|
||||
}
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
|
||||
if( OpI.isDef() ) // add to Defs only if this operand is a def
|
||||
addDef( *OpI );
|
||||
@ -56,7 +56,7 @@ void BBLiveVar::calcDefUseSets()
|
||||
|
||||
|
||||
// iterate over MI operands to find uses
|
||||
for(MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
|
||||
const Value *Op = *OpI;
|
||||
|
||||
if ( ((Op)->getType())->isLabelType() )
|
||||
|
@ -12,7 +12,7 @@
|
||||
void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
|
||||
{
|
||||
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
|
||||
if( OpI.isDef() ) // kill only if this operand is a def
|
||||
remove(*OpI); // this definition kills any uses
|
||||
@ -25,7 +25,7 @@ void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
|
||||
}
|
||||
|
||||
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
|
||||
|
||||
if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
|
||||
|
||||
@ -50,7 +50,7 @@ void LiveVarSet::applyTranferFuncForInst(const Instruction *const Inst)
|
||||
if( Inst->isDefinition() ) { // add to Defs iff this instr is a definition
|
||||
remove(Inst); // this definition kills any uses
|
||||
}
|
||||
Instruction::op_const_iterator OpI = Inst->op_begin(); // get operand iterat
|
||||
Instruction::const_op_iterator OpI = Inst->op_begin(); // get operand iterat
|
||||
|
||||
for( ; OpI != Inst->op_end() ; OpI++) { // iterate over operands
|
||||
if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
|
||||
|
@ -122,7 +122,7 @@ void LiveRangeInfo::constructLiveRanges()
|
||||
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
|
||||
if( DEBUG_RA) {
|
||||
MachineOperand::MachineOperandType OpTyp =
|
||||
@ -286,7 +286,7 @@ void LiveRangeInfo::coalesceLRs()
|
||||
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for(MachineInstr::val_op_const_iterator DefI(MInst);!DefI.done();++DefI){
|
||||
for(MachineInstr::val_const_op_iterator DefI(MInst);!DefI.done();++DefI){
|
||||
|
||||
if( DefI.isDef() ) { // iff this operand is a def
|
||||
|
||||
@ -294,7 +294,7 @@ void LiveRangeInfo::coalesceLRs()
|
||||
assert( LROfDef );
|
||||
RegClass *const RCOfDef = LROfDef->getRegClass();
|
||||
|
||||
MachineInstr::val_op_const_iterator UseI(MInst);
|
||||
MachineInstr::val_const_op_iterator UseI(MInst);
|
||||
for( ; !UseI.done(); ++UseI){ // for all uses
|
||||
|
||||
LiveRange *const LROfUse = getLiveRangeForValue( *UseI );
|
||||
|
@ -262,7 +262,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
|
||||
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
|
||||
|
||||
if( OpI.isDef() ) {
|
||||
// create a new LR iff this operand is a def
|
||||
@ -318,7 +318,7 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
|
||||
bool setInterf = false;
|
||||
|
||||
// iterate over MI operands to find defs
|
||||
for( MachineInstr::val_op_const_iterator It1(MInst);!It1.done(); ++It1) {
|
||||
for( MachineInstr::val_const_op_iterator It1(MInst);!It1.done(); ++It1) {
|
||||
|
||||
const LiveRange *const LROfOp1 = LRI.getLiveRangeForValue( *It1 );
|
||||
|
||||
@ -327,7 +327,7 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
|
||||
|
||||
//if( !LROfOp1 ) continue;
|
||||
|
||||
MachineInstr::val_op_const_iterator It2 = It1;
|
||||
MachineInstr::val_const_op_iterator It2 = It1;
|
||||
++It2;
|
||||
|
||||
for( ; !It2.done(); ++It2) {
|
||||
@ -429,7 +429,7 @@ void PhyRegAlloc::updateMachineCode()
|
||||
//mcInfo.popAllTempValues(TM);
|
||||
// TODO ** : do later
|
||||
|
||||
//for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
//for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
|
||||
|
||||
// Now replace set the registers for operands in the machine instruction
|
||||
@ -928,7 +928,7 @@ void PhyRegAlloc::printMachineCode()
|
||||
cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
|
||||
|
||||
|
||||
//for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
//for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
|
||||
|
||||
for(unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum) {
|
||||
|
||||
|
@ -612,10 +612,10 @@ SparcAsmPrinter::printGlobalVariable(const GlobalVariable* GV)
|
||||
printConstant(GV->getInitializer(), getID(GV));
|
||||
else {
|
||||
toAsm << "\t.align\t"
|
||||
<< TypeToAlignment(GV->getType()->getValueType(), Target) << endl;
|
||||
<< TypeToAlignment(GV->getType()->getElementType(), Target) << endl;
|
||||
toAsm << "\t.type\t" << getID(GV) << ",#object" << endl;
|
||||
toAsm << "\t.reserve\t" << getID(GV) << ","
|
||||
<< TypeToSize(GV->getType()->getValueType(), Target)
|
||||
<< TypeToSize(GV->getType()->getElementType(), Target)
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
@ -771,7 +771,7 @@ SetOperandsForMemInstr(MachineInstr* minstr,
|
||||
newIdxVec->insert(newIdxVec->end(), idxVec->begin(), idxVec->end());
|
||||
idxVec = newIdxVec;
|
||||
|
||||
assert(! ((PointerType*)ptrVal->getType())->getValueType()->isArrayType()
|
||||
assert(!((PointerType*)ptrVal->getType())->getElementType()->isArrayType()
|
||||
&& "GetElemPtr cannot be folded into array refs in selection");
|
||||
}
|
||||
else
|
||||
@ -782,7 +782,7 @@ SetOperandsForMemInstr(MachineInstr* minstr,
|
||||
//
|
||||
ptrVal = memInst->getPointerOperand();
|
||||
|
||||
const Type* opType = cast<PointerType>(ptrVal->getType())->getValueType();
|
||||
const Type* opType = cast<PointerType>(ptrVal->getType())->getElementType();
|
||||
if (opType->isArrayType())
|
||||
{
|
||||
assert((memInst->getNumOperands()
|
||||
@ -826,7 +826,7 @@ SetMemOperands_Internal(MachineInstr* minstr,
|
||||
|
||||
const PointerType* ptrType = (PointerType*) ptrVal->getType();
|
||||
|
||||
if (ptrType->getValueType()->isStructType())
|
||||
if (ptrType->getElementType()->isStructType())
|
||||
{
|
||||
// the offset is always constant for structs
|
||||
isConstantOffset = true;
|
||||
@ -839,7 +839,7 @@ SetMemOperands_Internal(MachineInstr* minstr,
|
||||
// It must be an array ref. Check if the offset is a constant,
|
||||
// and that the indexing has been lowered to a single offset.
|
||||
//
|
||||
assert(ptrType->getValueType()->isArrayType());
|
||||
assert(ptrType->getElementType()->isArrayType());
|
||||
assert(arrayOffsetVal != NULL
|
||||
&& "Expect to be given Value* for array offsets");
|
||||
|
||||
@ -1835,7 +1835,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
||||
cast<GetElementPtrInst>(subtreeRoot->getInstruction());
|
||||
const PointerType* ptrType =
|
||||
cast<PointerType>(getElemInst->getPointerOperand()->getType());
|
||||
if (! ptrType->getValueType()->isArrayType())
|
||||
if (! ptrType->getElementType()->isArrayType())
|
||||
{// we don't need a separate instr
|
||||
numInstr = 0; // don't forward operand!
|
||||
break;
|
||||
@ -1853,7 +1853,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
||||
const PointerType* instrType = (const PointerType*) instr->getType();
|
||||
assert(instrType->isPointerType());
|
||||
int tsize = (int)
|
||||
target.findOptimalStorageSize(instrType->getValueType());
|
||||
target.findOptimalStorageSize(instrType->getElementType());
|
||||
assert(tsize != 0 && "Just to check when this can happen");
|
||||
|
||||
Method* method = instr->getParent()->getParent();
|
||||
@ -1881,9 +1881,9 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
|
||||
Instruction* instr = subtreeRoot->getInstruction();
|
||||
const PointerType* instrType = (const PointerType*) instr->getType();
|
||||
assert(instrType->isPointerType() &&
|
||||
instrType->getValueType()->isArrayType());
|
||||
instrType->getElementType()->isArrayType());
|
||||
const Type* eltType =
|
||||
((ArrayType*) instrType->getValueType())->getElementType();
|
||||
((ArrayType*) instrType->getElementType())->getElementType();
|
||||
int tsize = (int) target.findOptimalStorageSize(eltType);
|
||||
|
||||
assert(tsize != 0 && "Just to check when this can happen");
|
||||
|
@ -151,7 +151,7 @@ unsigned TargetData::getIndexedOffset(const Type *ptrTy,
|
||||
unsigned Result = 0;
|
||||
|
||||
// Get the type pointed to...
|
||||
const Type *Ty = PtrTy->getValueType();
|
||||
const Type *Ty = PtrTy->getElementType();
|
||||
|
||||
for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) {
|
||||
if (const StructType *STy = dyn_cast<const StructType>(Ty)) {
|
||||
|
@ -34,7 +34,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
|
||||
// pointer value.
|
||||
//
|
||||
static bool AllIndicesZero(const MemAccessInst *MAI) {
|
||||
for (User::op_const_iterator S = MAI->idx_begin(), E = MAI->idx_end();
|
||||
for (User::const_op_iterator S = MAI->idx_begin(), E = MAI->idx_end();
|
||||
S != E; ++S)
|
||||
if (!isa<Constant>(*S) || !cast<Constant>(*S)->isNullValue())
|
||||
return false;
|
||||
@ -66,7 +66,7 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
|
||||
!isa<PointerType>(Ty)) return false; // Malloc always returns pointers
|
||||
|
||||
// Deal with the type to allocate, not the pointer type...
|
||||
Ty = cast<PointerType>(Ty)->getValueType();
|
||||
Ty = cast<PointerType>(Ty)->getElementType();
|
||||
|
||||
// Analyze the number of bytes allocated...
|
||||
analysis::ExprType Expr = analysis::ClassifyExpression(MI->getArraySize());
|
||||
@ -117,7 +117,7 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
|
||||
if (CastInst *CI = dyn_cast<CastInst>(*I))
|
||||
if (const PointerType *PT =
|
||||
dyn_cast<PointerType>(CI->getOperand(0)->getType()))
|
||||
if (getBaseTypeSize(PT->getValueType()) > ReqTypeSize)
|
||||
if (getBaseTypeSize(PT->getElementType()) > ReqTypeSize)
|
||||
return false; // We found a type bigger than this one!
|
||||
|
||||
return true;
|
||||
@ -133,10 +133,10 @@ static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty,
|
||||
analysis::ExprType Expr = analysis::ClassifyExpression(MI->getArraySize());
|
||||
|
||||
const PointerType *AllocTy = cast<PointerType>(Ty);
|
||||
const Type *ElType = AllocTy->getValueType();
|
||||
const Type *ElType = AllocTy->getElementType();
|
||||
|
||||
if (Expr.Var && !isa<ArrayType>(ElType)) {
|
||||
ElType = ArrayType::get(AllocTy->getValueType());
|
||||
ElType = ArrayType::get(AllocTy->getElementType());
|
||||
AllocTy = PointerType::get(ElType);
|
||||
}
|
||||
|
||||
@ -216,8 +216,8 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
|
||||
//
|
||||
if (PointerType *SPT = dyn_cast<PointerType>(I->getOperand(0)->getType()))
|
||||
if (PointerType *DPT = dyn_cast<PointerType>(I->getType()))
|
||||
if (ArrayType *AT = dyn_cast<ArrayType>(SPT->getValueType()))
|
||||
if (AT->getElementType() == DPT->getValueType())
|
||||
if (ArrayType *AT = dyn_cast<ArrayType>(SPT->getElementType()))
|
||||
if (AT->getElementType() == DPT->getElementType())
|
||||
return false;
|
||||
#endif
|
||||
break;
|
||||
@ -290,7 +290,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
|
||||
Indices.pop_back();
|
||||
ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices,
|
||||
true);
|
||||
if (ElTy == PTy->getValueType())
|
||||
if (ElTy == PTy->getElementType())
|
||||
break; // Found a match!!
|
||||
ElTy = 0;
|
||||
}
|
||||
@ -430,7 +430,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
|
||||
//
|
||||
vector<Value*> Indices = GEP->copyIndices();
|
||||
const Type *BaseType = GEP->getPointerOperand()->getType();
|
||||
const Type *PVTy = cast<PointerType>(Ty)->getValueType();
|
||||
const Type *PVTy = cast<PointerType>(Ty)->getElementType();
|
||||
Res = 0;
|
||||
while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) &&
|
||||
cast<ConstantUInt>(Indices.back())->getValue() == 0) {
|
||||
@ -546,8 +546,8 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
|
||||
//
|
||||
if (PointerType *SPT = dyn_cast<PointerType>(I->getOperand(0)->getType()))
|
||||
if (PointerType *DPT = dyn_cast<PointerType>(I->getType()))
|
||||
if (ArrayType *AT = dyn_cast<ArrayType>(SPT->getValueType()))
|
||||
if (AT->getElementType() == DPT->getValueType())
|
||||
if (ArrayType *AT = dyn_cast<ArrayType>(SPT->getElementType()))
|
||||
if (AT->getElementType() == DPT->getElementType())
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
@ -595,7 +595,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
|
||||
if (LI->hasIndices() && !AllIndicesZero(LI))
|
||||
return false;
|
||||
|
||||
const Type *LoadedTy = PT->getValueType();
|
||||
const Type *LoadedTy = PT->getElementType();
|
||||
|
||||
// They could be loading the first element of a composite type...
|
||||
if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
|
||||
@ -625,16 +625,16 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
|
||||
return ExpressionConvertableToType(I->getOperand(1), PointerType::get(Ty),
|
||||
CTMap);
|
||||
} else if (const PointerType *PT = dyn_cast<PointerType>(Ty)) {
|
||||
if (isa<ArrayType>(PT->getValueType()))
|
||||
if (isa<ArrayType>(PT->getElementType()))
|
||||
return false; // Avoid getDataSize on unsized array type!
|
||||
assert(V == I->getOperand(1));
|
||||
|
||||
// Must move the same amount of data...
|
||||
if (TD.getTypeSize(PT->getValueType()) !=
|
||||
if (TD.getTypeSize(PT->getElementType()) !=
|
||||
TD.getTypeSize(I->getOperand(0)->getType())) return false;
|
||||
|
||||
// Can convert store if the incoming value is convertable...
|
||||
return ExpressionConvertableToType(I->getOperand(0), PT->getValueType(),
|
||||
return ExpressionConvertableToType(I->getOperand(0), PT->getElementType(),
|
||||
CTMap);
|
||||
}
|
||||
return false;
|
||||
@ -667,7 +667,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
|
||||
return false; // Can't convert method pointer type yet. FIXME
|
||||
|
||||
const PointerType *MPtr = cast<PointerType>(I->getOperand(0)->getType());
|
||||
const MethodType *MTy = cast<MethodType>(MPtr->getValueType());
|
||||
const MethodType *MTy = cast<MethodType>(MPtr->getElementType());
|
||||
if (!MTy->isVarArg()) return false;
|
||||
|
||||
if ((OpNum-1) < MTy->getParamTypes().size())
|
||||
@ -743,7 +743,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
|
||||
const Type *RetTy = PointerType::get(ETy);
|
||||
// First operand is actually the given pointer...
|
||||
Res = new GetElementPtrInst(NewVal, Indices);
|
||||
assert(cast<PointerType>(Res->getType())->getValueType() == ETy &&
|
||||
assert(cast<PointerType>(Res->getType())->getElementType() == ETy &&
|
||||
"ConvertableToGEP broken!");
|
||||
break;
|
||||
}
|
||||
@ -774,7 +774,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
|
||||
|
||||
case Instruction::Load: {
|
||||
assert(I->getOperand(0) == OldVal && isa<PointerType>(NewVal->getType()));
|
||||
const Type *LoadedTy = cast<PointerType>(NewVal->getType())->getValueType();
|
||||
const Type *LoadedTy = cast<PointerType>(NewVal->getType())->getElementType();
|
||||
|
||||
vector<Value*> Indices;
|
||||
|
||||
@ -796,7 +796,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
|
||||
VMC.ExprMap[I] = Res;
|
||||
Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), NewPT, VMC));
|
||||
} else { // Replace the source pointer
|
||||
const Type *ValTy = cast<PointerType>(NewTy)->getValueType();
|
||||
const Type *ValTy = cast<PointerType>(NewTy)->getElementType();
|
||||
Res = new StoreInst(Constant::getNullConstant(ValTy), NewVal);
|
||||
VMC.ExprMap[I] = Res;
|
||||
Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), ValTy, VMC));
|
||||
|
@ -87,7 +87,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
|
||||
//
|
||||
for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I)
|
||||
if (const PointerType *PT = dyn_cast<PointerType>(I->first))
|
||||
if (const MethodType *MT = dyn_cast<MethodType>(PT->getValueType())) {
|
||||
if (const MethodType *MT = dyn_cast<MethodType>(PT->getElementType())) {
|
||||
SymbolTable::VarMap &Plane = I->second;
|
||||
for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end();
|
||||
PI != PE; ++PI) {
|
||||
@ -208,7 +208,7 @@ static inline bool ShouldNukeSymtabEntry(const pair<string, Value*> &E) {
|
||||
|
||||
// Nuke all pointers to primitive types as well...
|
||||
if (const PointerType *PT = dyn_cast<PointerType>(E.second))
|
||||
if (PT->getValueType()->isPrimitiveType()) return true;
|
||||
if (PT->getElementType()->isPrimitiveType()) return true;
|
||||
|
||||
// The only types that could contain .'s in the program are things generated
|
||||
// by GCC itself, including "complex.float" and friends. Nuke them too.
|
||||
|
@ -86,7 +86,7 @@ const Type *MutateStructTypes::ConvertType(const Type *Ty) {
|
||||
|
||||
case Type::PointerTyID:
|
||||
DestTy = PointerType::get(
|
||||
ConvertType(cast<PointerType>(Ty)->getValueType()));
|
||||
ConvertType(cast<PointerType>(Ty)->getElementType()));
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Unknown type!");
|
||||
@ -432,7 +432,7 @@ bool MutateStructTypes::doPerMethodWork(Method *m) {
|
||||
const Value *Ptr = MAI->getPointerOperand();
|
||||
Value *NewPtr = ConvertValue(Ptr);
|
||||
if (!Indices.empty()) {
|
||||
const Type *PTy = cast<PointerType>(Ptr->getType())->getValueType();
|
||||
const Type *PTy = cast<PointerType>(Ptr->getType())->getElementType();
|
||||
AdjustIndices(cast<CompositeType>(PTy), Indices);
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,10 @@ PrintMethodNameForType(const Type* type)
|
||||
if (PointerType* pty = dyn_cast<PointerType>(type))
|
||||
{
|
||||
const Type* elemTy;
|
||||
if (ArrayType* aty = dyn_cast<ArrayType>(pty->getValueType()))
|
||||
if (ArrayType* aty = dyn_cast<ArrayType>(pty->getElementType()))
|
||||
elemTy = aty->getElementType();
|
||||
else
|
||||
elemTy = pty->getValueType();
|
||||
elemTy = pty->getElementType();
|
||||
if (elemTy == Type::SByteTy || elemTy == Type::UByteTy)
|
||||
return "printString";
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
|
||||
// type.
|
||||
//
|
||||
if (!HasAddUse) {
|
||||
const Type *DestPointedTy = DestPTy->getValueType();
|
||||
const Type *DestPointedTy = DestPTy->getElementType();
|
||||
unsigned Depth = 1;
|
||||
const CompositeType *CurCTy = CTy;
|
||||
const Type *ElTy = 0;
|
||||
@ -313,12 +313,12 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
|
||||
if (Value *CastSrc = CI->getOperand(0)) // CSPT = CastSrcPointerType
|
||||
if (PointerType *CSPT = dyn_cast<PointerType>(CastSrc->getType()))
|
||||
// convertable types?
|
||||
if (Val->getType()->isLosslesslyConvertableTo(CSPT->getValueType()) &&
|
||||
if (Val->getType()->isLosslesslyConvertableTo(CSPT->getElementType()) &&
|
||||
!SI->hasIndices()) { // No subscripts yet!
|
||||
PRINT_PEEPHOLE3("st-src-cast:in ", Pointer, Val, SI);
|
||||
|
||||
// Insert the new T cast instruction... stealing old T's name
|
||||
CastInst *NCI = new CastInst(Val, CSPT->getValueType(),
|
||||
CastInst *NCI = new CastInst(Val, CSPT->getElementType(),
|
||||
CI->getName());
|
||||
CI->setName("");
|
||||
BI = BB->getInstList().insert(BI, NCI)+1;
|
||||
@ -372,7 +372,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
|
||||
if (CastInst *CI = dyn_cast<CastInst>(Pointer)) {
|
||||
Value *SrcVal = CI->getOperand(0);
|
||||
const PointerType *SrcTy = dyn_cast<PointerType>(SrcVal->getType());
|
||||
const Type *ElTy = SrcTy ? SrcTy->getValueType() : 0;
|
||||
const Type *ElTy = SrcTy ? SrcTy->getElementType() : 0;
|
||||
|
||||
// Make sure that nothing will be lost in the new cast...
|
||||
if (!LI->hasIndices() && SrcTy &&
|
||||
@ -445,7 +445,7 @@ static bool DoInsertArrayCast(Value *V, BasicBlock *BB,
|
||||
const PointerType *ThePtrType = dyn_cast<PointerType>(V->getType());
|
||||
if (!ThePtrType) return false;
|
||||
|
||||
const Type *ElTy = ThePtrType->getValueType();
|
||||
const Type *ElTy = ThePtrType->getElementType();
|
||||
if (isa<MethodType>(ElTy) || isa<ArrayType>(ElTy)) return false;
|
||||
|
||||
unsigned ElementSize = TD.getTypeSize(ElTy);
|
||||
@ -456,8 +456,8 @@ static bool DoInsertArrayCast(Value *V, BasicBlock *BB,
|
||||
switch (Inst->getOpcode()) {
|
||||
case Instruction::Cast: // There is already a cast instruction!
|
||||
if (const PointerType *PT = dyn_cast<const PointerType>(Inst->getType()))
|
||||
if (const ArrayType *AT = dyn_cast<const ArrayType>(PT->getValueType()))
|
||||
if (AT->getElementType() == ThePtrType->getValueType()) {
|
||||
if (const ArrayType *AT = dyn_cast<const ArrayType>(PT->getElementType()))
|
||||
if (AT->getElementType() == ThePtrType->getElementType()) {
|
||||
// Cast already exists! Don't mess around with it.
|
||||
return false; // No changes made to program though...
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ static inline bool isFirstClassType(const Type *Ty) {
|
||||
//
|
||||
static inline const CompositeType *getPointedToComposite(const Type *Ty) {
|
||||
const PointerType *PT = dyn_cast<PointerType>(Ty);
|
||||
return PT ? dyn_cast<CompositeType>(PT->getValueType()) : 0;
|
||||
return PT ? dyn_cast<CompositeType>(PT->getElementType()) : 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -179,7 +179,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
||||
// later by LinkGlobalInits...
|
||||
//
|
||||
GlobalVariable *DGV =
|
||||
new GlobalVariable(SGV->getType()->getValueType(), SGV->isConstant(),
|
||||
new GlobalVariable(SGV->getType()->getElementType(), SGV->isConstant(),
|
||||
SGV->hasInternalLinkage(), 0, SGV->getName());
|
||||
|
||||
// Add the new global to the dest module
|
||||
|
@ -67,7 +67,7 @@ bool LowerAllocations::doPerMethodWork(Method *M) {
|
||||
if (MallocInst *MI = dyn_cast<MallocInst>(*(BBIL.begin()+i))) {
|
||||
BBIL.remove(BBIL.begin()+i); // remove the malloc instr...
|
||||
|
||||
const Type *AllocTy = cast<PointerType>(MI->getType())->getValueType();
|
||||
const Type *AllocTy =cast<PointerType>(MI->getType())->getElementType();
|
||||
|
||||
// If the user is allocating an unsized array with a dynamic size arg,
|
||||
// start by getting the size of one element.
|
||||
|
@ -111,7 +111,7 @@ static void fillTypeNameTable(const Module *M,
|
||||
//
|
||||
const Type *Ty = cast<const Type>(I->second);
|
||||
if (!isa<PointerType>(Ty) ||
|
||||
!cast<PointerType>(Ty)->getValueType()->isPrimitiveType())
|
||||
!cast<PointerType>(Ty)->getElementType()->isPrimitiveType())
|
||||
TypeNames.insert(make_pair(Ty, "%"+I->first));
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,7 @@ static string calcTypeName(const Type *Ty, vector<const Type *> &TypeStack,
|
||||
break;
|
||||
}
|
||||
case Type::PointerTyID:
|
||||
Result = calcTypeName(cast<const PointerType>(Ty)->getValueType(),
|
||||
Result = calcTypeName(cast<const PointerType>(Ty)->getElementType(),
|
||||
TypeStack, TypeNames) + " *";
|
||||
break;
|
||||
case Type::ArrayTyID: {
|
||||
@ -325,7 +325,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
|
||||
if (!GV->hasInitializer()) Out << "uninitialized ";
|
||||
|
||||
Out << (GV->isConstant() ? "constant " : "global ");
|
||||
printType(GV->getType()->getValueType());
|
||||
printType(GV->getType()->getElementType());
|
||||
|
||||
if (GV->hasInitializer())
|
||||
writeOperand(GV->getInitializer(), false, false);
|
||||
@ -534,7 +534,7 @@ void AssemblyWriter::printInstruction(const Instruction *I) {
|
||||
Out << " void";
|
||||
} else if (isa<CallInst>(I)) {
|
||||
const PointerType *PTy = dyn_cast<PointerType>(Operand->getType());
|
||||
const MethodType *MTy = PTy ? dyn_cast<MethodType>(PTy->getValueType()) :0;
|
||||
const MethodType *MTy = PTy ?dyn_cast<MethodType>(PTy->getElementType()):0;
|
||||
const Type *RetTy = MTy ? MTy->getReturnType() : 0;
|
||||
|
||||
// If possible, print out the short form of the call instruction, but we can
|
||||
@ -574,7 +574,7 @@ void AssemblyWriter::printInstruction(const Instruction *I) {
|
||||
} else if (I->getOpcode() == Instruction::Malloc ||
|
||||
I->getOpcode() == Instruction::Alloca) {
|
||||
Out << " ";
|
||||
printType(cast<const PointerType>(I->getType())->getValueType());
|
||||
printType(cast<const PointerType>(I->getType())->getElementType());
|
||||
if (I->getNumOperands()) {
|
||||
Out << ",";
|
||||
writeOperand(I->getOperand(0), true);
|
||||
|
@ -62,7 +62,7 @@ void Method::setParent(Module *parent) {
|
||||
}
|
||||
|
||||
const MethodType *Method::getMethodType() const {
|
||||
return cast<MethodType>(cast<PointerType>(getType())->getValueType());
|
||||
return cast<MethodType>(cast<PointerType>(getType())->getElementType());
|
||||
}
|
||||
|
||||
const Type *Method::getReturnType() const {
|
||||
|
@ -179,7 +179,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
||||
// later by LinkGlobalInits...
|
||||
//
|
||||
GlobalVariable *DGV =
|
||||
new GlobalVariable(SGV->getType()->getValueType(), SGV->isConstant(),
|
||||
new GlobalVariable(SGV->getType()->getElementType(), SGV->isConstant(),
|
||||
SGV->hasInternalLinkage(), 0, SGV->getName());
|
||||
|
||||
// Add the new global to the dest module
|
||||
|
@ -237,7 +237,7 @@ int SlotCalculator::insertValue(const Value *D) {
|
||||
// of const ints), that they are inserted also. Same for global variable
|
||||
// initializers.
|
||||
//
|
||||
for(User::op_const_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
|
||||
for(User::const_op_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
|
||||
if (!isa<GlobalValue>(*I)) // Don't chain insert global values
|
||||
insertValue(*I);
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack,
|
||||
}
|
||||
case Type::PointerTyID: {
|
||||
const PointerType *PTy = cast<const PointerType>(Ty);
|
||||
Result = getTypeProps(PTy->getValueType(), TypeStack,
|
||||
Result = getTypeProps(PTy->getElementType(), TypeStack,
|
||||
isAbstract, isRecursive) + " *";
|
||||
break;
|
||||
}
|
||||
|
@ -16,13 +16,13 @@
|
||||
CallInst::CallInst(Value *Meth, const vector<Value*> ¶ms,
|
||||
const string &Name)
|
||||
: Instruction(cast<MethodType>(cast<PointerType>(Meth->getType())
|
||||
->getValueType())->getReturnType(),
|
||||
->getElementType())->getReturnType(),
|
||||
Instruction::Call, Name) {
|
||||
Operands.reserve(1+params.size());
|
||||
Operands.push_back(Use(Meth, this));
|
||||
|
||||
const MethodType *MTy =
|
||||
cast<MethodType>(cast<PointerType>(Meth->getType())->getValueType());
|
||||
cast<MethodType>(cast<PointerType>(Meth->getType())->getElementType());
|
||||
|
||||
const MethodType::ParamTypes &PL = MTy->getParamTypes();
|
||||
assert((params.size() == PL.size()) ||
|
||||
@ -47,14 +47,14 @@ InvokeInst::InvokeInst(Value *Meth, BasicBlock *IfNormal, \
|
||||
BasicBlock *IfException, const vector<Value*>¶ms,
|
||||
const string &Name)
|
||||
: TerminatorInst(cast<MethodType>(cast<PointerType>(Meth->getType())
|
||||
->getValueType())->getReturnType(),
|
||||
->getElementType())->getReturnType(),
|
||||
Instruction::Invoke, Name) {
|
||||
Operands.reserve(3+params.size());
|
||||
Operands.push_back(Use(Meth, this));
|
||||
Operands.push_back(Use(IfNormal, this));
|
||||
Operands.push_back(Use(IfException, this));
|
||||
const MethodType *MTy =
|
||||
cast<MethodType>(cast<PointerType>(Meth->getType())->getValueType());
|
||||
cast<MethodType>(cast<PointerType>(Meth->getType())->getElementType());
|
||||
|
||||
const MethodType::ParamTypes &PL = MTy->getParamTypes();
|
||||
assert((params.size() == PL.size()) ||
|
||||
|
@ -22,7 +22,7 @@ const Type* MemAccessInst::getIndexedType(const Type *Ptr,
|
||||
if (!Ptr->isPointerType()) return 0; // Type isn't a pointer type!
|
||||
|
||||
// Get the type pointed to...
|
||||
Ptr = cast<PointerType>(Ptr)->getValueType();
|
||||
Ptr = cast<PointerType>(Ptr)->getElementType();
|
||||
|
||||
unsigned CurIDX = 0;
|
||||
while (const CompositeType *ST = dyn_cast<CompositeType>(Ptr)) {
|
||||
@ -71,7 +71,7 @@ LoadInst::LoadInst(Value *Ptr, const vector<Value*> &Idx,
|
||||
}
|
||||
|
||||
LoadInst::LoadInst(Value *Ptr, const string &Name = "")
|
||||
: MemAccessInst(cast<PointerType>(Ptr->getType())->getValueType(),
|
||||
: MemAccessInst(cast<PointerType>(Ptr->getType())->getElementType(),
|
||||
Load, Name) {
|
||||
Operands.reserve(1);
|
||||
Operands.push_back(Use(Ptr, this));
|
||||
@ -121,5 +121,5 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, const vector<Value*> &Idx,
|
||||
}
|
||||
|
||||
bool GetElementPtrInst::isStructSelector() const {
|
||||
return ((PointerType*)Operands[0]->getType())->getValueType()->isStructType();
|
||||
return ((PointerType*)Operands[0]->getType())->getElementType()->isStructType();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ string MangleTypeName(const Type *Ty) {
|
||||
const string &longName = Ty->getDescription();
|
||||
return string(longName.c_str(), (longName.length() < 2) ? 1 : 2);
|
||||
} else if (PointerType *PTy = dyn_cast<PointerType>(Ty)) {
|
||||
mangledName = string("P_" + MangleTypeName(PTy->getValueType()));
|
||||
mangledName = string("P_" + MangleTypeName(PTy->getElementType()));
|
||||
} else if (StructType *STy = dyn_cast<StructType>(Ty)) {
|
||||
mangledName = string("S_");
|
||||
for (unsigned i=0; i < STy->getNumContainedTypes(); ++i)
|
||||
@ -41,6 +41,6 @@ string MangleName(const string &privateName, const Value *V) {
|
||||
// Lets drop the P_ before every global name since all globals are ptrs
|
||||
return privateName + "_" +
|
||||
MangleTypeName(isa<GlobalValue>(V)
|
||||
? cast<GlobalValue>(V)->getType()->getValueType()
|
||||
? cast<GlobalValue>(V)->getType()->getElementType()
|
||||
: V->getType());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user