aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-18 18:53:33 +0000
committerChris Lattner <sabre@nondot.org>2002-04-18 18:53:33 +0000
commit68d892dc0d503236099e43d39dda50556d394dbb (patch)
tree077c5ea415a0fa957d7a0f01aaee61220711d818 /lib
parent66e810be9f97fa744ca949d54b5d54358add84b8 (diff)
downloadexternal_llvm-68d892dc0d503236099e43d39dda50556d394dbb.zip
external_llvm-68d892dc0d503236099e43d39dda50556d394dbb.tar.gz
external_llvm-68d892dc0d503236099e43d39dda50556d394dbb.tar.bz2
Move asmwriter/getStrValue cruft into AsmWriter.cpp file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2300 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Constants.cpp128
1 files changed, 0 insertions, 128 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index b2335bc..52af0ee 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -142,134 +142,6 @@ ConstantPointerRef::ConstantPointerRef(GlobalValue *GV)
//===----------------------------------------------------------------------===//
-// getStrValue implementations
-
-std::string ConstantBool::getStrValue() const {
- return Val ? "true" : "false";
-}
-
-std::string ConstantSInt::getStrValue() const {
- return itostr(Val.Signed);
-}
-
-std::string ConstantUInt::getStrValue() const {
- return utostr(Val.Unsigned);
-}
-
-// ConstantFP::getStrValue - We would like to output the FP constant value in
-// exponential notation, but we cannot do this if doing so will lose precision.
-// Check here to make sure that we only output it in exponential format if we
-// can parse the value back and get the same value.
-//
-std::string ConstantFP::getStrValue() const {
- std::string StrVal = ftostr(Val);
-
- // Check to make sure that the stringized number is not some string like "Inf"
- // or NaN, that atof will accept, but the lexer will not. Check that the
- // string matches the "[-+]?[0-9]" regex.
- //
- if ((StrVal[0] >= '0' && StrVal[0] <= '9') ||
- ((StrVal[0] == '-' || StrVal[0] == '+') &&
- (StrVal[0] >= '0' && StrVal[0] <= '9'))) {
- double TestVal = atof(StrVal.c_str()); // Reparse stringized version!
- if (TestVal == Val)
- return StrVal;
- }
-
- // Otherwise we could not reparse it to exactly the same value, so we must
- // output the string in hexadecimal format!
- //
- // Behave nicely in the face of C TBAA rules... see:
- // http://www.nullstone.com/htmls/category/aliastyp.htm
- //
- char *Ptr = (char*)&Val;
- assert(sizeof(double) == sizeof(uint64_t) && sizeof(double) == 8 &&
- "assuming that double is 64 bits!");
- return "0x"+utohexstr(*(uint64_t*)Ptr);
-}
-
-std::string ConstantArray::getStrValue() const {
- std::string Result;
-
- // As a special case, print the array as a string if it is an array of
- // ubytes or an array of sbytes with positive values.
- //
- const Type *ETy = getType()->getElementType();
- bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy);
-
- if (ETy == Type::SByteTy) {
- for (unsigned i = 0; i < Operands.size(); ++i)
- if (ETy == Type::SByteTy &&
- cast<ConstantSInt>(Operands[i])->getValue() < 0) {
- isString = false;
- break;
- }
- }
-
- if (isString) {
- Result = "c\"";
- for (unsigned i = 0; i < Operands.size(); ++i) {
- unsigned char C = (ETy == Type::SByteTy) ?
- (unsigned char)cast<ConstantSInt>(Operands[i])->getValue() :
- (unsigned char)cast<ConstantUInt>(Operands[i])->getValue();
-
- if (isprint(C)) {
- Result += C;
- } else {
- Result += '\\';
- Result += ( C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A');
- Result += ((C&15) < 10) ? ((C&15)+'0') : ((C&15)-10+'A');
- }
- }
- Result += "\"";
-
- } else {
- Result = "[";
- if (Operands.size()) {
- Result += " " + Operands[0]->getType()->getDescription() +
- " " + cast<Constant>(Operands[0])->getStrValue();
- for (unsigned i = 1; i < Operands.size(); i++)
- Result += ", " + Operands[i]->getType()->getDescription() +
- " " + cast<Constant>(Operands[i])->getStrValue();
- }
- Result += " ]";
- }
-
- return Result;
-}
-
-std::string ConstantStruct::getStrValue() const {
- std::string Result = "{";
- if (Operands.size()) {
- Result += " " + Operands[0]->getType()->getDescription() +
- " " + cast<Constant>(Operands[0])->getStrValue();
- for (unsigned i = 1; i < Operands.size(); i++)
- Result += ", " + Operands[i]->getType()->getDescription() +
- " " + cast<Constant>(Operands[i])->getStrValue();
- }
-
- return Result + " }";
-}
-
-std::string ConstantPointerNull::getStrValue() const {
- return "null";
-}
-
-std::string ConstantPointerRef::getStrValue() const {
- const GlobalValue *V = getValue();
- if (V->hasName()) return "%" + V->getName();
-
- // FIXME: This is a gross hack.
- SlotCalculator *Table = new SlotCalculator(V->getParent(), true);
- int Slot = Table->getValSlot(V);
- delete Table;
-
- if (Slot >= 0) return std::string(" %") + itostr(Slot);
- else return "<pointer reference badref>";
-}
-
-
-//===----------------------------------------------------------------------===//
// classof implementations
bool ConstantInt::classof(const Constant *CPV) {