1 //===-- MachineCodeForInstruction.cpp -------------------------------------===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
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:
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).
20 // (2) "Implicit uses" are values used in the VM instruction but not in the
21 // machine instruction sequence
23 //===----------------------------------------------------------------------===//
25 #include "llvm/CodeGen/MachineCodeForInstruction.h"
26 #include "llvm/CodeGen/MachineInstr.h"
27 #include "../Target/SparcV9/MachineInstrAnnot.h"
28 #include "llvm/Instruction.h"
31 MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
32 return *(MachineCodeForInstruction*)I->getOrCreateAnnotation(MCFI_AID);
34 void MachineCodeForInstruction::destroy(const Instruction *I) {
35 I->deleteAnnotation(MCFI_AID);
40 AnnotationID llvm::MCFI_AID(
41 AnnotationManager::getID("CodeGen::MachineCodeForInstruction"));
43 static Annotation *CreateMCFI(AnnotationID AID, const Annotable *, void *) {
44 assert(AID == MCFI_AID);
45 return new MachineCodeForInstruction(); // Invoke constructor!
48 // Register the annotation with the annotation factory
49 static struct MCFIInitializer {
51 AnnotationManager::registerAnnotationFactory(MCFI_AID, &CreateMCFI);
57 MachineCodeForInstruction::dropAllReferences()
59 for (unsigned i=0, N=tempVec.size(); i < N; i++)
60 cast<Instruction>(tempVec[i])->dropAllReferences();
64 MachineCodeForInstruction::~MachineCodeForInstruction() {
65 // Let go of all uses in temp. instructions
68 // Free the Value objects created to hold intermediate values
69 for (unsigned i=0, N=tempVec.size(); i < N; i++)
72 // do not free the MachineInstr objects allocated. they are managed
73 // by the ilist in MachineBasicBlock
75 // Free the CallArgsDescriptor if it exists.