LLVM API Documentation
00001 //===-- MachineCodeForInstruction.h -----------------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // FIXME: This file is SparcV9 specific. Do not rely on this class for new 00011 // targets, it will go away in the future. 00012 // 00013 // Representation of the sequence of machine instructions created for a single 00014 // VM instruction. Additionally records information about hidden and implicit 00015 // values used by the machine instructions: about hidden values used by the 00016 // machine instructions: 00017 // 00018 // "Temporary values" are intermediate values used in the machine instruction 00019 // sequence, but not in the VM instruction Note that such values should be 00020 // treated as pure SSA values with no interpretation of their operands (i.e., as 00021 // a TmpInstruction object which actually represents such a value). 00022 // 00023 // (2) "Implicit uses" are values used in the VM instruction but not in 00024 // the machine instruction sequence 00025 // 00026 //===----------------------------------------------------------------------===// 00027 00028 #ifndef MACHINECODE_FOR_INSTRUCTION_H 00029 #define MACHINECODE_FOR_INSTRUCTION_H 00030 00031 #include <vector> 00032 00033 namespace llvm { 00034 00035 class MachineInstr; 00036 class Instruction; 00037 class Value; 00038 class CallArgsDescriptor; 00039 00040 class MachineCodeForInstruction { 00041 std::vector<Value*> tempVec; // used by m/c instr but not VM instr 00042 std::vector<MachineInstr*> Contents; // the machine instr for this VM instr 00043 CallArgsDescriptor* callArgsDesc; // only used for CALL instructions 00044 public: 00045 MachineCodeForInstruction() : callArgsDesc(NULL) {} 00046 ~MachineCodeForInstruction(); 00047 00048 static MachineCodeForInstruction &get(const Instruction *I); 00049 static void destroy(const Instruction *I); 00050 00051 // Access to underlying machine instructions... 00052 typedef std::vector<MachineInstr*>::iterator iterator; 00053 typedef std::vector<MachineInstr*>::const_iterator const_iterator; 00054 00055 unsigned size() const { return Contents.size(); } 00056 bool empty() const { return Contents.empty(); } 00057 MachineInstr *front() const { return Contents.front(); } 00058 MachineInstr *back() const { return Contents.back(); } 00059 MachineInstr *&operator[](unsigned i) { return Contents[i]; } 00060 MachineInstr *operator[](unsigned i) const { return Contents[i]; } 00061 void pop_back() { Contents.pop_back(); } 00062 00063 iterator begin() { return Contents.begin(); } 00064 iterator end() { return Contents.end(); } 00065 const_iterator begin() const { return Contents.begin(); } 00066 const_iterator end() const { return Contents.end(); } 00067 00068 template<class InIt> 00069 void insert(iterator where, InIt first, InIt last) { 00070 Contents.insert(where, first, last); 00071 } 00072 iterator erase(iterator where) { return Contents.erase(where); } 00073 iterator erase(iterator s, iterator e) { return Contents.erase(s, e); } 00074 00075 00076 // dropAllReferences() - This function drops all references within 00077 // temporary (hidden) instructions created in implementing the original 00078 // VM intruction. This ensures there are no remaining "uses" within 00079 // these hidden instructions, before the values of a method are freed. 00080 // 00081 void dropAllReferences(); 00082 00083 const std::vector<Value*> &getTempValues() const { return tempVec; } 00084 std::vector<Value*> &getTempValues() { return tempVec; } 00085 00086 MachineCodeForInstruction &addTemp(Value *tmp) { 00087 tempVec.push_back(tmp); 00088 return *this; 00089 } 00090 00091 void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; } 00092 CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; } 00093 }; 00094 00095 } // End llvm namespace 00096 00097 #endif