aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
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
commit1ee0ecf84a07693c3a517ba030fac8ac1f9f3fbc (patch)
treece6fb6a15a49539b812ba49d0aec84154fbe1aae /lib/VMCore
parent53fa1ae51008d22ce5d2aa6fbf22c1afc4ec1401 (diff)
downloadexternal_llvm-1ee0ecf84a07693c3a517ba030fac8ac1f9f3fbc.zip
external_llvm-1ee0ecf84a07693c3a517ba030fac8ac1f9f3fbc.tar.gz
external_llvm-1ee0ecf84a07693c3a517ba030fac8ac1f9f3fbc.tar.bz2
add more support for ConstantDataSequential
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Constants.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 9f1abbd..d329c67 100644
--- a/lib/VMCore/Constants.cpp
+++ b/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();
}