* Swithc to new MachineCodeForInstruction model
* Implement memory freeing for instruction temporaries


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1653 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
index dd9e330..a457abe 100644
--- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp
+++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
@@ -14,8 +14,9 @@
 #include "llvm/Target/Sparc.h"
 #include "llvm/CodeGen/InstrScheduling.h"
 #include "llvm/CodeGen/InstrSelection.h"
+#include "llvm/CodeGen/MachineCodeForInstruction.h"
+#include "llvm/CodeGen/MachineCodeForMethod.h"
 #include "llvm/CodeGen/PhyRegAlloc.h"
-#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "llvm/Method.h"
 #include <iostream>
 using std::cerr;
@@ -102,11 +103,11 @@
         unsigned N = GetInstructionsForEpilog(exitBB, target, minstrVec);
         
         MachineCodeForBasicBlock& bbMvec = exitBB->getMachineInstrVec();
-        MachineCodeForVMInstr& termMvec =
-          exitBB->getTerminator()->getMachineInstrVec();
+        MachineCodeForInstruction &termMvec =
+          MachineCodeForInstruction::get(exitBB->getTerminator());
         
         // Remove the NOPs in the delay slots of the return instruction
-        const MachineInstrInfo& mii = target.getInstrInfo();
+        const MachineInstrInfo &mii = target.getInstrInfo();
         unsigned numNOPs = 0;
         while (termMvec.back()->getOpCode() == NOP)
           {
@@ -283,7 +284,7 @@
 UltraSparc::compileMethod(Method *method)
 {
   // Construct and initialize the MachineCodeForMethod object for this method.
-  (void) MachineCodeForMethod::construct(method, *this);
+  MachineCodeForMethod::construct(method, *this);
   
   if (SelectInstructionsForMethod(method, *this))
     {
@@ -310,3 +311,19 @@
   
   return false;
 }
+
+static void freeMachineCode(Instruction *I) {
+  MachineCodeForInstruction::destroy(I);
+}
+
+//
+// freeCompiledMethod - Release all memory associated with the compiled image
+// for this method.
+//
+void 
+UltraSparc::freeCompiledMethod(Method *M)
+{
+  for_each(M->inst_begin(), M->inst_end(), freeMachineCode);
+  // Don't destruct MachineCodeForMethod - The global printer needs it
+  //MachineCodeForMethod::destruct(M);
+}