llvm.org GIT mirror llvm / 2c39b15
Resubmit the changes to llvm core to update the functions to support different pointer sizes on a per address space basis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165941 91177308-0d34-0410-b5e6-96231b3b80d8 Micah Villmow 8 years ago
40 changed file(s) with 190 addition(s) and 109 deletion(s). Raw diff Collapse all Expand all
230230 }
231231
232232 /// Layout pointer alignment
233 /// FIXME: The defaults need to be removed once all of
234 /// the backends/clients are updated.
235 unsigned getPointerABIAlignment(unsigned AS = 0) const {
233 unsigned getPointerABIAlignment(unsigned AS) const {
236234 DenseMap::const_iterator val = Pointers.find(AS);
237235 if (val == Pointers.end()) {
238236 val = Pointers.find(0);
240238 return val->second.ABIAlign;
241239 }
242240 /// Return target's alignment for stack-based pointers
243 /// FIXME: The defaults need to be removed once all of
244 /// the backends/clients are updated.
245 unsigned getPointerPrefAlignment(unsigned AS = 0) const {
241 unsigned getPointerPrefAlignment(unsigned AS) const {
246242 DenseMap::const_iterator val = Pointers.find(AS);
247243 if (val == Pointers.end()) {
248244 val = Pointers.find(0);
250246 return val->second.PrefAlign;
251247 }
252248 /// Layout pointer size
253 /// FIXME: The defaults need to be removed once all of
254 /// the backends/clients are updated.
255 unsigned getPointerSize(unsigned AS = 0) const {
249 unsigned getPointerSize(unsigned AS) const {
256250 DenseMap::const_iterator val = Pointers.find(AS);
257251 if (val == Pointers.end()) {
258252 val = Pointers.find(0);
260254 return val->second.TypeBitWidth;
261255 }
262256 /// Layout pointer size, in bits
263 /// FIXME: The defaults need to be removed once all of
264 /// the backends/clients are updated.
265 unsigned getPointerSizeInBits(unsigned AS = 0) const {
257 unsigned getPointerSizeInBits(unsigned AS) const {
266258 DenseMap::const_iterator val = Pointers.find(AS);
267259 if (val == Pointers.end()) {
268260 val = Pointers.find(0);
347347 static unsigned getPointerOperandIndex() { return 1U; }
348348
349349 unsigned getPointerAddressSpace() const {
350 return cast(getPointerOperand()->getType())->getAddressSpace();
350 if (getPointerOperand()->getType()->isPointerTy())
351 return cast(getPointerOperand()->getType())
352 ->getAddressSpace();
353 if (getPointerOperand()->getType()->isVectorTy()
354 && cast(getPointerOperand()->getType())->isPointerTy())
355 return cast(cast(
356 getPointerOperand()->getType())->getElementType())
357 ->getAddressSpace();
358 llvm_unreachable("Only a vector of pointers or pointers can be used!");
359 return 0;
351360 }
352361
353362 // Methods for support type inquiry through isa, cast, and dyn_cast:
36173626
36183627 /// @brief return the address space of the pointer.
36193628 unsigned getAddressSpace() const {
3620 return cast(getType())->getAddressSpace();
3629 if (getType()->isPointerTy())
3630 return cast(getType())->getAddressSpace();
3631 if (getType()->isVectorTy() &&
3632 cast(getType())->getElementType()->isPointerTy())
3633 return cast(
3634 cast(getType())->getElementType())
3635 ->getAddressSpace();
3636 llvm_unreachable("Must be a pointer or a vector of pointers.");
3637 return 0;
36213638 }
36223639
36233640 // Methods for support type inquiry through isa, cast, and dyn_cast:
36583675
36593676 /// @brief return the address space of the pointer.
36603677 unsigned getPointerAddressSpace() const {
3661 return cast(getOperand(0)->getType())->getAddressSpace();
3678 Type *Ty = getOperand(0)->getType();
3679 if (Ty->isPointerTy())
3680 return cast(Ty)->getAddressSpace();
3681 if (Ty->isVectorTy()
3682 && cast(Ty)->getElementType()->isPointerTy())
3683 return cast(
3684 cast(Ty)->getElementType())
3685 ->getAddressSpace();
3686 llvm_unreachable("Must be a pointer or a vector of pointers.");
3687 return 0;
36623688 }
36633689
36643690 // 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 addrspace = 0) const { return PointerTy; }
148 virtual MVT getPointerTy(uint32_t AS = 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 IntPtrWidth = TD.getPointerSizeInBits();
188 unsigned AS = cast(GEP)->getPointerAddressSpace();
189 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
189190 uint64_t PtrSizeMask = ~0ULL >> (64-IntPtrWidth);
190191
191192 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
174179 /** Returns the integer type that is the same size as a pointer on a target.
175180 See the method llvm::DataLayout::getIntPtrType. */
176181 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);
177187
178188 /** Computes the size of a type in bytes for a target.
179189 See the method llvm::DataLayout::getTypeSizeInBits. */
285285 V = GEPOp->getOperand(0);
286286 continue;
287287 }
288
288
289 unsigned AS = GEPOp->getPointerAddressSpace();
289290 // Walk the indices of the GEP, accumulating them into BaseOff/VarIndices.
290291 gep_type_iterator GTI = gep_type_begin(GEPOp);
291292 for (User::const_op_iterator I = GEPOp->op_begin()+1,
314315 // If the integer type is smaller than the pointer size, it is implicitly
315316 // sign extended to pointer size.
316317 unsigned Width = cast(Index->getType())->getBitWidth();
317 if (TD->getPointerSizeInBits() > Width)
318 if (TD->getPointerSizeInBits(AS) > Width)
318319 Extension = EK_SignExt;
319320
320321 // Use GetLinearExpression to decompose the index into a C1*V+C2 form.
343344
344345 // Make sure that we have a scale that makes sense for this target's
345346 // pointer size.
346 if (unsigned ShiftBits = 64-TD->getPointerSizeInBits()) {
347 if (unsigned ShiftBits = 64-TD->getPointerSizeInBits(AS)) {
347348 Scale <<= ShiftBits;
348349 Scale = (int64_t)Scale >> ShiftBits;
349350 }
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())
93 Op->getType()->getScalarSizeInBits() <= TD->getPointerSizeInBits(
94 cast(CI)->getAddressSpace()))
9495 return true;
9596
9697 // A ptrtoint cast is free so long as the result is large enough to store
9798 // the pointer, and a legal integer type.
9899 if (isa(CI) && TD &&
99100 TD->isLegalInteger(Op->getType()->getScalarSizeInBits()) &&
100 Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits())
101 Op->getType()->getScalarSizeInBits() >= TD->getPointerSizeInBits(
102 cast(CI)->getPointerAddressSpace()))
101103 return true;
102104
103105 // 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 if (TD->getPointerSizeInBits() < InWidth) {
918 unsigned AS = cast(CE->getType())->getAddressSpace();
919 if (TD->getPointerSizeInBits(AS) < InWidth) {
919920 Constant *Mask =
920921 ConstantInt::get(CE->getContext(), APInt::getLowBitsSet(InWidth,
921 TD->getPointerSizeInBits()));
922 TD->getPointerSizeInBits(AS)));
922923 Input = ConstantExpr::getAnd(Input, Mask);
923924 }
924925 // Do a zext or trunc to get to the dest size.
931932 // the int size is >= the ptr size. This requires knowing the width of a
932933 // pointer, so it can't be done in ConstantExpr::getCast.
933934 if (ConstantExpr *CE = dyn_cast(Ops[0]))
934 if (TD &&
935 TD->getPointerSizeInBits() <= CE->getType()->getScalarSizeInBits() &&
936 CE->getOpcode() == Instruction::PtrToInt)
935 if (TD && CE->getOpcode() == Instruction::PtrToInt &&
936 TD->getPointerSizeInBits(
937 cast(CE->getOperand(0)->getType())->getAddressSpace())
938 <= CE->getType()->getScalarSizeInBits())
937939 return FoldBitCast(CE->getOperand(0), DestTy, *TD);
938940
939941 return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
242242 if (!TD)
243243 return false;
244244
245 unsigned IntPtrWidth = TD->getPointerSizeInBits();
245 unsigned AS = GEP.getPointerAddressSpace();
246 unsigned IntPtrWidth = TD->getPointerSizeInBits(AS);
246247 assert(IntPtrWidth == Offset.getBitWidth());
247248
248249 for (gep_type_iterator GTI = gep_type_begin(GEP), GTE = gep_type_end(GEP);
390391 // Track base/offset pairs when converted to a plain integer provided the
391392 // integer is large enough to represent the pointer.
392393 unsigned IntegerSize = I.getType()->getScalarSizeInBits();
393 if (TD && IntegerSize >= TD->getPointerSizeInBits()) {
394 unsigned AS = I.getPointerAddressSpace();
395 if (TD && IntegerSize >= TD->getPointerSizeInBits(AS)) {
394396 std::pair BaseAndOffset
395397 = ConstantOffsetPtrs.lookup(I.getOperand(0));
396398 if (BaseAndOffset.first)
424426 // modifications provided the integer is not too large.
425427 Value *Op = I.getOperand(0);
426428 unsigned IntegerSize = Op->getType()->getScalarSizeInBits();
427 if (TD && IntegerSize <= TD->getPointerSizeInBits()) {
429 unsigned AS = I.getAddressSpace();
430 if (TD && IntegerSize <= TD->getPointerSizeInBits(AS)) {
428431 std::pair BaseAndOffset = ConstantOffsetPtrs.lookup(Op);
429432 if (BaseAndOffset.first)
430433 ConstantOffsetPtrs[&I] = BaseAndOffset;
759762 if (!TD || !V->getType()->isPointerTy())
760763 return 0;
761764
762 unsigned IntPtrWidth = TD->getPointerSizeInBits();
765 unsigned AS = cast(V->getType())->getAddressSpace();;
766 unsigned IntPtrWidth = TD->getPointerSizeInBits(AS);
763767 APInt Offset = APInt::getNullValue(IntPtrWidth);
764768
765769 // Even though we don't look through PHI nodes, we could be called on an
823827 // size of the byval type by the target's pointer size.
824828 PointerType *PTy = cast(CS.getArgument(I)->getType());
825829 unsigned TypeSize = TD->getTypeSizeInBits(PTy->getElementType());
826 unsigned PointerSize = TD->getPointerSizeInBits();
830 unsigned AS = PTy->getAddressSpace();
831 unsigned PointerSize = TD->getPointerSizeInBits(AS);
827832 // Ceiling division.
828833 unsigned NumStores = (TypeSize + PointerSize - 1) / PointerSize;
829834
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 IntPtrWidth = TD.getPointerSizeInBits();
668 unsigned AS = GEP->getPointerAddressSpace();
669 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
669670 assert(IntPtrWidth == Offset.getBitWidth());
670671
671672 gep_type_iterator GTI = gep_type_begin(GEP);
695696 /// accumulates the total constant offset applied in the returned constant. It
696697 /// returns 0 if V is not a pointer, and returns the constant '0' if there are
697698 /// no constant offsets applied.
699 /// FIXME: This function also exists in InlineCost.cpp.
698700 static Constant *stripAndComputeConstantOffsets(const DataLayout &TD,
699701 Value *&V) {
700702 if (!V->getType()->isPointerTy())
701703 return 0;
702704
703 unsigned IntPtrWidth = TD.getPointerSizeInBits();
705 unsigned AS = cast(V->getType())->getAddressSpace();;
706 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
704707 APInt Offset = APInt::getNullValue(IntPtrWidth);
705708
706709 // Even though we don't look through PHI nodes, we could be called on an
18761879 // Turn icmp (ptrtoint x), (ptrtoint/constant) into a compare of the input
18771880 // if the integer type is the same size as the pointer type.
18781881 if (MaxRecurse && Q.TD && isa(LI) &&
1879 Q.TD->getPointerSizeInBits() == DstTy->getPrimitiveSizeInBits()) {
1882 Q.TD->getPointerSizeInBits(
1883 cast(LI)->getPointerAddressSpace()) ==
1884 DstTy->getPrimitiveSizeInBits()) {
18801885 if (Constant *RHSC = dyn_cast(RHS)) {
18811886 // Transfer the cast to the constant.
18821887 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 ? TD->getPointerSizeInBits() : 0;
42 return TD ?
43 TD->getPointerSizeInBits(cast(Ty)->getAddressSpace()) : 0;
4344 }
4445
4546 static void ComputeMaskedBitsAddSub(bool Add, Value *Op0, Value *Op1, bool NSW,
16201621
16211622 // Re-sign extend from the pointer size if needed to get overflow edge cases
16221623 // right.
1623 unsigned PtrSize = TD.getPointerSizeInBits();
1624 unsigned AS = GEP->getPointerAddressSpace();
1625 unsigned PtrSize = TD.getPointerSizeInBits(AS);
16241626 if (PtrSize < 64)
16251627 Offset = SignExtend64(Offset, PtrSize);
16261628
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 PtrSize = TD->getPointerSizeInBits()/8;
387 unsigned AS = GV->getType()->getAddressSpace();
388 unsigned PtrSize = TD->getPointerSizeInBits(AS)/8;
388389 OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"),
389390 PtrSize, 0);
390391 OutStreamer.EmitIntValue(0, PtrSize, 0);
12981299
12991300 // Emit the function pointers in the target-specific order
13001301 const DataLayout *TD = TM.getDataLayout();
1301 unsigned Align = Log2_32(TD->getPointerPrefAlignment());
1302 unsigned Align = Log2_32(TD->getPointerPrefAlignment(0));
13021303 std::stable_sort(Structors.begin(), Structors.end(), priority_order);
13031304 for (unsigned i = 0, e = Structors.size(); i != e; ++i) {
13041305 const MCSection *OutputSection =
14791480 if (Offset == 0)
14801481 return Base;
14811482
1483 unsigned AS = cast(CE->getType())->getAddressSpace();
14821484 // Truncate/sext the offset to the pointer size.
1483 unsigned Width = TD.getPointerSizeInBits();
1485 unsigned Width = TD.getPointerSizeInBits(AS);
14841486 if (Width < 64)
14851487 Offset = SignExtend64(Offset, Width);
14861488
111111
112112 switch (Encoding & 0x07) {
113113 default: llvm_unreachable("Invalid encoded value.");
114 case dwarf::DW_EH_PE_absptr: return TM.getDataLayout()->getPointerSize();
114 case dwarf::DW_EH_PE_absptr: return TM.getDataLayout()->getPointerSize(0);
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(); break;
202 Size = Asm->getDataLayout().getPointerSize(0); 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();
224 case dwarf::DW_FORM_addr: return AP->getDataLayout().getPointerSize(0);
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();
251 return AP->getDataLayout().getPointerSize(0);
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();
275 return AP->getDataLayout().getPointerSize(0);
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());
386 * Asm->getDataLayout().getPointerSize(0));
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());
452 * Asm->getDataLayout().getPointerSize(0));
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());
1767 Asm->EmitInt8(Asm->getDataLayout().getPointerSize(0));
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() + 1);
1813 Asm->EmitInt8(Asm->getDataLayout().getPointerSize(0) + 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(),
1820 Asm->getDataLayout().getPointerSize(0),
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();
2049 unsigned char Size = Asm->getDataLayout().getPointerSize(0);
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();
2146 unsigned char Size = Asm->getDataLayout().getPointerSize(0);
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());
2204 Asm->EmitInt8(Asm->getDataLayout().getPointerSize(0));
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);
2235 Asm->getDataLayout().getPointerSize(0),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();
419 TypeFormatSize = Asm->getDataLayout().getPointerSize(0);
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();
93 unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(0);
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();
552 return TD.getPointerSize(0);
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();
572 return TD.getPointerABIAlignment(0);
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;
34513454
34523455 if (VT == MVT::Other) {
3453 if (DstAlign >= TLI.getDataLayout()->getPointerPrefAlignment() ||
3456 if (DstAlign >= TLI.getDataLayout()->getPointerPrefAlignment(AS) ||
34543457 TLI.allowsUnalignedMemoryAccesses(VT)) {
34553458 VT = TLI.getPointerTy();
34563459 } else {
7676 Flags,
7777 SectionKind::getDataRel(),
7878 0, Label->getName());
79 unsigned Size = TM.getDataLayout()->getPointerSize();
79 unsigned Size = TM.getDataLayout()->getPointerSize(0);
8080 Streamer.SwitchSection(Sec);
81 Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment());
81 Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment(0));
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"
1920 #include "llvm/Module.h"
2021 #include "llvm/ExecutionEngine/GenericValue.h"
2122 #include "llvm/ADT/SmallString.h"
266267 void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
267268 const std::vector &InputArgv) {
268269 clear(); // Free the old contents.
269 unsigned PtrSize = EE->getDataLayout()->getPointerSize();
270 unsigned PtrSize = EE->getDataLayout()->getPointerSize(0);
270271 Array = new char[(InputArgv.size()+1)*PtrSize];
271272
272273 DEBUG(dbgs() << "JIT: ARGV = " << (void*)Array << "\n");
341342 #ifndef NDEBUG
342343 /// isTargetNullPtr - Return whether the target pointer stored at Loc is null.
343344 static bool isTargetNullPtr(ExecutionEngine *EE, void *Loc) {
344 unsigned PtrSize = EE->getDataLayout()->getPointerSize();
345 unsigned PtrSize = EE->getDataLayout()->getPointerSize(0);
345346 for (unsigned i = 0; i < PtrSize; ++i)
346347 if (*(i + (uint8_t*)Loc))
347348 return false;
643644 }
644645 case Instruction::PtrToInt: {
645646 GenericValue GV = getConstantValue(Op0);
646 uint32_t PtrWidth = TD->getPointerSizeInBits();
647 unsigned AS = cast(CE->getOperand(1)->getType())
648 ->getAddressSpace();
649 uint32_t PtrWidth = TD->getPointerSizeInBits(AS);
647650 GV.IntVal = APInt(PtrWidth, uintptr_t(GV.PointerVal));
648651 return GV;
649652 }
650653 case Instruction::IntToPtr: {
651654 GenericValue GV = getConstantValue(Op0);
652 uint32_t PtrWidth = TD->getPointerSizeInBits();
655 unsigned AS = cast(CE->getType())->getAddressSpace();
656 uint32_t PtrWidth = TD->getPointerSizeInBits(AS);
653657 if (PtrWidth != GV.IntVal.getBitWidth())
654658 GV.IntVal = GV.IntVal.zextOrTrunc(PtrWidth);
655659 assert(GV.IntVal.getBitWidth() <= 64 && "Bad pointer width");
10531053 GenericValue Dest, Src = getOperandValue(SrcVal, SF);
10541054 assert(DstTy->isPointerTy() && "Invalid PtrToInt instruction");
10551055
1056 uint32_t PtrSize = TD.getPointerSizeInBits();
1056 unsigned AS = cast(DstTy)->getAddressSpace();
1057 uint32_t PtrSize = TD.getPointerSizeInBits(AS);
10571058 if (PtrSize != Src.IntVal.getBitWidth())
10581059 Src.IntVal = Src.IntVal.zextOrTrunc(PtrSize);
10591060
375375 case 'x': case 'X':
376376 if (HowLong >= 1) {
377377 if (HowLong == 1 &&
378 TheInterpreter->getDataLayout()->getPointerSizeInBits() == 64 &&
378 TheInterpreter->getDataLayout()->getPointerSizeInBits(0) == 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"
1617 #include "llvm/Function.h"
18 #include "llvm/GlobalVariable.h"
1719 #include "llvm/ADT/DenseMap.h"
1820 #include "llvm/CodeGen/JITCodeEmitter.h"
1921 #include "llvm/CodeGen/MachineFunction.h"
6567 void
6668 JITDwarfEmitter::EmitFrameMoves(intptr_t BaseLabelPtr,
6769 const std::vector &Moves) const {
68 unsigned PointerSize = TD->getPointerSize();
70 unsigned PointerSize = TD->getPointerSize(0);
6971 int stackGrowth = stackGrowthDirection == TargetFrameLowering::StackGrowsUp ?
7072 PointerSize : -PointerSize;
7173 MCSymbol *BaseLabel = 0;
377379 for (unsigned i = 0, e = CallSites.size(); i < e; ++i)
378380 SizeSites += MCAsmInfo::getULEB128Size(CallSites[i].Action);
379381
380 unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize();
382 unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize(0);
381383
382384 unsigned TypeOffset = sizeof(int8_t) + // Call site format
383385 // Call-site table length
453455 const GlobalVariable *GV = TypeInfos[M - 1];
454456
455457 if (GV) {
456 if (TD->getPointerSize() == sizeof(int32_t))
458 if (TD->getPointerSize(GV->getType()->getAddressSpace()) == sizeof(int32_t))
457459 JCE->emitInt32((intptr_t)Jit.getOrEmitGlobalVariable(GV));
458460 else
459461 JCE->emitInt64((intptr_t)Jit.getOrEmitGlobalVariable(GV));
460462 } else {
461 if (TD->getPointerSize() == sizeof(int32_t))
463 if (TD->getPointerSize(0) == sizeof(int32_t))
462464 JCE->emitInt32(0);
463465 else
464466 JCE->emitInt64(0);
480482
481483 unsigned char*
482484 JITDwarfEmitter::EmitCommonEHFrame(const Function* Personality) const {
483 unsigned PointerSize = TD->getPointerSize();
485 unsigned PointerSize = TD->getPointerSize(0);
484486 int stackGrowth = stackGrowthDirection == TargetFrameLowering::StackGrowsUp ?
485487 PointerSize : -PointerSize;
486488
540542 unsigned char* StartFunction,
541543 unsigned char* EndFunction,
542544 unsigned char* ExceptionTable) const {
543 unsigned PointerSize = TD->getPointerSize();
545 unsigned PointerSize = TD->getPointerSize(0);
544546
545547 // EH frame header.
546548 unsigned char* StartEHPtr = (unsigned char*)JCE->getCurrentPCValue();
2525 //===----------------------------------------------------------------------===//
2626
2727 ARMELFWriterInfo::ARMELFWriterInfo(TargetMachine &TM)
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits() == 64,
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits(0) == 64,
2929 TM.getDataLayout()->isLittleEndian()) {
3030 }
3131
2525 //===----------------------------------------------------------------------===//
2626
2727 MBlazeELFWriterInfo::MBlazeELFWriterInfo(TargetMachine &TM)
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits() == 64,
28 : TargetELFWriterInfo(TM.getDataLayout()->getPointerSizeInBits(0) == 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();
883 uint64_t SlotSize = TD->getPointerSize(0);
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(), MVT::i16);
903 DAG.getConstant(TD->getPointerSize(0), 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 if (TD.getPointerSizeInBits() != 64) {
129 int SExtAmount = 64-TD.getPointerSizeInBits();
128 unsigned AS = PtrVal->getType()->isPointerTy() ?
129 cast(PtrVal->getType())->getAddressSpace() : 0;
130 if (TD.getPointerSizeInBits(AS) != 64) {
131 int SExtAmount = 64-TD.getPointerSizeInBits(AS);
130132 Offset = (Offset << SExtAmount) >> SExtAmount;
131133 }
132134
13771379
13781380 const FunctionType *FTy = dyn_cast(Ty);
13791381 if (FTy)
1380 return TD->getPointerPrefAlignment();
1382 return TD->getPointerPrefAlignment(0);
13811383 return TD->getPrefTypeAlignment(Ty);
13821384 }
13831385
438438 bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
439439 const DataLayout *TD = TM.getDataLayout();
440440
441 bool isPPC64 = TD->getPointerSizeInBits() == 64;
441 bool isPPC64 = TD->getPointerSizeInBits(0) == 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() == 64;
547 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits(0) == 64;
548548
549549 const TargetLoweringObjectFileMachO &TLOFMacho =
550550 static_cast(getObjFileLowering());
639639
640640
641641 bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
642 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64;
642 bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits(0) == 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 = ((MachineFunction &)MF).getFrameInfo();
500 MachineFrameInfo *MFI = (const_cast(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();
58 return unwrap(TD)->getPointerSize(0);
59 }
60
61 unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS) {
62 return unwrap(TD)->getPointerSize(AS);
5963 }
6064
6165 LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) {
6266 return wrap(unwrap(TD)->getIntPtrType(getGlobalContext()));
67 }
68
69 LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS) {
70 return wrap(unwrap(TD)->getIntPtrType(getGlobalContext(), AS));
6371 }
6472
6573 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);
695 TD->getPointerSize(0), 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();
319 int stackGrowth = -TD->getPointerSize(0);
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();
719 int stackGrowth = -TD->getPointerSize(0);
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();
2654 uint64_t SlotSize = TD->getPointerSize(0);
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();
3022 uint64_t SlotSize = TD->getPointerSize(0);
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()),
7645 SDValue Scale = DAG.getConstant(Log2_64_Ceil(TD->getPointerSize(0)),
76467646 getPointerTy());
76477647 IDX = DAG.getNode(ISD::SHL, dl, getPointerTy(), IDX, Scale);
76487648
1029210292 if (Depth > 0) {
1029310293 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
1029410294 SDValue Offset =
10295 DAG.getConstant(TD->getPointerSize(),
10295 DAG.getConstant(TD->getPointerSize(0),
1029610296 Subtarget->is64Bit() ? MVT::i64 : MVT::i32);
1029710297 return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
1029810298 DAG.getNode(ISD::ADD, dl, getPointerTy(),
1032410324
1032510325 SDValue X86TargetLowering::LowerFRAME_TO_ARGS_OFFSET(SDValue Op,
1032610326 SelectionDAG &DAG) const {
10327 return DAG.getIntPtrConstant(2*TD->getPointerSize());
10327 return DAG.getIntPtrConstant(2*TD->getPointerSize(0));
1032810328 }
1032910329
1033010330 SDValue X86TargetLowering::LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const {
1033910339 unsigned StoreAddrReg = (Subtarget->is64Bit() ? X86::RCX : X86::ECX);
1034010340
1034110341 SDValue StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), Frame,
10342 DAG.getIntPtrConstant(TD->getPointerSize()));
10342 DAG.getIntPtrConstant(TD->getPointerSize(0)));
1034310343 StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), StoreAddr, Offset);
1034410344 Chain = DAG.getStore(Chain, dl, Handler, StoreAddr, MachinePointerInfo(),
1034510345 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();
12951296 if (TD) {
12961297 if (CI.getOperand(0)->getType()->getScalarSizeInBits() >
1297 TD->getPointerSizeInBits()) {
1298 TD->getPointerSizeInBits(AS)) {
12981299 Value *P = Builder->CreateTrunc(CI.getOperand(0),
12991300 TD->getIntPtrType(CI.getContext()));
13001301 return new IntToPtrInst(P, CI.getType());
13011302 }
13021303 if (CI.getOperand(0)->getType()->getScalarSizeInBits() <
1303 TD->getPointerSizeInBits()) {
1304 TD->getPointerSizeInBits(AS)) {
13041305 Value *P = Builder->CreateZExt(CI.getOperand(0),
13051306 TD->getIntPtrType(CI.getContext()));
13061307 return new IntToPtrInst(P, CI.getType());
13671368 // If the destination integer type is not the intptr_t type for this target,
13681369 // do a ptrtoint to intptr_t then do a trunc or zext. This allows the cast
13691370 // to be exposed to other transforms.
1371 unsigned AS = CI.getPointerAddressSpace();
13701372 if (TD) {
1371 if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) {
1373 if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits(AS)) {
13721374 Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
13731375 TD->getIntPtrType(CI.getContext()));
13741376 return new TruncInst(P, CI.getType());
13751377 }
1376 if (CI.getType()->getScalarSizeInBits() > TD->getPointerSizeInBits()) {
1378 if (CI.getType()->getScalarSizeInBits() > TD->getPointerSizeInBits(AS)) {
13771379 Value *P = Builder->CreatePtrToInt(CI.getOperand(0),
13781380 TD->getIntPtrType(CI.getContext()));
13791381 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();
367368 // If the index is larger than the pointer size of the target, truncate the
368369 // index down like the GEP would do implicitly. We don't have to do this for
369370 // an inbounds GEP because the index can't be out of range.
370371 if (!GEP->isInBounds() &&
371 Idx->getType()->getPrimitiveSizeInBits() > TD->getPointerSizeInBits())
372 Idx->getType()->getPrimitiveSizeInBits() > TD->getPointerSizeInBits(AS))
372373 Idx = Builder->CreateTrunc(Idx, TD->getIntPtrType(Idx->getContext()));
373374
374375 // If the comparison is only true for one or two elements, emit direct
527528 }
528529 }
529530
531 unsigned AS = cast(GEP)->getPointerAddressSpace();
530532 // Okay, we know we have a single variable index, which must be a
531533 // pointer/array/vector index. If there is no offset, life is simple, return
532534 // the index.
533 unsigned IntPtrWidth = TD.getPointerSizeInBits();
535 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
534536 if (Offset == 0) {
535537 // Cast to intptrty in case a truncation occurs. If an extension is needed,
536538 // we don't need to bother extending: the extension won't affect where the
15511553 // Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
15521554 // integer type is the same size as the pointer type.
15531555 if (TD && LHSCI->getOpcode() == Instruction::PtrToInt &&
1554 TD->getPointerSizeInBits() ==
1556 TD->getPointerSizeInBits(
1557 cast(LHSCI)->getPointerAddressSpace()) ==
15551558 cast(DestTy)->getBitWidth()) {
15561559 Value *RHSOp = 0;
15571560 if (Constant *RHSC = dyn_cast(ICI.getOperand(1))) {
734734 BL.reset(new BlackList(ClBlackListFile));
735735
736736 C = &(M.getContext());
737 LongSize = TD->getPointerSizeInBits();
737 LongSize = TD->getPointerSizeInBits(0);
738738 IntptrTy = Type::getIntNTy(*C, LongSize);
739739 IntptrPtrTy = PointerType::get(IntptrTy, 0);
740740
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 NumPointerStores = Bytes/TD.getPointerSize();
176 unsigned AS = cast(TheStores[0])->getPointerAddressSpace();
177 unsigned NumPointerStores = Bytes/TD.getPointerSize(AS);
177178
178179 // Assume the remaining bytes if any are done a byte at a time.
179 unsigned NumByteStores = Bytes - NumPointerStores*TD.getPointerSize();
180 unsigned NumByteStores = Bytes - NumPointerStores*TD.getPointerSize(AS);
180181
181182 // If we will reduce the # stores (according to this heuristic), do the
182183 // 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();
449450 for (gep_type_iterator GTI = gep_type_begin(GEPI), GTE = gep_type_end(GEPI);
450451 GTI != GTE; ++GTI) {
451452 ConstantInt *OpC = dyn_cast(GTI.getOperand());
475476 continue;
476477 }
477478
478 APInt Index = OpC->getValue().sextOrTrunc(TD.getPointerSizeInBits());
479 APInt Index = OpC->getValue().sextOrTrunc(TD.getPointerSizeInBits(AS));
479480 Index *= APInt(Index.getBitWidth(),
480481 TD.getTypeAllocSize(GTI.getIndexedType()));
481482 Index += APInt(Index.getBitWidth(), (uint64_t)GEPOffset,
17831784 break;
17841785 if (SequentialType *SeqTy = dyn_cast(ElementTy)) {
17851786 ElementTy = SeqTy->getElementType();
1786 Indices.push_back(IRB.getInt(APInt(TD.getPointerSizeInBits(), 0)));
1787 Indices.push_back(IRB.getInt(APInt(TD.getPointerSizeInBits(
1788 ElementTy->isPointerTy() ?
1789 cast(ElementTy)->getAddressSpace(): 0), 0)));
17871790 } else if (StructType *STy = dyn_cast(ElementTy)) {
17881791 if (STy->element_begin() == STy->element_end())
17891792 break; // Nothing left to descend into.
23212324
23222325 Value *getAdjustedAllocaPtr(IRBuilder<> &IRB, Type *PointerTy) {
23232326 assert(BeginOffset >= NewAllocaBeginOffset);
2324 APInt Offset(TD.getPointerSizeInBits(), BeginOffset - NewAllocaBeginOffset);
2327 unsigned AS = cast(PointerTy)->getAddressSpace();
2328 APInt Offset(TD.getPointerSizeInBits(AS), BeginOffset - NewAllocaBeginOffset);
23252329 return getAdjustedPtr(IRB, TD, &NewAI, Offset, PointerTy, getName(""));
23262330 }
23272331
26762680 const AllocaPartitioning::MemTransferOffsets &MTO
26772681 = P.getMemTransferOffsets(II);
26782682
2683 assert(OldPtr->getType()->isPointerTy() && "Must be a pointer type!");
2684 unsigned AS = cast(OldPtr->getType())->getAddressSpace();
26792685 // Compute the relative offset within the transfer.
2680 unsigned IntPtrWidth = TD.getPointerSizeInBits();
2686 unsigned IntPtrWidth = TD.getPointerSizeInBits(AS);
26812687 APInt RelOffset(IntPtrWidth, BeginOffset - (IsDest ? MTO.DestBegin
26822688 : MTO.SourceBegin));
26832689
805805 const DataLayout *TD) {
806806 assert(V->getType()->isPointerTy() &&
807807 "getOrEnforceKnownAlignment expects a pointer!");
808 unsigned BitWidth = TD ? TD->getPointerSizeInBits() : 64;
808 unsigned AS = cast(V->getType())->getAddressSpace();
809 unsigned BitWidth = TD ? TD->getPointerSizeInBits(AS) : 64;
809810 APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0);
810811 ComputeMaskedBits(V, KnownZero, KnownOne, TD);
811812 unsigned TrailZ = KnownZero.countTrailingOnes();