[MCA] Improved debug prints. NFC



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353852 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/MCA/Support.h b/include/llvm/MCA/Support.h
index de38c9c..fc36ed4 100644
--- a/include/llvm/MCA/Support.h
+++ b/include/llvm/MCA/Support.h
@@ -60,24 +60,13 @@
     return (Denominator == 1) ? Numerator : (double)Numerator / Denominator;
   }
 
+  unsigned getNumerator() const { return Numerator; }
+  unsigned getDenominator() const { return Denominator; }
+
   // Add the components of RHS to this instance.  Instead of calculating
   // the final value here, we keep track of the numerator and denominator
   // separately, to reduce floating point error.
-  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;
-  }
+  ResourceCycles &operator+=(const ResourceCycles &RHS);
 };
 
 /// Populates vector Masks with processor resource masks.
diff --git a/lib/MCA/Stages/ExecuteStage.cpp b/lib/MCA/Stages/ExecuteStage.cpp
index 2060fcd..9e0bd26 100644
--- a/lib/MCA/Stages/ExecuteStage.cpp
+++ b/lib/MCA/Stages/ExecuteStage.cpp
@@ -188,9 +188,10 @@
   LLVM_DEBUG({
     dbgs() << "[E] Instruction Issued: #" << IR << '\n';
     for (const std::pair<ResourceRef, ResourceCycles> &Resource : Used) {
+      assert(Resource.second.getDenominator() == 1 && "Invalid cycles!");
       dbgs() << "[E] Resource Used: [" << Resource.first.first << '.'
              << Resource.first.second << "], ";
-      dbgs() << "cycles: " << Resource.second << '\n';
+      dbgs() << "cycles: " << Resource.second.getNumerator() << '\n';
     }
   });
 
diff --git a/lib/MCA/Support.cpp b/lib/MCA/Support.cpp
index e11062f..ce1f0f6 100644
--- a/lib/MCA/Support.cpp
+++ b/lib/MCA/Support.cpp
@@ -20,6 +20,22 @@
 
 #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 @@
                     << "\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
 }