Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 1 | //===-- MachineCodeForInstruction.cpp -------------------------------------===// |
| 2 | // |
Chris Lattner | 51a8d85 | 2002-10-28 01:21:55 +0000 | [diff] [blame] | 3 | // Representation of the sequence of machine instructions created for a single |
| 4 | // VM instruction. Additionally records information about hidden and implicit |
| 5 | // values used by the machine instructions: about hidden values used by the |
| 6 | // machine instructions: |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 7 | // |
Chris Lattner | 51a8d85 | 2002-10-28 01:21:55 +0000 | [diff] [blame] | 8 | // "Temporary values" are intermediate values used in the machine instruction |
| 9 | // sequence, but not in the VM instruction Note that such values should be |
| 10 | // treated as pure SSA values with no interpretation of their operands (i.e., as |
| 11 | // a TmpInstruction object which actually represents such a value). |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 12 | // |
Chris Lattner | 51a8d85 | 2002-10-28 01:21:55 +0000 | [diff] [blame] | 13 | // (2) "Implicit uses" are values used in the VM instruction but not in the |
| 14 | // machine instruction sequence |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 15 | // |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | #include "llvm/CodeGen/MachineCodeForInstruction.h" |
| 19 | #include "llvm/CodeGen/MachineInstr.h" |
Vikram S. Adve | e68a343 | 2002-10-29 19:38:46 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineInstrAnnot.h" |
Vikram S. Adve | ded1bf8 | 2002-03-24 03:40:11 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/InstrSelection.h" |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 22 | |
Chris Lattner | 51a8d85 | 2002-10-28 01:21:55 +0000 | [diff] [blame] | 23 | AnnotationID MCFI_AID( |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 24 | AnnotationManager::getID("CodeGen::MachineCodeForInstruction")); |
| 25 | |
| 26 | static Annotation *CreateMCFI(AnnotationID AID, const Annotable *, void *) { |
| 27 | assert(AID == MCFI_AID); |
| 28 | return new MachineCodeForInstruction(); // Invoke constructor! |
| 29 | } |
| 30 | |
| 31 | // Register the annotation with the annotation factory |
Vikram S. Adve | 45c3877 | 2002-07-08 23:04:31 +0000 | [diff] [blame] | 32 | static struct MCFIInitializer { |
| 33 | MCFIInitializer() { |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 34 | AnnotationManager::registerAnnotationFactory(MCFI_AID, &CreateMCFI); |
| 35 | } |
Vikram S. Adve | 45c3877 | 2002-07-08 23:04:31 +0000 | [diff] [blame] | 36 | } RegisterCreateMCFI; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 37 | |
Vikram S. Adve | ded1bf8 | 2002-03-24 03:40:11 +0000 | [diff] [blame] | 38 | |
Vikram S. Adve | ded1bf8 | 2002-03-24 03:40:11 +0000 | [diff] [blame] | 39 | void |
| 40 | MachineCodeForInstruction::dropAllReferences() |
| 41 | { |
| 42 | for (unsigned i=0, N=tempVec.size(); i < N; i++) |
| 43 | cast<TmpInstruction>(tempVec[i])->dropAllReferences(); |
| 44 | } |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 45 | |
Vikram S. Adve | ded1bf8 | 2002-03-24 03:40:11 +0000 | [diff] [blame] | 46 | |
Vikram S. Adve | ded1bf8 | 2002-03-24 03:40:11 +0000 | [diff] [blame] | 47 | MachineCodeForInstruction::~MachineCodeForInstruction() |
| 48 | { |
| 49 | // Let go of all uses in temp. instructions |
| 50 | dropAllReferences(); |
| 51 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 52 | // Free the Value objects created to hold intermediate values |
| 53 | for (unsigned i=0, N=tempVec.size(); i < N; i++) |
| 54 | delete tempVec[i]; |
| 55 | |
| 56 | // Free the MachineInstr objects allocated, if any. |
| 57 | for (unsigned i=0, N = size(); i < N; i++) |
| 58 | delete (*this)[i]; |
Vikram S. Adve | e68a343 | 2002-10-29 19:38:46 +0000 | [diff] [blame] | 59 | |
| 60 | // Free the CallArgsDescriptor if it exists. |
| 61 | if (callArgsDesc) |
| 62 | delete callArgsDesc; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 63 | } |