1 //===-- MachineCodeForInstruction.cpp -------------------------------------===//
3 // Representation of the sequence of machine instructions created
4 // for a single VM instruction. Additionally records information
5 // about hidden and implicit values used by the machine instructions:
6 // about hidden values used by the machine instructions:
8 // "Temporary values" are intermediate values used in the machine
9 // instruction sequence, but not in the VM instruction
10 // Note that such values should be treated as pure SSA values with
11 // no interpretation of their operands (i.e., as a TmpInstruction
12 // object which actually represents such a value).
14 // (2) "Implicit uses" are values used in the VM instruction but not in
15 // the machine instruction sequence
17 //===----------------------------------------------------------------------===//
19 #include "llvm/CodeGen/MachineCodeForInstruction.h"
20 #include "llvm/CodeGen/MachineInstr.h"
21 #include "llvm/CodeGen/InstrSelection.h"
22 #include "llvm/Instruction.h"
24 static AnnotationID MCFI_AID(
25 AnnotationManager::getID("CodeGen::MachineCodeForInstruction"));
27 static Annotation *CreateMCFI(AnnotationID AID, const Annotable *, void *) {
28 assert(AID == MCFI_AID);
29 return new MachineCodeForInstruction(); // Invoke constructor!
32 // Register the annotation with the annotation factory
33 static struct Initializer {
35 AnnotationManager::registerAnnotationFactory(MCFI_AID, &CreateMCFI);
40 MachineCodeForInstruction&
41 MachineCodeForInstruction::get(const Instruction *I){
42 return *(MachineCodeForInstruction*)I->getOrCreateAnnotation(MCFI_AID);
47 MachineCodeForInstruction::destroy(const Instruction *I) {
48 I->deleteAnnotation(MCFI_AID);
53 MachineCodeForInstruction::dropAllReferences()
55 for (unsigned i=0, N=tempVec.size(); i < N; i++)
56 cast<TmpInstruction>(tempVec[i])->dropAllReferences();
60 MachineCodeForInstruction::MachineCodeForInstruction()
61 : Annotation(MCFI_AID)
65 MachineCodeForInstruction::~MachineCodeForInstruction()
67 // Let go of all uses in temp. instructions
70 // Free the Value objects created to hold intermediate values
71 for (unsigned i=0, N=tempVec.size(); i < N; i++)
74 // Free the MachineInstr objects allocated, if any.
75 for (unsigned i=0, N = size(); i < N; i++)