Added LLVM project notice to the top of every C++ source file.
[oota-llvm.git] / lib / CodeGen / MachineCodeForInstruction.cpp
1 //===-- MachineCodeForInstruction.cpp -------------------------------------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // Representation of the sequence of machine instructions created for a single
11 // VM instruction.  Additionally records information about hidden and implicit
12 // values used by the machine instructions: about hidden values used by the
13 // machine instructions:
14 // 
15 // "Temporary values" are intermediate values used in the machine instruction
16 // sequence, but not in the VM instruction Note that such values should be
17 // treated as pure SSA values with no interpretation of their operands (i.e., as
18 // a TmpInstruction object which actually represents such a value).
19 // 
20 // (2) "Implicit uses" are values used in the VM instruction but not in the
21 //     machine instruction sequence
22 // 
23 //===----------------------------------------------------------------------===//
24
25 #include "llvm/CodeGen/MachineCodeForInstruction.h"
26 #include "llvm/CodeGen/MachineInstr.h"
27 #include "llvm/CodeGen/MachineInstrAnnot.h"
28 #include "llvm/CodeGen/InstrSelection.h"
29
30 AnnotationID MCFI_AID(
31              AnnotationManager::getID("CodeGen::MachineCodeForInstruction"));
32
33 static Annotation *CreateMCFI(AnnotationID AID, const Annotable *, void *) {
34   assert(AID == MCFI_AID);
35   return new MachineCodeForInstruction();  // Invoke constructor!
36 }
37
38 // Register the annotation with the annotation factory
39 static struct MCFIInitializer {
40   MCFIInitializer() {
41     AnnotationManager::registerAnnotationFactory(MCFI_AID, &CreateMCFI);
42   }
43 } RegisterCreateMCFI;
44
45
46 void
47 MachineCodeForInstruction::dropAllReferences()
48 {
49   for (unsigned i=0, N=tempVec.size(); i < N; i++)
50     cast<TmpInstruction>(tempVec[i])->dropAllReferences();
51 }
52
53
54 MachineCodeForInstruction::~MachineCodeForInstruction()
55 {
56   // Let go of all uses in temp. instructions
57   dropAllReferences();
58   
59   // Free the Value objects created to hold intermediate values
60   for (unsigned i=0, N=tempVec.size(); i < N; i++)
61     delete tempVec[i];
62   
63   // Free the MachineInstr objects allocated, if any.
64   for (unsigned i=0, N = size(); i < N; i++)
65     delete (*this)[i];
66
67   // Free the CallArgsDescriptor if it exists.
68   if (callArgsDesc)
69     delete callArgsDesc;
70 }