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-07-26 23:04:00 +00:00
|
|
|
const BasicBlock *currBB;
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-06-02 04:12:39 +00:00
|
|
|
// Tracks which instruction references which BasicBlock
|
2003-07-26 23:04:00 +00:00
|
|
|
std::vector<std::pair<const BasicBlock*,
|
2003-06-02 04:12:39 +00:00
|
|
|
std::pair<unsigned*,MachineInstr*> > > BBRefs;
|
|
|
|
// Tracks where each BasicBlock starts
|
2003-07-26 23:04:00 +00:00
|
|
|
std::map<const 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-07-29 20:52:56 +00:00
|
|
|
/// runOnMachineFunction - emits the given machine function to memory.
|
|
|
|
///
|
2003-05-27 21:45:05 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
2003-07-29 20:52:56 +00:00
|
|
|
|
|
|
|
/// emitWord - writes out the given 32-bit value to memory at the current PC.
|
|
|
|
///
|
2003-06-04 20:01:13 +00:00
|
|
|
void emitWord(unsigned Val);
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-07-29 20:52:56 +00:00
|
|
|
/// getBinaryCodeForInstr - This function, generated by the
|
|
|
|
/// CodeEmitterGenerator using TableGen, produces the binary encoding for
|
|
|
|
/// machine instructions.
|
2003-05-27 21:45:05 +00:00
|
|
|
///
|
2003-06-02 04:12:39 +00:00
|
|
|
unsigned getBinaryCodeForInstr(MachineInstr &MI);
|
2003-05-27 21:45:05 +00:00
|
|
|
|
2003-07-29 20:52:56 +00:00
|
|
|
/// emitFarCall - produces a code sequence to make a call to a destination
|
|
|
|
/// that does not fit in the 30 bits that a call instruction allows.
|
|
|
|
///
|
|
|
|
void emitFarCall(uint64_t Addr);
|
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
private:
|
2003-07-29 20:52:56 +00:00
|
|
|
/// getMachineOpValue -
|
|
|
|
///
|
2003-06-02 04:12:39 +00:00
|
|
|
int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
|
2003-07-29 20:52:56 +00:00
|
|
|
|
|
|
|
/// emitBasicBlock -
|
|
|
|
///
|
2003-05-27 21:45:05 +00:00
|
|
|
void emitBasicBlock(MachineBasicBlock &MBB);
|
2003-07-29 20:52:56 +00:00
|
|
|
|
|
|
|
/// getValueBit -
|
|
|
|
///
|
|
|
|
unsigned getValueBit(int64_t Val, unsigned bit);
|
|
|
|
|
|
|
|
/// getGlobalAddress -
|
|
|
|
///
|
2003-06-02 04:12:39 +00:00
|
|
|
void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
|
|
|
|
bool isPCRelative);
|
2003-07-29 20:52:56 +00:00
|
|
|
/// emitFarCall -
|
|
|
|
///
|
2003-07-14 23:26:03 +00:00
|
|
|
unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI);
|
2003-07-15 19:09:43 +00:00
|
|
|
|
2003-05-27 21:45:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|