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 // 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:
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).
20 // (2) "Implicit uses" are values used in the VM instruction but not in
21 // the machine instruction sequence
23 //===----------------------------------------------------------------------===//
25 #ifndef LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
26 #define LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
28 #include "Support/Annotation.h"
36 class CallArgsDescriptor;
38 extern AnnotationID MCFI_AID;
40 class MachineCodeForInstruction : public Annotation {
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() : Annotation(MCFI_AID), callArgsDesc(NULL) {}
46 ~MachineCodeForInstruction();
48 static MachineCodeForInstruction &get(const Instruction *I) {
50 return *(MachineCodeForInstruction*)
51 ((Annotable*)I)->getOrCreateAnnotation(MCFI_AID);
53 static void destroy(const Instruction *I) {
54 ((Annotable*)I)->deleteAnnotation(MCFI_AID);
57 // Access to underlying machine instructions...
58 typedef std::vector<MachineInstr*>::iterator iterator;
59 typedef std::vector<MachineInstr*>::const_iterator const_iterator;
61 unsigned size() const { return Contents.size(); }
62 bool empty() const { return Contents.empty(); }
63 MachineInstr *front() const { return Contents.front(); }
64 MachineInstr *back() const { return Contents.back(); }
65 MachineInstr *&operator[](unsigned i) { return Contents[i]; }
66 MachineInstr *operator[](unsigned i) const { return Contents[i]; }
67 void pop_back() { Contents.pop_back(); }
69 iterator begin() { return Contents.begin(); }
70 iterator end() { return Contents.end(); }
71 const_iterator begin() const { return Contents.begin(); }
72 const_iterator end() const { return Contents.end(); }
75 void insert(iterator where, InIt first, InIt last) {
76 Contents.insert(where, first, last);
78 iterator erase(iterator where) { return Contents.erase(where); }
79 iterator erase(iterator s, iterator e) { return Contents.erase(s, e); }
82 // dropAllReferences() - This function drops all references within
83 // temporary (hidden) instructions created in implementing the original
84 // VM intruction. This ensures there are no remaining "uses" within
85 // these hidden instructions, before the values of a method are freed.
87 void dropAllReferences();
89 const std::vector<Value*> &getTempValues() const { return tempVec; }
90 std::vector<Value*> &getTempValues() { return tempVec; }
92 MachineCodeForInstruction &addTemp(Value *tmp) {
93 tempVec.push_back(tmp);
97 void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; }
98 CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; }
101 } // End llvm namespace