[llvm] r187223 - Re-add DataLayout pointer size convenience functions.
Matt Arsenault
Matthew.Arsenault at amd.com
Fri Jul 26 10:37:20 PDT 2013
Author: arsenm
Date: Fri Jul 26 12:37:20 2013
New Revision: 187223
URL: http://llvm.org/viewvc/llvm-project?rev=187223&view=rev
Log:
Re-add DataLayout pointer size convenience functions.
These were reverted in r167222 along with the rest
of the last different address space pointer size attempt.
These will be used in later commits.
Modified:
llvm/trunk/include/llvm/IR/DataLayout.h
llvm/trunk/lib/IR/DataLayout.cpp
Modified: llvm/trunk/include/llvm/IR/DataLayout.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DataLayout.h?rev=187223&r1=187222&r2=187223&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DataLayout.h (original)
+++ llvm/trunk/include/llvm/IR/DataLayout.h Fri Jul 26 12:37:20 2013
@@ -271,6 +271,18 @@ public:
unsigned getPointerSizeInBits(unsigned AS = 0) const {
return getPointerSize(AS) * 8;
}
+
+ /// Layout pointer size, in bits, based on the type. If this function is
+ /// called with a pointer type, then the type size of the pointer is returned.
+ /// If this function is called with a vector of pointers, then the type size
+ /// of the pointer is returned. This should only be called with a pointer or
+ /// vector of pointers.
+ unsigned getPointerTypeSizeInBits(Type *) const;
+
+ unsigned getPointerTypeSize(Type *Ty) const {
+ return getPointerTypeSizeInBits(Ty) / 8;
+ }
+
/// Size examples:
///
/// Type SizeInBits StoreSizeInBits AllocSizeInBits[*]
Modified: llvm/trunk/lib/IR/DataLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DataLayout.cpp?rev=187223&r1=187222&r2=187223&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DataLayout.cpp (original)
+++ llvm/trunk/lib/IR/DataLayout.cpp Fri Jul 26 12:37:20 2013
@@ -507,6 +507,16 @@ std::string DataLayout::getStringReprese
return OS.str();
}
+unsigned DataLayout::getPointerTypeSizeInBits(Type *Ty) const {
+ assert(Ty->isPtrOrPtrVectorTy() &&
+ "This should only be called with a pointer or pointer vector type");
+
+ if (Ty->isPointerTy())
+ return getTypeSizeInBits(Ty);
+
+ Type *EleTy = cast<VectorType>(Ty)->getElementType();
+ return getTypeSizeInBits(EleTy);
+}
/*!
\param abi_or_pref Flag that determines which alignment is returned. true
More information about the llvm-commits
mailing list