IntType getUIntMaxType() const {
return getCorrespondingUnsignedType(IntMaxType);
}
- IntType getPtrDiffType(unsigned AddrSpace) const {
- return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
+ IntType getPtrDiffType(LangAS AddrSpace) const {
+ return AddrSpace == LangAS::Default ? PtrDiffType
+ : getPtrDiffTypeV(AddrSpace);
}
- IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
+ IntType getUnsignedPtrDiffType(LangAS AddrSpace) const {
return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
}
IntType getIntPtrType() const { return IntPtrType; }
/// Return the width of pointers on this target, for the
/// specified address space.
- uint64_t getPointerWidth(unsigned AddrSpace) const {
- return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
+ uint64_t getPointerWidth(LangAS AddrSpace) const {
+ return AddrSpace == LangAS::Default ? PointerWidth
+ : getPointerWidthV(AddrSpace);
}
- uint64_t getPointerAlign(unsigned AddrSpace) const {
- return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
+ uint64_t getPointerAlign(LangAS AddrSpace) const {
+ return AddrSpace == LangAS::Default ? PointerAlign
+ : getPointerAlignV(AddrSpace);
}
/// Return the maximum width of pointers on this target.
/// Determine whether the __int128 type is supported on this target.
virtual bool hasInt128Type() const {
- return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128;
+ return (getPointerWidth(LangAS::Default) >= 64) ||
+ getTargetOpts().ForceEnableInt128;
} // FIXME
/// Determine whether the _BitInt type is supported on this target. This
unsigned getProgramAddressSpace() const { return ProgramAddrSpace; }
// Return the size of unwind_word for this target.
- virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+ virtual unsigned getUnwindWordWidth() const {
+ return getPointerWidth(LangAS::Default);
+ }
/// Return the "preferred" register width on this target.
virtual unsigned getRegisterWidth() const {
}
const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; }
+ unsigned getTargetAddressSpace(LangAS AS) const {
+ if (isTargetAddressSpace(AS))
+ return toTargetAddressSpace(AS);
+ return getAddressSpaceMap()[(unsigned)AS];
+ }
/// Map from the address space field in builtin description strings to the
/// language address space.
protected:
/// Copy type and layout related info.
void copyAuxTarget(const TargetInfo *Aux);
- virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
+ virtual uint64_t getPointerWidthV(LangAS AddrSpace) const {
return PointerWidth;
}
- virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
+ virtual uint64_t getPointerAlignV(LangAS AddrSpace) const {
return PointerAlign;
}
- virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
+ virtual enum IntType getPtrDiffTypeV(LangAS AddrSpace) const {
return PtrDiffType;
}
virtual ArrayRef<const char *> getGCCRegNames() const = 0;
uint64_t Width = EltInfo.Width.getQuantity() * Size;
unsigned Align = EltInfo.Align.getQuantity();
if (!Context.getTargetInfo().getCXXABI().isMicrosoft() ||
- Context.getTargetInfo().getPointerWidth(0) == 64)
+ Context.getTargetInfo().getPointerWidth(LangAS::Default) == 64)
Width = llvm::alignTo(Width, Align);
return TypeInfoChars(CharUnits::fromQuantity(Width),
CharUnits::fromQuantity(Align),
uint64_t Width = 0;
unsigned Align = 8;
AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
- unsigned AS = 0;
+ LangAS AS = LangAS::Default;
switch (T->getTypeClass()) {
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
Align = EltInfo.Align;
AlignRequirement = EltInfo.AlignRequirement;
if (!getTargetInfo().getCXXABI().isMicrosoft() ||
- getTargetInfo().getPointerWidth(0) == 64)
+ getTargetInfo().getPointerWidth(LangAS::Default) == 64)
Width = llvm::alignTo(Width, Align);
break;
}
}
break;
case BuiltinType::NullPtr:
- Width = Target->getPointerWidth(0); // C++ 3.9.1p11: sizeof(nullptr_t)
- Align = Target->getPointerAlign(0); // == sizeof(void*)
+ // C++ 3.9.1p11: sizeof(nullptr_t) == sizeof(void*)
+ Width = Target->getPointerWidth(LangAS::Default);
+ Align = Target->getPointerAlign(LangAS::Default);
break;
case BuiltinType::ObjCId:
case BuiltinType::ObjCClass:
case BuiltinType::ObjCSel:
- Width = Target->getPointerWidth(0);
- Align = Target->getPointerAlign(0);
+ Width = Target->getPointerWidth(LangAS::Default);
+ Align = Target->getPointerAlign(LangAS::Default);
break;
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
- AS = getTargetAddressSpace(
- Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T)));
+ AS = Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T));
Width = Target->getPointerWidth(AS);
Align = Target->getPointerAlign(AS);
break;
}
break;
case Type::ObjCObjectPointer:
- Width = Target->getPointerWidth(0);
- Align = Target->getPointerAlign(0);
+ Width = Target->getPointerWidth(LangAS::Default);
+ Align = Target->getPointerAlign(LangAS::Default);
break;
case Type::BlockPointer:
- AS = getTargetAddressSpace(cast<BlockPointerType>(T)->getPointeeType());
+ AS = cast<BlockPointerType>(T)->getPointeeType().getAddressSpace();
Width = Target->getPointerWidth(AS);
Align = Target->getPointerAlign(AS);
break;
case Type::RValueReference:
// alignof and sizeof should never enter this code path here, so we go
// the pointer route.
- AS = getTargetAddressSpace(cast<ReferenceType>(T)->getPointeeType());
+ AS = cast<ReferenceType>(T)->getPointeeType().getAddressSpace();
Width = Target->getPointerWidth(AS);
Align = Target->getPointerAlign(AS);
break;
case Type::Pointer:
- AS = getTargetAddressSpace(cast<PointerType>(T)->getPointeeType());
+ AS = cast<PointerType>(T)->getPointeeType().getAddressSpace();
Width = Target->getPointerWidth(AS);
Align = Target->getPointerAlign(AS);
break;
break;
case Type::Pipe:
- Width = Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
- Align = Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
+ Width = Target->getPointerWidth(LangAS::opencl_global);
+ Align = Target->getPointerAlign(LangAS::opencl_global);
break;
}
/// getPointerDiffType - Return the unique type for "ptrdiff_t" (C99 7.17)
/// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
QualType ASTContext::getPointerDiffType() const {
- return getFromTargetType(Target->getPtrDiffType(0));
+ return getFromTargetType(Target->getPtrDiffType(LangAS::Default));
}
/// Return the unique unsigned counterpart of "ptrdiff_t"
/// integer type. The standard (C11 7.21.6.1p7) refers to this type
/// in the definition of %tu format specifier.
QualType ASTContext::getUnsignedPointerDiffType() const {
- return getFromTargetType(Target->getUnsignedPtrDiffType(0));
+ return getFromTargetType(Target->getUnsignedPtrDiffType(LangAS::Default));
}
/// Return the unique type for "pid_t" defined in
MemberPointerInfo
getMemberPointerInfo(const MemberPointerType *MPT) const override {
const TargetInfo &Target = Context.getTargetInfo();
- TargetInfo::IntType PtrDiff = Target.getPtrDiffType(0);
+ TargetInfo::IntType PtrDiff = Target.getPtrDiffType(LangAS::Default);
MemberPointerInfo MPI;
MPI.Width = Target.getTypeWidth(PtrDiff);
MPI.Align = Target.getTypeAlign(PtrDiff);
return false;
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
- CharUnits PointerSize =
- Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
+ CharUnits PointerSize = Context.toCharUnitsFromBits(
+ Context.getTargetInfo().getPointerWidth(LangAS::Default));
return Layout.getNonVirtualSize() == PointerSize;
}
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
if (!MD->isStatic())
++ArgWords;
+ uint64_t DefaultPtrWidth = TI.getPointerWidth(LangAS::Default);
for (const auto &AT : Proto->param_types()) {
// If an argument type is incomplete there is no way to get its size to
// correctly encode into the mangling scheme.
if (AT->isIncompleteType())
break;
// Size should be aligned to pointer size.
- ArgWords +=
- llvm::alignTo(ASTContext.getTypeSize(AT), TI.getPointerWidth(0)) /
- TI.getPointerWidth(0);
+ ArgWords += llvm::alignTo(ASTContext.getTypeSize(AT), DefaultPtrWidth) /
+ DefaultPtrWidth;
}
- Out << ((TI.getPointerWidth(0) / 8) * ArgWords);
+ Out << ((DefaultPtrWidth / 8) * ArgWords);
}
void MangleContext::mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &Out) {
// The nominal struct is laid out with pointers followed by ints and aligned
// to a pointer width if any are present and an int width otherwise.
const TargetInfo &Target = Context.getTargetInfo();
- unsigned PtrSize = Target.getPointerWidth(0);
+ unsigned PtrSize = Target.getPointerWidth(LangAS::Default);
unsigned IntSize = Target.getIntWidth();
unsigned Ptrs, Ints;
if (Ptrs + Ints > 1 && Target.getTriple().isArch32Bit())
MPI.Align = 64;
else if (Ptrs)
- MPI.Align = Target.getPointerAlign(0);
+ MPI.Align = Target.getPointerAlign(LangAS::Default);
else
MPI.Align = Target.getIntAlign();
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_)
: Context(C), Out(Out_), Structor(nullptr), StructorType(-1),
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
- PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
- 64) {}
+ PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(
+ LangAS::Default) == 64) {}
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_,
const CXXConstructorDecl *D, CXXCtorType Type)
: Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
- PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
- 64) {}
+ PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(
+ LangAS::Default) == 64) {}
MicrosoftCXXNameMangler(MicrosoftMangleContextImpl &C, raw_ostream &Out_,
const CXXDestructorDecl *D, CXXDtorType Type)
: Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
TemplateArgStringStorage(TemplateArgStringStorageAlloc),
- PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(0) ==
- 64) {}
+ PointersAre64Bit(C.getASTContext().getTargetInfo().getPointerWidth(
+ LangAS::Default) == 64) {}
raw_ostream &getStream() const { return Out; }
const CXXMethodDecl *MD, const MethodVFTableLocation &ML) {
// Get the vftable offset.
CharUnits PointerWidth = getASTContext().toCharUnitsFromBits(
- getASTContext().getTargetInfo().getPointerWidth(0));
+ getASTContext().getTargetInfo().getPointerWidth(LangAS::Default));
uint64_t OffsetInVFTable = ML.Index * PointerWidth.getQuantity();
Out << "?_9";
// primary base, add it in now.
} else if (RD->isDynamicClass()) {
assert(DataSize == 0 && "Vtable pointer must be at offset zero!");
- CharUnits PtrWidth =
- Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
- CharUnits PtrAlign =
- Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0));
+ CharUnits PtrWidth = Context.toCharUnitsFromBits(
+ Context.getTargetInfo().getPointerWidth(LangAS::Default));
+ CharUnits PtrAlign = Context.toCharUnitsFromBits(
+ Context.getTargetInfo().getPointerAlign(LangAS::Default));
EnsureVTablePointerAlignment(PtrAlign);
HasOwnVFPtr = true;
if (D->getType()->isIncompleteArrayType()) {
setDeclInfo(true /* IsIncompleteArrayType */);
- } else if (const ReferenceType *RT = D->getType()->getAs<ReferenceType>()) {
- unsigned AS = Context.getTargetAddressSpace(RT->getPointeeType());
- EffectiveFieldSize = FieldSize = Context.toCharUnitsFromBits(
- Context.getTargetInfo().getPointerWidth(AS));
- FieldAlign = Context.toCharUnitsFromBits(
- Context.getTargetInfo().getPointerAlign(AS));
} else {
setDeclInfo(false /* IsIncompleteArrayType */);
// than the pointer size.
if (const MaxFieldAlignmentAttr *MFAA = RD->getAttr<MaxFieldAlignmentAttr>()){
unsigned PackedAlignment = MFAA->getAlignment();
- if (PackedAlignment <= Context.getTargetInfo().getPointerWidth(0))
+ if (PackedAlignment <=
+ Context.getTargetInfo().getPointerWidth(LangAS::Default))
MaxFieldAlignment = Context.toCharUnitsFromBits(PackedAlignment);
}
// Packed attribute forces max field alignment to be 1.
SharedVBPtrBase = nullptr;
// Calculate pointer size and alignment. These are used for vfptr and vbprt
// injection.
- PointerInfo.Size =
- Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
- PointerInfo.Alignment =
- Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0));
+ PointerInfo.Size = Context.toCharUnitsFromBits(
+ Context.getTargetInfo().getPointerWidth(LangAS::Default));
+ PointerInfo.Alignment = Context.toCharUnitsFromBits(
+ Context.getTargetInfo().getPointerAlign(LangAS::Default));
// Respect pragma pack.
if (!MaxFieldAlignment.isZero())
PointerInfo.Alignment = std::min(PointerInfo.Alignment, MaxFieldAlignment);
// Under the relative ABI, the offset widths are 32-bit ints instead of
// pointer widths.
CharUnits OffsetWidth = Context.toCharUnitsFromBits(
- VTables.isRelativeLayout() ? 32
- : Context.getTargetInfo().getPointerWidth(0));
+ VTables.isRelativeLayout()
+ ? 32
+ : Context.getTargetInfo().getPointerWidth(LangAS::Default));
CharUnits OffsetOffset = OffsetWidth * OffsetIndex;
return OffsetOffset;
WavefrontSize = GPUFeatures & llvm::AMDGPU::FEATURE_WAVE32 ? 32 : 64;
AllowAMDGPUUnsafeFPAtomics = Opts.AllowAMDGPUUnsafeFPAtomics;
- // Set pointer width and alignment for target address space 0.
- PointerWidth = PointerAlign = getPointerWidthV(Generic);
+ // Set pointer width and alignment for the generic address space.
+ PointerWidth = PointerAlign = getPointerWidthV(LangAS::Default);
if (getMaxPointerWidth() == 64) {
LongWidth = LongAlign = 64;
SizeType = UnsignedLong;
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override;
- uint64_t getPointerWidthV(unsigned AddrSpace) const override {
+ uint64_t getPointerWidthV(LangAS AS) const override {
if (isR600(getTriple()))
return 32;
+ unsigned TargetAS = getTargetAddressSpace(AS);
- if (AddrSpace == Private || AddrSpace == Local)
+ if (TargetAS == Private || TargetAS == Local)
return 32;
return 64;
}
- uint64_t getPointerAlignV(unsigned AddrSpace) const override {
+ uint64_t getPointerAlignV(LangAS AddrSpace) const override {
return getPointerWidthV(AddrSpace);
}
if (DisableMadd4)
Builder.defineMacro("__mips_no_madd4", Twine(1));
- Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
+ Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(LangAS::Default)));
Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
.Case("o32", 32)
.Case("n32", 64)
.Case("n64", 64)
- .Default(getPointerWidth(0));
+ .Default(getPointerWidth(LangAS::Default));
}
bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
}
// Copy properties from host target.
- PointerWidth = HostTarget->getPointerWidth(/* AddrSpace = */ 0);
- PointerAlign = HostTarget->getPointerAlign(/* AddrSpace = */ 0);
+ PointerWidth = HostTarget->getPointerWidth(LangAS::Default);
+ PointerAlign = HostTarget->getPointerAlign(LangAS::Default);
BoolWidth = HostTarget->getBoolWidth();
BoolAlign = HostTarget->getBoolAlign();
IntWidth = HostTarget->getIntWidth();
HostTarget->getDefaultAlignForAttributeAligned();
SizeType = HostTarget->getSizeType();
IntMaxType = HostTarget->getIntMaxType();
- PtrDiffType = HostTarget->getPtrDiffType(/* AddrSpace = */ 0);
+ PtrDiffType = HostTarget->getPtrDiffType(LangAS::Default);
IntPtrType = HostTarget->getIntPtrType();
WCharType = HostTarget->getWCharType();
WIntType = HostTarget->getWIntType();
void setSupportedOpenCLOpts() override { supportAllOpenCLOpts(); }
- uint64_t getPointerWidthV(unsigned AddrSpace) const override {
- if (AddrSpace == ptr32_sptr || AddrSpace == ptr32_uptr)
+ uint64_t getPointerWidthV(LangAS AS) const override {
+ unsigned TargetAddrSpace = getTargetAddressSpace(AS);
+ if (TargetAddrSpace == ptr32_sptr || TargetAddrSpace == ptr32_uptr)
return 32;
- if (AddrSpace == ptr64)
+ if (TargetAddrSpace == ptr64)
return 64;
return PointerWidth;
}
- uint64_t getPointerAlignV(unsigned AddrSpace) const override {
+ uint64_t getPointerAlignV(LangAS AddrSpace) const override {
return getPointerWidthV(AddrSpace);
}
if (CGM.getLangOpts().OpenCL) {
// The header is basically 'struct { int; int; generic void *;
// custom_fields; }'. Assert that struct is packed.
- auto GenericAS =
- CGM.getContext().getTargetAddressSpace(LangAS::opencl_generic);
- auto GenPtrAlign =
- CharUnits::fromQuantity(CGM.getTarget().getPointerAlign(GenericAS) / 8);
- auto GenPtrSize =
- CharUnits::fromQuantity(CGM.getTarget().getPointerWidth(GenericAS) / 8);
+ auto GenPtrAlign = CharUnits::fromQuantity(
+ CGM.getTarget().getPointerAlign(LangAS::opencl_generic) / 8);
+ auto GenPtrSize = CharUnits::fromQuantity(
+ CGM.getTarget().getPointerWidth(LangAS::opencl_generic) / 8);
assert(CGM.getIntSize() <= GenPtrSize);
assert(CGM.getIntAlign() <= GenPtrAlign);
assert((2 * CGM.getIntSize()).isMultipleOf(GenPtrAlign));
IsOpenCL ? CGM.getOpenCLRuntime().getGenericVoidPointerType() : VoidPtrTy;
LangAS GenVoidPtrAddr = IsOpenCL ? LangAS::opencl_generic : LangAS::Default;
auto GenVoidPtrSize = CharUnits::fromQuantity(
- CGM.getTarget().getPointerWidth(
- CGM.getContext().getTargetAddressSpace(GenVoidPtrAddr)) /
- 8);
+ CGM.getTarget().getPointerWidth(GenVoidPtrAddr) / 8);
// Using the computed layout, generate the actual block function.
bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
CodeGenFunction BlockCGF{CGM, true};
if (Arg->getType()->isIntegerType() &&
getContext().getTypeSize(Arg->getType()) <
- getContext().getTargetInfo().getPointerWidth(0) &&
+ getContext().getTargetInfo().getPointerWidth(LangAS::Default) &&
Arg->isNullPointerConstant(getContext(),
Expr::NPC_ValueDependentIsNotNull)) {
return getContext().getIntPtrType();
QualType PointeeTy,
llvm::DIFile *Unit) {
// Bit size, align and offset of the type.
- // Size is always the size of a pointer. We can't use getTypeSize here
- // because that does not return the correct value for references.
- unsigned AddressSpace = CGM.getContext().getTargetAddressSpace(PointeeTy);
- uint64_t Size = CGM.getTarget().getPointerWidth(AddressSpace);
+ // Size is always the size of a pointer.
+ uint64_t Size = CGM.getContext().getTypeSize(Ty);
auto Align = getTypeAlignIfRequired(Ty, CGM.getContext());
- Optional<unsigned> DWARFAddressSpace =
- CGM.getTarget().getDWARFAddressSpace(AddressSpace);
+ Optional<unsigned> DWARFAddressSpace = CGM.getTarget().getDWARFAddressSpace(
+ CGM.getContext().getTargetAddressSpace(PointeeTy));
SmallVector<llvm::Metadata *, 4> Annots;
auto *BTFAttrTy = dyn_cast<BTFTagAttributedType>(PointeeTy);
if (isa<ClassTemplateSpecializationDecl>(RD)) {
// Create pointer type directly in this case.
const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
- QualType PointeeTy = ThisPtrTy->getPointeeType();
- unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy);
- uint64_t Size = CGM.getTarget().getPointerWidth(AS);
+ uint64_t Size = CGM.getContext().getTypeSize(ThisPtrTy);
auto Align = getTypeAlignIfRequired(ThisPtrTy, CGM.getContext());
- llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit);
+ llvm::DIType *PointeeType =
+ getOrCreateType(ThisPtrTy->getPointeeType(), Unit);
llvm::DIType *ThisPtrType =
DBuilder.createPointerType(PointeeType, Size, Align);
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
CharUnits Align = CGM.getContext().getDeclAlign(VD);
if (Align > CGM.getContext().toCharUnitsFromBits(
- CGM.getTarget().getPointerAlign(0))) {
+ CGM.getTarget().getPointerAlign(LangAS::Default))) {
CharUnits FieldOffsetInBytes =
CGM.getContext().toCharUnitsFromBits(FieldOffset);
CharUnits AlignedOffsetInBytes = FieldOffsetInBytes.alignTo(Align);
Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
// offset of __forwarding field
offset = CGM.getContext().toCharUnitsFromBits(
- CGM.getTarget().getPointerWidth(0));
+ CGM.getTarget().getPointerWidth(LangAS::Default));
Expr.push_back(offset.getQuantity());
Expr.push_back(llvm::dwarf::DW_OP_deref);
Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
// Reference values are always non-null and have the width of a pointer.
if (Field->getType()->isReferenceType())
NumNonZeroBytes += CGF.getContext().toCharUnitsFromBits(
- CGF.getTarget().getPointerWidth(0));
+ CGF.getTarget().getPointerWidth(LangAS::Default));
else
NumNonZeroBytes += GetNumNonZeroBytesInInit(E, CGF);
}
auto LiteralLength = SL->getLength();
- if ((CGM.getTarget().getPointerWidth(0) == 64) &&
+ if ((CGM.getTarget().getPointerWidth(LangAS::Default) == 64) &&
(LiteralLength < 9) && !isNonASCII) {
// Tiny strings are only used on 64-bit platforms. They store 8 7-bit
// ASCII characters in the high 56 bits, followed by a 4-bit length and a
Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), type);
if (GCAttr == Qualifiers::Strong) {
- assert(CGM.getContext().getTypeSize(type)
- == CGM.getTarget().getPointerWidth(0));
+ assert(CGM.getContext().getTypeSize(type) ==
+ CGM.getTarget().getPointerWidth(LangAS::Default));
IvarsInfo.push_back(IvarInfo(fieldOffset, /*size in words*/ 1));
}
}
llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy);
if (RunSkipBlockVars.empty())
return nullPtr;
- unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(0);
+ unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default);
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;
RunSkipBlockVars.clear();
bool hasUnion = false;
- unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(0);
+ unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default);
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;
if (!getCodeGenOpts().LTOUnit)
return;
- CharUnits PointerWidth =
- Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
+ CharUnits PointerWidth = Context.toCharUnitsFromBits(
+ Context.getTargetInfo().getPointerWidth(LangAS::Default));
typedef std::pair<const CXXRecordDecl *, unsigned> AddressPoint;
std::vector<AddressPoint> AddressPoints;
BFloatTy = llvm::Type::getBFloatTy(LLVMContext);
FloatTy = llvm::Type::getFloatTy(LLVMContext);
DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
- PointerWidthInBits = C.getTargetInfo().getPointerWidth(0);
+ PointerWidthInBits = C.getTargetInfo().getPointerWidth(LangAS::Default);
PointerAlignInBytes =
- C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(0)).getQuantity();
+ C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(LangAS::Default))
+ .getQuantity();
SizeSizeInBytes =
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
IntAlignInBytes =
} else {
const ASTContext &Context = getContext();
CharUnits PointerWidth = Context.toCharUnitsFromBits(
- Context.getTargetInfo().getPointerWidth(0));
+ Context.getTargetInfo().getPointerWidth(LangAS::Default));
VTableOffset = Index * PointerWidth.getQuantity();
}
// values are read.
unsigned PAlign = CGM.getItaniumVTableContext().isRelativeLayout()
? 32
- : CGM.getTarget().getPointerAlign(0);
+ : CGM.getTarget().getPointerAlign(LangAS::Default);
VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
Name, VTableType, llvm::GlobalValue::ExternalLinkage,
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
VFunc = CGF.EmitVTableTypeCheckedLoad(
MethodDecl->getParent(), VTable, TyPtr,
- VTableIndex * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
+ VTableIndex *
+ CGM.getContext().getTargetInfo().getPointerWidth(LangAS::Default) /
+ 8);
} else {
CGF.EmitTypeMetadataCodeForVCall(MethodDecl->getParent(), VTable, Loc);
if (CGM.supportsCOMDAT() && GV->isWeakForLinker())
GV->setComdat(M.getOrInsertComdat(GV->getName()));
- CharUnits Align =
- CGM.getContext().toCharUnitsFromBits(CGM.getTarget().getPointerAlign(0));
+ CharUnits Align = CGM.getContext().toCharUnitsFromBits(
+ CGM.getTarget().getPointerAlign(LangAS::Default));
GV->setAlignment(Align.getAsAlign());
// The Itanium ABI specifies that type_info objects must be globally
// LLP64 platforms.
QualType OffsetFlagsTy = CGM.getContext().LongTy;
const TargetInfo &TI = CGM.getContext().getTargetInfo();
- if (TI.getTriple().isOSCygMing() && TI.getPointerWidth(0) > TI.getLongWidth())
+ if (TI.getTriple().isOSCygMing() &&
+ TI.getPointerWidth(LangAS::Default) > TI.getLongWidth())
OffsetFlagsTy = CGM.getContext().LongLongTy;
llvm::Type *OffsetFlagsLTy =
CGM.getTypes().ConvertType(OffsetFlagsTy);
friend struct MSRTTIBuilder;
bool isImageRelative() const {
- return CGM.getTarget().getPointerWidth(/*AddrSpace=*/0) == 64;
+ return CGM.getTarget().getPointerWidth(LangAS::Default) == 64;
}
// 5 routines for constructing the llvm types for MS RTTI structs.
CharUnits AddressPoint =
getContext().getLangOpts().RTTIData
? getContext().toCharUnitsFromBits(
- getContext().getTargetInfo().getPointerWidth(0))
+ getContext().getTargetInfo().getPointerWidth(LangAS::Default))
: CharUnits::Zero();
if (Info.PathToIntroducingObject.empty()) {
if (CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
VFunc = CGF.EmitVTableTypeCheckedLoad(
getObjectWithVPtr(), VTable, Ty,
- ML.Index * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
+ ML.Index *
+ CGM.getContext().getTargetInfo().getPointerWidth(LangAS::Default) /
+ 8);
} else {
if (CGM.getCodeGenOpts().PrepareForLTO)
CGF.EmitTypeMetadataCodeForVCall(getObjectWithVPtr(), VTable, Loc);
}
if (Ty->isPtrOrPtrVectorTy()) {
auto *PtrTy = cast<llvm::PointerType>(Ty->getScalarType());
- unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
- PtrTy->getAddressSpace());
+ unsigned PtrWidth =
+ CGM.getDataLayout().getPointerSizeInBits(PtrTy->getAddressSpace());
if (PtrWidth > 64)
llvm_unreachable("pattern initialization of unsupported pointer width");
llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
CharUnits swiftcall::getMaximumVoluntaryIntegerSize(CodeGenModule &CGM) {
// Currently always the size of an ordinary pointer.
return CGM.getContext().toCharUnitsFromBits(
- CGM.getContext().getTargetInfo().getPointerWidth(0));
+ CGM.getContext().getTargetInfo().getPointerWidth(LangAS::Default));
}
CharUnits swiftcall::getNaturalAlignment(CodeGenModule &CGM, llvm::Type *type) {
if (type->isPointerTy()) {
intCount++;
} else if (auto intTy = dyn_cast<llvm::IntegerType>(type)) {
- auto ptrWidth = cgt.getTarget().getPointerWidth(0);
+ auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
} else {
assert(type->isVectorTy() || type->isFloatingPointTy());
Alignment = getContext().getTypeUnadjustedAlign(Ty);
Alignment = Alignment < 128 ? 64 : 128;
} else {
- Alignment = std::max(getContext().getTypeAlign(Ty),
- (unsigned)getTarget().getPointerWidth(0));
+ Alignment =
+ std::max(getContext().getTypeAlign(Ty),
+ (unsigned)getTarget().getPointerWidth(LangAS::Default));
}
Size = llvm::alignTo(Size, Alignment);
if (!isAggregateTypeForABI(Ty) && !isIllegalVectorType(Ty))
return EmitVAArgInstr(CGF, VAListAddr, Ty, ABIArgInfo::getDirect());
- uint64_t PointerSize = getTarget().getPointerWidth(0) / 8;
+ uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8;
CharUnits SlotSize = CharUnits::fromQuantity(PointerSize);
// Empty records are ignored for parameter passing purposes.
// Integer arguments are promoted to 32-bit on O32 and 64-bit on N32/N64.
// Pointers are also promoted in the same way but this only matters for N32.
unsigned SlotSizeInBits = IsO32 ? 32 : 64;
- unsigned PtrWidth = getTarget().getPointerWidth(0);
+ unsigned PtrWidth = getTarget().getPointerWidth(LangAS::Default);
bool DidPromote = false;
if ((Ty->isIntegerType() &&
getContext().getIntWidth(Ty) < SlotSizeInBits) ||
case llvm::Triple::riscv32:
case llvm::Triple::riscv64: {
StringRef ABIStr = getTarget().getABI();
- unsigned XLen = getTarget().getPointerWidth(0);
+ unsigned XLen = getTarget().getPointerWidth(LangAS::Default);
unsigned ABIFLen = 0;
if (ABIStr.endswith("f"))
ABIFLen = 32;
else if (ABIStr.endswith("d"))
ABIFRLen = 64;
return SetCGInfo(new LoongArchTargetCodeGenInfo(
- Types, getTarget().getPointerWidth(0), ABIFRLen));
+ Types, getTarget().getPointerWidth(LangAS::Default), ABIFRLen));
}
}
}
Builder.defineMacro("__LITTLE_ENDIAN__");
}
- if (TI.getPointerWidth(0) == 64 && TI.getLongWidth() == 64
- && TI.getIntWidth() == 32) {
+ if (TI.getPointerWidth(LangAS::Default) == 64 && TI.getLongWidth() == 64 &&
+ TI.getIntWidth() == 32) {
Builder.defineMacro("_LP64");
Builder.defineMacro("__LP64__");
}
- if (TI.getPointerWidth(0) == 32 && TI.getLongWidth() == 32
- && TI.getIntWidth() == 32) {
+ if (TI.getPointerWidth(LangAS::Default) == 32 && TI.getLongWidth() == 32 &&
+ TI.getIntWidth() == 32) {
Builder.defineMacro("_ILP32");
Builder.defineMacro("__ILP32__");
}
DefineTypeSizeAndWidth("__SIZE", TI.getSizeType(), TI, Builder);
DefineTypeSizeAndWidth("__UINTMAX", TI.getUIntMaxType(), TI, Builder);
- DefineTypeSizeAndWidth("__PTRDIFF", TI.getPtrDiffType(0), TI, Builder);
+ DefineTypeSizeAndWidth("__PTRDIFF", TI.getPtrDiffType(LangAS::Default), TI,
+ Builder);
DefineTypeSizeAndWidth("__INTPTR", TI.getIntPtrType(), TI, Builder);
DefineTypeSizeAndWidth("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
DefineTypeSizeof("__SIZEOF_LONG__", TI.getLongWidth(), TI, Builder);
DefineTypeSizeof("__SIZEOF_LONG_DOUBLE__",TI.getLongDoubleWidth(),TI,Builder);
DefineTypeSizeof("__SIZEOF_LONG_LONG__", TI.getLongLongWidth(), TI, Builder);
- DefineTypeSizeof("__SIZEOF_POINTER__", TI.getPointerWidth(0), TI, Builder);
+ DefineTypeSizeof("__SIZEOF_POINTER__", TI.getPointerWidth(LangAS::Default),
+ TI, Builder);
DefineTypeSizeof("__SIZEOF_SHORT__", TI.getShortWidth(), TI, Builder);
DefineTypeSizeof("__SIZEOF_PTRDIFF_T__",
- TI.getTypeWidth(TI.getPtrDiffType(0)), TI, Builder);
+ TI.getTypeWidth(TI.getPtrDiffType(LangAS::Default)), TI,
+ Builder);
DefineTypeSizeof("__SIZEOF_SIZE_T__",
TI.getTypeWidth(TI.getSizeType()), TI, Builder);
DefineTypeSizeof("__SIZEOF_WCHAR_T__",
DefineFmt("__UINTMAX", TI.getUIntMaxType(), TI, Builder);
Builder.defineMacro("__UINTMAX_C_SUFFIX__",
TI.getTypeConstantSuffix(TI.getUIntMaxType()));
- DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(0), Builder);
- DefineFmt("__PTRDIFF", TI.getPtrDiffType(0), TI, Builder);
+ DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(LangAS::Default), Builder);
+ DefineFmt("__PTRDIFF", TI.getPtrDiffType(LangAS::Default), TI, Builder);
DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Builder);
DefineFmt("__INTPTR", TI.getIntPtrType(), TI, Builder);
DefineType("__SIZE_TYPE__", TI.getSizeType(), Builder);
// Define a __POINTER_WIDTH__ macro for stdint.h.
Builder.defineMacro("__POINTER_WIDTH__",
- Twine((int)TI.getPointerWidth(0)));
+ Twine((int)TI.getPointerWidth(LangAS::Default)));
// Define __BIGGEST_ALIGNMENT__ to be compatible with gcc.
Builder.defineMacro("__BIGGEST_ALIGNMENT__",
DEFINE_LOCK_FREE_MACRO(INT, Int);
DEFINE_LOCK_FREE_MACRO(LONG, Long);
DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
- Builder.defineMacro(Prefix + "POINTER_LOCK_FREE",
- getLockFreeValue(TI.getPointerWidth(0), TI));
+ Builder.defineMacro(
+ Prefix + "POINTER_LOCK_FREE",
+ getLockFreeValue(TI.getPointerWidth(LangAS::Default), TI));
#undef DEFINE_LOCK_FREE_MACRO
};
addLockFreeMacros("__CLANG_ATOMIC_");
return;
if (index.isUnsigned() || !index.isNegative()) {
const auto &ASTC = getASTContext();
- unsigned AddrBits =
- ASTC.getTargetInfo().getPointerWidth(ASTC.getTargetAddressSpace(
- EffectiveType->getCanonicalTypeInternal()));
+ unsigned AddrBits = ASTC.getTargetInfo().getPointerWidth(
+ EffectiveType->getCanonicalTypeInternal().getAddressSpace());
if (index.getBitWidth() < AddrBits)
index = index.zext(AddrBits);
Optional<CharUnits> ElemCharUnits =
break;
case 7:
if (Str == "pointer")
- DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
+ DestWidth = S.Context.getTargetInfo().getPointerWidth(LangAS::Default);
break;
case 11:
if (Str == "unwind_word")
// The type of __null will be int or long, depending on the size of
// pointers on the target.
QualType Ty;
- unsigned pw = Context.getTargetInfo().getPointerWidth(0);
+ unsigned pw = Context.getTargetInfo().getPointerWidth(LangAS::Default);
if (pw == Context.getTargetInfo().getIntWidth())
Ty = Context.IntTy;
else if (pw == Context.getTargetInfo().getLongWidth())
// tree? Or should the consumer just recalculate the value?
// FIXME: Using a dummy value will interact poorly with attribute enable_if.
IntegerLiteral Size(
- Context, llvm::APInt::getZero(Context.getTargetInfo().getPointerWidth(0)),
+ Context,
+ llvm::APInt::getZero(
+ Context.getTargetInfo().getPointerWidth(LangAS::Default)),
Context.getSizeType(), SourceLocation());
AllocArgs.push_back(&Size);
// Add address space to type based on its attributes.
LangAS ASIdx = LangAS::Default;
- uint64_t PtrWidth = S.Context.getTargetInfo().getPointerWidth(0);
+ uint64_t PtrWidth =
+ S.Context.getTargetInfo().getPointerWidth(LangAS::Default);
if (PtrWidth == 32) {
if (Attrs[attr::Ptr64])
ASIdx = LangAS::ptr64;
public:
WalkAST(BugReporter &br, const CheckerBase *checker, AnalysisDeclContext *ac)
: BR(br), Checker(checker), AC(ac), ASTC(AC->getASTContext()),
- PtrWidth(ASTC.getTargetInfo().getPointerWidth(0)) {}
+ PtrWidth(ASTC.getTargetInfo().getPointerWidth(LangAS::Default)) {}
// Statement visitor methods.
void VisitChildren(Stmt *S);
std::make_shared<clang::TargetOptions>(compiler.getTargetOpts())));
const clang::TargetInfo &TInfo = compiler.getTarget();
- PtrSize = TInfo.getPointerWidth(0) / 8;
+ PtrSize = TInfo.getPointerWidth(clang::LangAS::Default) / 8;
compiler.createFileManager();
compiler.createSourceManager(compiler.getFileManager());