summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/BlockFrequency.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-25 21:57:38 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-25 21:57:38 +0000
commit6e630d46d203fb0651c58d3a5607d49f234437ec (patch)
treeb85fa34b7220c17ed61dd5313fc3534b918b9d6d /llvm/lib/Support/BlockFrequency.cpp
parent02661d9605f8f741969b1d62143f8af5f7e3c430 (diff)
downloadbcm5719-llvm-6e630d46d203fb0651c58d3a5607d49f234437ec.tar.gz
bcm5719-llvm-6e630d46d203fb0651c58d3a5607d49f234437ec.zip
Print block frequencies in decimal form.
This is easier to read than the internal fixed-point representation. If anybody knows the correct algorithm for converting fixed-point numbers to base 10, feel free to fix it. llvm-svn: 184881
Diffstat (limited to 'llvm/lib/Support/BlockFrequency.cpp')
-rw-r--r--llvm/lib/Support/BlockFrequency.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/Support/BlockFrequency.cpp b/llvm/lib/Support/BlockFrequency.cpp
index 84a993e3e5b..572dbf57654 100644
--- a/llvm/lib/Support/BlockFrequency.cpp
+++ b/llvm/lib/Support/BlockFrequency.cpp
@@ -117,7 +117,16 @@ BlockFrequency::operator+(const BlockFrequency &Prob) const {
}
void BlockFrequency::print(raw_ostream &OS) const {
- OS << Frequency;
+ // Convert fixed-point number to decimal.
+ OS << Frequency / getEntryFrequency() << ".";
+ uint64_t Rem = Frequency % getEntryFrequency();
+ uint64_t Eps = 1;
+ do {
+ Rem *= 10;
+ Eps *= 10;
+ OS << Rem / getEntryFrequency();
+ Rem = Rem % getEntryFrequency();
+ } while (Rem >= Eps/2);
}
namespace llvm {
OpenPOWER on IntegriCloud