llvm.org GIT mirror llvm / 7a17675
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 Chris Lattner 18 years ago
53 changed file(s) with 146 addition(s) and 147 deletion(s). Raw diff Collapse all Expand all
1515
1616 class constant_iterator
1717 : public std::forward_iterator {
18 Method::inst_const_iterator InstI; // Method instruction iterator
18 Method::const_inst_iterator InstI; // Method instruction iterator
1919 unsigned OpIdx; // Operand index
2020
2121 typedef constant_iterator _Self;
266266 vector implicitIsDef; // machine instruction (eg, call args)
267267
268268 public:
269 typedef ValOpIterator val_op_const_iterator;
269 typedef ValOpIterator val_const_op_iterator;
270270 typedef ValOpIterator val_op_iterator;
271271
272272 public:
306306
307307 public:
308308 friend ostream& operator<<(ostream& os, const MachineInstr& minstr);
309 friend val_op_const_iterator;
309 friend val_const_op_iterator;
310310 friend val_op_iterator;
311311
312312 public:
311311 PointerType(const Type *ElType);
312312 public:
313313
314 inline const Type *getValueType() const { return ValueType; }
314 inline const Type *getElementType() const { return ValueType; }
315315
316316 virtual const Type *getContainedType(unsigned i) const {
317317 return i == 0 ? ValueType.get() : 0;
113113 BasicBlock::iterator, Instruction*> inst_iterator;
114114 typedef InstIterator
115115 BasicBlock::const_iterator,
116 const Instruction*> inst_const_iterator;
116 const Instruction*> const_inst_iterator;
117117
118118 // This inner class is used to implement inst_begin() & inst_end() for
119 // inst_iterator and inst_const_iterator's.
119 // inst_iterator and const_inst_iterator's.
120120 //
121121 template
122122 class InstIterator {
196196
197197 inline inst_iterator inst_begin() { return inst_iterator(*this); }
198198 inline inst_iterator inst_end() { return inst_iterator(*this, true); }
199 inline inst_const_iterator inst_begin() const { return inst_const_iterator(*this); }
200 inline inst_const_iterator inst_end() const { return inst_const_iterator(*this, true); }
199 inline const_inst_iterator inst_begin() const { return const_inst_iterator(*this); }
200 inline const_inst_iterator inst_end() const { return const_inst_iterator(*this, true); }
201201 };
202202
203203 // Provide specializations of GraphTraits to be able to treat a method as a
3939 // Operand Iterator interface...
4040 //
4141 typedef vector::iterator op_iterator;
42 typedef vector::const_iterator op_const_iterator;
42 typedef vector::const_iterator const_op_iterator;
4343
4444 inline op_iterator op_begin() { return Operands.begin(); }
45 inline op_const_iterator op_begin() const { return Operands.begin(); }
45 inline const_op_iterator op_begin() const { return Operands.begin(); }
4646 inline op_iterator op_end() { return Operands.end(); }
47 inline op_const_iterator op_end() const { return Operands.end(); }
47 inline const_op_iterator op_end() const { return Operands.end(); }
4848
4949 // dropAllReferences() - This function is in charge of "letting go" of all
5050 // objects that this User refers to. This allows one to
2626
2727 if (ArraySize) {
2828 // Make sure they didn't try to specify a size for !(unsized array) type
29 assert(getType()->getValueType()->isArrayType() &&
30 cast(getType()->getValueType())->isUnsized() &&
29 assert(getType()->getElementType()->isArrayType() &&
30 cast(getType()->getElementType())->isUnsized() &&
3131 "Trying to allocate something other than unsized array, with size!");
3232 assert(ArraySize->getType() == Type::UIntTy &&
3333 "Malloc/Allocation array size != UIntTy!");
3636 Operands.push_back(Use(ArraySize, this));
3737 } else {
3838 // Make sure that the pointer is not to an unsized array!
39 assert(!getType()->getValueType()->isArrayType() ||
40 cast(getType()->getValueType())->isSized() &&
39 assert(!getType()->getElementType()->isArrayType() ||
40 cast(getType()->getElementType())->isSized() &&
4141 "Trying to allocate unsized array without size!");
4242 }
4343 }
6262 // getAllocatedType - Return the type that is being allocated by the
6363 // instruction.
6464 inline const Type *getAllocatedType() const {
65 return getType()->getValueType();
65 return getType()->getElementType();
6666 }
6767
6868 virtual Instruction *clone() const = 0;
182182 inline op_iterator idx_begin() {
183183 return op_begin()+getFirstIndexOperandNumber();
184184 }
185 inline op_const_iterator idx_begin() const {
185 inline const_op_iterator idx_begin() const {
186186 return op_begin()+getFirstIndexOperandNumber();
187187 }
188188 inline op_iterator idx_end() { return op_end(); }
189 inline op_const_iterator idx_end() const { return op_end(); }
189 inline const_op_iterator idx_end() const { return op_end(); }
190190
191191
192192 vector copyIndices() const {
129129 return (cgn->begin() == cgn->end());
130130 }
131131
132 for (Method::inst_const_iterator I = M->inst_begin(), E = M->inst_end();
132 for (Method::const_inst_iterator I = M->inst_begin(), E = M->inst_end();
133133 I != E; ++I)
134134 if ((*I)->getOpcode() == Instruction::Call)
135135 return false;
5050 //
5151 bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) {
5252 const Method *M = Meth; // We don't need/want write access
53 for (Method::inst_const_iterator I = M->inst_begin(), E = M->inst_end();
53 for (Method::const_inst_iterator I = M->inst_begin(), E = M->inst_end();
5454 I != E; ++I) {
5555 const Instruction *Inst = *I;
5656 const Type *ITy = Inst->getType();
5858 // Loop over all of the instructions in the method, adding their return type
5959 // as well as the types of their operands.
6060 //
61 for (Method::inst_const_iterator II = M->inst_begin(), IE = M->inst_end();
61 for (Method::const_inst_iterator II = M->inst_begin(), IE = M->inst_end();
6262 II != IE; ++II) {
6363 const Instruction *I = *II;
6464 const Type *Ty = I->getType();
6565
6666 IncorporateType(Ty); // Incorporate the type of the instruction
67 for (User::op_const_iterator OI = I->op_begin(), OE = I->op_end();
67 for (User::const_op_iterator OI = I->op_begin(), OE = I->op_end();
6868 OI != OE; ++OI)
6969 if ((*OI)->getType() != Ty) // Avoid set lookup in common case
7070 IncorporateType((*OI)->getType()); // Insert inst operand types as well
3838 }
3939
4040 // iterate over MI operands to find defs
41 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
41 for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
4242
4343 if( OpI.isDef() ) // add to Defs only if this operand is a def
4444 addDef( *OpI );
5555
5656
5757 // iterate over MI operands to find uses
58 for(MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
58 for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
5959 const Value *Op = *OpI;
6060
6161 if ( ((Op)->getType())->isLabelType() )
1111 void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
1212 {
1313
14 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
14 for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
1515
1616 if( OpI.isDef() ) // kill only if this operand is a def
1717 remove(*OpI); // this definition kills any uses
2424 }
2525
2626
27 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
27 for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
2828
2929 if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
3030
4949 if( Inst->isDefinition() ) { // add to Defs iff this instr is a definition
5050 remove(Inst); // this definition kills any uses
5151 }
52 Instruction::op_const_iterator OpI = Inst->op_begin(); // get operand iterat
52 Instruction::const_op_iterator OpI = Inst->op_begin(); // get operand iterat
5353
5454 for( ; OpI != Inst->op_end() ; OpI++) { // iterate over operands
5555 if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
5353 }
5454
5555 case Type::PointerTyID:
56 if (handleType(TypeSet, ((const PointerType *)T)->getValueType()))
56 if (handleType(TypeSet, cast(T)->getElementType()))
5757 return true;
5858 break;
5959
183183 static inline ValID &getValIDFromPlaceHolder(const Value *Val) {
184184 const Type *Ty = Val->getType();
185185 if (isa(Ty) &&
186 isa(cast(Ty)->getValueType()))
187 Ty = cast(Ty)->getValueType();
186 isa(cast(Ty)->getElementType()))
187 Ty = cast(Ty)->getElementType();
188188
189189 switch (Ty->getPrimitiveID()) {
190190 case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getDef();
195195 static inline int getLineNumFromPlaceHolder(const Value *Val) {
196196 const Type *Ty = Val->getType();
197197 if (isa(Ty) &&
198 isa(cast(Ty)->getValueType()))
199 Ty = cast(Ty)->getValueType();
198 isa(cast(Ty)->getElementType()))
199 Ty = cast(Ty)->getElementType();
200200
201201 switch (Ty->getPrimitiveID()) {
202202 case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getLineNum();
982982 // TODO: GlobalVariable here that includes the said information!
983983
984984 // Create a placeholder for the global variable reference...
985 GlobalVariable *GV = new GlobalVariable(PT->getValueType(), false,true);
985 GlobalVariable *GV = new GlobalVariable(PT->getElementType(),
986 false, true);
986987 // Keep track of the fact that we have a forward ref to recycle it
987988 CurModule.GlobalRefs.insert(make_pair(make_pair(PT, $2), GV));
988989
13501351 const MethodType *Ty;
13511352
13521353 if (!(PMTy = dyn_cast($2->get())) ||
1353 !(Ty = dyn_cast(PMTy->getValueType()))) {
1354 !(Ty = dyn_cast(PMTy->getElementType()))) {
13541355 // Pull out the types of all of the arguments...
13551356 vector ParamTypes;
13561357 if ($5) {
14861487 const MethodType *Ty;
14871488
14881489 if (!(PMTy = dyn_cast($2->get())) ||
1489 !(Ty = dyn_cast(PMTy->getValueType()))) {
1490 !(Ty = dyn_cast(PMTy->getElementType()))) {
14901491 // Pull out the types of all of the arguments...
14911492 vector ParamTypes;
14921493 if ($5) {
304304
305305 // Create a placeholder for the global variable reference...
306306 GlobalVariable *GVar =
307 new GlobalVariable(PT->getValueType(), false, true);
307 new GlobalVariable(PT->getElementType(), false, true);
308308
309309 // Keep track of the fact that we have a forward ref to recycle it
310310 GlobalRefs.insert(make_pair(make_pair(PT, Slot), GVar));
226226 // Check to make sure we have a pointer to method type
227227 PointerType *PTy = dyn_cast(M->getType());
228228 if (PTy == 0) return failure(true);
229 MethodType *MTy = dyn_cast(PTy->getValueType());
229 MethodType *MTy = dyn_cast(PTy->getElementType());
230230 if (MTy == 0) return failure(true);
231231
232232 vector Params;
286286 // Check to make sure we have a pointer to method type
287287 PointerType *PTy = dyn_cast(M->getType());
288288 if (PTy == 0) return failure(true);
289 MethodType *MTy = dyn_cast(PTy->getValueType());
289 MethodType *MTy = dyn_cast(PTy->getElementType());
290290 if (MTy == 0) return failure(true);
291291
292292 vector Params;
350350 vector Idx;
351351 if (!isa(Raw.Ty)) return failure(true);
352352 const CompositeType *TopTy =
353 dyn_cast(cast(Raw.Ty)->getValueType());
353 dyn_cast(cast(Raw.Ty)->getElementType());
354354
355355 switch (Raw.NumOperands) {
356356 case 0: cerr << "Invalid load encountered!\n"; return failure(true);
404404 vector Idx;
405405 if (!isa(Raw.Ty)) return failure(true);
406406 const CompositeType *TopTy =
407 dyn_cast(cast(Raw.Ty)->getValueType());
407 dyn_cast(cast(Raw.Ty)->getElementType());
408408
409409 switch (Raw.NumOperands) {
410410 case 0:
261261 }
262262
263263 const PointerType *PMTy = MethodSignatureList.front().first; // PtrMeth
264 const MethodType *MTy = dyn_cast(PMTy->getValueType());
264 const MethodType *MTy = dyn_cast(PMTy->getElementType());
265265 if (MTy == 0) return failure(true); // Not ptr to method!
266266
267267 unsigned isInternal;
391391 }
392392
393393 const PointerType *PTy = cast(Ty);
394 const Type *ElTy = PTy->getValueType();
394 const Type *ElTy = PTy->getElementType();
395395
396396 Constant *Initializer = 0;
397397 if (VarType & 2) { // Does it have an initalizer?
429429 while (MethSignature != Type::VoidTyID) { // List is terminated by Void
430430 const Type *Ty = getType(MethSignature);
431431 if (!Ty || !isa(Ty) ||
432 !isa(cast(Ty)->getValueType())) {
432 !isa(cast(Ty)->getElementType())) {
433433 Error = "Method not ptr to meth type! Ty = " + Ty->getDescription();
434434 return failure(true);
435435 }
436436
437437 // We create methods by passing the underlying MethodType to create...
438 Ty = cast(Ty)->getValueType();
438 Ty = cast(Ty)->getElementType();
439439
440440 // When the ModuleGlobalInfo section is read, we load the type of each
441441 // method and the 'ModuleValues' slot that it lands in. We then load a
7373
7474 case Type::PointerTyID: {
7575 const PointerType *PT = cast(T);
76 int Slot = Table.getValSlot(PT->getValueType());
76 int Slot = Table.getValSlot(PT->getElementType());
7777 assert(Slot != -1 && "Type used but not available!!");
7878 output_vbr((unsigned)Slot, Out);
7979 break;
225225 NumOperands++;
226226 } else if (const CallInst *CI = dyn_cast(I)) {// Handle VarArg calls
227227 PointerType *Ty = cast(CI->getCalledValue()->getType());
228 if (cast(Ty->getValueType())->isVarArg()) {
228 if (cast(Ty->getElementType())->isVarArg()) {
229229 outputInstrVarArgsCall(I, Table, Type, Out);
230230 return;
231231 }
232232 } else if (const InvokeInst *II = dyn_cast(I)) { // ... & Invokes
233233 PointerType *Ty = cast(II->getCalledValue()->getType());
234 if (cast(Ty->getValueType())->isVarArg()) {
234 if (cast(Ty->getElementType())->isVarArg()) {
235235 outputInstrVarArgsCall(I, Table, Type, Out);
236236 return;
237237 }
236236 // of const ints), that they are inserted also. Same for global variable
237237 // initializers.
238238 //
239 for(User::op_const_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
239 for(User::const_op_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
240240 if (!isa(*I)) // Don't chain insert global values
241241 insertValue(*I);
242242 }
267267 const LiveVarSet* liveVars =
268268 methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
269269
270 for (MachineInstr::val_op_const_iterator vo(minstr); ! vo.done(); ++vo)
270 for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
271271 if (liveVars->find(*vo) == liveVars->end())
272272 {
273273 hasLastUse = true;
249249
250250 PHINode *PN = (PHINode *) (*IIt);
251251
252 Value *PhiCpRes =
253 new Value(PN->getType(), PN->getValueType() );
252 Value *PhiCpRes = new Value(PN->getType(), PN->getValueType());
254253
255254 string *Name = new string("PhiCp:");
256255 (*Name) += (int) PhiCpRes;
101101 #undef DEBUG_VAL_OP_ITERATOR
102102 #ifdef DEBUG_VAL_OP_ITERATOR
103103 os << endl << "\tValue operands are: ";
104 for (MachineInstr::val_op_const_iterator vo(&minstr); ! vo.done(); ++vo)
104 for (MachineInstr::val_const_op_iterator vo(&minstr); ! vo.done(); ++vo)
105105 {
106106 const Value* val = *vo;
107107 os << val << (vo.isDef()? "(def), " : ", ");
217217
218218 unsigned int maxSize = 0;
219219
220 for (Method::inst_const_iterator I=method->inst_begin(),E=method->inst_end();
220 for (Method::const_inst_iterator I=method->inst_begin(),E=method->inst_end();
221221 I != E; ++I)
222222 if ((*I)->getOpcode() == Instruction::Call)
223223 {
121121
122122
123123 // iterate over MI operands to find defs
124 for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
124 for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
125125
126126 if( DEBUG_RA) {
127127 MachineOperand::MachineOperandType OpTyp =
285285
286286
287287 // iterate over MI operands to find defs
288 for(MachineInstr::val_op_const_iterator DefI(MInst);!DefI.done();++DefI){
288 for(MachineInstr::val_const_op_iterator DefI(MInst);!DefI.done();++DefI){
289289
290290 if( DefI.isDef() ) { // iff this operand is a def
291291
293293 assert( LROfDef );
294294 RegClass *const RCOfDef = LROfDef->getRegClass();
295295
296 MachineInstr::val_op_const_iterator UseI(MInst);
296 MachineInstr::val_const_op_iterator UseI(MInst);
297297 for( ; !UseI.done(); ++UseI){ // for all uses
298298
299299 LiveRange *const LROfUse = getLiveRangeForValue( *UseI );
261261
262262
263263 // iterate over MI operands to find defs
264 for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
264 for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
265265
266266 if( OpI.isDef() ) {
267267 // create a new LR iff this operand is a def
317317 bool setInterf = false;
318318
319319 // iterate over MI operands to find defs
320 for( MachineInstr::val_op_const_iterator It1(MInst);!It1.done(); ++It1) {
320 for( MachineInstr::val_const_op_iterator It1(MInst);!It1.done(); ++It1) {
321321
322322 const LiveRange *const LROfOp1 = LRI.getLiveRangeForValue( *It1 );
323323
326326
327327 //if( !LROfOp1 ) continue;
328328
329 MachineInstr::val_op_const_iterator It2 = It1;
329 MachineInstr::val_const_op_iterator It2 = It1;
330330 ++It2;
331331
332332 for( ; !It2.done(); ++It2) {
428428 //mcInfo.popAllTempValues(TM);
429429 // TODO ** : do later
430430
431 //for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
431 //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
432432
433433
434434 // Now replace set the registers for operands in the machine instruction
927927 cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
928928
929929
930 //for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
930 //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
931931
932932 for(unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum) {
933933
236236 GlobalVariable *GV = cast(GVal);
237237
238238 // First off, we must allocate space for the global variable to point at...
239 const Type *Ty = GV->getType()->getValueType(); // Type to be allocated
239 const Type *Ty = GV->getType()->getElementType(); // Type to be allocated
240240 unsigned NumElements = 1;
241241
242242 if (isa(Ty) && cast(Ty)->isUnsized()) {
727727 //===----------------------------------------------------------------------===//
728728
729729 void Interpreter::executeAllocInst(AllocationInst *I, ExecutionContext &SF) {
730 const Type *Ty = I->getType()->getValueType(); // Type to be allocated
730 const Type *Ty = I->getType()->getElementType(); // Type to be allocated
731731 unsigned NumElements = 1;
732732
733733 if (I->getNumOperands()) { // Allocating a unsized array type?
770770
771771 PointerTy Total = 0;
772772 const Type *Ty =
773 cast(I->getPointerOperand()->getType())->getValueType();
773 cast(I->getPointerOperand()->getType())->getElementType();
774774
775775 unsigned ArgOff = I->getFirstIndexOperandNumber();
776776 while (ArgOff < I->getNumOperands()) {
129129
130130 // Specialize print([ubyte {x N} ] *) and print(sbyte *)
131131 if (PointerType *PTy = dyn_cast(M->getParamTypes()[0].get()))
132 if (PTy->getValueType() == Type::SByteTy ||
133 isa(PTy->getValueType())) {
132 if (PTy->getElementType() == Type::SByteTy ||
133 isa(PTy->getElementType())) {
134134 return lle_VP_printstr(M, ArgVal);
135135 }
136136
178178 // later by LinkGlobalInits...
179179 //
180180 GlobalVariable *DGV =
181 new GlobalVariable(SGV->getType()->getValueType(), SGV->isConstant(),
181 new GlobalVariable(SGV->getType()->getElementType(), SGV->isConstant(),
182182 SGV->hasInternalLinkage(), 0, SGV->getName());
183183
184184 // Add the new global to the dest module
267267 const LiveVarSet* liveVars =
268268 methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
269269
270 for (MachineInstr::val_op_const_iterator vo(minstr); ! vo.done(); ++vo)
270 for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
271271 if (liveVars->find(*vo) == liveVars->end())
272272 {
273273 hasLastUse = true;
249249
250250 PHINode *PN = (PHINode *) (*IIt);
251251
252 Value *PhiCpRes =
253 new Value(PN->getType(), PN->getValueType() );
252 Value *PhiCpRes = new Value(PN->getType(), PN->getValueType());
254253
255254 string *Name = new string("PhiCp:");
256255 (*Name) += (int) PhiCpRes;
3838 }
3939
4040 // iterate over MI operands to find defs
41 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
41 for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
4242
4343 if( OpI.isDef() ) // add to Defs only if this operand is a def
4444 addDef( *OpI );
5555
5656
5757 // iterate over MI operands to find uses
58 for(MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; ++OpI) {
58 for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; ++OpI) {
5959 const Value *Op = *OpI;
6060
6161 if ( ((Op)->getType())->isLabelType() )
1111 void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
1212 {
1313
14 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
14 for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
1515
1616 if( OpI.isDef() ) // kill only if this operand is a def
1717 remove(*OpI); // this definition kills any uses
2424 }
2525
2626
27 for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
27 for( MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done() ; OpI++) {
2828
2929 if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
3030
4949 if( Inst->isDefinition() ) { // add to Defs iff this instr is a definition
5050 remove(Inst); // this definition kills any uses
5151 }
52 Instruction::op_const_iterator OpI = Inst->op_begin(); // get operand iterat
52 Instruction::const_op_iterator OpI = Inst->op_begin(); // get operand iterat
5353
5454 for( ; OpI != Inst->op_end() ; OpI++) { // iterate over operands
5555 if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
121121
122122
123123 // iterate over MI operands to find defs
124 for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
124 for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
125125
126126 if( DEBUG_RA) {
127127 MachineOperand::MachineOperandType OpTyp =
285285
286286
287287 // iterate over MI operands to find defs
288 for(MachineInstr::val_op_const_iterator DefI(MInst);!DefI.done();++DefI){
288 for(MachineInstr::val_const_op_iterator DefI(MInst);!DefI.done();++DefI){
289289
290290 if( DefI.isDef() ) { // iff this operand is a def
291291
293293 assert( LROfDef );
294294 RegClass *const RCOfDef = LROfDef->getRegClass();
295295
296 MachineInstr::val_op_const_iterator UseI(MInst);
296 MachineInstr::val_const_op_iterator UseI(MInst);
297297 for( ; !UseI.done(); ++UseI){ // for all uses
298298
299299 LiveRange *const LROfUse = getLiveRangeForValue( *UseI );
261261
262262
263263 // iterate over MI operands to find defs
264 for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
264 for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
265265
266266 if( OpI.isDef() ) {
267267 // create a new LR iff this operand is a def
317317 bool setInterf = false;
318318
319319 // iterate over MI operands to find defs
320 for( MachineInstr::val_op_const_iterator It1(MInst);!It1.done(); ++It1) {
320 for( MachineInstr::val_const_op_iterator It1(MInst);!It1.done(); ++It1) {
321321
322322 const LiveRange *const LROfOp1 = LRI.getLiveRangeForValue( *It1 );
323323
326326
327327 //if( !LROfOp1 ) continue;
328328
329 MachineInstr::val_op_const_iterator It2 = It1;
329 MachineInstr::val_const_op_iterator It2 = It1;
330330 ++It2;
331331
332332 for( ; !It2.done(); ++It2) {
428428 //mcInfo.popAllTempValues(TM);
429429 // TODO ** : do later
430430
431 //for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
431 //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
432432
433433
434434 // Now replace set the registers for operands in the machine instruction
927927 cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
928928
929929
930 //for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
930 //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
931931
932932 for(unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum) {
933933
611611 printConstant(GV->getInitializer(), getID(GV));
612612 else {
613613 toAsm << "\t.align\t"
614 << TypeToAlignment(GV->getType()->getValueType(), Target) << endl;
614 << TypeToAlignment(GV->getType()->getElementType(), Target) << endl;
615615 toAsm << "\t.type\t" << getID(GV) << ",#object" << endl;
616616 toAsm << "\t.reserve\t" << getID(GV) << ","
617 << TypeToSize(GV->getType()->getValueType(), Target)
617 << TypeToSize(GV->getType()->getElementType(), Target)
618618 << endl;
619619 }
620620 }
770770 newIdxVec->insert(newIdxVec->end(), idxVec->begin(), idxVec->end());
771771 idxVec = newIdxVec;
772772
773 assert(! ((PointerType*)ptrVal->getType())->getValueType()->isArrayType()
773 assert(!((PointerType*)ptrVal->getType())->getElementType()->isArrayType()
774774 && "GetElemPtr cannot be folded into array refs in selection");
775775 }
776776 else
781781 //
782782 ptrVal = memInst->getPointerOperand();
783783
784 const Type* opType = cast(ptrVal->getType())->getValueType();
784 const Type* opType = cast(ptrVal->getType())->getElementType();
785785 if (opType->isArrayType())
786786 {
787787 assert((memInst->getNumOperands()
825825
826826 const PointerType* ptrType = (PointerType*) ptrVal->getType();
827827
828 if (ptrType->getValueType()->isStructType())
828 if (ptrType->getElementType()->isStructType())
829829 {
830830 // the offset is always constant for structs
831831 isConstantOffset = true;
838838 // It must be an array ref. Check if the offset is a constant,
839839 // and that the indexing has been lowered to a single offset.
840840 //
841 assert(ptrType->getValueType()->isArrayType());
841 assert(ptrType->getElementType()->isArrayType());
842842 assert(arrayOffsetVal != NULL
843843 && "Expect to be given Value* for array offsets");
844844
18341834 cast(subtreeRoot->getInstruction());
18351835 const PointerType* ptrType =
18361836 cast(getElemInst->getPointerOperand()->getType());
1837 if (! ptrType->getValueType()->isArrayType())
1837 if (! ptrType->getElementType()->isArrayType())
18381838 {// we don't need a separate instr
18391839 numInstr = 0; // don't forward operand!
18401840 break;
18521852 const PointerType* instrType = (const PointerType*) instr->getType();
18531853 assert(instrType->isPointerType());
18541854 int tsize = (int)
1855 target.findOptimalStorageSize(instrType->getValueType());
1855 target.findOptimalStorageSize(instrType->getElementType());
18561856 assert(tsize != 0 && "Just to check when this can happen");
18571857
18581858 Method* method = instr->getParent()->getParent();
18801880 Instruction* instr = subtreeRoot->getInstruction();
18811881 const PointerType* instrType = (const PointerType*) instr->getType();
18821882 assert(instrType->isPointerType() &&
1883 instrType->getValueType()->isArrayType());
1883 instrType->getElementType()->isArrayType());
18841884 const Type* eltType =
1885 ((ArrayType*) instrType->getValueType())->getElementType();
1885 ((ArrayType*) instrType->getElementType())->getElementType();
18861886 int tsize = (int) target.findOptimalStorageSize(eltType);
18871887
18881888 assert(tsize != 0 && "Just to check when this can happen");
150150 unsigned Result = 0;
151151
152152 // Get the type pointed to...
153 const Type *Ty = PtrTy->getValueType();
153 const Type *Ty = PtrTy->getElementType();
154154
155155 for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) {
156156 if (const StructType *STy = dyn_cast(Ty)) {
3333 // pointer value.
3434 //
3535 static bool AllIndicesZero(const MemAccessInst *MAI) {
36 for (User::op_const_iterator S = MAI->idx_begin(), E = MAI->idx_end();
36 for (User::const_op_iterator S = MAI->idx_begin(), E = MAI->idx_end();
3737 S != E; ++S)
3838 if (!isa(*S) || !cast(*S)->isNullValue())
3939 return false;
6565 !isa(Ty)) return false; // Malloc always returns pointers
6666
6767 // Deal with the type to allocate, not the pointer type...
68 Ty = cast(Ty)->getValueType();
68 Ty = cast(Ty)->getElementType();
6969
7070 // Analyze the number of bytes allocated...
7171 analysis::ExprType Expr = analysis::ClassifyExpression(MI->getArraySize());
116116 if (CastInst *CI = dyn_cast(*I))
117117 if (const PointerType *PT =
118118 dyn_cast(CI->getOperand(0)->getType()))
119 if (getBaseTypeSize(PT->getValueType()) > ReqTypeSize)
119 if (getBaseTypeSize(PT->getElementType()) > ReqTypeSize)
120120 return false; // We found a type bigger than this one!
121121
122122 return true;
132132 analysis::ExprType Expr = analysis::ClassifyExpression(MI->getArraySize());
133133
134134 const PointerType *AllocTy = cast(Ty);
135 const Type *ElType = AllocTy->getValueType();
135 const Type *ElType = AllocTy->getElementType();
136136
137137 if (Expr.Var && !isa(ElType)) {
138 ElType = ArrayType::get(AllocTy->getValueType());
138 ElType = ArrayType::get(AllocTy->getElementType());
139139 AllocTy = PointerType::get(ElType);
140140 }
141141
215215 //
216216 if (PointerType *SPT = dyn_cast(I->getOperand(0)->getType()))
217217 if (PointerType *DPT = dyn_cast(I->getType()))
218 if (ArrayType *AT = dyn_cast(SPT->getValueType()))
219 if (AT->getElementType() == DPT->getValueType())
218 if (ArrayType *AT = dyn_cast(SPT->getElementType()))
219 if (AT->getElementType() == DPT->getElementType())
220220 return false;
221221 #endif
222222 break;
289289 Indices.pop_back();
290290 ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices,
291291 true);
292 if (ElTy == PTy->getValueType())
292 if (ElTy == PTy->getElementType())
293293 break; // Found a match!!
294294 ElTy = 0;
295295 }
429429 //
430430 vector Indices = GEP->copyIndices();
431431 const Type *BaseType = GEP->getPointerOperand()->getType();
432 const Type *PVTy = cast(Ty)->getValueType();
432 const Type *PVTy = cast(Ty)->getElementType();
433433 Res = 0;
434434 while (!Indices.empty() && isa(Indices.back()) &&
435435 cast(Indices.back())->getValue() == 0) {
545545 //
546546 if (PointerType *SPT = dyn_cast(I->getOperand(0)->getType()))
547547 if (PointerType *DPT = dyn_cast(I->getType()))
548 if (ArrayType *AT = dyn_cast(SPT->getValueType()))
549 if (AT->getElementType() == DPT->getValueType())
548 if (ArrayType *AT = dyn_cast(SPT->getElementType()))
549 if (AT->getElementType() == DPT->getElementType())
550550 return false;
551551 #endif
552552 return true;
594594 if (LI->hasIndices() && !AllIndicesZero(LI))
595595 return false;
596596
597 const Type *LoadedTy = PT->getValueType();
597 const Type *LoadedTy = PT->getElementType();
598598
599599 // They could be loading the first element of a composite type...
600600 if (const CompositeType *CT = dyn_cast(LoadedTy)) {
624624 return ExpressionConvertableToType(I->getOperand(1), PointerType::get(Ty),
625625 CTMap);
626626 } else if (const PointerType *PT = dyn_cast(Ty)) {
627 if (isa(PT->getValueType()))
627 if (isa(PT->getElementType()))
628628 return false; // Avoid getDataSize on unsized array type!
629629 assert(V == I->getOperand(1));
630630
631631 // Must move the same amount of data...
632 if (TD.getTypeSize(PT->getValueType()) !=
632 if (TD.getTypeSize(PT->getElementType()) !=
633633 TD.getTypeSize(I->getOperand(0)->getType())) return false;
634634
635635 // Can convert store if the incoming value is convertable...
636 return ExpressionConvertableToType(I->getOperand(0), PT->getValueType(),
636 return ExpressionConvertableToType(I->getOperand(0), PT->getElementType(),
637637 CTMap);
638638 }
639639 return false;
666666 return false; // Can't convert method pointer type yet. FIXME
667667
668668 const PointerType *MPtr = cast(I->getOperand(0)->getType());
669 const MethodType *MTy = cast(MPtr->getValueType());
669 const MethodType *MTy = cast(MPtr->getElementType());
670670 if (!MTy->isVarArg()) return false;
671671
672672 if ((OpNum-1) < MTy->getParamTypes().size())
742742 const Type *RetTy = PointerType::get(ETy);
743743 // First operand is actually the given pointer...
744744 Res = new GetElementPtrInst(NewVal, Indices);
745 assert(cast(Res->getType())->getValueType() == ETy &&
745 assert(cast(Res->getType())->getElementType() == ETy &&
746746 "ConvertableToGEP broken!");
747747 break;
748748 }
773773
774774 case Instruction::Load: {
775775 assert(I->getOperand(0) == OldVal && isa(NewVal->getType()));
776 const Type *LoadedTy = cast(NewVal->getType())->getValueType();
776 const Type *LoadedTy = cast(NewVal->getType())->getElementType();
777777
778778 vector Indices;
779779
795795 VMC.ExprMap[I] = Res;
796796 Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), NewPT, VMC));
797797 } else { // Replace the source pointer
798 const Type *ValTy = cast(NewTy)->getValueType();
798 const Type *ValTy = cast(NewTy)->getElementType();
799799 Res = new StoreInst(Constant::getNullConstant(ValTy), NewVal);
800800 VMC.ExprMap[I] = Res;
801801 Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), ValTy, VMC));
8686 //
8787 for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I)
8888 if (const PointerType *PT = dyn_cast(I->first))
89 if (const MethodType *MT = dyn_cast(PT->getValueType())) {
89 if (const MethodType *MT = dyn_cast(PT->getElementType())) {
9090 SymbolTable::VarMap &Plane = I->second;
9191 for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end();
9292 PI != PE; ++PI) {
207207
208208 // Nuke all pointers to primitive types as well...
209209 if (const PointerType *PT = dyn_cast(E.second))
210 if (PT->getValueType()->isPrimitiveType()) return true;
210 if (PT->getElementType()->isPrimitiveType()) return true;
211211
212212 // The only types that could contain .'s in the program are things generated
213213 // by GCC itself, including "complex.float" and friends. Nuke them too.
8585
8686 case Type::PointerTyID:
8787 DestTy = PointerType::get(
88 ConvertType(cast(Ty)->getValueType()));
88 ConvertType(cast(Ty)->getElementType()));
8989 break;
9090 default:
9191 assert(0 && "Unknown type!");
431431 const Value *Ptr = MAI->getPointerOperand();
432432 Value *NewPtr = ConvertValue(Ptr);
433433 if (!Indices.empty()) {
434 const Type *PTy = cast(Ptr->getType())->getValueType();
434 const Type *PTy = cast(Ptr->getType())->getElementType();
435435 AdjustIndices(cast(PTy), Indices);
436436 }
437437
3838 if (PointerType* pty = dyn_cast(type))
3939 {
4040 const Type* elemTy;
41 if (ArrayType* aty = dyn_cast(pty->getValueType()))
41 if (ArrayType* aty = dyn_cast(pty->getElementType()))
4242 elemTy = aty->getElementType();
4343 else
44 elemTy = pty->getValueType();
44 elemTy = pty->getElementType();
4545 if (elemTy == Type::SByteTy || elemTy == Type::UByteTy)
4646 return "printString";
4747 }
219219 // type.
220220 //
221221 if (!HasAddUse) {
222 const Type *DestPointedTy = DestPTy->getValueType();
222 const Type *DestPointedTy = DestPTy->getElementType();
223223 unsigned Depth = 1;
224224 const CompositeType *CurCTy = CTy;
225225 const Type *ElTy = 0;
312312 if (Value *CastSrc = CI->getOperand(0)) // CSPT = CastSrcPointerType
313313 if (PointerType *CSPT = dyn_cast(CastSrc->getType()))
314314 // convertable types?
315 if (Val->getType()->isLosslesslyConvertableTo(CSPT->getValueType()) &&
315 if (Val->getType()->isLosslesslyConvertableTo(CSPT->getElementType()) &&
316316 !SI->hasIndices()) { // No subscripts yet!
317317 PRINT_PEEPHOLE3("st-src-cast:in ", Pointer, Val, SI);
318318
319319 // Insert the new T cast instruction... stealing old T's name
320 CastInst *NCI = new CastInst(Val, CSPT->getValueType(),
320 CastInst *NCI = new CastInst(Val, CSPT->getElementType(),
321321 CI->getName());
322322 CI->setName("");
323323 BI = BB->getInstList().insert(BI, NCI)+1;
371371 if (CastInst *CI = dyn_cast(Pointer)) {
372372 Value *SrcVal = CI->getOperand(0);
373373 const PointerType *SrcTy = dyn_cast(SrcVal->getType());
374 const Type *ElTy = SrcTy ? SrcTy->getValueType() : 0;
374 const Type *ElTy = SrcTy ? SrcTy->getElementType() : 0;
375375
376376 // Make sure that nothing will be lost in the new cast...
377377 if (!LI->hasIndices() && SrcTy &&
444444 const PointerType *ThePtrType = dyn_cast(V->getType());
445445 if (!ThePtrType) return false;
446446
447 const Type *ElTy = ThePtrType->getValueType();
447 const Type *ElTy = ThePtrType->getElementType();
448448 if (isa(ElTy) || isa(ElTy)) return false;
449449
450450 unsigned ElementSize = TD.getTypeSize(ElTy);
455455 switch (Inst->getOpcode()) {
456456 case Instruction::Cast: // There is already a cast instruction!
457457 if (const PointerType *PT = dyn_cast(Inst->getType()))
458 if (const ArrayType *AT = dyn_cast(PT->getValueType()))
459 if (AT->getElementType() == ThePtrType->getValueType()) {
458 if (const ArrayType *AT = dyn_cast(PT->getElementType()))
459 if (AT->getElementType() == ThePtrType->getElementType()) {
460460 // Cast already exists! Don't mess around with it.
461461 return false; // No changes made to program though...
462462 }
4242 //
4343 static inline const CompositeType *getPointedToComposite(const Type *Ty) {
4444 const PointerType *PT = dyn_cast(Ty);
45 return PT ? dyn_cast(PT->getValueType()) : 0;
45 return PT ? dyn_cast(PT->getElementType()) : 0;
4646 }
4747
4848
178178 // later by LinkGlobalInits...
179179 //
180180 GlobalVariable *DGV =
181 new GlobalVariable(SGV->getType()->getValueType(), SGV->isConstant(),
181 new GlobalVariable(SGV->getType()->getElementType(), SGV->isConstant(),
182182 SGV->hasInternalLinkage(), 0, SGV->getName());
183183
184184 // Add the new global to the dest module
6666 if (MallocInst *MI = dyn_cast(*(BBIL.begin()+i))) {
6767 BBIL.remove(BBIL.begin()+i); // remove the malloc instr...
6868
69 const Type *AllocTy = cast(MI->getType())->getValueType();
69 const Type *AllocTy =cast(MI->getType())->getElementType();
7070
7171 // If the user is allocating an unsized array with a dynamic size arg,
7272 // start by getting the size of one element.
110110 //
111111 const Type *Ty = cast(I->second);
112112 if (!isa(Ty) ||
113 !cast(Ty)->getValueType()->isPrimitiveType())
113 !cast(Ty)->getElementType()->isPrimitiveType())
114114 TypeNames.insert(make_pair(Ty, "%"+I->first));
115115 }
116116 }
173173 break;
174174 }
175175 case Type::PointerTyID:
176 Result = calcTypeName(cast(Ty)->getValueType(),
176 Result = calcTypeName(cast(Ty)->getElementType(),
177177 TypeStack, TypeNames) + " *";
178178 break;
179179 case Type::ArrayTyID: {
324324 if (!GV->hasInitializer()) Out << "uninitialized ";
325325
326326 Out << (GV->isConstant() ? "constant " : "global ");
327 printType(GV->getType()->getValueType());
327 printType(GV->getType()->getElementType());
328328
329329 if (GV->hasInitializer())
330330 writeOperand(GV->getInitializer(), false, false);
533533 Out << " void";
534534 } else if (isa(I)) {
535535 const PointerType *PTy = dyn_cast(Operand->getType());
536 const MethodType *MTy = PTy ? dyn_cast(PTy->getValueType()) :0;
536 const MethodType *MTy = PTy ?dyn_cast(PTy->getElementType()):0;
537537 const Type *RetTy = MTy ? MTy->getReturnType() : 0;
538538
539539 // If possible, print out the short form of the call instruction, but we can
573573 } else if (I->getOpcode() == Instruction::Malloc ||
574574 I->getOpcode() == Instruction::Alloca) {
575575 Out << " ";
576 printType(cast(I->getType())->getValueType());
576 printType(cast(I->getType())->getElementType());
577577 if (I->getNumOperands()) {
578578 Out << ",";
579579 writeOperand(I->getOperand(0), true);
6161 }
6262
6363 const MethodType *Method::getMethodType() const {
64 return cast(cast(getType())->getValueType());
64 return cast(cast(getType())->getElementType());
6565 }
6666
6767 const Type *Method::getReturnType() const {
178178 // later by LinkGlobalInits...
179179 //
180180 GlobalVariable *DGV =
181 new GlobalVariable(SGV->getType()->getValueType(), SGV->isConstant(),
181 new GlobalVariable(SGV->getType()->getElementType(), SGV->isConstant(),
182182 SGV->hasInternalLinkage(), 0, SGV->getName());
183183
184184 // Add the new global to the dest module
236236 // of const ints), that they are inserted also. Same for global variable
237237 // initializers.
238238 //
239 for(User::op_const_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
239 for(User::const_op_iterator I = U->op_begin(), E = U->op_end(); I != E; ++I)
240240 if (!isa(*I)) // Don't chain insert global values
241241 insertValue(*I);
242242 }
296296 }
297297 case Type::PointerTyID: {
298298 const PointerType *PTy = cast(Ty);
299 Result = getTypeProps(PTy->getValueType(), TypeStack,
299 Result = getTypeProps(PTy->getElementType(), TypeStack,
300300 isAbstract, isRecursive) + " *";
301301 break;
302302 }
1515 CallInst::CallInst(Value *Meth, const vector ¶ms,
1616 const string &Name)
1717 : Instruction(cast(cast(Meth->getType())
18 ->getValueType())->getReturnType(),
18 ->getElementType())->getReturnType(),
1919 Instruction::Call, Name) {
2020 Operands.reserve(1+params.size());
2121 Operands.push_back(Use(Meth, this));
2222
2323 const MethodType *MTy =
24 cast(cast(Meth->getType())->getValueType());
24 cast(cast(Meth->getType())->getElementType());
2525
2626 const MethodType::ParamTypes &PL = MTy->getParamTypes();
2727 assert((params.size() == PL.size()) ||
4646 BasicBlock *IfException, const vector¶ms,
4747 const string &Name)
4848 : TerminatorInst(cast(cast(Meth->getType())
49 ->getValueType())->getReturnType(),
49 ->getElementType())->getReturnType(),
5050 Instruction::Invoke, Name) {
5151 Operands.reserve(3+params.size());
5252 Operands.push_back(Use(Meth, this));
5353 Operands.push_back(Use(IfNormal, this));
5454 Operands.push_back(Use(IfException, this));
5555 const MethodType *MTy =
56 cast(cast(Meth->getType())->getValueType());
56 cast(cast(Meth->getType())->getElementType());
5757
5858 const MethodType::ParamTypes &PL = MTy->getParamTypes();
5959 assert((params.size() == PL.size()) ||
2121 if (!Ptr->isPointerType()) return 0; // Type isn't a pointer type!
2222
2323 // Get the type pointed to...
24 Ptr = cast(Ptr)->getValueType();
24 Ptr = cast(Ptr)->getElementType();
2525
2626 unsigned CurIDX = 0;
2727 while (const CompositeType *ST = dyn_cast(Ptr)) {
7070 }
7171
7272 LoadInst::LoadInst(Value *Ptr, const string &Name = "")
73 : MemAccessInst(cast(Ptr->getType())->getValueType(),
73 : MemAccessInst(cast(Ptr->getType())->getElementType(),
7474 Load, Name) {
7575 Operands.reserve(1);
7676 Operands.push_back(Use(Ptr, this));
120120 }
121121
122122 bool GetElementPtrInst::isStructSelector() const {
123 return ((PointerType*)Operands[0]->getType())->getValueType()->isStructType();
123 return ((PointerType*)Operands[0]->getType())->getElementType()->isStructType();
124124 }
1616 const string &longName = Ty->getDescription();
1717 return string(longName.c_str(), (longName.length() < 2) ? 1 : 2);
1818 } else if (PointerType *PTy = dyn_cast(Ty)) {
19 mangledName = string("P_" + MangleTypeName(PTy->getValueType()));
19 mangledName = string("P_" + MangleTypeName(PTy->getElementType()));
2020 } else if (StructType *STy = dyn_cast(Ty)) {
2121 mangledName = string("S_");
2222 for (unsigned i=0; i < STy->getNumContainedTypes(); ++i)
4040 // Lets drop the P_ before every global name since all globals are ptrs
4141 return privateName + "_" +
4242 MangleTypeName(isa(V)
43 ? cast(V)->getType()->getValueType()
43 ? cast(V)->getType()->getElementType()
4444 : V->getType());
4545 }