summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-24 13:41:11 +0000
committerChris Lattner <sabre@nondot.org>2012-01-24 13:41:11 +0000
commit00245f420a2110ada859d19bf20a8b4e6ec2fe23 (patch)
treedfadd4feee650233b54512fccf15b4c0e13902ce /llvm/lib/VMCore/Constants.cpp
parent33a7e2f2a1910e4f2d0309bcb84218364e585cca (diff)
downloadbcm5719-llvm-00245f420a2110ada859d19bf20a8b4e6ec2fe23.tar.gz
bcm5719-llvm-00245f420a2110ada859d19bf20a8b4e6ec2fe23.zip
add more support for ConstantDataSequential
llvm-svn: 148802
Diffstat (limited to 'llvm/lib/VMCore/Constants.cpp')
-rw-r--r--llvm/lib/VMCore/Constants.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 9f1abbd17bb..d329c67af0e 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -1995,8 +1995,7 @@ Type *ConstantDataSequential::getElementType() const {
}
StringRef ConstantDataSequential::getRawDataValues() const {
- return StringRef(DataElements,
- getType()->getNumElements()*getElementByteSize());
+ return StringRef(DataElements, getNumElements()*getElementByteSize());
}
/// isElementTypeCompatible - Return true if a ConstantDataSequential can be
@@ -2018,6 +2017,12 @@ bool ConstantDataSequential::isElementTypeCompatible(const Type *Ty) {
return false;
}
+/// getNumElements - Return the number of elements in the array or vector.
+unsigned ConstantDataSequential::getNumElements() const {
+ return getType()->getNumElements();
+}
+
+
/// getElementByteSize - Return the size in bytes of the elements in the data.
uint64_t ConstantDataSequential::getElementByteSize() const {
return getElementType()->getPrimitiveSizeInBits()/8;
@@ -2025,7 +2030,7 @@ uint64_t ConstantDataSequential::getElementByteSize() const {
/// getElementPointer - Return the start of the specified element.
const char *ConstantDataSequential::getElementPointer(unsigned Elt) const {
- assert(Elt < getElementType()->getNumElements() && "Invalid Elt");
+ assert(Elt < getNumElements() && "Invalid Elt");
return DataElements+Elt*getElementByteSize();
}
OpenPOWER on IntegriCloud