mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 20:33:15 +00:00
[block-freq] Add a print method on BlockFrequencyImpl for printing block frequencies and a convenience method for the common case of getting/printing a basic block.
BlockFrequencies can only be printed relative to their entry frequency. Thus since the entry frequency is no longer necessarily a static constant on the BlockFrequency class and is instead a potentially dynamic value taken from BlockFrequencyImpl, we must necessarily print it via a method on BlockFrequencyImpl. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197285 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ccf34d2295
commit
5efbda1437
@ -343,6 +343,30 @@ public:
|
||||
void dump() const {
|
||||
print(dbgs());
|
||||
}
|
||||
|
||||
// Utility method that looks up the block frequency associated with BB and
|
||||
// prints it to OS.
|
||||
raw_ostream &printBlockFreq(raw_ostream &OS,
|
||||
const BlockT *BB) {
|
||||
return printBlockFreq(OS, getBlockFreq(BB));
|
||||
}
|
||||
|
||||
raw_ostream &printBlockFreq(raw_ostream &OS,
|
||||
const BlockFrequency &Freq) const {
|
||||
// Convert fixed-point number to decimal.
|
||||
uint64_t Frequency = Freq.getFrequency();
|
||||
OS << Frequency / EntryFreq << ".";
|
||||
uint64_t Rem = Frequency % EntryFreq;
|
||||
uint64_t Eps = 1;
|
||||
do {
|
||||
Rem *= 10;
|
||||
Eps *= 10;
|
||||
OS << Rem / EntryFreq;
|
||||
Rem = Rem % EntryFreq;
|
||||
} while (Rem >= Eps/2);
|
||||
return OS;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user