forked from OSchip/llvm-project
detemplatize alpha code emission, it is now JIT specific.
llvm-svn: 95133
This commit is contained in:
parent
debb901045
commit
4578098b97
|
@ -28,11 +28,14 @@
|
|||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
class AlphaCodeEmitter {
|
||||
MachineCodeEmitter &MCE;
|
||||
class AlphaCodeEmitter : public MachineFunctionPass {
|
||||
JITCodeEmitter &MCE;
|
||||
const AlphaInstrInfo *II;
|
||||
public:
|
||||
AlphaCodeEmitter(MachineCodeEmitter &mce) : MCE(mce) {}
|
||||
static char ID;
|
||||
|
||||
AlphaCodeEmitter(JITCodeEmitter &mce) : MachineFunctionPass(&ID),
|
||||
MCE(mce) {}
|
||||
|
||||
/// getBinaryCodeForInstr - This function, generated by the
|
||||
/// CodeEmitterGenerator using TableGen, produces the binary encoding for
|
||||
|
@ -44,36 +47,16 @@ namespace {
|
|||
|
||||
unsigned getMachineOpValue(const MachineInstr &MI,
|
||||
const MachineOperand &MO);
|
||||
};
|
||||
|
||||
template <class CodeEmitter>
|
||||
class Emitter : public MachineFunctionPass, public AlphaCodeEmitter
|
||||
{
|
||||
const AlphaInstrInfo *II;
|
||||
TargetMachine &TM;
|
||||
CodeEmitter &MCE;
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
explicit Emitter(TargetMachine &tm, CodeEmitter &mce)
|
||||
: MachineFunctionPass(&ID), AlphaCodeEmitter(mce),
|
||||
II(0), TM(tm), MCE(mce) {}
|
||||
Emitter(TargetMachine &tm, CodeEmitter &mce, const AlphaInstrInfo& ii)
|
||||
: MachineFunctionPass(&ID), AlphaCodeEmitter(mce),
|
||||
II(&ii), TM(tm), MCE(mce) {}
|
||||
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF);
|
||||
|
||||
|
||||
virtual const char *getPassName() const {
|
||||
return "Alpha Machine Code Emitter";
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void emitBasicBlock(MachineBasicBlock &MBB);
|
||||
};
|
||||
|
||||
template <class CodeEmitter>
|
||||
char Emitter<CodeEmitter>::ID = 0;
|
||||
}
|
||||
|
||||
/// createAlphaCodeEmitterPass - Return a pass that emits the collected Alpha
|
||||
|
@ -81,11 +64,10 @@ namespace {
|
|||
|
||||
FunctionPass *llvm::createAlphaJITCodeEmitterPass(AlphaTargetMachine &TM,
|
||||
JITCodeEmitter &JCE) {
|
||||
return new Emitter<JITCodeEmitter>(TM, JCE);
|
||||
return new AlphaCodeEmitter(JCE);
|
||||
}
|
||||
|
||||
template <class CodeEmitter>
|
||||
bool Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF) {
|
||||
bool AlphaCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
|
||||
II = ((AlphaTargetMachine&)MF.getTarget()).getInstrInfo();
|
||||
|
||||
do {
|
||||
|
@ -97,8 +79,7 @@ bool Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF) {
|
|||
return false;
|
||||
}
|
||||
|
||||
template <class CodeEmitter>
|
||||
void Emitter<CodeEmitter>::emitBasicBlock(MachineBasicBlock &MBB) {
|
||||
void AlphaCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
|
||||
MCE.StartMachineBasicBlock(&MBB);
|
||||
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
|
||||
I != E; ++I) {
|
||||
|
|
Loading…
Reference in New Issue