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;
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:
public:
friend ostream& operator<<(ostream& os, const MachineInstr& minstr);
- friend val_op_const_iterator;
+ friend val_const_op_iterator;
friend val_op_iterator;
public:
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;
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 {
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
// 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
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!");
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!");
}
}
// 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;
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 {
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;
//
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();
// 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
}
// 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 );
// 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() )
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
}
- 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
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
}
case Type::PointerTyID:
- if (handleType(TypeSet, ((const PointerType *)T)->getValueType()))
+ if (handleType(TypeSet, cast<const PointerType>(T)->getElementType()))
return true;
break;
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();
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();
// 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));
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) {
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) {
// 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));
// 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;
// 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;
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);
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:
}
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;
}
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?
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
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;
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;
}
// 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);
}
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;
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;
#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), " : ", ");
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)
{
// 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 =
// 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
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 );
// 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
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 );
//if( !LROfOp1 ) continue;
- MachineInstr::val_op_const_iterator It2 = It1;
+ MachineInstr::val_const_op_iterator It2 = It1;
++It2;
for( ; !It2.done(); ++It2) {
//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
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) {
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()) {
//===----------------------------------------------------------------------===//
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?
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()) {
// 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);
}
// 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
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;
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;
}
// 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 );
// 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() )
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
}
- 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
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
// 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 =
// 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
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 );
// 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
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 );
//if( !LROfOp1 ) continue;
- MachineInstr::val_op_const_iterator It2 = It1;
+ MachineInstr::val_const_op_iterator It2 = It1;
++It2;
for( ; !It2.done(); ++It2) {
//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
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) {
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;
}
}
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
//
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()
const PointerType* ptrType = (PointerType*) ptrVal->getType();
- if (ptrType->getValueType()->isStructType())
+ if (ptrType->getElementType()->isStructType())
{
// the offset is always constant for structs
isConstantOffset = true;
// 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");
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;
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();
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");
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)) {
// 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;
!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());
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;
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);
}
//
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;
Indices.pop_back();
ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices,
true);
- if (ElTy == PTy->getValueType())
+ if (ElTy == PTy->getElementType())
break; // Found a match!!
ElTy = 0;
}
//
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) {
//
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;
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)) {
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;
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())
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;
}
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;
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));
//
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) {
// 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.
case Type::PointerTyID:
DestTy = PointerType::get(
- ConvertType(cast<PointerType>(Ty)->getValueType()));
+ ConvertType(cast<PointerType>(Ty)->getElementType()));
break;
default:
assert(0 && "Unknown type!");
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);
}
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";
}
// type.
//
if (!HasAddUse) {
- const Type *DestPointedTy = DestPTy->getValueType();
+ const Type *DestPointedTy = DestPTy->getElementType();
unsigned Depth = 1;
const CompositeType *CurCTy = CTy;
const Type *ElTy = 0;
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;
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 &&
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);
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...
}
//
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;
}
// 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
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.
//
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));
}
}
break;
}
case Type::PointerTyID:
- Result = calcTypeName(cast<const PointerType>(Ty)->getValueType(),
+ Result = calcTypeName(cast<const PointerType>(Ty)->getElementType(),
TypeStack, TypeNames) + " *";
break;
case Type::ArrayTyID: {
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);
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
} 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);
}
const MethodType *Method::getMethodType() const {
- return cast<MethodType>(cast<PointerType>(getType())->getValueType());
+ return cast<MethodType>(cast<PointerType>(getType())->getElementType());
}
const Type *Method::getReturnType() const {
// 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
// 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);
}
}
case Type::PointerTyID: {
const PointerType *PTy = cast<const PointerType>(Ty);
- Result = getTypeProps(PTy->getValueType(), TypeStack,
+ Result = getTypeProps(PTy->getElementType(), TypeStack,
isAbstract, isRecursive) + " *";
break;
}
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()) ||
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()) ||
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)) {
}
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));
}
bool GetElementPtrInst::isStructSelector() const {
- return ((PointerType*)Operands[0]->getType())->getValueType()->isStructType();
+ return ((PointerType*)Operands[0]->getType())->getElementType()->isStructType();
}
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)
// 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());
}