blob: 213a736ff5e2a0d93a44ff34b2ed5047e3336aa0 [file] [log] [blame]
Chris Lattner919c4f82002-08-09 20:04:28 +00001//===-- llvm/CodeGen/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
28#ifndef LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
29#define LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
30
Chris Lattnercb09cc22003-01-14 21:29:58 +000031#include "Support/Annotation.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000032#include <vector>
John Criswellbe583b92003-06-11 14:01:36 +000033
Brian Gaeked0fde302003-11-11 22:41:34 +000034namespace llvm {
35
Chris Lattnerf2868ce2002-02-03 07:54:50 +000036class MachineInstr;
37class Instruction;
38class Value;
Vikram S. Advee68a3432002-10-29 19:38:46 +000039class CallArgsDescriptor;
Chris Lattnerf2868ce2002-02-03 07:54:50 +000040
Chris Lattner51a8d852002-10-28 01:21:55 +000041extern AnnotationID MCFI_AID;
42
Chris Lattner919c4f82002-08-09 20:04:28 +000043class MachineCodeForInstruction : public Annotation {
Vikram S. Advee68a3432002-10-29 19:38:46 +000044 std::vector<Value*> tempVec; // used by m/c instr but not VM instr
45 std::vector<MachineInstr*> Contents; // the machine instr for this VM instr
46 CallArgsDescriptor* callArgsDesc; // only used for CALL instructions
Chris Lattnerf2868ce2002-02-03 07:54:50 +000047public:
Vikram S. Adve601899d2002-10-30 20:38:49 +000048 MachineCodeForInstruction() : Annotation(MCFI_AID), callArgsDesc(NULL) {}
Chris Lattnerf2868ce2002-02-03 07:54:50 +000049 ~MachineCodeForInstruction();
50
Chris Lattnere85f2342004-02-29 19:02:26 +000051 static MachineCodeForInstruction &get(const Instruction *I);
52 static void destroy(const Instruction *I);
Chris Lattnerf2868ce2002-02-03 07:54:50 +000053
Chris Lattner919c4f82002-08-09 20:04:28 +000054 // Access to underlying machine instructions...
55 typedef std::vector<MachineInstr*>::iterator iterator;
56 typedef std::vector<MachineInstr*>::const_iterator const_iterator;
57
58 unsigned size() const { return Contents.size(); }
59 bool empty() const { return Contents.empty(); }
60 MachineInstr *front() const { return Contents.front(); }
61 MachineInstr *back() const { return Contents.back(); }
62 MachineInstr *&operator[](unsigned i) { return Contents[i]; }
63 MachineInstr *operator[](unsigned i) const { return Contents[i]; }
64 void pop_back() { Contents.pop_back(); }
65
66 iterator begin() { return Contents.begin(); }
67 iterator end() { return Contents.end(); }
68 const_iterator begin() const { return Contents.begin(); }
69 const_iterator end() const { return Contents.end(); }
70
71 template<class InIt>
72 void insert(iterator where, InIt first, InIt last) {
73 Contents.insert(where, first, last);
74 }
75 iterator erase(iterator where) { return Contents.erase(where); }
76 iterator erase(iterator s, iterator e) { return Contents.erase(s, e); }
77
78
Vikram S. Advedfe412d2002-03-24 03:58:02 +000079 // dropAllReferences() - This function drops all references within
80 // temporary (hidden) instructions created in implementing the original
81 // VM intruction. This ensures there are no remaining "uses" within
82 // these hidden instructions, before the values of a method are freed.
83 //
84 void dropAllReferences();
85
Chris Lattnerf2868ce2002-02-03 07:54:50 +000086 const std::vector<Value*> &getTempValues() const { return tempVec; }
87 std::vector<Value*> &getTempValues() { return tempVec; }
88
Chris Lattner919c4f82002-08-09 20:04:28 +000089 MachineCodeForInstruction &addTemp(Value *tmp) {
Chris Lattnerf2868ce2002-02-03 07:54:50 +000090 tempVec.push_back(tmp);
91 return *this;
92 }
Vikram S. Advee68a3432002-10-29 19:38:46 +000093
94 void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; }
95 CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; }
Chris Lattnerf2868ce2002-02-03 07:54:50 +000096};
97
Brian Gaeked0fde302003-11-11 22:41:34 +000098} // End llvm namespace
99
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000100#endif