[llvm-mca] Move the logic that updates the register files from InstrBuilder to DispatchUnit. NFCI

Before this patch, the register file was always updated at instruction creation
time. That means, new read-after-write dependencies, and new temporary registers
were allocated at instruction creation time.

This patch refactors the code in InstrBuilder, and move all the logic that
updates the register file into the dispatch unit. We only want to update the
register file when instructions are effectively dispatched (not before).

This refactoring also helps removing a bad dependency between the InstrBuilder
and the DispatchUnit.

No functional change intended.

llvm-svn: 327514
diff --git a/llvm/tools/llvm-mca/Instruction.h b/llvm/tools/llvm-mca/Instruction.h
index 8d0bb0f..a760193 100644
--- a/llvm/tools/llvm-mca/Instruction.h
+++ b/llvm/tools/llvm-mca/Instruction.h
@@ -131,6 +131,7 @@
 /// writes only partially update the register associated to this read.
 class ReadState {
   const ReadDescriptor &RD;
+  unsigned RegisterID;
   unsigned DependentWrites;
   int CyclesLeft;
   unsigned TotalCycles;
@@ -142,14 +143,15 @@
     return (CyclesLeft == UNKNOWN_CYCLES || CyclesLeft == 0);
   }
 
-  ReadState(const ReadDescriptor &Desc)
-      : RD(Desc), DependentWrites(0), CyclesLeft(UNKNOWN_CYCLES),
-        TotalCycles(0) {}
+  ReadState(const ReadDescriptor &Desc, unsigned RegID)
+      : RD(Desc), RegisterID(RegID), DependentWrites(0),
+        CyclesLeft(UNKNOWN_CYCLES), TotalCycles(0) {}
   ReadState(const ReadState &Other) = delete;
   ReadState &operator=(const ReadState &Other) = delete;
 
   const ReadDescriptor &getDescriptor() const { return RD; }
   unsigned getSchedClass() const { return RD.SchedClassID; }
+  unsigned getRegisterID() const { return RegisterID; }
   void cycleEvent();
   void writeStartEvent(unsigned Cycles);
   void setDependentWrites(unsigned Writes) { DependentWrites = Writes; }