llvm.org GIT mirror llvm / ca5092a
Avoid int to string conversion in Twine or raw_ostream contexts. Some output changes from uppercase hex to lowercase hex, no other functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321526 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 2 years ago
18 changed file(s) with 60 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
384384 void DemandedBits::print(raw_ostream &OS) {
385385 performAnalysis();
386386 for (auto &KV : AliveBits) {
387 OS << "DemandedBits: 0x" << utohexstr(KV.second.getLimitedValue()) << " for "
388 << *KV.first << "\n";
387 OS << "DemandedBits: 0x" << Twine::utohexstr(KV.second.getLimitedValue())
388 << " for " << *KV.first << '\n';
389389 }
390390 }
391391
7575 if (TempDir.empty())
7676 return;
7777 // User asked to save temps, let dump the bitcode file after import.
78 std::string SaveTempPath = (TempDir + llvm::utostr(count) + Suffix).str();
78 std::string SaveTempPath = (TempDir + llvm::Twine(count) + Suffix).str();
7979 std::error_code EC;
8080 raw_fd_ostream OS(SaveTempPath, EC, sys::fs::F_None);
8181 if (EC)
665665 ParseIndexList(Data, Offset, Indicies);
666666 break;
667667 default:
668 errs() << "unrecognised tag: 0x" << utohexstr(Tag) << '\n';
668 errs() << "unrecognised tag: 0x" << Twine::utohexstr(Tag) << '\n';
669669 return;
670670 }
671671
109109 return 1;
110110
111111 if (ErrorsPrinted > 0)
112 return reportError(argv0, utostr(ErrorsPrinted) + " errors.\n");
112 return reportError(argv0, Twine(ErrorsPrinted) + " errors.\n");
113113
114114 // Declare success.
115115 Out.keep();
17961796 llvm_unreachable("unsupported fp type");
17971797
17981798 APInt API = APF.bitcastToAPInt();
1799 std::string hexstr(utohexstr(API.getZExtValue()));
1800 O << lead;
1801 if (hexstr.length() < numHex)
1802 O << std::string(numHex - hexstr.length(), '0');
1803 O << utohexstr(API.getZExtValue());
1799 O << lead << format_hex_no_prefix(API.getZExtValue(), numHex, /*Upper=*/true);
18041800 }
18051801
18061802 void NVPTXAsmPrinter::printScalarConstant(const Constant *CPV, raw_ostream &O) {
1010 #include "llvm/ADT/StringExtras.h"
1111 #include "llvm/MC/MCAssembler.h"
1212 #include "llvm/MC/MCContext.h"
13 #include "llvm/Support/Format.h"
1314 using namespace llvm;
1415
1516 #define DEBUG_TYPE "nvptx-mcexpr"
4647 }
4748
4849 APInt API = APF.bitcastToAPInt();
49 std::string HexStr(utohexstr(API.getZExtValue()));
50 if (HexStr.length() < NumHex)
51 OS << std::string(NumHex - HexStr.length(), '0');
52 OS << utohexstr(API.getZExtValue());
50 OS << format_hex_no_prefix(API.getZExtValue(), NumHex, /*Upper=*/true);
5351 }
5452
5553 const NVPTXGenericMCSymbolRefExpr*
189189
190190 if (isVerbose()) {
191191 OutStreamer->AddComment("fallthrough-return: $pop" +
192 utostr(MFI->getWARegStackId(
192 Twine(MFI->getWARegStackId(
193193 MFI->getWAReg(MI->getOperand(0).getReg()))));
194194 OutStreamer->AddBlankLine();
195195 }
8989 if (isa(MD) && cast(MD)->isDistinct()) {
9090 Metadata *&GlobalMD = LocalToGlobal[MD];
9191 if (!GlobalMD) {
92 std::string NewName =
93 (to_string(LocalToGlobal.size()) + ModuleId).str();
92 std::string NewName = (Twine(LocalToGlobal.size()) + ModuleId).str();
9493 GlobalMD = MDString::get(M.getContext(), NewName);
9594 }
9695
27012701 unsigned Align = Arg.getParamAlignment();
27022702 if (Align == 0) Align = DL.getABITypeAlignment(Ty);
27032703
2704 const std::string &Name = Arg.hasName() ? Arg.getName().str() :
2705 "Arg" + llvm::to_string(Arg.getArgNo());
2706 AllocaInst *AI = IRB.CreateAlloca(Ty, nullptr, Twine(Name) + ".byval");
2704 AllocaInst *AI = IRB.CreateAlloca(
2705 Ty, nullptr,
2706 (Arg.hasName() ? Arg.getName() : "Arg" + Twine(Arg.getArgNo())) +
2707 ".byval");
27072708 AI->setAlignment(Align);
27082709 Arg.replaceAllUsesWith(AI);
27092710
640640 DenseMap VNums;
641641 for (auto *I : Insts) {
642642 uint32_t N = VN.lookupOrAdd(I);
643 DEBUG(dbgs() << " VN=" << utohexstr(N) << " for" << *I << "\n");
643 DEBUG(dbgs() << " VN=" << Twine::utohexstr(N) << " for" << *I << "\n");
644644 if (N == ~0U)
645645 return None;
646646 VNums[N]++;
352352 auto Coverage = std::move(CoverageOrErr.get());
353353 unsigned Mismatched = Coverage->getMismatchedCount();
354354 if (Mismatched) {
355 warning(utostr(Mismatched) + " functions have mismatched data");
355 warning(Twine(Mismatched) + " functions have mismatched data");
356356
357357 if (ViewOpts.Debug) {
358358 for (const auto &HashMismatch : Coverage->getHashMismatches())
359359 errs() << "hash-mismatch: "
360360 << "No profile record found for '" << HashMismatch.first << "'"
361 << " with hash = 0x" << utohexstr(HashMismatch.second) << "\n";
361 << " with hash = 0x" << Twine::utohexstr(HashMismatch.second)
362 << '\n';
362363
363364 for (const auto &CounterMismatch : Coverage->getCounterMismatches())
364365 errs() << "counter-mismatch: "
16421642 outs() << " <" << TargetName;
16431643 uint64_t Disp = Target - TargetAddress;
16441644 if (Disp)
1645 outs() << "+0x" << utohexstr(Disp);
1645 outs() << "+0x" << Twine::utohexstr(Disp);
16461646 outs() << '>';
16471647 }
16481648 }
766766 for (uintptr_t I = TableStart; I < TableEnd; I += EntrySize) {
767767 uint32_t RVA = *reinterpret_cast(I);
768768 raw_ostream &OS = W.startLine();
769 OS << "0x" << utohexstr(Obj->getImageBase() + RVA);
769 OS << "0x" << Twine::utohexstr(Obj->getImageBase() + RVA);
770770 if (PrintExtra)
771771 PrintExtra(OS, reinterpret_cast(I));
772772 OS << '\n';
18991899
19001900 ArrayRef Contents = unwrapOrError(Obj->getSectionContents(&Sec));
19011901 if (Contents[0] != ARMBuildAttrs::Format_Version) {
1902 errs() << "unrecognised FormatVersion: 0x" << utohexstr(Contents[0])
1903 << '\n';
1902 errs() << "unrecognised FormatVersion: 0x"
1903 << Twine::utohexstr(Contents[0]) << '\n';
19041904 continue;
19051905 }
19061906
6464 }
6565 } while (YIn.nextDocument());
6666
67 error("yaml2obj: Cannot find the " + utostr(DocNum) +
67 error("yaml2obj: Cannot find the " + Twine(DocNum) +
6868 llvm::getOrdinalSuffix(DocNum) + " document");
6969 }
7070
18721872 // Verify that we are passing the right number of operands.
18731873 if (Frag->getNumArgs() != Children.size()) {
18741874 TP.error("'" + Op->getName() + "' fragment requires " +
1875 utostr(Frag->getNumArgs()) + " operands!");
1875 Twine(Frag->getNumArgs()) + " operands!");
18761876 return nullptr;
18771877 }
18781878
21942194 SignBitAndAbove == 1)
21952195 continue;
21962196
2197 TP.error("Integer value '" + itostr(II->getValue()) +
2197 TP.error("Integer value '" + Twine(II->getValue()) +
21982198 "' is out of range for type '" + getEnumName(VT) + "'!");
21992199 break;
22002200 }
22442244 MadeChange |= UpdateNodeType(i, Int->IS.RetVTs[i], TP);
22452245
22462246 if (getNumChildren() != NumParamVTs + 1) {
2247 TP.error("Intrinsic '" + Int->Name + "' expects " +
2248 utostr(NumParamVTs) + " operands, not " +
2249 utostr(getNumChildren() - 1) + " operands!");
2247 TP.error("Intrinsic '" + Int->Name + "' expects " + Twine(NumParamVTs) +
2248 " operands, not " + Twine(getNumChildren() - 1) + " operands!");
22502249 return false;
22512250 }
22522251
22702269 if (NI.getNumOperands() >= 0 &&
22712270 getNumChildren() != (unsigned)NI.getNumOperands()) {
22722271 TP.error(getOperator()->getName() + " node requires exactly " +
2273 itostr(NI.getNumOperands()) + " operands!");
2272 Twine(NI.getNumOperands()) + " operands!");
22742273 return false;
22752274 }
22762275
23392338 TreePatternNode *SubIdxChild = getChild(I + 1);
23402339 if (!isOperandClass(SubIdxChild, "SubRegIndex")) {
23412340 TP.error("REG_SEQUENCE requires a SubRegIndex for operand " +
2342 itostr(I + 1) + "!");
2341 Twine(I + 1) + "!");
23432342 return false;
23442343 }
23452344 }
35133512 CGIOperandList::OperandInfo &Op = CGI.Operands[i];
35143513 const std::string &OpName = Op.Name;
35153514 if (OpName.empty())
3516 I->error("Operand #" + utostr(i) + " in operands list has no name!");
3515 I->error("Operand #" + Twine(i) + " in operands list has no name!");
35173516
35183517 if (!InstInputsCheck.count(OpName)) {
35193518 // If this is an operand with a DefaultOps set filled in, we can ignore
282282 if (i > 0) {
283283 DEBUG(dbgs() << ", ");
284284 }
285 DEBUG(dbgs() << "0x" << utohexstr(InsnClass[i]));
285 DEBUG(dbgs() << "0x" << Twine::utohexstr(InsnClass[i]));
286286 }
287287 DFAInput InsnInput = getDFAInsnInput(InsnClass);
288 DEBUG(dbgs() << " (input: 0x" << utohexstr(InsnInput) << ")");
288 DEBUG(dbgs() << " (input: 0x" << Twine::utohexstr(InsnInput) << ")");
289289 }
290290
291291 //
300300 if (i > 0) {
301301 DEBUG(dbgs() << ", ");
302302 }
303 DEBUG(dbgs() << "0x" << utohexstr(thisState));
303 DEBUG(dbgs() << "0x" << Twine::utohexstr(thisState));
304304 }
305305 }
306306
360360
361361 DenseSet VisitedResourceStates;
362362
363 DEBUG(dbgs() << " thisState: 0x" << utohexstr(thisState) << "\n");
363 DEBUG(dbgs() << " thisState: 0x" << Twine::utohexstr(thisState) << "\n");
364364 AddInsnClassStages(InsnClass, ComboBitToBitsMap,
365365 numstages - 1, numstages,
366366 thisState, thisState,
380380 DEBUG({
381381 dbgsIndent((1 + numstages - chkstage) << 1);
382382 dbgs() << "AddInsnClassStages " << chkstage << " (0x"
383 << utohexstr(thisStage) << ") from ";
383 << Twine::utohexstr(thisStage) << ") from ";
384384 dbgsInsnClass(InsnClass);
385385 dbgs() << "\n";
386386 });
394394 if (resourceMask & thisStage) {
395395 unsigned combo = ComboBitToBitsMap[resourceMask];
396396 if (combo && ((~prevState & combo) != combo)) {
397 DEBUG(dbgs() << "\tSkipped Add 0x" << utohexstr(prevState)
398 << " - combo op 0x" << utohexstr(resourceMask)
399 << " (0x" << utohexstr(combo) <<") cannot be scheduled\n");
397 DEBUG(dbgs() << "\tSkipped Add 0x" << Twine::utohexstr(prevState)
398 << " - combo op 0x" << Twine::utohexstr(resourceMask)
399 << " (0x" << Twine::utohexstr(combo)
400 << ") cannot be scheduled\n");
400401 continue;
401402 }
402403 //
406407 unsigned ResultingResourceState = prevState | resourceMask | combo;
407408 DEBUG({
408409 dbgsIndent((2 + numstages - chkstage) << 1);
409 dbgs() << "0x" << utohexstr(prevState)
410 << " | 0x" << utohexstr(resourceMask);
410 dbgs() << "0x" << Twine::utohexstr(prevState) << " | 0x"
411 << Twine::utohexstr(resourceMask);
411412 if (combo)
412 dbgs() << " | 0x" << utohexstr(combo);
413 dbgs() << " = 0x" << utohexstr(ResultingResourceState) << " ";
413 dbgs() << " | 0x" << Twine::utohexstr(combo);
414 dbgs() << " = 0x" << Twine::utohexstr(ResultingResourceState) << " ";
414415 });
415416
416417 //
432433 VisitedResourceStates.insert(ResultingResourceState);
433434 PossibleStates.insert(ResultingResourceState);
434435 DEBUG(dbgs() << "\tResultingResourceState: 0x"
435 << utohexstr(ResultingResourceState) << "\n");
436 << Twine::utohexstr(ResultingResourceState) << "\n");
436437 } else {
437438 DEBUG(dbgs() << "\tSkipped Add - state already seen\n");
438439 }
492493 // These cases are caught later in AddInsnClass.
493494 unsigned combo = ComboBitToBitsMap[InsnClass[i]];
494495 if (combo && ((~resources & combo) != combo)) {
495 DEBUG(dbgs() << "\tSkipped canMaybeAdd 0x" << utohexstr(resources)
496 << " - combo op 0x" << utohexstr(InsnClass[i])
497 << " (0x" << utohexstr(combo) <<") cannot be scheduled\n");
496 DEBUG(dbgs() << "\tSkipped canMaybeAdd 0x"
497 << Twine::utohexstr(resources) << " - combo op 0x"
498 << Twine::utohexstr(InsnClass[i]) << " (0x"
499 << Twine::utohexstr(combo) << ") cannot be scheduled\n");
498500 available = false;
499501 break;
500502 }
572574 for (State::TransitionMap::iterator
573575 II = SI->Transitions.begin(), IE = SI->Transitions.end();
574576 II != IE; ++II) {
575 OS << "{0x" << utohexstr(getDFAInsnInput(II->first)) << ", "
576 << II->second->stateNum
577 << "},\t";
577 OS << "{0x" << Twine::utohexstr(getDFAInsnInput(II->first)) << ", "
578 << II->second->stateNum << "},\t";
578579 }
579580 ValidTransitions += SI->Transitions.size();
580581
667668 "Exceeded maximum number of representable resources");
668669 unsigned FuncResources = (unsigned) (1U << j);
669670 FUNameToBitsMap[FUs[j]->getName()] = FuncResources;
670 DEBUG(dbgs() << " " << FUs[j]->getName()
671 << ":0x" << utohexstr(FuncResources));
671 DEBUG(dbgs() << " " << FUs[j]->getName() << ":0x"
672 << Twine::utohexstr(FuncResources));
672673 }
673674 if (((int) numFUs) > maxFUs) {
674675 maxFUs = numFUs;
712713 const std::string &ComboFuncName = ComboFunc->getName();
713714 unsigned ComboBit = FUNameToBitsMap[ComboFuncName];
714715 unsigned ComboResources = ComboBit;
715 DEBUG(dbgs() << " combo: " << ComboFuncName
716 << ":0x" << utohexstr(ComboResources) << "\n");
716 DEBUG(dbgs() << " combo: " << ComboFuncName << ":0x"
717 << Twine::utohexstr(ComboResources) << "\n");
717718 for (unsigned k = 0, M = FuncList.size(); k < M; ++k) {
718719 std::string FuncName = FuncList[k]->getName();
719720 unsigned FuncResources = FUNameToBitsMap[FuncName];
720 DEBUG(dbgs() << " " << FuncName
721 << ":0x" << utohexstr(FuncResources) << "\n");
721 DEBUG(dbgs() << " " << FuncName << ":0x"
722 << Twine::utohexstr(FuncResources) << "\n");
722723 ComboResources |= FuncResources;
723724 }
724725 ComboBitToBitsMap[ComboBit] = ComboResources;
725726 numCombos++;
726727 DEBUG(dbgs() << " => combo bits: " << ComboFuncName << ":0x"
727 << utohexstr(ComboBit) << " = 0x"
728 << utohexstr(ComboResources) << "\n");
728 << Twine::utohexstr(ComboBit) << " = 0x"
729 << Twine::utohexstr(ComboResources) << "\n");
729730 }
730731 }
731732 return numCombos;
780781 dbglen += 8;
781782 DEBUG(dbgs() << "\t");
782783 }
783 DEBUG(dbgs() << " (bits: 0x" << utohexstr(UnitBitValue) << ")\n");
784 DEBUG(dbgs() << " (bits: 0x" << Twine::utohexstr(UnitBitValue) << ")\n");
784785 }
785786
786787 if (!UnitBits.empty())
447447
448448 // If the entry fit in the table, just emit it.
449449 if (FixedEncodings[i] != ~0U) {
450 OS << "0x" << utohexstr(FixedEncodings[i]) << ", ";
450 OS << "0x" << Twine::utohexstr(FixedEncodings[i]) << ", ";
451451 continue;
452452 }
453453