Change machinecode for instruction to not inherit from vector.
[oota-llvm.git] / lib / Target / SparcV9 / MachineCodeForInstruction.h
1 //===-- llvm/CodeGen/MachineCodeForInstruction.h ----------------*- C++ -*-===//
2 //
3 // Representation of the sequence of machine instructions created for a single
4 // VM instruction.  Additionally records information about hidden and implicit
5 // values used by the machine instructions: about hidden values used by the
6 // machine instructions:
7 // 
8 // "Temporary values" are intermediate values used in the machine instruction
9 // sequence, but not in the VM instruction Note that such values should be
10 // treated as pure SSA values with no interpretation of their operands (i.e., as
11 // a TmpInstruction object which actually represents such a value).
12 // 
13 // (2) "Implicit uses" are values used in the VM instruction but not in
14 //     the machine instruction sequence
15 // 
16 //===----------------------------------------------------------------------===//
17
18 #ifndef LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
19 #define LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
20
21 #include "llvm/Annotation.h"
22 #include <vector>
23 class MachineInstr;
24 class Instruction;
25 class Value;
26
27 class MachineCodeForInstruction : public Annotation {
28   std::vector<Value*> tempVec;         // used by m/c instr but not VM instr
29   std::vector<MachineInstr*> Contents;
30 public:
31   MachineCodeForInstruction();
32   ~MachineCodeForInstruction();
33   
34   static MachineCodeForInstruction &get(const Instruction *I);
35   static void destroy(const Instruction *I);
36
37   // Access to underlying machine instructions...
38   typedef std::vector<MachineInstr*>::iterator iterator;
39   typedef std::vector<MachineInstr*>::const_iterator const_iterator;
40
41   unsigned size() const { return Contents.size(); }
42   bool empty() const { return Contents.empty(); }
43   MachineInstr *front() const { return Contents.front(); }
44   MachineInstr *back() const { return Contents.back(); }
45   MachineInstr *&operator[](unsigned i) { return Contents[i]; }
46   MachineInstr *operator[](unsigned i) const { return Contents[i]; }
47   void pop_back() { Contents.pop_back(); }
48
49   iterator begin() { return Contents.begin(); }
50   iterator end()   { return Contents.end(); }
51   const_iterator begin() const { return Contents.begin(); }
52   const_iterator end()   const { return Contents.end(); }
53
54   template<class InIt>
55   void insert(iterator where, InIt first, InIt last) {
56     Contents.insert(where, first, last);
57   }
58   iterator erase(iterator where) { return Contents.erase(where); }
59   iterator erase(iterator s, iterator e) { return Contents.erase(s, e); }
60   
61
62   // dropAllReferences() - This function drops all references within
63   // temporary (hidden) instructions created in implementing the original
64   // VM intruction.  This ensures there are no remaining "uses" within
65   // these hidden instructions, before the values of a method are freed.
66   //
67   void dropAllReferences();
68
69   const std::vector<Value*> &getTempValues() const { return tempVec; }
70         std::vector<Value*> &getTempValues()       { return tempVec; }
71   
72   MachineCodeForInstruction &addTemp(Value *tmp) {
73     tempVec.push_back(tmp);
74     return *this;
75   }
76 };
77
78 #endif