2002-02-03 08:54:50 +01:00
|
|
|
//===-- MachineCodeForInstruction.cpp -------------------------------------===//
|
2003-10-20 21:43:21 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
2002-10-28 02:21:55 +01:00
|
|
|
// Representation of the sequence of machine instructions created for a single
|
|
|
|
// VM instruction. Additionally records information about hidden and implicit
|
|
|
|
// values used by the machine instructions: about hidden values used by the
|
|
|
|
// machine instructions:
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
2002-10-28 02:21:55 +01:00
|
|
|
// "Temporary values" are intermediate values used in the machine instruction
|
|
|
|
// sequence, but not in the VM instruction Note that such values should be
|
|
|
|
// treated as pure SSA values with no interpretation of their operands (i.e., as
|
|
|
|
// a TmpInstruction object which actually represents such a value).
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
2002-10-28 02:21:55 +01:00
|
|
|
// (2) "Implicit uses" are values used in the VM instruction but not in the
|
|
|
|
// machine instruction sequence
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineCodeForInstruction.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2004-02-29 22:40:53 +01:00
|
|
|
#include "../Target/SparcV9/MachineInstrAnnot.h"
|
2004-01-10 20:16:26 +01:00
|
|
|
#include "llvm/Instruction.h"
|
2004-01-09 07:30:18 +01:00
|
|
|
using namespace llvm;
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2004-02-29 20:02:39 +01:00
|
|
|
MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
|
|
|
|
return *(MachineCodeForInstruction*)I->getOrCreateAnnotation(MCFI_AID);
|
|
|
|
}
|
|
|
|
void MachineCodeForInstruction::destroy(const Instruction *I) {
|
|
|
|
I->deleteAnnotation(MCFI_AID);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-01-09 07:30:18 +01:00
|
|
|
AnnotationID llvm::MCFI_AID(
|
2002-02-03 08:54:50 +01:00
|
|
|
AnnotationManager::getID("CodeGen::MachineCodeForInstruction"));
|
|
|
|
|
|
|
|
static Annotation *CreateMCFI(AnnotationID AID, const Annotable *, void *) {
|
|
|
|
assert(AID == MCFI_AID);
|
|
|
|
return new MachineCodeForInstruction(); // Invoke constructor!
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register the annotation with the annotation factory
|
2002-07-09 01:04:31 +02:00
|
|
|
static struct MCFIInitializer {
|
|
|
|
MCFIInitializer() {
|
2002-02-03 08:54:50 +01:00
|
|
|
AnnotationManager::registerAnnotationFactory(MCFI_AID, &CreateMCFI);
|
|
|
|
}
|
2002-07-09 01:04:31 +02:00
|
|
|
} RegisterCreateMCFI;
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2002-03-24 04:40:11 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
MachineCodeForInstruction::dropAllReferences()
|
|
|
|
{
|
|
|
|
for (unsigned i=0, N=tempVec.size(); i < N; i++)
|
2004-01-10 20:16:26 +01:00
|
|
|
cast<Instruction>(tempVec[i])->dropAllReferences();
|
2002-03-24 04:40:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-09 07:30:18 +01:00
|
|
|
MachineCodeForInstruction::~MachineCodeForInstruction() {
|
2002-03-24 04:40:11 +01:00
|
|
|
// Let go of all uses in temp. instructions
|
|
|
|
dropAllReferences();
|
|
|
|
|
2002-02-03 08:54:50 +01:00
|
|
|
// Free the Value objects created to hold intermediate values
|
|
|
|
for (unsigned i=0, N=tempVec.size(); i < N; i++)
|
|
|
|
delete tempVec[i];
|
|
|
|
|
2004-02-12 03:27:10 +01:00
|
|
|
// do not free the MachineInstr objects allocated. they are managed
|
|
|
|
// by the ilist in MachineBasicBlock
|
2002-10-29 20:38:46 +01:00
|
|
|
|
|
|
|
// Free the CallArgsDescriptor if it exists.
|
2004-01-09 07:30:18 +01:00
|
|
|
delete callArgsDesc;
|
2002-02-03 08:54:50 +01:00
|
|
|
}
|