mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
remove some uses of llvm/Support/Streams.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79842 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
+28
-50
@@ -14,16 +14,16 @@
|
||||
#include "llvm/Support/Timer.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/System/Process.h"
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
using namespace llvm;
|
||||
|
||||
// GetLibSupportInfoOutputFile - Return a file stream to print our output on.
|
||||
namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); }
|
||||
namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); }
|
||||
|
||||
// getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
|
||||
// of constructor/destructor ordering being unspecified by C++. Basically the
|
||||
@@ -269,38 +269,17 @@ NamedRegionTimer::NamedRegionTimer(const std::string &Name,
|
||||
// TimerGroup Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// printAlignedFP - Simulate the printf "%A.Bf" format, where A is the
|
||||
// TotalWidth size, and B is the AfterDec size.
|
||||
//
|
||||
static void printAlignedFP(double Val, unsigned AfterDec, unsigned TotalWidth,
|
||||
std::ostream &OS) {
|
||||
assert(TotalWidth >= AfterDec+1 && "Bad FP Format!");
|
||||
OS.width(TotalWidth-AfterDec-1);
|
||||
char OldFill = OS.fill();
|
||||
OS.fill(' ');
|
||||
OS << (int)Val; // Integer part;
|
||||
OS << ".";
|
||||
OS.width(AfterDec);
|
||||
OS.fill('0');
|
||||
unsigned ResultFieldSize = 1;
|
||||
while (AfterDec--) ResultFieldSize *= 10;
|
||||
OS << (int)(Val*ResultFieldSize) % ResultFieldSize;
|
||||
OS.fill(OldFill);
|
||||
}
|
||||
|
||||
static void printVal(double Val, double Total, std::ostream &OS) {
|
||||
static void printVal(double Val, double Total, raw_ostream &OS) {
|
||||
if (Total < 1e-7) // Avoid dividing by zero...
|
||||
OS << " ----- ";
|
||||
else {
|
||||
OS << " ";
|
||||
printAlignedFP(Val, 4, 7, OS);
|
||||
OS << " (";
|
||||
printAlignedFP(Val*100/Total, 1, 5, OS);
|
||||
OS << "%)";
|
||||
OS << " " << format("%7.4f", Val) << " (";
|
||||
OS << format("%5.1f", Val*100/Total) << "%)";
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::print(const Timer &Total, std::ostream &OS) {
|
||||
void Timer::print(const Timer &Total, raw_ostream &OS) {
|
||||
if (&Total < this) {
|
||||
Total.Lock.acquire();
|
||||
Lock.acquire();
|
||||
@@ -320,13 +299,11 @@ void Timer::print(const Timer &Total, std::ostream &OS) {
|
||||
OS << " ";
|
||||
|
||||
if (Total.MemUsed) {
|
||||
OS.width(9);
|
||||
OS << MemUsed << " ";
|
||||
OS << format("%9lld", (long long)MemUsed) << " ";
|
||||
}
|
||||
if (Total.PeakMem) {
|
||||
if (PeakMem) {
|
||||
OS.width(9);
|
||||
OS << PeakMem << " ";
|
||||
OS << format("%9lld", (long long)PeakMem) << " ";
|
||||
} else
|
||||
OS << " ";
|
||||
}
|
||||
@@ -344,23 +321,25 @@ void Timer::print(const Timer &Total, std::ostream &OS) {
|
||||
}
|
||||
|
||||
// GetLibSupportInfoOutputFile - Return a file stream to print our output on...
|
||||
std::ostream *
|
||||
raw_ostream *
|
||||
llvm::GetLibSupportInfoOutputFile() {
|
||||
std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
|
||||
if (LibSupportInfoOutputFilename.empty())
|
||||
return cerr.stream();
|
||||
return &errs();
|
||||
if (LibSupportInfoOutputFilename == "-")
|
||||
return cout.stream();
|
||||
return &outs();
|
||||
|
||||
std::ostream *Result = new std::ofstream(LibSupportInfoOutputFilename.c_str(),
|
||||
std::ios::app);
|
||||
if (!Result->good()) {
|
||||
cerr << "Error opening info-output-file '"
|
||||
|
||||
std::string Error;
|
||||
raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(),
|
||||
Error, raw_fd_ostream::F_Append);
|
||||
if (Error.empty())
|
||||
return Result;
|
||||
|
||||
errs() << "Error opening info-output-file '"
|
||||
<< LibSupportInfoOutputFilename << " for appending!\n";
|
||||
delete Result;
|
||||
return cerr.stream();
|
||||
}
|
||||
return Result;
|
||||
delete Result;
|
||||
return &errs();
|
||||
}
|
||||
|
||||
|
||||
@@ -375,7 +354,7 @@ void TimerGroup::removeTimer() {
|
||||
unsigned Padding = (80-Name.length())/2;
|
||||
if (Padding > 80) Padding = 0; // Don't allow "negative" numbers
|
||||
|
||||
std::ostream *OutStream = GetLibSupportInfoOutputFile();
|
||||
raw_ostream *OutStream = GetLibSupportInfoOutputFile();
|
||||
|
||||
++NumTimers;
|
||||
{ // Scope to contain Total timer... don't allow total timer to drop us to
|
||||
@@ -397,10 +376,8 @@ void TimerGroup::removeTimer() {
|
||||
if (this != DefaultTimerGroup) {
|
||||
*OutStream << " Total Execution Time: ";
|
||||
|
||||
printAlignedFP(Total.getProcessTime(), 4, 5, *OutStream);
|
||||
*OutStream << " seconds (";
|
||||
printAlignedFP(Total.getWallTime(), 4, 5, *OutStream);
|
||||
*OutStream << " wall clock)\n";
|
||||
*OutStream << format("%5.4f", Total.getProcessTime()) << " seconds (";
|
||||
*OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n";
|
||||
}
|
||||
*OutStream << "\n";
|
||||
|
||||
@@ -422,13 +399,14 @@ void TimerGroup::removeTimer() {
|
||||
TimersToPrint[i].print(Total, *OutStream);
|
||||
|
||||
Total.print(Total, *OutStream);
|
||||
*OutStream << std::endl; // Flush output
|
||||
*OutStream << '\n';
|
||||
OutStream->flush();
|
||||
}
|
||||
--NumTimers;
|
||||
|
||||
TimersToPrint.clear();
|
||||
|
||||
if (OutStream != cerr.stream() && OutStream != cout.stream())
|
||||
if (OutStream != &errs() && OutStream != &outs())
|
||||
delete OutStream; // Close the file...
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user