[llvm-commits] [llvm] r42488 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp

Dale Johannesen dalej at apple.com
Mon Oct 1 09:03:14 PDT 2007


Author: johannes
Date: Mon Oct  1 11:03:14 2007
New Revision: 42488

URL: http://llvm.org/viewvc/llvm-project?rev=42488&view=rev
Log:
Add getABITypeSize, getABITypeSizeInBits

Modified:
    llvm/trunk/include/llvm/Target/TargetData.h
    llvm/trunk/lib/Target/TargetData.cpp

Modified: llvm/trunk/include/llvm/Target/TargetData.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=42488&r1=42487&r2=42488&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetData.h (original)
+++ llvm/trunk/include/llvm/Target/TargetData.h Mon Oct  1 11:03:14 2007
@@ -159,10 +159,23 @@
   /// type.
   uint64_t getTypeSize(const Type *Ty) const;
 
+  /// getABITypeSize - Return the number of bytes allocated for the specified
+  /// type when used as an element in a larger object, including alignment
+  /// padding.
+  uint64_t getABITypeSize(const Type *Ty) const {
+    unsigned char Align = getABITypeAlignment(Ty);
+    return (getTypeSize(Ty) + Align - 1)/Align*Align;
+  }
+
   /// getTypeSizeInBits - Return the number of bits necessary to hold the
   /// specified type.
   uint64_t getTypeSizeInBits(const Type* Ty) const;
 
+  /// getABITypeSizeInBits - Return the number of bytes allocated for the
+  /// specified type when used as an element in a larger object, including
+  ///  alignment padding.
+  uint64_t getABITypeSizeInBits(const Type* Ty) const;
+
   /// getABITypeAlignment - Return the minimum ABI-required alignment for the
   /// specified type.
   unsigned char getABITypeAlignment(const Type *Ty) const;

Modified: llvm/trunk/lib/Target/TargetData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=42488&r1=42487&r2=42488&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetData.cpp (original)
+++ llvm/trunk/lib/Target/TargetData.cpp Mon Oct  1 11:03:14 2007
@@ -471,7 +471,12 @@
     return getTypeSize(Ty) * 8;
 }
 
-
+uint64_t TargetData::getABITypeSizeInBits(const Type *Ty) const {
+  if (Ty->isInteger())
+    return cast<IntegerType>(Ty)->getBitWidth();
+  else
+    return getABITypeSize(Ty) * 8;
+}
 /*!
   \param abi_or_pref Flag that determines which alignment is returned. true
   returns the ABI alignment, false returns the preferred alignment.





More information about the llvm-commits mailing list