[llvm-mca] Unify the API for the various views. NFCI

This allows the customization of the performance report.

Users can specify their own custom sequence of views.
Each view contributes a portion of the performance report generated by the
BackendPrinter.

Internally, class BackendPrinter keeps a sequence of views; views are printed
out in sequence when method 'printReport()' is called. 

This patch addresses one of the two review comments from Clement in D43951.

llvm-svn: 327018
diff --git a/llvm/tools/llvm-mca/Backend.h b/llvm/tools/llvm-mca/Backend.h
index 6e2db08..5d1df1d 100644
--- a/llvm/tools/llvm-mca/Backend.h
+++ b/llvm/tools/llvm-mca/Backend.h
@@ -48,7 +48,7 @@
   std::unique_ptr<InstrBuilder> IB;
   std::unique_ptr<Scheduler> HWS;
   std::unique_ptr<DispatchUnit> DU;
-  std::unique_ptr<SourceMgr> SM;
+  SourceMgr &SM;
   unsigned Cycles;
 
   llvm::DenseMap<unsigned, std::unique_ptr<Instruction>> Instructions;
@@ -58,7 +58,7 @@
 
 public:
   Backend(const llvm::MCSubtargetInfo &Subtarget, const llvm::MCInstrInfo &MCII,
-          const llvm::MCRegisterInfo &MRI, std::unique_ptr<SourceMgr> Source,
+          const llvm::MCRegisterInfo &MRI, SourceMgr &Source,
           unsigned DispatchWidth = 0, unsigned RegisterFileSize = 0,
           unsigned MaxRetirePerCycle = 0, unsigned LoadQueueSize = 0,
           unsigned StoreQueueSize = 0, bool AssumeNoAlias = false)
@@ -69,17 +69,17 @@
         DU(llvm::make_unique<DispatchUnit>(
             this, MRI, Subtarget.getSchedModel().MicroOpBufferSize,
             RegisterFileSize, MaxRetirePerCycle, DispatchWidth, HWS.get())),
-        SM(std::move(Source)), Cycles(0) {
+        SM(Source), Cycles(0) {
     IB = llvm::make_unique<InstrBuilder>(MCII, getProcResourceMasks());
   }
 
   void run() {
-    while (SM->hasNext() || !DU->isRCUEmpty())
+    while (SM.hasNext() || !DU->isRCUEmpty())
       runCycle(Cycles++);
   }
 
-  unsigned getNumIterations() const { return SM->getNumIterations(); }
-  unsigned getNumInstructions() const { return SM->size(); }
+  unsigned getNumIterations() const { return SM.getNumIterations(); }
+  unsigned getNumInstructions() const { return SM.size(); }
   unsigned getNumCycles() const { return Cycles; }
   unsigned getTotalRegisterMappingsCreated() const {
     return DU->getTotalRegisterMappingsCreated();
@@ -114,14 +114,14 @@
   }
 
   const llvm::MCInst &getMCInstFromIndex(unsigned Index) const {
-    return SM->getMCInstFromIndex(Index);
+    return SM.getMCInstFromIndex(Index);
   }
 
   const InstrDesc &getInstrDesc(const llvm::MCInst &Inst) const {
     return IB->getOrCreateInstrDesc(STI, Inst);
   }
 
-  const SourceMgr &getSourceMgr() const { return *SM; }
+  const SourceMgr &getSourceMgr() const { return SM; }
 
   void addEventListener(HWEventListener *Listener);
   void notifyCycleBegin(unsigned Cycle);