diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-04-18 18:53:33 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-04-18 18:53:33 +0000 | 
| commit | 1ce991d6b9a28b97bd92dc3e1b264ccd632e2fca (patch) | |
| tree | f74987d4c86ff467340e090f3d04ef302dd29462 /llvm/lib/VMCore/Constants.cpp | |
| parent | 1e19468e4ae907a243d3380f307f3b8ea1b0c7ef (diff) | |
| download | bcm5719-llvm-1ce991d6b9a28b97bd92dc3e1b264ccd632e2fca.tar.gz bcm5719-llvm-1ce991d6b9a28b97bd92dc3e1b264ccd632e2fca.zip | |
Move asmwriter/getStrValue cruft into AsmWriter.cpp file.
llvm-svn: 2300
Diffstat (limited to 'llvm/lib/VMCore/Constants.cpp')
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 128 | 
1 files changed, 0 insertions, 128 deletions
| diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index b2335bc9444..52af0ee19ee 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/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) { | 

