[PATCH] Re-add DataLayout convenience functions for getting pointer size
Eli Friedman
eli.friedman at gmail.com
Thu Jul 25 15:54:59 PDT 2013
LGTM.
-Eli
On Thu, Jul 25, 2013 at 3:42 PM, Matt Arsenault
<Matthew.Arsenault at amd.com> wrote:
> Remove version that takes a Value*
>
> http://llvm-reviews.chandlerc.com/D1197
>
> CHANGE SINCE LAST DIFF
> http://llvm-reviews.chandlerc.com/D1197?vs=2964&id=3010#toc
>
> Files:
> include/llvm/IR/DataLayout.h
> lib/IR/DataLayout.cpp
>
> Index: include/llvm/IR/DataLayout.h
> ===================================================================
> --- include/llvm/IR/DataLayout.h
> +++ include/llvm/IR/DataLayout.h
> @@ -271,6 +271,18 @@
> 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[*]
> Index: lib/IR/DataLayout.cpp
> ===================================================================
> --- lib/IR/DataLayout.cpp
> +++ lib/IR/DataLayout.cpp
> @@ -507,6 +507,16 @@
> 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