summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetData.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-20 23:32:04 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-20 23:32:04 +0000
commit2239163496f18d07301cfa738c2f76459ae695de (patch)
treea9759676ce8c4dba907334ca55b7544da007056d /llvm/lib/Target/TargetData.cpp
parentba66c520371d456ea5abe54b6805247816150e39 (diff)
downloadbcm5719-llvm-2239163496f18d07301cfa738c2f76459ae695de.tar.gz
bcm5719-llvm-2239163496f18d07301cfa738c2f76459ae695de.zip
Implement a getTypeSizeInBits method. This helps in transforms that want
to ensure the bit size of a type is identical before proceeding. llvm-svn: 33413
Diffstat (limited to 'llvm/lib/Target/TargetData.cpp')
-rw-r--r--llvm/lib/Target/TargetData.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp
index 3cfdd40ddd4..f50e6c3bd39 100644
--- a/llvm/lib/Target/TargetData.cpp
+++ b/llvm/lib/Target/TargetData.cpp
@@ -426,6 +426,16 @@ uint64_t TargetData::getTypeSize(const Type *Ty) const {
return Size;
}
+uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const {
+ if (Ty->isInteger())
+ return cast<IntegerType>(Ty)->getBitWidth();
+
+ uint64_t Size;
+ unsigned char Align;
+ getTypeInfoABI(Ty, this, Size, Align);
+ return Size * 8;
+}
+
unsigned char TargetData::getTypeAlignmentABI(const Type *Ty) const {
uint64_t Size;
unsigned char Align;
OpenPOWER on IntegriCloud