aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-08 08:34:58 +0000
committerChris Lattner <sabre@nondot.org>2008-03-08 08:34:58 +0000
commitf72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643 (patch)
treeecf899a3aeac54a74ab8883787c126b69745573a
parent0eaed12e634dfd14f44620f63b8d3276fed028dd (diff)
Fix a fixme by allowing pointers in different address spaces to have
different widths. Start simplifying TargetInfo accessor methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48050 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/ASTContext.cpp10
-rw-r--r--CodeGen/CodeGenModule.cpp8
-rw-r--r--include/clang/Basic/TargetInfo.h32
3 files changed, 20 insertions, 30 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index b5b28bc390..5dd7d9aeeb 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -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.
diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp
index 554fc3fbeb..d2b6047525 100644
--- a/CodeGen/CodeGenModule.cpp
+++ b/CodeGen/CodeGenModule.cpp
@@ -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;
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index ec6030135a..4fb50bca91 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -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);