Chris Lattner | 85015a0 | 2004-08-16 21:55:02 +0000 | [diff] [blame] | 1 | //===-- MachineCodeForInstruction.h -----------------------------*- C++ -*-===// |
John Criswell | 6fbcc26 | 2003-10-20 20:19:47 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 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. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 9 | // |
Chris Lattner | 159286d | 2004-06-27 18:21:20 +0000 | [diff] [blame] | 10 | // FIXME: This file is SparcV9 specific. Do not rely on this class for new |
| 11 | // targets, it will go away in the future. |
| 12 | // |
Chris Lattner | 919c4f8 | 2002-08-09 20:04:28 +0000 | [diff] [blame] | 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: |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 17 | // |
Chris Lattner | 919c4f8 | 2002-08-09 20:04:28 +0000 | [diff] [blame] | 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). |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 22 | // |
Chris Lattner | 919c4f8 | 2002-08-09 20:04:28 +0000 | [diff] [blame] | 23 | // (2) "Implicit uses" are values used in the VM instruction but not in |
| 24 | // the machine instruction sequence |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 25 | // |
| 26 | //===----------------------------------------------------------------------===// |
| 27 | |
Chris Lattner | 85015a0 | 2004-08-16 21:55:02 +0000 | [diff] [blame] | 28 | #ifndef MACHINECODE_FOR_INSTRUCTION_H |
| 29 | #define MACHINECODE_FOR_INSTRUCTION_H |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 30 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 31 | #include <vector> |
John Criswell | be583b9 | 2003-06-11 14:01:36 +0000 | [diff] [blame] | 32 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 33 | namespace llvm { |
| 34 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 35 | class MachineInstr; |
| 36 | class Instruction; |
| 37 | class Value; |
Vikram S. Adve | e68a343 | 2002-10-29 19:38:46 +0000 | [diff] [blame] | 38 | class CallArgsDescriptor; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 39 | |
Chris Lattner | ea104df | 2004-06-27 18:50:49 +0000 | [diff] [blame] | 40 | class MachineCodeForInstruction { |
Vikram S. Adve | e68a343 | 2002-10-29 19:38:46 +0000 | [diff] [blame] | 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 |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 44 | public: |
Chris Lattner | ea104df | 2004-06-27 18:50:49 +0000 | [diff] [blame] | 45 | MachineCodeForInstruction() : callArgsDesc(NULL) {} |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 46 | ~MachineCodeForInstruction(); |
| 47 | |
Chris Lattner | e85f234 | 2004-02-29 19:02:26 +0000 | [diff] [blame] | 48 | static MachineCodeForInstruction &get(const Instruction *I); |
| 49 | static void destroy(const Instruction *I); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 50 | |
Chris Lattner | 919c4f8 | 2002-08-09 20:04:28 +0000 | [diff] [blame] | 51 | // Access to underlying machine instructions... |
| 52 | typedef std::vector<MachineInstr*>::iterator iterator; |
| 53 | typedef std::vector<MachineInstr*>::const_iterator const_iterator; |
| 54 | |
| 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(); } |
| 62 | |
| 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(); } |
| 67 | |
| 68 | template<class InIt> |
| 69 | void insert(iterator where, InIt first, InIt last) { |
| 70 | Contents.insert(where, first, last); |
| 71 | } |
| 72 | iterator erase(iterator where) { return Contents.erase(where); } |
| 73 | iterator erase(iterator s, iterator e) { return Contents.erase(s, e); } |
| 74 | |
| 75 | |
Vikram S. Adve | dfe412d | 2002-03-24 03:58:02 +0000 | [diff] [blame] | 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. |
| 80 | // |
| 81 | void dropAllReferences(); |
| 82 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 83 | const std::vector<Value*> &getTempValues() const { return tempVec; } |
| 84 | std::vector<Value*> &getTempValues() { return tempVec; } |
| 85 | |
Chris Lattner | 919c4f8 | 2002-08-09 20:04:28 +0000 | [diff] [blame] | 86 | MachineCodeForInstruction &addTemp(Value *tmp) { |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 87 | tempVec.push_back(tmp); |
| 88 | return *this; |
| 89 | } |
Vikram S. Adve | e68a343 | 2002-10-29 19:38:46 +0000 | [diff] [blame] | 90 | |
| 91 | void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; } |
| 92 | CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; } |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 95 | } // End llvm namespace |
| 96 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 97 | #endif |