summaryrefslogtreecommitdiff
path: root/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-24 09:31:43 +0000
committerChris Lattner <sabre@nondot.org>2012-01-24 09:31:43 +0000
commit9e631da253bff90d9da5ace21bd73f1c838e72eb (patch)
treeee0015a94cee5cd31296621542ba8eaf3ff82481 /lib/VMCore/Constants.cpp
parent62339073127df4579905f551f61c132cf21d2aad (diff)
downloadllvm-9e631da253bff90d9da5ace21bd73f1c838e72eb.tar.gz
llvm-9e631da253bff90d9da5ace21bd73f1c838e72eb.tar.bz2
llvm-9e631da253bff90d9da5ace21bd73f1c838e72eb.tar.xz
Add AsmPrinter (aka MCLowering) support for ConstantDataSequential,
and clean up some other misc stuff. Unlike ConstantArray, we will prefer to emit .fill directives for "String" arrays that all have the same value, since they are denser than emitting a .ascii git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r--lib/VMCore/Constants.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 0525882828..9f1abbd17b 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -1994,6 +1994,11 @@ Type *ConstantDataSequential::getElementType() const {
return getType()->getElementType();
}
+StringRef ConstantDataSequential::getRawDataValues() const {
+ return StringRef(DataElements,
+ getType()->getNumElements()*getElementByteSize());
+}
+
/// isElementTypeCompatible - Return true if a ConstantDataSequential can be
/// formed with a vector or array of the specified element type.
/// ConstantDataArray only works with normal float and int types that are
@@ -2067,14 +2072,12 @@ Constant *ConstantDataSequential::getImpl(StringRef Elements, Type *Ty) {
}
void ConstantDataSequential::destroyConstant() {
- uint64_t ByteSize = getElementByteSize() * getElementType()->getNumElements();
-
// Remove the constant from the StringMap.
StringMap<ConstantDataSequential*> &CDSConstants =
getType()->getContext().pImpl->CDSConstants;
StringMap<ConstantDataSequential*>::iterator Slot =
- CDSConstants.find(StringRef(DataElements, ByteSize));
+ CDSConstants.find(getRawDataValues());
assert(Slot != CDSConstants.end() && "CDS not found in uniquing table");
@@ -2226,15 +2229,6 @@ bool ConstantDataSequential::isString() const {
return isa<ArrayType>(getType()) && getElementType()->isIntegerTy(8);
}
-/// getAsString - If this array is isString(), then this method returns the
-/// array as a StringRef. Otherwise, it asserts out.
-///
-StringRef ConstantDataSequential::getAsString() const {
- assert(isString() && "Not a string");
- return StringRef(DataElements, getType()->getNumElements());
-}
-
-
/// isCString - This method returns true if the array "isString", ends with a
/// nul byte, and does not contains any other nul bytes.
bool ConstantDataSequential::isCString() const {