blob: c50c8b8c6aef55a7c76ea6f42628c492d61ac6f7 [file] [log] [blame]
Chris Lattnerf2868ce2002-02-03 07:54:50 +00001//===-- MachineCodeForInstruction.cpp -------------------------------------===//
John Criswellb576c942003-10-20 19:43:21 +00002//
3// The LLVM Compiler Infrastructure
4//
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.
7//
8//===----------------------------------------------------------------------===//
Chris Lattnerf2868ce2002-02-03 07:54:50 +00009//
Chris Lattner51a8d852002-10-28 01:21:55 +000010// 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:
Chris Lattnerf2868ce2002-02-03 07:54:50 +000014//
Chris Lattner51a8d852002-10-28 01:21:55 +000015// "Temporary values" are intermediate values used in the machine instruction
Brian Gaekecdd69e62004-05-30 03:33:48 +000016// sequence, but not in the VM instruction. Note that such values should be
Chris Lattner51a8d852002-10-28 01:21:55 +000017// treated as pure SSA values with no interpretation of their operands (i.e., as
18// a TmpInstruction object which actually represents such a value).
Chris Lattnerf2868ce2002-02-03 07:54:50 +000019//
Chris Lattner51a8d852002-10-28 01:21:55 +000020// (2) "Implicit uses" are values used in the VM instruction but not in the
21// machine instruction sequence
Chris Lattnerf2868ce2002-02-03 07:54:50 +000022//
23//===----------------------------------------------------------------------===//
24
25#include "llvm/CodeGen/MachineCodeForInstruction.h"
Chris Lattner4e7244e2004-06-27 18:52:17 +000026#include "llvm/Function.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000027#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner4e7244e2004-06-27 18:52:17 +000028#include "llvm/CodeGen/MachineFunction.h"
29#include "llvm/CodeGen/MachineFunctionInfo.h"
Chris Lattnerc81295a2004-02-29 21:40:53 +000030#include "../Target/SparcV9/MachineInstrAnnot.h"
Chris Lattnerd5da1972004-01-09 06:30:18 +000031using namespace llvm;
Chris Lattnerf2868ce2002-02-03 07:54:50 +000032
Chris Lattner585911e2004-02-29 19:02:39 +000033MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
Chris Lattner4e7244e2004-06-27 18:52:17 +000034 MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
35 return MF.getInfo()->MCFIEntries[I];
Chris Lattner585911e2004-02-29 19:02:39 +000036}
37void MachineCodeForInstruction::destroy(const Instruction *I) {
Chris Lattner4e7244e2004-06-27 18:52:17 +000038 MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
39 MF.getInfo()->MCFIEntries.erase(I);
Chris Lattner585911e2004-02-29 19:02:39 +000040}
41
Vikram S. Adveded1bf82002-03-24 03:40:11 +000042void
43MachineCodeForInstruction::dropAllReferences()
44{
45 for (unsigned i=0, N=tempVec.size(); i < N; i++)
Chris Lattnerae7fc3a2004-01-10 19:16:26 +000046 cast<Instruction>(tempVec[i])->dropAllReferences();
Vikram S. Adveded1bf82002-03-24 03:40:11 +000047}
Chris Lattnerf2868ce2002-02-03 07:54:50 +000048
Vikram S. Adveded1bf82002-03-24 03:40:11 +000049
Chris Lattnerd5da1972004-01-09 06:30:18 +000050MachineCodeForInstruction::~MachineCodeForInstruction() {
Vikram S. Adveded1bf82002-03-24 03:40:11 +000051 // Let go of all uses in temp. instructions
52 dropAllReferences();
53
Chris Lattnerf2868ce2002-02-03 07:54:50 +000054 // Free the Value objects created to hold intermediate values
55 for (unsigned i=0, N=tempVec.size(); i < N; i++)
56 delete tempVec[i];
57
Alkis Evlogimenosc0b9dc52004-02-12 02:27:10 +000058 // do not free the MachineInstr objects allocated. they are managed
59 // by the ilist in MachineBasicBlock
Vikram S. Advee68a3432002-10-29 19:38:46 +000060
61 // Free the CallArgsDescriptor if it exists.
Chris Lattnerd5da1972004-01-09 06:30:18 +000062 delete callArgsDesc;
Chris Lattnerf2868ce2002-02-03 07:54:50 +000063}