1 //===-- llvm/CodeGen/MachineCodeForInstruction.h ----------------*- C++ -*-===//
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:
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).
13 // (2) "Implicit uses" are values used in the VM instruction but not in
14 // the machine instruction sequence
16 //===----------------------------------------------------------------------===//
18 #ifndef LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
19 #define LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
21 #include "Support/Annotation.h"
28 class CallArgsDescriptor;
30 extern AnnotationID MCFI_AID;
32 class MachineCodeForInstruction : public Annotation {
33 std::vector<Value*> tempVec; // used by m/c instr but not VM instr
34 std::vector<MachineInstr*> Contents; // the machine instr for this VM instr
35 CallArgsDescriptor* callArgsDesc; // only used for CALL instructions
37 MachineCodeForInstruction() : Annotation(MCFI_AID), callArgsDesc(NULL) {}
38 ~MachineCodeForInstruction();
40 static MachineCodeForInstruction &get(const Instruction *I) {
42 return *(MachineCodeForInstruction*)
43 ((Annotable*)I)->getOrCreateAnnotation(MCFI_AID);
45 static void destroy(const Instruction *I) {
46 ((Annotable*)I)->deleteAnnotation(MCFI_AID);
49 // Access to underlying machine instructions...
50 typedef std::vector<MachineInstr*>::iterator iterator;
51 typedef std::vector<MachineInstr*>::const_iterator const_iterator;
53 unsigned size() const { return Contents.size(); }
54 bool empty() const { return Contents.empty(); }
55 MachineInstr *front() const { return Contents.front(); }
56 MachineInstr *back() const { return Contents.back(); }
57 MachineInstr *&operator[](unsigned i) { return Contents[i]; }
58 MachineInstr *operator[](unsigned i) const { return Contents[i]; }
59 void pop_back() { Contents.pop_back(); }
61 iterator begin() { return Contents.begin(); }
62 iterator end() { return Contents.end(); }
63 const_iterator begin() const { return Contents.begin(); }
64 const_iterator end() const { return Contents.end(); }
67 void insert(iterator where, InIt first, InIt last) {
68 Contents.insert(where, first, last);
70 iterator erase(iterator where) { return Contents.erase(where); }
71 iterator erase(iterator s, iterator e) { return Contents.erase(s, e); }
74 // dropAllReferences() - This function drops all references within
75 // temporary (hidden) instructions created in implementing the original
76 // VM intruction. This ensures there are no remaining "uses" within
77 // these hidden instructions, before the values of a method are freed.
79 void dropAllReferences();
81 const std::vector<Value*> &getTempValues() const { return tempVec; }
82 std::vector<Value*> &getTempValues() { return tempVec; }
84 MachineCodeForInstruction &addTemp(Value *tmp) {
85 tempVec.push_back(tmp);
89 void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; }
90 CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; }