[cfe-commits] r48050 - in /cfe/trunk: AST/ASTContext.cpp CodeGen/CodeGenModule.cpp include/clang/Basic/TargetInfo.h
Chris Lattner
sabre at nondot.org
Sat Mar 8 00:34:58 PST 2008
Author: lattner
Date: Sat Mar 8 02:34:58 2008
New Revision: 48050
URL: http://llvm.org/viewvc/llvm-project?rev=48050&view=rev
Log:
Fix a fixme by allowing pointers in different address spaces to have
different widths. Start simplifying TargetInfo accessor methods.
Modified:
cfe/trunk/AST/ASTContext.cpp
cfe/trunk/CodeGen/CodeGenModule.cpp
cfe/trunk/include/clang/Basic/TargetInfo.h
Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=48050&r1=48049&r2=48050&view=diff
==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Sat Mar 8 02:34:58 2008
@@ -260,9 +260,15 @@
// 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.
Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=48050&r1=48049&r2=48050&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Sat Mar 8 02:34:58 2008
@@ -339,9 +339,7 @@
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::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;
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=48050&r1=48049&r2=48050&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Sat Mar 8 02:34:58 2008
@@ -64,12 +64,10 @@
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 @@
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 @@
}
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);
More information about the cfe-commits
mailing list