1 //===-- llvm/CodeGen/MachineCodeForInstruction.h ----------------*- C++ -*-===//
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 // FIXME: This file is SparcV9 specific. Do not rely on this class for new
11 // targets, it will go away in the future.
13 // Representation of the sequence of machine instructions created for a single
14 // VM instruction. Additionally records information about hidden and implicit
15 // values used by the machine instructions: about hidden values used by the
16 // machine instructions:
18 // "Temporary values" are intermediate values used in the machine instruction
19 // sequence, but not in the VM instruction Note that such values should be
20 // treated as pure SSA values with no interpretation of their operands (i.e., as
21 // a TmpInstruction object which actually represents such a value).
23 // (2) "Implicit uses" are values used in the VM instruction but not in
24 // the machine instruction sequence
26 //===----------------------------------------------------------------------===//
28 #ifndef LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
29 #define LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
38 class CallArgsDescriptor;
40 class MachineCodeForInstruction {
41 std::vector<Value*> tempVec; // used by m/c instr but not VM instr
42 std::vector<MachineInstr*> Contents; // the machine instr for this VM instr
43 CallArgsDescriptor* callArgsDesc; // only used for CALL instructions
45 MachineCodeForInstruction() : callArgsDesc(NULL) {}
46 ~MachineCodeForInstruction();
48 static MachineCodeForInstruction &get(const Instruction *I);
49 static void destroy(const Instruction *I);
51 // Access to underlying machine instructions...
52 typedef std::vector<MachineInstr*>::iterator iterator;
53 typedef std::vector<MachineInstr*>::const_iterator const_iterator;
55 unsigned size() const { return Contents.size(); }
56 bool empty() const { return Contents.empty(); }
57 MachineInstr *front() const { return Contents.front(); }
58 MachineInstr *back() const { return Contents.back(); }
59 MachineInstr *&operator[](unsigned i) { return Contents[i]; }
60 MachineInstr *operator[](unsigned i) const { return Contents[i]; }
61 void pop_back() { Contents.pop_back(); }
63 iterator begin() { return Contents.begin(); }
64 iterator end() { return Contents.end(); }
65 const_iterator begin() const { return Contents.begin(); }
66 const_iterator end() const { return Contents.end(); }
69 void insert(iterator where, InIt first, InIt last) {
70 Contents.insert(where, first, last);
72 iterator erase(iterator where) { return Contents.erase(where); }
73 iterator erase(iterator s, iterator e) { return Contents.erase(s, e); }
76 // dropAllReferences() - This function drops all references within
77 // temporary (hidden) instructions created in implementing the original
78 // VM intruction. This ensures there are no remaining "uses" within
79 // these hidden instructions, before the values of a method are freed.
81 void dropAllReferences();
83 const std::vector<Value*> &getTempValues() const { return tempVec; }
84 std::vector<Value*> &getTempValues() { return tempVec; }
86 MachineCodeForInstruction &addTemp(Value *tmp) {
87 tempVec.push_back(tmp);
91 void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; }
92 CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; }
95 } // End llvm namespace