llvm-6502/lib/Target/SparcV9/SparcV9CodeEmitter.h
Misha Brukman 0897c60822 SparcV9CodeEmitter.cpp:
* Doxygen-ified comments
* Added capability to make far calls (i.e., beyond 30 bits in CALL instr)
  which implies that we need to delete function references that were added by
  the call to addFunctionReference() because the actual call instruction is 10
  instructions away (thanks to 64-bit address construction)
* Cleaned up code that generates far jumps by using an array+loop

SparcV9CodeEmitter.h:
* Explained more of the side-effects of emitFarCall()


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7639 91177308-0d34-0410-b5e6-96231b3b80d8
2003-08-06 16:20:22 +00:00

81 lines
2.4 KiB
C++

//===-- SparcV9CodeEmitter.h ------------------------------------*- C++ -*-===//
//
//
//===----------------------------------------------------------------------===//
#ifndef SPARCV9CODEEMITTER_H
#define SPARCV9CODEEMITTER_H
#include "llvm/BasicBlock.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Target/TargetMachine.h"
class GlobalValue;
class MachineInstr;
class MachineOperand;
class SparcV9CodeEmitter : public MachineFunctionPass {
TargetMachine &TM;
MachineCodeEmitter &MCE;
const BasicBlock *currBB;
// Tracks which instruction references which BasicBlock
std::vector<std::pair<const BasicBlock*,
std::pair<unsigned*,MachineInstr*> > > BBRefs;
// Tracks where each BasicBlock starts
std::map<const BasicBlock*, long> BBLocations;
// Tracks locations of Constants which are laid out in memory (e.g. FP)
// But we also need to map Constants to ConstantPool indices
std::map<const Constant*, unsigned> ConstantMap;
public:
SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M);
~SparcV9CodeEmitter();
/// runOnMachineFunction - emits the given machine function to memory.
///
bool runOnMachineFunction(MachineFunction &F);
/// emitWord - writes out the given 32-bit value to memory at the current PC.
///
void emitWord(unsigned Val);
/// getBinaryCodeForInstr - This function, generated by the
/// CodeEmitterGenerator using TableGen, produces the binary encoding for
/// machine instructions.
///
unsigned getBinaryCodeForInstr(MachineInstr &MI);
/// 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.
/// If the function F is non-null, this also saves the return address in
/// the LazyResolver map of the JITResolver.
void emitFarCall(uint64_t Addr, Function *F = 0);
private:
/// getMachineOpValue -
///
int64_t getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
/// emitBasicBlock -
///
void emitBasicBlock(MachineBasicBlock &MBB);
/// getValueBit -
///
unsigned getValueBit(int64_t Val, unsigned bit);
/// getGlobalAddress -
///
void* getGlobalAddress(GlobalValue *V, MachineInstr &MI,
bool isPCRelative);
/// emitFarCall -
///
unsigned getRealRegNum(unsigned fakeReg, MachineInstr &MI);
};
#endif