aboutsummaryrefslogtreecommitdiff
path: root/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
commit7c2924367087caa738d1c6349d04a4645c6c26fa (patch)
treee7c67d85b52ad48bb425e59bc1eb985452feba48 /lib/Target/TargetData.cpp
parent2c1ce4f28ec3b9d09b20b7cba83acf65756bd615 (diff)
Implement a getTypeSizeInBits method. This helps in transforms that want
to ensure the bit size of a type is identical before proceeding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33413 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r--lib/Target/TargetData.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 3cfdd40ddd..f50e6c3bd3 100644
--- a/lib/Target/TargetData.cpp
+++ b/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;