forked from OSchip/llvm-project
Fix a fixme by allowing pointers in different address spaces to have
different widths. Start simplifying TargetInfo accessor methods. llvm-svn: 48050
This commit is contained in:
parent
c3a669ba63
commit
2dca6ff505
|
@ -260,9 +260,15 @@ ASTContext::getTypeInfo(QualType T) {
|
|||
// alignment requirements: getPointerInfo should take an AddrSpace.
|
||||
return getTypeInfo(QualType(cast<ASQualType>(T)->getBaseType(), 0));
|
||||
case Type::ObjCQualifiedId:
|
||||
case Type::Pointer:
|
||||
Target.getPointerInfo(Size, Align);
|
||||
Size = Target.getPointerWidth(0);
|
||||
Align = Target.getPointerAlign(0);
|
||||
break;
|
||||
case Type::Pointer: {
|
||||
unsigned AS = cast<PointerType>(T)->getPointeeType().getAddressSpace();
|
||||
Size = Target.getPointerWidth(AS);
|
||||
Align = Target.getPointerAlign(AS);
|
||||
break;
|
||||
}
|
||||
case Type::Reference:
|
||||
// "When applied to a reference or a reference type, the result is the size
|
||||
// of the referenced type." C++98 5.3.3p2: expr.sizeof.
|
||||
|
|
|
@ -339,9 +339,7 @@ llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,const llvm::Type **Tys,
|
|||
llvm::Function *CodeGenModule::getMemCpyFn() {
|
||||
if (MemCpyFn) return MemCpyFn;
|
||||
llvm::Intrinsic::ID IID;
|
||||
uint64_t Size; unsigned Align;
|
||||
Context.Target.getPointerInfo(Size, Align);
|
||||
switch (Size) {
|
||||
switch (Context.Target.getPointerWidth(0)) {
|
||||
default: assert(0 && "Unknown ptr width");
|
||||
case 32: IID = llvm::Intrinsic::memcpy_i32; break;
|
||||
case 64: IID = llvm::Intrinsic::memcpy_i64; break;
|
||||
|
@ -352,9 +350,7 @@ llvm::Function *CodeGenModule::getMemCpyFn() {
|
|||
llvm::Function *CodeGenModule::getMemSetFn() {
|
||||
if (MemSetFn) return MemSetFn;
|
||||
llvm::Intrinsic::ID IID;
|
||||
uint64_t Size; unsigned Align;
|
||||
Context.Target.getPointerInfo(Size, Align);
|
||||
switch (Size) {
|
||||
switch (Context.Target.getPointerWidth(0)) {
|
||||
default: assert(0 && "Unknown ptr width");
|
||||
case 32: IID = llvm::Intrinsic::memset_i32; break;
|
||||
case 64: IID = llvm::Intrinsic::memset_i64; break;
|
||||
|
|
|
@ -64,12 +64,10 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
/// getPointerWidth - Return the width of pointers on this target, we
|
||||
/// currently assume one pointer type.
|
||||
void getPointerInfo(uint64_t &Size, unsigned &Align) const {
|
||||
Size = 32; // FIXME: implement correctly.
|
||||
Align = 32;
|
||||
}
|
||||
/// getPointerWidth - Return the width of pointers on this target, for the
|
||||
/// specified address space. FIXME: implement correctly.
|
||||
uint64_t getPointerWidth(unsigned AddrSpace) const { return 32; }
|
||||
uint64_t getPointerAlign(unsigned AddrSpace) const { return 32; }
|
||||
|
||||
/// getBoolInfo - Return the size of '_Bool' and C++ 'bool' for this target,
|
||||
/// in bits.
|
||||
|
@ -119,13 +117,9 @@ public:
|
|||
void getLongDoubleInfo(uint64_t &Size, unsigned &Align,
|
||||
const llvm::fltSemantics *&Format) const;
|
||||
|
||||
/// getWCharInfo - Return the size of wchar_t in bits.
|
||||
///
|
||||
void getWCharInfo(uint64_t &Size, unsigned &Align) const {
|
||||
Size = WCharWidth;
|
||||
Align = WCharAlign;
|
||||
}
|
||||
|
||||
unsigned getWCharWidth() const { return WCharWidth; }
|
||||
unsigned getWCharAlign() const { return WCharAlign; }
|
||||
|
||||
/// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
|
||||
/// target, in bits.
|
||||
unsigned getIntMaxTWidth() const {
|
||||
|
@ -182,20 +176,14 @@ public:
|
|||
}
|
||||
|
||||
unsigned getCharWidth(bool isWide = false) const {
|
||||
uint64_t Size; unsigned Align;
|
||||
if (isWide)
|
||||
getWCharInfo(Size, Align);
|
||||
else
|
||||
getCharInfo(Size, Align);
|
||||
return static_cast<unsigned>(Size);
|
||||
}
|
||||
|
||||
unsigned getWCharWidth() const {
|
||||
return WCharWidth;
|
||||
uint64_t Size; unsigned Align;
|
||||
getWCharInfo(Size, Align);
|
||||
getCharInfo(Size, Align);
|
||||
return static_cast<unsigned>(Size);
|
||||
}
|
||||
|
||||
|
||||
unsigned getIntWidth() const {
|
||||
uint64_t Size; unsigned Align;
|
||||
getIntInfo(Size, Align);
|
||||
|
|
Loading…
Reference in New Issue