2002-08-09 20:04:28 +00:00
|
|
|
//===-- llvm/CodeGen/MachineCodeForInstruction.h ----------------*- C++ -*-===//
|
2002-02-03 07:54:50 +00:00
|
|
|
//
|
2002-08-09 20:04:28 +00:00
|
|
|
// Representation of the sequence of machine instructions created for a single
|
|
|
|
// VM instruction. Additionally records information about hidden and implicit
|
|
|
|
// values used by the machine instructions: about hidden values used by the
|
|
|
|
// machine instructions:
|
2002-02-03 07:54:50 +00:00
|
|
|
//
|
2002-08-09 20:04:28 +00:00
|
|
|
// "Temporary values" are intermediate values used in the machine instruction
|
|
|
|
// sequence, but not in the VM instruction Note that such values should be
|
|
|
|
// treated as pure SSA values with no interpretation of their operands (i.e., as
|
|
|
|
// a TmpInstruction object which actually represents such a value).
|
2002-02-03 07:54:50 +00:00
|
|
|
//
|
2002-08-09 20:04:28 +00:00
|
|
|
// (2) "Implicit uses" are values used in the VM instruction but not in
|
|
|
|
// the machine instruction sequence
|
2002-02-03 07:54:50 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
|
|
|
|
#define LLVM_CODEGEN_MACHINECODE_FOR_INSTRUCTION_H
|
|
|
|
|
2003-01-14 21:29:58 +00:00
|
|
|
#include "Support/Annotation.h"
|
2002-02-03 07:54:50 +00:00
|
|
|
#include <vector>
|
2003-06-11 14:01:36 +00:00
|
|
|
|
2002-02-03 07:54:50 +00:00
|
|
|
class MachineInstr;
|
|
|
|
class Instruction;
|
|
|
|
class Value;
|
2002-10-29 19:38:46 +00:00
|
|
|
class CallArgsDescriptor;
|
2002-02-03 07:54:50 +00:00
|
|
|
|
2002-10-28 01:21:55 +00:00
|
|
|
extern AnnotationID MCFI_AID;
|
|
|
|
|
2002-08-09 20:04:28 +00:00
|
|
|
class MachineCodeForInstruction : public Annotation {
|
2002-10-29 19:38:46 +00:00
|
|
|
std::vector<Value*> tempVec; // used by m/c instr but not VM instr
|
|
|
|
std::vector<MachineInstr*> Contents; // the machine instr for this VM instr
|
|
|
|
CallArgsDescriptor* callArgsDesc; // only used for CALL instructions
|
2002-02-03 07:54:50 +00:00
|
|
|
public:
|
2002-10-30 20:38:49 +00:00
|
|
|
MachineCodeForInstruction() : Annotation(MCFI_AID), callArgsDesc(NULL) {}
|
2002-02-03 07:54:50 +00:00
|
|
|
~MachineCodeForInstruction();
|
|
|
|
|
2002-10-28 01:21:55 +00:00
|
|
|
static MachineCodeForInstruction &get(const Instruction *I) {
|
|
|
|
assert(I != NULL);
|
2002-10-28 01:27:30 +00:00
|
|
|
return *(MachineCodeForInstruction*)
|
|
|
|
((Annotable*)I)->getOrCreateAnnotation(MCFI_AID);
|
2002-10-28 01:21:55 +00:00
|
|
|
}
|
|
|
|
static void destroy(const Instruction *I) {
|
2002-10-28 01:27:30 +00:00
|
|
|
((Annotable*)I)->deleteAnnotation(MCFI_AID);
|
2002-10-28 01:21:55 +00:00
|
|
|
}
|
2002-02-03 07:54:50 +00:00
|
|
|
|
2002-08-09 20:04:28 +00:00
|
|
|
// Access to underlying machine instructions...
|
|
|
|
typedef std::vector<MachineInstr*>::iterator iterator;
|
|
|
|
typedef std::vector<MachineInstr*>::const_iterator const_iterator;
|
|
|
|
|
|
|
|
unsigned size() const { return Contents.size(); }
|
|
|
|
bool empty() const { return Contents.empty(); }
|
|
|
|
MachineInstr *front() const { return Contents.front(); }
|
|
|
|
MachineInstr *back() const { return Contents.back(); }
|
|
|
|
MachineInstr *&operator[](unsigned i) { return Contents[i]; }
|
|
|
|
MachineInstr *operator[](unsigned i) const { return Contents[i]; }
|
|
|
|
void pop_back() { Contents.pop_back(); }
|
|
|
|
|
|
|
|
iterator begin() { return Contents.begin(); }
|
|
|
|
iterator end() { return Contents.end(); }
|
|
|
|
const_iterator begin() const { return Contents.begin(); }
|
|
|
|
const_iterator end() const { return Contents.end(); }
|
|
|
|
|
|
|
|
template<class InIt>
|
|
|
|
void insert(iterator where, InIt first, InIt last) {
|
|
|
|
Contents.insert(where, first, last);
|
|
|
|
}
|
|
|
|
iterator erase(iterator where) { return Contents.erase(where); }
|
|
|
|
iterator erase(iterator s, iterator e) { return Contents.erase(s, e); }
|
|
|
|
|
|
|
|
|
2002-03-24 03:58:02 +00:00
|
|
|
// dropAllReferences() - This function drops all references within
|
|
|
|
// temporary (hidden) instructions created in implementing the original
|
|
|
|
// VM intruction. This ensures there are no remaining "uses" within
|
|
|
|
// these hidden instructions, before the values of a method are freed.
|
|
|
|
//
|
|
|
|
void dropAllReferences();
|
|
|
|
|
2002-02-03 07:54:50 +00:00
|
|
|
const std::vector<Value*> &getTempValues() const { return tempVec; }
|
|
|
|
std::vector<Value*> &getTempValues() { return tempVec; }
|
|
|
|
|
2002-08-09 20:04:28 +00:00
|
|
|
MachineCodeForInstruction &addTemp(Value *tmp) {
|
2002-02-03 07:54:50 +00:00
|
|
|
tempVec.push_back(tmp);
|
|
|
|
return *this;
|
|
|
|
}
|
2002-10-29 19:38:46 +00:00
|
|
|
|
|
|
|
void setCallArgsDescriptor(CallArgsDescriptor* desc) { callArgsDesc = desc; }
|
|
|
|
CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; }
|
2002-02-03 07:54:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|