diff options
Diffstat (limited to 'llvm/lib/MCA/Support.cpp')
-rw-r--r-- | llvm/lib/MCA/Support.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/MCA/Support.cpp b/llvm/lib/MCA/Support.cpp index e11062f4d72..ce1f0f6f211 100644 --- a/llvm/lib/MCA/Support.cpp +++ b/llvm/lib/MCA/Support.cpp @@ -20,6 +20,22 @@ namespace mca { #define DEBUG_TYPE "llvm-mca" +ResourceCycles &ResourceCycles::operator+=(const ResourceCycles &RHS) { + if (Denominator == RHS.Denominator) + Numerator += RHS.Numerator; + else { + // Create a common denominator for LHS and RHS by calculating the least + // common multiple from the GCD. + unsigned GCD = GreatestCommonDivisor64(Denominator, RHS.Denominator); + unsigned LCM = (Denominator * RHS.Denominator) / GCD; + unsigned LHSNumerator = Numerator * (LCM / Denominator); + unsigned RHSNumerator = RHS.Numerator * (LCM / RHS.Denominator); + Numerator = LHSNumerator + RHSNumerator; + Denominator = LCM; + } + return *this; +} + void computeProcResourceMasks(const MCSchedModel &SM, MutableArrayRef<uint64_t> Masks) { unsigned ProcResourceID = 0; @@ -56,8 +72,9 @@ void computeProcResourceMasks(const MCSchedModel &SM, << "\n"); for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) { const MCProcResourceDesc &Desc = *SM.getProcResource(I); - LLVM_DEBUG(dbgs() << '[' << I << "] " << Desc.Name << " - " << Masks[I] - << '\n'); + LLVM_DEBUG(dbgs() << '[' << format_decimal(I,2) << "] " << " - " + << format_hex(Masks[I],16) << " - " + << Desc.Name << '\n'); } #endif } |