blob: f3080628ee83906141ea961c99d381510e35e2fa [file] [log] [blame]
Chris Lattnerf2868ce2002-02-03 07:54:50 +00001//===-- MachineCodeForInstruction.cpp -------------------------------------===//
2//
Chris Lattner51a8d852002-10-28 01:21:55 +00003// 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 Lattnerf2868ce2002-02-03 07:54:50 +00007//
Chris Lattner51a8d852002-10-28 01:21:55 +00008// "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 Lattnerf2868ce2002-02-03 07:54:50 +000012//
Chris Lattner51a8d852002-10-28 01:21:55 +000013// (2) "Implicit uses" are values used in the VM instruction but not in the
14// machine instruction sequence
Chris Lattnerf2868ce2002-02-03 07:54:50 +000015//
16//===----------------------------------------------------------------------===//
17
18#include "llvm/CodeGen/MachineCodeForInstruction.h"
19#include "llvm/CodeGen/MachineInstr.h"
Vikram S. Adveded1bf82002-03-24 03:40:11 +000020#include "llvm/CodeGen/InstrSelection.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000021
Chris Lattner51a8d852002-10-28 01:21:55 +000022AnnotationID MCFI_AID(
Chris Lattnerf2868ce2002-02-03 07:54:50 +000023 AnnotationManager::getID("CodeGen::MachineCodeForInstruction"));
24
25static Annotation *CreateMCFI(AnnotationID AID, const Annotable *, void *) {
26 assert(AID == MCFI_AID);
27 return new MachineCodeForInstruction(); // Invoke constructor!
28}
29
30// Register the annotation with the annotation factory
Vikram S. Adve45c38772002-07-08 23:04:31 +000031static struct MCFIInitializer {
32 MCFIInitializer() {
Chris Lattnerf2868ce2002-02-03 07:54:50 +000033 AnnotationManager::registerAnnotationFactory(MCFI_AID, &CreateMCFI);
34 }
Vikram S. Adve45c38772002-07-08 23:04:31 +000035} RegisterCreateMCFI;
Chris Lattnerf2868ce2002-02-03 07:54:50 +000036
Vikram S. Adveded1bf82002-03-24 03:40:11 +000037
Vikram S. Adveded1bf82002-03-24 03:40:11 +000038void
39MachineCodeForInstruction::dropAllReferences()
40{
41 for (unsigned i=0, N=tempVec.size(); i < N; i++)
42 cast<TmpInstruction>(tempVec[i])->dropAllReferences();
43}
Chris Lattnerf2868ce2002-02-03 07:54:50 +000044
Vikram S. Adveded1bf82002-03-24 03:40:11 +000045
Vikram S. Adveded1bf82002-03-24 03:40:11 +000046MachineCodeForInstruction::~MachineCodeForInstruction()
47{
48 // Let go of all uses in temp. instructions
49 dropAllReferences();
50
Chris Lattnerf2868ce2002-02-03 07:54:50 +000051 // Free the Value objects created to hold intermediate values
52 for (unsigned i=0, N=tempVec.size(); i < N; i++)
53 delete tempVec[i];
54
55 // Free the MachineInstr objects allocated, if any.
56 for (unsigned i=0, N = size(); i < N; i++)
57 delete (*this)[i];
58}