blob: fc36267cb9e75a5fc27b6cd498f20e6043f01286 [file] [log] [blame]
Chris Lattner85015a02004-08-16 21:55:02 +00001//===-- MachineCodeForInstruction.h -----------------------------*- C++ -*-===//
John Criswell6fbcc262003-10-20 20:19:47 +00002//
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 Lattnerf2868ce2002-02-03 07:54:50 +00009//
Chris Lattner159286d2004-06-27 18:21:20 +000010// 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 Lattner919c4f82002-08-09 20:04:28 +000013// 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 Lattnerf2868ce2002-02-03 07:54:50 +000017//
Chris Lattner919c4f82002-08-09 20:04:28 +000018// "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 Lattnerf2868ce2002-02-03 07:54:50 +000022//
Chris Lattner919c4f82002-08-09 20:04:28 +000023// (2) "Implicit uses" are values used in the VM instruction but not in
24// the machine instruction sequence
Chris Lattnerf2868ce2002-02-03 07:54:50 +000025//
26//===----------------------------------------------------------------------===//
27
Chris Lattner85015a02004-08-16 21:55:02 +000028#ifndef MACHINECODE_FOR_INSTRUCTION_H
29#define MACHINECODE_FOR_INSTRUCTION_H
Chris Lattnerf2868ce2002-02-03 07:54:50 +000030
Chris Lattnerf2868ce2002-02-03 07:54:50 +000031#include <vector>
John Criswellbe583b92003-06-11 14:01:36 +000032
Brian Gaeked0fde302003-11-11 22:41:34 +000033namespace llvm {
34
Chris Lattnerf2868ce2002-02-03 07:54:50 +000035class MachineInstr;
36class Instruction;
37class Value;
Vikram S. Advee68a3432002-10-29 19:38:46 +000038class CallArgsDescriptor;
Chris Lattnerf2868ce2002-02-03 07:54:50 +000039
Chris Lattnerea104df2004-06-27 18:50:49 +000040 class MachineCodeForInstruction {
Vikram S. Advee68a3432002-10-29 19:38:46 +000041 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 Lattnerf2868ce2002-02-03 07:54:50 +000044public:
Chris Lattnerea104df2004-06-27 18:50:49 +000045 MachineCodeForInstruction() : callArgsDesc(NULL) {}
Chris Lattnerf2868ce2002-02-03 07:54:50 +000046 ~MachineCodeForInstruction();
47
Chris Lattnere85f2342004-02-29 19:02:26 +000048 static MachineCodeForInstruction &get(const Instruction *I);
49 static void destroy(const Instruction *I);
Chris Lattnerf2868ce2002-02-03 07:54:50 +000050
Chris Lattner919c4f82002-08-09 20:04:28 +000051 // 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. Advedfe412d2002-03-24 03:58:02 +000076 // 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 Lattnerf2868ce2002-02-03 07:54:50 +000083 const std::vector<Value*> &getTempValues() const { return tempVec; }
84 std::vector<Value*> &getTempValues() { return tempVec; }
85
Chris Lattner919c4f82002-08-09 20:04:28 +000086 MachineCodeForInstruction &addTemp(Value *tmp) {
Chris Lattnerf2868ce2002-02-03 07:54:50 +000087 tempVec.push_back(tmp);
88 return *this;
89 }
Vikram S. Advee68a3432002-10-29 19:38:46 +000090
91 void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; }
92 CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; }
Chris Lattnerf2868ce2002-02-03 07:54:50 +000093};
94
Brian Gaeked0fde302003-11-11 22:41:34 +000095} // End llvm namespace
96
Chris Lattnerf2868ce2002-02-03 07:54:50 +000097#endif