Fix a regression in InstCombine/xor.ll
[oota-llvm.git] / lib / CodeGen / MachineCodeForInstruction.cpp
1 //===-- MachineCodeForInstruction.cpp -------------------------------------===//
2 // 
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 //===----------------------------------------------------------------------===//
9 //
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:
14 // 
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).
19 // 
20 // (2) "Implicit uses" are values used in the VM instruction but not in the
21 //     machine instruction sequence
22 // 
23 //===----------------------------------------------------------------------===//
24
25 #include "llvm/CodeGen/MachineCodeForInstruction.h"
26 #include "llvm/Function.h"
27 #include "llvm/CodeGen/MachineInstr.h"
28 #include "llvm/CodeGen/MachineFunction.h"
29 #include "llvm/CodeGen/MachineFunctionInfo.h"
30 #include "../Target/SparcV9/MachineInstrAnnot.h"
31 using namespace llvm;
32
33 MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
34   MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
35   return MF.getInfo()->MCFIEntries[I];
36 }
37 void MachineCodeForInstruction::destroy(const Instruction *I) {
38   MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
39   MF.getInfo()->MCFIEntries.erase(I);
40 }
41
42 void
43 MachineCodeForInstruction::dropAllReferences()
44 {
45   for (unsigned i=0, N=tempVec.size(); i < N; i++)
46     cast<Instruction>(tempVec[i])->dropAllReferences();
47 }
48
49
50 MachineCodeForInstruction::~MachineCodeForInstruction() {
51   // Let go of all uses in temp. instructions
52   dropAllReferences();
53   
54   // 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   
58   // do not free the MachineInstr objects allocated. they are managed
59   // by the ilist in MachineBasicBlock
60
61   // Free the CallArgsDescriptor if it exists.
62   delete callArgsDesc;
63 }