2003-05-30 20:17:33 +00:00
|
|
|
//===-- SparcV9CodeEmitter.h ------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-05-27 21:45:05 +00:00
|
|
|
|
|
|
|
#ifndef SPARCV9CODEEMITTER_H
|
|
|
|
#define SPARCV9CODEEMITTER_H
|
|
|
|
|
2003-05-27 22:41:44 +00:00
|
|
|
#include "llvm/BasicBlock.h"
|
2003-05-27 21:45:05 +00:00
|
|
|
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2003-05-30 20:17:33 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-06-02 04:12:39 +00:00
|
|
|
class GlobalValue;
|
|
|
|
class MachineInstr;
|
|
|
|
class MachineOperand;
|
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
class SparcV9CodeEmitter : public MachineFunctionPass {
|
2003-06-04 20:01:13 +00:00
|
|
|
TargetMachine &TM;
|
|
|
|
MachineCodeEmitter &MCE;
|
2003-05-27 22:48:28 +00:00
|
|
|
BasicBlock *currBB;
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-06-02 04:12:39 +00:00
|
|
|
// Tracks which instruction references which BasicBlock
|
|
|
|
std::vector<std::pair<BasicBlock*,
|
|
|
|
std::pair<unsigned*,MachineInstr*> > > BBRefs;
|
|
|
|
// Tracks where each BasicBlock starts
|
|
|
|
std::map<BasicBlock*, long> BBLocations;
|
2003-06-04 20:01:13 +00:00
|
|
|
|
2003-06-02 04:12:39 +00:00
|
|
|
// Tracks locations of Constants which are laid out in memory (e.g. FP)
|
2003-06-04 20:01:13 +00:00
|
|
|
// But we also need to map Constants to ConstantPool indices
|
|
|
|
std::map<const Constant*, unsigned> ConstantMap;
|
2003-06-02 04:12:39 +00:00
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
public:
|
2003-06-04 20:01:13 +00:00
|
|
|
SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M);
|
|
|
|
~SparcV9CodeEmitter();
|
2003-05-30 20:17:33 +00:00
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
2003-06-04 20:01:13 +00:00
|
|
|
void emitWord(unsigned Val);
|
2003-05-27 21:45:05 +00:00
|
|
|
|
|
|
|
/// Function generated by the CodeEmitterGenerator using TableGen
|
|
|
|
///
|
2003-06-02 04:12:39 +00:00
|
|
|
unsigned getBinaryCodeForInstr(MachineInstr &MI);
|
2003-05-27 21:45:05 +00:00
|
|
|
|
|
|
|
private:
|
2003-06-02 04:12:39 +00:00
|
|
|
int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
|
2003-07-03 18:36:47 +00:00
|
|
|
inline unsigned getValueBit(int64_t Val, unsigned bit);
|
2003-05-27 21:45:05 +00:00
|
|
|
void emitBasicBlock(MachineBasicBlock &MBB);
|
2003-06-02 04:12:39 +00:00
|
|
|
void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
|
|
|
|
bool isPCRelative);
|
2003-07-14 23:26:03 +00:00
|
|
|
unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI);
|
2003-07-15 19:09:43 +00:00
|
|
|
inline void emitFarCall(uint64_t Addr);
|
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|