llvm.org GIT mirror llvm / fb384d6
Revert 165732 for further review. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165747 91177308-0d34-0410-b5e6-96231b3b80d8 Micah Villmow 8 years ago
40 changed file(s) with 109 addition(s) and 188 deletion(s). Raw diff Collapse all Expand all
230230 }
231231
232232 /// Layout pointer alignment
233 unsigned getPointerABIAlignment(unsigned AS) const {
233 /// FIXME: The defaults need to be removed once all of
234 /// the backends/clients are updated.
235 unsigned getPointerABIAlignment(unsigned AS = 0) const {
234236 DenseMap::const_iterator val = Pointers.find(AS);
235237 if (val == Pointers.end()) {
236238 val = Pointers.find(0);
238240 return val->second.ABIAlign;
239241 }
240242 /// Return target's alignment for stack-based pointers
241 unsigned getPointerPrefAlignment(unsigned AS) const {
243 /// FIXME: The defaults need to be removed once all of
244 /// the backends/clients are updated.
245 unsigned getPointerPrefAlignment(unsigned AS = 0) const {
242246 DenseMap::const_iterator val = Pointers.find(AS);
243247 if (val == Pointers.end()) {
244248 val = Pointers.find(0);
246250 return val->second.PrefAlign;
247251 }
248252 /// Layout pointer size
249 unsigned getPointerSize(unsigned AS) const {
253 /// FIXME: The defaults need to be removed once all of
254 /// the backends/clients are updated.
255 unsigned getPointerSize(unsigned AS = 0) const {
250256 DenseMap::const_iterator val = Pointers.find(AS);
251257 if (val == Pointers.end()) {
252258 val = Pointers.find(0);
254260 return val->second.TypeBitWidth;
255261 }
256262 /// Layout pointer size, in bits
257 unsigned getPointerSizeInBits(unsigned AS) const {
263 /// FIXME: The defaults need to be removed once all of
264 /// the backends/clients are updated.
265 unsigned getPointerSizeInBits(unsigned AS = 0) const {
258266 DenseMap::const_iterator val = Pointers.find(AS);
259267 if (val == Pointers.end()) {
260268 val = Pointers.find(0);
349349 static unsigned getPointerOperandIndex() { return 1U; }
350350
351351 unsigned getPointerAddressSpace() const {
352 if (getPointerOperand()->getType()->isPointerTy())
353 return cast(getPointerOperand()->getType())
354 ->getAddressSpace();
355 if (getPointerOperand()->getType()->isVectorTy()
356 && cast(getPointerOperand()->getType())->isPointerTy())
357 return cast(cast(
358 getPointerOperand()->getType())->getElementType())
359 ->getAddressSpace();
360 llvm_unreachable("Only a vector of pointers or pointers can be used!");
361 return 0;
352 return cast(getPointerOperand()->getType())->getAddressSpace();
362353 }
363354
364355 // Methods for support type inquiry through isa, cast, and dyn_cast:
36613652
36623653 /// @brief return the address space of the pointer.
36633654 unsigned getAddressSpace() const {
3664 if (getType()->isPointerTy())
3665 return cast(getType())->getAddressSpace();
3666 if (getType()->isVectorTy() &&
3667 cast(getType())->getElementType()->isPointerTy())
3668 return cast(
3669 cast(getType())->getElementType())
3670 ->getAddressSpace();
3671 llvm_unreachable("Must be a pointer or a vector of pointers.");
3672 return 0;
3655 return cast(getType())->getAddressSpace();
36733656 }
36743657
36753658 // Methods for support type inquiry through isa, cast, and dyn_cast:
37113694
37123695 /// @brief return the address space of the pointer.
37133696 unsigned getPointerAddressSpace() const {
3714 Type *Ty = getOperand(0)->getType();
3715 if (Ty->isPointerTy())
3716 return cast(Ty)->getAddressSpace();
3717 if (Ty->isVectorTy()
3718 && cast(Ty)->getElementType()->isPointerTy())
3719 return cast(
3720 cast(Ty)->getElementType())
3721 ->getAddressSpace();
3722 llvm_unreachable("Must be a pointer or a vector of pointers.");
3723 return 0;
3697 return cast(getOperand(0)->getType())->getAddressSpace();
37243698 }
37253699
37263700 // Methods for support type inquiry through isa, cast, and dyn_cast:
145145 // Return the pointer type for the given address space, defaults to
146146 // the pointer type from the data layout.
147147 // FIXME: The default needs to be removed once all the code is updated.
148 virtual MVT getPointerTy(uint32_t AS = 0) const { return PointerTy; }
148 virtual MVT getPointerTy(uint32_t addrspace = 0) const { return PointerTy; }
149149 virtual MVT getShiftAmountTy(EVT LHSTy) const;
150150
151151 /// isSelectExpensive - Return true if the select operation is expensive for
185185 bool isInBounds = cast(GEP)->isInBounds() && !NoAssumptions;
186186
187187 // Build a mask for high order bits.
188 unsigned AS = cast(GEP)->getPointerAddressSpace();
189 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
188 unsigned IntPtrWidth = TD.getPointerSizeInBits();
190189 uint64_t PtrSizeMask = ~0ULL >> (64-IntPtrWidth);
191190
192191 for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end(); i != e;
171171 See the method llvm::DataLayout::getPointerSize. */
172172 unsigned LLVMPointerSize(LLVMTargetDataRef);
173173
174 /** Returns the pointer size in bytes for a target for a specified
175 address space.
176 See the method llvm::DataLayout::getPointerSize. */
177 unsigned LLVMPointerSizeForAS(LLVMTargetDataRef, unsigned AS);
178
179174 /** Returns the integer type that is the same size as a pointer on a target.
180175 See the method llvm::DataLayout::getIntPtrType. */
181176 LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef);
182
183 /** Returns the integer type that is the same size as a pointer on a target.
184 This version allows the address space to be specified.
185 See the method llvm::DataLayout::getIntPtrType. */
186 LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef, unsigned AS);
187177
188178 /** Computes the size of a type in bytes for a target.
189179 See the method llvm::DataLayout::getTypeSizeInBits. */
285285 V = GEPOp->getOperand(0);
286286 continue;
287287 }
288
289 unsigned AS = GEPOp->getPointerAddressSpace();
288
290289 // Walk the indices of the GEP, accumulating them into BaseOff/VarIndices.
291290 gep_type_iterator GTI = gep_type_begin(GEPOp);
292291 for (User::const_op_iterator I = GEPOp->op_begin()+1,
315314 // If the integer type is smaller than the pointer size, it is implicitly
316315 // sign extended to pointer size.
317316 unsigned Width = cast(Index->getType())->getBitWidth();
318 if (TD->getPointerSizeInBits(AS) > Width)
317 if (TD->getPointerSizeInBits() > Width)
319318 Extension = EK_SignExt;
320319
321320 // Use GetLinearExpression to decompose the index into a C1*V+C2 form.
344343
345344 // Make sure that we have a scale that makes sense for this target's
346345 // pointer size.
347 if (unsigned ShiftBits = 64-TD->getPointerSizeInBits(AS)) {
346 if (unsigned ShiftBits = 64-TD->getPointerSizeInBits()) {
348347 Scale <<= ShiftBits;
349348 Scale = (int64_t)Scale >> ShiftBits;
350349 }
9090 // which doesn't contain values outside the range of a pointer.
9191 if (isa(CI) && TD &&
9292 TD->isLegalInteger(Op->getType()->getScalarSizeInBits()) &&
93 Op->getType()->getScalarSizeInBits() <= TD->getPointerSizeInBits(
94 cast(CI)->getAddressSpace()))
93 Op->getType()->getScalarSizeInBits() <= TD->getPointerSizeInBits())
9594 return true;
9695
9796 // A ptrtoint cast is free so long as the result is large enough to store
9897 // the pointer, and a legal integer type.
9998 if (isa(CI) && TD &&
10099 TD->isLegalInteger(Op->getType()->getScalarSizeInBits()) &&
101 Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits(
102 cast(CI)->getPointerAddressSpace()))
100 Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits())
103101 return true;
104102
105103 // trunc to a native type is free (assuming the target has compare and
915915 if (TD && CE->getOpcode() == Instruction::IntToPtr) {
916916 Constant *Input = CE->getOperand(0);
917917 unsigned InWidth = Input->getType()->getScalarSizeInBits();
918 unsigned AS = cast(CE->getType())->getAddressSpace();
919 if (TD->getPointerSizeInBits(AS) < InWidth) {
918 if (TD->getPointerSizeInBits() < InWidth) {
920919 Constant *Mask =
921920 ConstantInt::get(CE->getContext(), APInt::getLowBitsSet(InWidth,
922 TD->getPointerSizeInBits(AS)));
921 TD->getPointerSizeInBits()));
923922 Input = ConstantExpr::getAnd(Input, Mask);
924923 }
925924 // Do a zext or trunc to get to the dest size.
932931 // the int size is >= the ptr size. This requires knowing the width of a
933932 // pointer, so it can't be done in ConstantExpr::getCast.
934933 if (ConstantExpr *CE = dyn_cast(Ops[0]))
935 if (TD && CE->getOpcode() == Instruction::PtrToInt &&
936 TD->getPointerSizeInBits(
937 cast(CE->getOperand(0)->getType())->getAddressSpace())
938 <= CE->getType()->getScalarSizeInBits())
934 if (TD &&
935 TD->getPointerSizeInBits() <= CE->getType()->getScalarSizeInBits() &&
936 CE->getOpcode() == Instruction::PtrToInt)
939937 return FoldBitCast(CE->getOperand(0), DestTy, *TD);
940938
941939 return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
242242 if (!TD)
243243 return false;
244244
245 unsigned AS = GEP.getPointerAddressSpace();
246 unsigned IntPtrWidth = TD->getPointerSizeInBits(AS);
245 unsigned IntPtrWidth = TD->getPointerSizeInBits();
247246 assert(IntPtrWidth == Offset.getBitWidth());
248247
249248 for (gep_type_iterator GTI = gep_type_begin(GEP), GTE = gep_type_end(GEP);
391390 // Track base/offset pairs when converted to a plain integer provided the
392391 // integer is large enough to represent the pointer.
393392 unsigned IntegerSize = I.getType()->getScalarSizeInBits();
394 unsigned AS = I.getPointerAddressSpace();
395 if (TD && IntegerSize >= TD->getPointerSizeInBits(AS)) {
393 if (TD && IntegerSize >= TD->getPointerSizeInBits()) {
396394 std::pair BaseAndOffset
397395 = ConstantOffsetPtrs.lookup(I.getOperand(0));
398396 if (BaseAndOffset.first)
426424 // modifications provided the integer is not too large.
427425 Value *Op = I.getOperand(0);
428426 unsigned IntegerSize = Op->getType()->getScalarSizeInBits();
429 unsigned AS = I.getAddressSpace();
430 if (TD && IntegerSize <= TD->getPointerSizeInBits(AS)) {
427 if (TD && IntegerSize <= TD->getPointerSizeInBits()) {
431428 std::pair BaseAndOffset = ConstantOffsetPtrs.lookup(Op);
432429 if (BaseAndOffset.first)
433430 ConstantOffsetPtrs[&I] = BaseAndOffset;
762759 if (!TD || !V->getType()->isPointerTy())
763760 return 0;
764761
765 unsigned AS = cast(V->getType())->getAddressSpace();;
766 unsigned IntPtrWidth = TD->getPointerSizeInBits(AS);
762 unsigned IntPtrWidth = TD->getPointerSizeInBits();
767763 APInt Offset = APInt::getNullValue(IntPtrWidth);
768764
769765 // Even though we don't look through PHI nodes, we could be called on an
827823 // size of the byval type by the target's pointer size.
828824 PointerType *PTy = cast(CS.getArgument(I)->getType());
829825 unsigned TypeSize = TD->getTypeSizeInBits(PTy->getElementType());
830 unsigned AS = PTy->getAddressSpace();
831 unsigned PointerSize = TD->getPointerSizeInBits(AS);
826 unsigned PointerSize = TD->getPointerSizeInBits();
832827 // Ceiling division.
833828 unsigned NumStores = (TypeSize + PointerSize - 1) / PointerSize;
834829
665665 /// 'Offset' APInt must be the bitwidth of the target's pointer size.
666666 static bool accumulateGEPOffset(const DataLayout &TD, GEPOperator *GEP,
667667 APInt &Offset) {
668 unsigned AS = GEP->getPointerAddressSpace();
669 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
668 unsigned IntPtrWidth = TD.getPointerSizeInBits();
670669 assert(IntPtrWidth == Offset.getBitWidth());
671670
672671 gep_type_iterator GTI = gep_type_begin(GEP);
696695 /// accumulates the total constant offset applied in the returned constant. It
697696 /// returns 0 if V is not a pointer, and returns the constant '0' if there are
698697 /// no constant offsets applied.
699 /// FIXME: This function also exists in InlineCost.cpp.
700698 static Constant *stripAndComputeConstantOffsets(const DataLayout &TD,
701699 Value *&V) {
702700 if (!V->getType()->isPointerTy())
703701 return 0;
704702
705 unsigned AS = cast(V->getType())->getAddressSpace();;
706 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
703 unsigned IntPtrWidth = TD.getPointerSizeInBits();
707704 APInt Offset = APInt::getNullValue(IntPtrWidth);
708705
709706 // Even though we don't look through PHI nodes, we could be called on an
18791876 // Turn icmp (ptrtoint x), (ptrtoint/constant) into a compare of the input
18801877 // if the integer type is the same size as the pointer type.
18811878 if (MaxRecurse && Q.TD && isa(LI) &&
1882 Q.TD->getPointerSizeInBits(
1883 cast(LI)->getPointerAddressSpace()) ==
1884 DstTy->getPrimitiveSizeInBits()) {
1879 Q.TD->getPointerSizeInBits() == DstTy->getPrimitiveSizeInBits()) {
18851880 if (Constant *RHSC = dyn_cast(RHS)) {
18861881 // Transfer the cast to the constant.
18871882 if (Value *V = SimplifyICmpInst(Pred, SrcOp,
3939 if (unsigned BitWidth = Ty->getScalarSizeInBits())
4040 return BitWidth;
4141 assert(isa(Ty) && "Expected a pointer type!");
42 return TD ?
43 TD->getPointerSizeInBits(cast(Ty)->getAddressSpace()) : 0;
42 return TD ? TD->getPointerSizeInBits() : 0;
4443 }
4544
4645 static void ComputeMaskedBitsAddSub(bool Add, Value *Op0, Value *Op1, bool NSW,
16211620
16221621 // Re-sign extend from the pointer size if needed to get overflow edge cases
16231622 // right.
1624 unsigned AS = GEP->getPointerAddressSpace();
1625 unsigned PtrSize = TD.getPointerSizeInBits(AS);
1623 unsigned PtrSize = TD.getPointerSizeInBits();
16261624 if (PtrSize < 64)
16271625 Offset = SignExtend64(Offset, PtrSize);
16281626
384384 // - __tlv_bootstrap - used to make sure support exists
385385 // - spare pointer, used when mapped by the runtime
386386 // - pointer to mangled symbol above with initializer
387 unsigned AS = GV->getType()->getAddressSpace();
388 unsigned PtrSize = TD->getPointerSizeInBits(AS)/8;
387 unsigned PtrSize = TD->getPointerSizeInBits()/8;
389388 OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"),
390389 PtrSize, 0);
391390 OutStreamer.EmitIntValue(0, PtrSize, 0);
12991298
13001299 // Emit the function pointers in the target-specific order
13011300 const DataLayout *TD = TM.getDataLayout();
1302 unsigned Align = Log2_32(TD->getPointerPrefAlignment(0));
1301 unsigned Align = Log2_32(TD->getPointerPrefAlignment());
13031302 std::stable_sort(Structors.begin(), Structors.end(), priority_order);
13041303 for (unsigned i = 0, e = Structors.size(); i != e; ++i) {
13051304 const MCSection *OutputSection =
14801479 if (Offset == 0)
14811480 return Base;
14821481
1483 unsigned AS = cast(CE->getType())->getAddressSpace();
14841482 // Truncate/sext the offset to the pointer size.
1485 unsigned Width = TD.getPointerSizeInBits(AS);
1483 unsigned Width = TD.getPointerSizeInBits();
14861484 if (Width < 64)
14871485 Offset = SignExtend64(Offset, Width);
14881486
111111
112112 switch (Encoding & 0x07) {
113113 default: llvm_unreachable("Invalid encoded value.");
114 case dwarf::DW_EH_PE_absptr: return TM.getDataLayout()->getPointerSize(0);
114 case dwarf::DW_EH_PE_absptr: return TM.getDataLayout()->getPointerSize();
115115 case dwarf::DW_EH_PE_udata2: return 2;
116116 case dwarf::DW_EH_PE_udata4: return 4;
117117 case dwarf::DW_EH_PE_udata8: return 8;
199199 case dwarf::DW_FORM_udata: Asm->EmitULEB128(Integer); return;
200200 case dwarf::DW_FORM_sdata: Asm->EmitSLEB128(Integer); return;
201201 case dwarf::DW_FORM_addr:
202 Size = Asm->getDataLayout().getPointerSize(0); break;
202 Size = Asm->getDataLayout().getPointerSize(); break;
203203 default: llvm_unreachable("DIE Value form not supported yet");
204204 }
205205 Asm->OutStreamer.EmitIntValue(Integer, Size, 0/*addrspace*/);
221221 case dwarf::DW_FORM_data8: return sizeof(int64_t);
222222 case dwarf::DW_FORM_udata: return MCAsmInfo::getULEB128Size(Integer);
223223 case dwarf::DW_FORM_sdata: return MCAsmInfo::getSLEB128Size(Integer);
224 case dwarf::DW_FORM_addr: return AP->getDataLayout().getPointerSize(0);
224 case dwarf::DW_FORM_addr: return AP->getDataLayout().getPointerSize();
225225 default: llvm_unreachable("DIE Value form not supported yet");
226226 }
227227 }
248248 unsigned DIELabel::SizeOf(AsmPrinter *AP, unsigned Form) const {
249249 if (Form == dwarf::DW_FORM_data4) return 4;
250250 if (Form == dwarf::DW_FORM_strp) return 4;
251 return AP->getDataLayout().getPointerSize(0);
251 return AP->getDataLayout().getPointerSize();
252252 }
253253
254254 #ifndef NDEBUG
272272 unsigned DIEDelta::SizeOf(AsmPrinter *AP, unsigned Form) const {
273273 if (Form == dwarf::DW_FORM_data4) return 4;
274274 if (Form == dwarf::DW_FORM_strp) return 4;
275 return AP->getDataLayout().getPointerSize(0);
275 return AP->getDataLayout().getPointerSize();
276276 }
277277
278278 #ifndef NDEBUG
383383 // DW_AT_ranges appropriately.
384384 TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4,
385385 DebugRangeSymbols.size()
386 * Asm->getDataLayout().getPointerSize(0));
386 * Asm->getDataLayout().getPointerSize());
387387 for (SmallVector::const_iterator RI = Ranges.begin(),
388388 RE = Ranges.end(); RI != RE; ++RI) {
389389 DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
449449 // DW_AT_ranges appropriately.
450450 TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4,
451451 DebugRangeSymbols.size()
452 * Asm->getDataLayout().getPointerSize(0));
452 * Asm->getDataLayout().getPointerSize());
453453 for (SmallVector::const_iterator RI = Ranges.begin(),
454454 RE = Ranges.end(); RI != RE; ++RI) {
455455 DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first));
17641764 Asm->EmitSectionOffset(Asm->GetTempSymbol("abbrev_begin"),
17651765 DwarfAbbrevSectionSym);
17661766 Asm->OutStreamer.AddComment("Address Size (in bytes)");
1767 Asm->EmitInt8(Asm->getDataLayout().getPointerSize(0));
1767 Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
17681768
17691769 emitDIE(Die);
17701770 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("info_end", TheCU->getID()));
18101810 Asm->EmitInt8(0);
18111811
18121812 Asm->OutStreamer.AddComment("Op size");
1813 Asm->EmitInt8(Asm->getDataLayout().getPointerSize(0) + 1);
1813 Asm->EmitInt8(Asm->getDataLayout().getPointerSize() + 1);
18141814 Asm->OutStreamer.AddComment("DW_LNE_set_address");
18151815 Asm->EmitInt8(dwarf::DW_LNE_set_address);
18161816
18171817 Asm->OutStreamer.AddComment("Section end label");
18181818
18191819 Asm->OutStreamer.EmitSymbolValue(Asm->GetTempSymbol("section_end",SectionEnd),
1820 Asm->getDataLayout().getPointerSize(0),
1820 Asm->getDataLayout().getPointerSize(),
18211821 0/*AddrSpace*/);
18221822
18231823 // Mark end of matrix.
20462046 // Start the dwarf loc section.
20472047 Asm->OutStreamer.SwitchSection(
20482048 Asm->getObjFileLowering().getDwarfLocSection());
2049 unsigned char Size = Asm->getDataLayout().getPointerSize(0);
2049 unsigned char Size = Asm->getDataLayout().getPointerSize();
20502050 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_loc", 0));
20512051 unsigned index = 1;
20522052 for (SmallVector::iterator
21432143 // Start the dwarf ranges section.
21442144 Asm->OutStreamer.SwitchSection(
21452145 Asm->getObjFileLowering().getDwarfRangesSection());
2146 unsigned char Size = Asm->getDataLayout().getPointerSize(0);
2146 unsigned char Size = Asm->getDataLayout().getPointerSize();
21472147 for (SmallVector::iterator
21482148 I = DebugRangeSymbols.begin(), E = DebugRangeSymbols.end();
21492149 I != E; ++I) {
22012201 Asm->OutStreamer.AddComment("Dwarf Version");
22022202 Asm->EmitInt16(dwarf::DWARF_VERSION);
22032203 Asm->OutStreamer.AddComment("Address Size (in bytes)");
2204 Asm->EmitInt8(Asm->getDataLayout().getPointerSize(0));
2204 Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
22052205
22062206 for (SmallVector::iterator I = InlinedSPNodes.begin(),
22072207 E = InlinedSPNodes.end(); I != E; ++I) {
22322232
22332233 if (Asm->isVerbose()) Asm->OutStreamer.AddComment("low_pc");
22342234 Asm->OutStreamer.EmitSymbolValue(LI->first,
2235 Asm->getDataLayout().getPointerSize(0),0);
2235 Asm->getDataLayout().getPointerSize(),0);
22362236 }
22372237 }
22382238
416416 // that we're omitting that bit.
417417 TTypeEncoding = dwarf::DW_EH_PE_omit;
418418 // dwarf::DW_EH_PE_absptr
419 TypeFormatSize = Asm->getDataLayout().getPointerSize(0);
419 TypeFormatSize = Asm->getDataLayout().getPointerSize();
420420 } else {
421421 // Okay, we have actual filters or typeinfos to emit. As such, we need to
422422 // pick a type encoding for them. We're about to emit a list of pointers to
9090 /// either condition is detected in a function which uses the GC.
9191 ///
9292 void OcamlGCMetadataPrinter::finishAssembly(AsmPrinter &AP) {
93 unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(0);
93 unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize();
9494
9595 AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection());
9696 EmitCamlGlobal(getModule(), AP, "code_end");
549549 // address of a block, in which case it is the pointer size.
550550 switch (getEntryKind()) {
551551 case MachineJumpTableInfo::EK_BlockAddress:
552 return TD.getPointerSize(0);
552 return TD.getPointerSize();
553553 case MachineJumpTableInfo::EK_GPRel64BlockAddress:
554554 return 8;
555555 case MachineJumpTableInfo::EK_GPRel32BlockAddress:
569569 // alignment.
570570 switch (getEntryKind()) {
571571 case MachineJumpTableInfo::EK_BlockAddress:
572 return TD.getPointerABIAlignment(0);
572 return TD.getPointerABIAlignment();
573573 case MachineJumpTableInfo::EK_GPRel64BlockAddress:
574574 return TD.getABIIntegerTypeAlignment(64);
575575 case MachineJumpTableInfo::EK_GPRel32BlockAddress:
34483448 EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign,
34493449 IsZeroVal, MemcpyStrSrc,
34503450 DAG.getMachineFunction());
3451 Type *vtType = VT.isExtended() ? VT.getTypeForEVT(*DAG.getContext()) : NULL;
3452 unsigned AS = (vtType && vtType->isPointerTy()) ?
3453 cast(vtType)->getAddressSpace() : 0;
34543451
34553452 if (VT == MVT::Other) {
3456 if (DstAlign >= TLI.getDataLayout()->getPointerPrefAlignment(AS) ||
3453 if (DstAlign >= TLI.getDataLayout()->getPointerPrefAlignment() ||
34573454 TLI.allowsUnalignedMemoryAccesses(VT)) {
34583455 VT = TLI.getPointerTy();
34593456 } else {
7676 Flags,
7777 SectionKind::getDataRel(),
7878 0, Label->getName());
79 unsigned Size = TM.getDataLayout()->getPointerSize(0);
79 unsigned Size = TM.getDataLayout()->getPointerSize();
8080 Streamer.SwitchSection(Sec);
81 Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment(0));
81 Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment());
8282 Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject);
8383 const MCExpr *E = MCConstantExpr::Create(Size, getContext());
8484 Streamer.EmitELFSize(Label, E);
1616
1717 #include "llvm/Constants.h"
1818 #include "llvm/DerivedTypes.h"
19 #include "llvm/Instructions.h"
2019 #include "llvm/Module.h"
2120 #include "llvm/ExecutionEngine/GenericValue.h"
2221 #include "llvm/ADT/SmallString.h"
267266 void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
268267 const std::vector &InputArgv) {
269268 clear(); // Free the old contents.
270 unsigned PtrSize = EE->getDataLayout()->getPointerSize(0);
269 unsigned PtrSize = EE->getDataLayout()->getPointerSize();
271270 Array = new char[(InputArgv.size()+1)*PtrSize];
272271
273272 DEBUG(dbgs() << "JIT: ARGV = " << (void*)Array << "\n");
342341 #ifndef NDEBUG
343342 /// isTargetNullPtr - Return whether the target pointer stored at Loc is null.
344343 static bool isTargetNullPtr(ExecutionEngine *EE, void *Loc) {
345 unsigned PtrSize = EE->getDataLayout()->getPointerSize(0);
344 unsigned PtrSize = EE->getDataLayout()->getPointerSize();
346345 for (unsigned i = 0; i < PtrSize; ++i)
347346 if (*(i + (uint8_t*)Loc))
348347 return false;
644643 }
645644 case Instruction::PtrToInt: {
646645 GenericValue GV = getConstantValue(Op0);
647 unsigned AS = cast(CE)->getPointerAddressSpace();
648 uint32_t PtrWidth = TD->getPointerSizeInBits(AS);
646 uint32_t PtrWidth = TD->getPointerSizeInBits();
649647 GV.IntVal = APInt(PtrWidth, uintptr_t(GV.PointerVal));
650648 return GV;
651649 }
652650 case Instruction::IntToPtr: {
653651 GenericValue GV = getConstantValue(Op0);
654 unsigned AS = cast(CE)->getAddressSpace();
655 uint32_t PtrWidth = TD->getPointerSizeInBits(AS);
652 uint32_t PtrWidth = TD->getPointerSizeInBits();
656653 if (PtrWidth != GV.IntVal.getBitWidth())
657654 GV.IntVal = GV.IntVal.zextOrTrunc(PtrWidth);
658655 assert(GV.IntVal.getBitWidth() <= 64 && "Bad pointer width");
10531053 GenericValue Dest, Src = getOperandValue(SrcVal, SF);
10541054 assert(DstTy->isPointerTy() && "Invalid PtrToInt instruction");
10551055
1056 unsigned AS = cast(DstTy)->getAddressSpace();
1057 uint32_t PtrSize = TD.getPointerSizeInBits(AS);
1056 uint32_t PtrSize = TD.getPointerSizeInBits();
10581057 if (PtrSize != Src.IntVal.getBitWidth())
10591058 Src.IntVal = Src.IntVal.zextOrTrunc(PtrSize);
10601059
375375 case 'x': case 'X':
376376 if (HowLong >= 1) {
377377 if (HowLong == 1 &&
378 TheInterpreter->getDataLayout()->getPointerSizeInBits(0) == 64 &&
378 TheInterpreter->getDataLayout()->getPointerSizeInBits() == 64 &&
379379 sizeof(long) < sizeof(int64_t)) {
380380 // Make sure we use %lld with a 64 bit argument because we might be
381381 // compiling LLI on a 32 bit compiler.
1313
1414 #include "JIT.h"
1515 #include "JITDwarfEmitter.h"
16 #include "llvm/DerivedTypes.h"
1716 #include "llvm/Function.h"
18 #include "llvm/GlobalVariable.h"
1917 #include "llvm/ADT/DenseMap.h"
2018 #include "llvm/CodeGen/JITCodeEmitter.h"
2119 #include "llvm/CodeGen/MachineFunction.h"
6765 void
6866 JITDwarfEmitter::EmitFrameMoves(intptr_t BaseLabelPtr,
6967 const std::vector &Moves) const {
70 unsigned PointerSize = TD->getPointerSize(0);
68 unsigned PointerSize = TD->getPointerSize();
7169 int stackGrowth = stackGrowthDirection == TargetFrameLowering::StackGrowsUp ?
7270 PointerSize : -PointerSize;
7371 MCSymbol *BaseLabel = 0;
379377 for (unsigned i = 0, e = CallSites.size(); i < e; ++i)
380378 SizeSites += MCAsmInfo::getULEB128Size(CallSites[i].Action);
381379
382 unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize(0);
380 unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize();
383381
384382 unsigned TypeOffset = sizeof(int8_t) + // Call site format
385383 // Call-site table length
455453 const GlobalVariable *GV = TypeInfos[M - 1];
456454
457455 if (GV) {
458 if (TD->getPointerSize(GV->getType()->getAddressSpace()) == sizeof(int32_t))
456 if (TD->getPointerSize() == sizeof(int32_t))
459457 JCE->emitInt32((intptr_t)Jit.getOrEmitGlobalVariable(GV));
460458 else
461459 JCE->emitInt64((intptr_t)Jit.getOrEmitGlobalVariable(GV));
462460 } else {
463 if (TD->getPointerSize(0) == sizeof(int32_t))
461 if (TD->getPointerSize() == sizeof(int32_t))
464462 JCE->emitInt32(0);
465463 else
466464 JCE->emitInt64(0);
482480
483481 unsigned char*
484482 JITDwarfEmitter::EmitCommonEHFrame(const Function* Personality) const {
485 unsigned PointerSize = TD->getPointerSize(0);
483 unsigned PointerSize = TD->getPointerSize();
486484 int stackGrowth = stackGrowthDirection == TargetFrameLowering::StackGrowsUp ?
487485 PointerSize : -PointerSize;
488486
542540 unsigned char* StartFunction,
543541 unsigned char* EndFunction,
544542 unsigned char* ExceptionTable) const {
545 unsigned PointerSize = TD->getPointerSize(0);
543 unsigned PointerSize = TD->getPointerSize();
546544
547545 // EH frame header.
548546 unsigned char* StartEHPtr = (unsigned char*)JCE->getCurrentPCValue();
2525 //===----------------------------------------------------------------------===//
2626
2727 ARMELFWriterInfo::ARMELFWriterInfo(TargetMachine &TM)
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits(0) == 64,
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits() == 64,
2929 TM.getDataLayout()->isLittleEndian()) {
3030 }
3131
2525 //===----------------------------------------------------------------------===//
2626
2727 MBlazeELFWriterInfo::MBlazeELFWriterInfo(TargetMachine &TM)
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits(0) == 64,
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits() == 64,
2929 TM.getDataLayout()->isLittleEndian()) {
3030 }
3131
880880
881881 if (ReturnAddrIndex == 0) {
882882 // Set up a frame object for the return address.
883 uint64_t SlotSize = TD->getPointerSize(0);
883 uint64_t SlotSize = TD->getPointerSize();
884884 ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject(SlotSize, -SlotSize,
885885 true);
886886 FuncInfo->setRAIndex(ReturnAddrIndex);
900900 if (Depth > 0) {
901901 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
902902 SDValue Offset =
903 DAG.getConstant(TD->getPointerSize(0), MVT::i16);
903 DAG.getConstant(TD->getPointerSize(), MVT::i16);
904904 return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
905905 DAG.getNode(ISD::ADD, dl, getPointerTy(),
906906 FrameAddr, Offset),
125125 return Base;
126126
127127 // Truncate/sext the offset to the pointer size.
128 unsigned AS = cast(CE)->getPointerAddressSpace();
129 if (TD.getPointerSizeInBits(AS) != 64) {
130 int SExtAmount = 64-TD.getPointerSizeInBits(AS);
128 if (TD.getPointerSizeInBits() != 64) {
129 int SExtAmount = 64-TD.getPointerSizeInBits();
131130 Offset = (Offset << SExtAmount) >> SExtAmount;
132131 }
133132
13781377
13791378 const FunctionType *FTy = dyn_cast(Ty);
13801379 if (FTy)
1381 return TD->getPointerPrefAlignment(0);
1380 return TD->getPointerPrefAlignment();
13821381 return TD->getPrefTypeAlignment(Ty);
13831382 }
13841383
438438 bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
439439 const DataLayout *TD = TM.getDataLayout();
440440
441 bool isPPC64 = TD->getPointerSizeInBits(0) == 64;
441 bool isPPC64 = TD->getPointerSizeInBits() == 64;
442442
443443 if (isPPC64 && !TOC.empty()) {
444444 const MCSectionELF *Section = OutStreamer.getContext().getELFSection(".toc",
544544
545545 void PPCDarwinAsmPrinter::
546546 EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
547 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits(0) == 64;
547 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64;
548548
549549 const TargetLoweringObjectFileMachO &TLOFMacho =
550550 static_cast(getObjFileLowering());
639639
640640
641641 bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
642 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits(0) == 64;
642 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64;
643643
644644 // Darwin/PPC always uses mach-o.
645645 const TargetLoweringObjectFileMachO &TLOFMacho =
497497 } else if (CRSpillFrameIdx) {
498498 FrameIdx = CRSpillFrameIdx;
499499 } else {
500 MachineFrameInfo *MFI = (const_cast(MF)).getFrameInfo();
500 MachineFrameInfo *MFI = ((MachineFunction &)MF).getFrameInfo();
501501 FrameIdx = MFI->CreateFixedObject((uint64_t)4, (int64_t)-4, true);
502502 CRSpillFrameIdx = FrameIdx;
503503 }
5555 }
5656
5757 unsigned LLVMPointerSize(LLVMTargetDataRef TD) {
58 return unwrap(TD)->getPointerSize(0);
59 }
60
61 unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS) {
62 return unwrap(TD)->getPointerSize(AS);
58 return unwrap(TD)->getPointerSize();
6359 }
6460
6561 LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) {
6662 return wrap(unwrap(TD)->getIntPtrType(getGlobalContext()));
67 }
68
69 LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS) {
70 return wrap(unwrap(TD)->getIntPtrType(getGlobalContext(), AS));
7163 }
7264
7365 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
692692 for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
693693 OutStreamer.EmitLabel(Stubs[i].first);
694694 OutStreamer.EmitSymbolValue(Stubs[i].second.getPointer(),
695 TD->getPointerSize(0), 0);
695 TD->getPointerSize(), 0);
696696 }
697697 Stubs.clear();
698698 }
316316 bool HasFP = hasFP(MF);
317317
318318 // Calculate amount of bytes used for return address storing.
319 int stackGrowth = -TD->getPointerSize(0);
319 int stackGrowth = -TD->getPointerSize();
320320
321321 // FIXME: This is dirty hack. The code itself is pretty mess right now.
322322 // It should be rewritten from scratch and generalized sometimes.
716716 std::vector &Moves = MMI.getFrameMoves();
717717 const DataLayout *TD = MF.getTarget().getDataLayout();
718718 uint64_t NumBytes = 0;
719 int stackGrowth = -TD->getPointerSize(0);
719 int stackGrowth = -TD->getPointerSize();
720720
721721 if (HasFP) {
722722 // Calculate required stack adjustment.
26512651 unsigned StackAlignment = TFI.getStackAlignment();
26522652 uint64_t AlignMask = StackAlignment - 1;
26532653 int64_t Offset = StackSize;
2654 uint64_t SlotSize = TD->getPointerSize(0);
2654 uint64_t SlotSize = TD->getPointerSize();
26552655 if ( (Offset & AlignMask) <= (StackAlignment - SlotSize) ) {
26562656 // Number smaller than 12 so just add the difference.
26572657 Offset += ((StackAlignment - SlotSize) - (Offset & AlignMask));
30193019
30203020 if (ReturnAddrIndex == 0) {
30213021 // Set up a frame object for the return address.
3022 uint64_t SlotSize = TD->getPointerSize(0);
3022 uint64_t SlotSize = TD->getPointerSize();
30233023 ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject(SlotSize, -SlotSize,
30243024 false);
30253025 FuncInfo->setRAIndex(ReturnAddrIndex);
76427642 IDX = DAG.getLoad(getPointerTy(), dl, Chain, IDX, MachinePointerInfo(),
76437643 false, false, false, 0);
76447644
7645 SDValue Scale = DAG.getConstant(Log2_64_Ceil(TD->getPointerSize(0)),
7645 SDValue Scale = DAG.getConstant(Log2_64_Ceil(TD->getPointerSize()),
76467646 getPointerTy());
76477647 IDX = DAG.getNode(ISD::SHL, dl, getPointerTy(), IDX, Scale);
76487648
1027710277 if (Depth > 0) {
1027810278 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
1027910279 SDValue Offset =
10280 DAG.getConstant(TD->getPointerSize(0),
10280 DAG.getConstant(TD->getPointerSize(),
1028110281 Subtarget->is64Bit() ? MVT::i64 : MVT::i32);
1028210282 return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
1028310283 DAG.getNode(ISD::ADD, dl, getPointerTy(),
1030910309
1031010310 SDValue X86TargetLowering::LowerFRAME_TO_ARGS_OFFSET(SDValue Op,
1031110311 SelectionDAG &DAG) const {
10312 return DAG.getIntPtrConstant(2*TD->getPointerSize(0));
10312 return DAG.getIntPtrConstant(2*TD->getPointerSize());
1031310313 }
1031410314
1031510315 SDValue X86TargetLowering::LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const {
1032410324 unsigned StoreAddrReg = (Subtarget->is64Bit() ? X86::RCX : X86::ECX);
1032510325
1032610326 SDValue StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), Frame,
10327 DAG.getIntPtrConstant(TD->getPointerSize(0)));
10327 DAG.getIntPtrConstant(TD->getPointerSize()));
1032810328 StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), StoreAddr, Offset);
1032910329 Chain = DAG.getStore(Chain, dl, Handler, StoreAddr, MachinePointerInfo(),
1033010330 false, false, 0);
12921292 // If the source integer type is not the intptr_t type for this target, do a
12931293 // trunc or zext to the intptr_t type, then inttoptr of it. This allows the
12941294 // cast to be exposed to other transforms.
1295 unsigned AS = CI.getAddressSpace();
12961295 if (TD) {
12971296 if (CI.getOperand(0)->getType()->getScalarSizeInBits() >
1298 TD->getPointerSizeInBits(AS)) {
1297 TD->getPointerSizeInBits()) {
12991298 Value *P = Builder->CreateTrunc(CI.getOperand(0),
13001299 TD->getIntPtrType(CI.getContext()));
13011300 return new IntToPtrInst(P, CI.getType());
13021301 }
13031302 if (CI.getOperand(0)->getType()->getScalarSizeInBits() <
1304 TD->getPointerSizeInBits(AS)) {
1303 TD->getPointerSizeInBits()) {
13051304 Value *P = Builder->CreateZExt(CI.getOperand(0),
13061305 TD->getIntPtrType(CI.getContext()));
13071306 return new IntToPtrInst(P, CI.getType());
13681367 // If the destination integer type is not the intptr_t type for this target,
13691368 // do a ptrtoint to intptr_t then do a trunc or zext. This allows the cast
13701369 // to be exposed to other transforms.
1371 unsigned AS = CI.getPointerAddressSpace();
13721370 if (TD) {
1373 if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits(AS)) {
1371 if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) {
13741372 Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
13751373 TD->getIntPtrType(CI.getContext()));
13761374 return new TruncInst(P, CI.getType());
13771375 }
1378 if (CI.getType()->getScalarSizeInBits() > TD->getPointerSizeInBits(AS)) {
1376 if (CI.getType()->getScalarSizeInBits() > TD->getPointerSizeInBits()) {
13791377 Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
13801378 TD->getIntPtrType(CI.getContext()));
13811379 return new ZExtInst(P, CI.getType());
364364 // order the state machines in complexity of the generated code.
365365 Value *Idx = GEP->getOperand(2);
366366
367 unsigned AS = GEP->getPointerAddressSpace();
368367 // If the index is larger than the pointer size of the target, truncate the
369368 // index down like the GEP would do implicitly. We don't have to do this for
370369 // an inbounds GEP because the index can't be out of range.
371370 if (!GEP->isInBounds() &&
372 Idx->getType()->getPrimitiveSizeInBits() > TD->getPointerSizeInBits(AS))
371 Idx->getType()->getPrimitiveSizeInBits() > TD->getPointerSizeInBits())
373372 Idx = Builder->CreateTrunc(Idx, TD->getIntPtrType(Idx->getContext()));
374373
375374 // If the comparison is only true for one or two elements, emit direct
528527 }
529528 }
530529
531 unsigned AS = cast(GEP)->getPointerAddressSpace();
532530 // Okay, we know we have a single variable index, which must be a
533531 // pointer/array/vector index. If there is no offset, life is simple, return
534532 // the index.
535 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
533 unsigned IntPtrWidth = TD.getPointerSizeInBits();
536534 if (Offset == 0) {
537535 // Cast to intptrty in case a truncation occurs. If an extension is needed,
538536 // we don't need to bother extending: the extension won't affect where the
15531551 // Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
15541552 // integer type is the same size as the pointer type.
15551553 if (TD && LHSCI->getOpcode() == Instruction::PtrToInt &&
1556 TD->getPointerSizeInBits(
1557 cast(LHSCI)->getPointerAddressSpace()) ==
1554 TD->getPointerSizeInBits() ==
15581555 cast(DestTy)->getBitWidth()) {
15591556 Value *RHSOp = 0;
15601557 if (Constant *RHSC = dyn_cast(ICI.getOperand(1))) {
741741 BL.reset(new BlackList(ClBlackListFile));
742742
743743 C = &(M.getContext());
744 LongSize = TD->getPointerSizeInBits(0);
744 LongSize = TD->getPointerSizeInBits();
745745 IntptrTy = Type::getIntNTy(*C, LongSize);
746746 IntptrPtrTy = PointerType::get(IntptrTy, 0);
747747
173173 // this width can be stored. If so, check to see whether we will end up
174174 // actually reducing the number of stores used.
175175 unsigned Bytes = unsigned(End-Start);
176 unsigned AS = cast(TheStores[0])->getPointerAddressSpace();
177 unsigned NumPointerStores = Bytes/TD.getPointerSize(AS);
176 unsigned NumPointerStores = Bytes/TD.getPointerSize();
178177
179178 // Assume the remaining bytes if any are done a byte at a time.
180 unsigned NumByteStores = Bytes - NumPointerStores*TD.getPointerSize(AS);
179 unsigned NumByteStores = Bytes - NumPointerStores*TD.getPointerSize();
181180
182181 // If we will reduce the # stores (according to this heuristic), do the
183182 // transformation. This encourages merging 4 x i8 -> i32 and 2 x i16 -> i32
446446
447447 bool computeConstantGEPOffset(GetElementPtrInst &GEPI, int64_t &GEPOffset) {
448448 GEPOffset = Offset;
449 unsigned int AS = GEPI.getPointerAddressSpace();
450449 for (gep_type_iterator GTI = gep_type_begin(GEPI), GTE = gep_type_end(GEPI);
451450 GTI != GTE; ++GTI) {
452451 ConstantInt *OpC = dyn_cast(GTI.getOperand());
476475 continue;
477476 }
478477
479 APInt Index = OpC->getValue().sextOrTrunc(TD.getPointerSizeInBits(AS));
478 APInt Index = OpC->getValue().sextOrTrunc(TD.getPointerSizeInBits());
480479 Index *= APInt(Index.getBitWidth(),
481480 TD.getTypeAllocSize(GTI.getIndexedType()));
482481 Index += APInt(Index.getBitWidth(), (uint64_t)GEPOffset,
17841783 break;
17851784 if (SequentialType *SeqTy = dyn_cast(ElementTy)) {
17861785 ElementTy = SeqTy->getElementType();
1787 Indices.push_back(IRB.getInt(APInt(TD.getPointerSizeInBits(
1788 ElementTy->isPointerTy() ?
1789 cast(ElementTy)->getAddressSpace(): 0), 0)));
1786 Indices.push_back(IRB.getInt(APInt(TD.getPointerSizeInBits(), 0)));
17901787 } else if (StructType *STy = dyn_cast(ElementTy)) {
17911788 if (STy->element_begin() == STy->element_end())
17921789 break; // Nothing left to descend into.
22412238
22422239 Value *getAdjustedAllocaPtr(IRBuilder<> &IRB, Type *PointerTy) {
22432240 assert(BeginOffset >= NewAllocaBeginOffset);
2244 unsigned AS = cast(PointerTy)->getAddressSpace();
2245 APInt Offset(TD.getPointerSizeInBits(AS), BeginOffset - NewAllocaBeginOffset);
2241 APInt Offset(TD.getPointerSizeInBits(), BeginOffset - NewAllocaBeginOffset);
22462242 return getAdjustedPtr(IRB, TD, &NewAI, Offset, PointerTy, getName(""));
22472243 }
22482244
25812577 const AllocaPartitioning::MemTransferOffsets &MTO
25822578 = P.getMemTransferOffsets(II);
25832579
2584 assert(OldPtr->getType()->isPointerTy() && "Must be a pointer type!");
2585 unsigned AS = cast(OldPtr->getType())->getAddressSpace();
25862580 // Compute the relative offset within the transfer.
2587 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
2581 unsigned IntPtrWidth = TD.getPointerSizeInBits();
25882582 APInt RelOffset(IntPtrWidth, BeginOffset - (IsDest ? MTO.DestBegin
25892583 : MTO.SourceBegin));
25902584
805805 const DataLayout *TD) {
806806 assert(V->getType()->isPointerTy() &&
807807 "getOrEnforceKnownAlignment expects a pointer!");
808 unsigned AS = cast(V->getType())->getAddressSpace();
809 unsigned BitWidth = TD ? TD->getPointerSizeInBits(AS) : 64;
808 unsigned BitWidth = TD ? TD->getPointerSizeInBits() : 64;
810809 APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
811810 ComputeMaskedBits(V, KnownZero, KnownOne, TD);
812811 unsigned TrailZ = KnownZero.countTrailingOnes();