mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-16 23:38:40 +00:00
detemplatize the ppc code emitter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95142 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5335bce43d
commit
fc89bc903c
@ -17,26 +17,34 @@
|
|||||||
#include "PPC.h"
|
#include "PPC.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
|
||||||
#include "llvm/CodeGen/JITCodeEmitter.h"
|
#include "llvm/CodeGen/JITCodeEmitter.h"
|
||||||
#include "llvm/CodeGen/ObjectCodeEmitter.h"
|
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
|
||||||
#include "llvm/Support/Debug.h"
|
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class PPCCodeEmitter {
|
class PPCCodeEmitter : public MachineFunctionPass {
|
||||||
TargetMachine &TM;
|
TargetMachine &TM;
|
||||||
MachineCodeEmitter &MCE;
|
JITCodeEmitter &MCE;
|
||||||
|
|
||||||
|
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
|
AU.addRequired<MachineModuleInfo>();
|
||||||
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char ID;
|
||||||
|
|
||||||
|
/// MovePCtoLROffset - When/if we see a MovePCtoLR instruction, we record
|
||||||
|
/// its address in the function into this pointer.
|
||||||
|
void *MovePCtoLROffset;
|
||||||
public:
|
public:
|
||||||
PPCCodeEmitter(TargetMachine &tm, MachineCodeEmitter &mce):
|
|
||||||
TM(tm), MCE(mce) {}
|
PPCCodeEmitter(TargetMachine &tm, JITCodeEmitter &mce)
|
||||||
|
: MachineFunctionPass(&ID), TM(tm), MCE(mce) {}
|
||||||
|
|
||||||
/// getBinaryCodeForInstr - This function, generated by the
|
/// getBinaryCodeForInstr - This function, generated by the
|
||||||
/// CodeEmitterGenerator using TableGen, produces the binary encoding for
|
/// CodeEmitterGenerator using TableGen, produces the binary encoding for
|
||||||
@ -49,27 +57,6 @@ namespace {
|
|||||||
unsigned getMachineOpValue(const MachineInstr &MI,
|
unsigned getMachineOpValue(const MachineInstr &MI,
|
||||||
const MachineOperand &MO);
|
const MachineOperand &MO);
|
||||||
|
|
||||||
/// MovePCtoLROffset - When/if we see a MovePCtoLR instruction, we record
|
|
||||||
/// its address in the function into this pointer.
|
|
||||||
|
|
||||||
void *MovePCtoLROffset;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class CodeEmitter>
|
|
||||||
class Emitter : public MachineFunctionPass, public PPCCodeEmitter {
|
|
||||||
TargetMachine &TM;
|
|
||||||
CodeEmitter &MCE;
|
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
||||||
AU.addRequired<MachineModuleInfo>();
|
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
static char ID;
|
|
||||||
Emitter(TargetMachine &tm, CodeEmitter &mce)
|
|
||||||
: MachineFunctionPass(&ID), PPCCodeEmitter(tm, mce), TM(tm), MCE(mce) {}
|
|
||||||
|
|
||||||
const char *getPassName() const { return "PowerPC Machine Code Emitter"; }
|
const char *getPassName() const { return "PowerPC Machine Code Emitter"; }
|
||||||
|
|
||||||
/// runOnMachineFunction - emits the given MachineFunction to memory
|
/// runOnMachineFunction - emits the given MachineFunction to memory
|
||||||
@ -84,20 +71,18 @@ namespace {
|
|||||||
///
|
///
|
||||||
unsigned getValueBit(int64_t Val, unsigned bit) { return (Val >> bit) & 1; }
|
unsigned getValueBit(int64_t Val, unsigned bit) { return (Val >> bit) & 1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class CodeEmitter>
|
|
||||||
char Emitter<CodeEmitter>::ID = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char PPCCodeEmitter::ID = 0;
|
||||||
|
|
||||||
/// createPPCCodeEmitterPass - Return a pass that emits the collected PPC code
|
/// createPPCCodeEmitterPass - Return a pass that emits the collected PPC code
|
||||||
/// to the specified MCE object.
|
/// to the specified MCE object.
|
||||||
FunctionPass *llvm::createPPCJITCodeEmitterPass(PPCTargetMachine &TM,
|
FunctionPass *llvm::createPPCJITCodeEmitterPass(PPCTargetMachine &TM,
|
||||||
JITCodeEmitter &JCE) {
|
JITCodeEmitter &JCE) {
|
||||||
return new Emitter<JITCodeEmitter>(TM, JCE);
|
return new PPCCodeEmitter(TM, JCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class CodeEmitter>
|
bool PPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
bool Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF) {
|
|
||||||
assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
|
assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
|
||||||
MF.getTarget().getRelocationModel() != Reloc::Static) &&
|
MF.getTarget().getRelocationModel() != Reloc::Static) &&
|
||||||
"JIT relocation model must be set to static or default!");
|
"JIT relocation model must be set to static or default!");
|
||||||
@ -113,8 +98,7 @@ bool Emitter<CodeEmitter>::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class CodeEmitter>
|
void PPCCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
|
||||||
void Emitter<CodeEmitter>::emitBasicBlock(MachineBasicBlock &MBB) {
|
|
||||||
MCE.StartMachineBasicBlock(&MBB);
|
MCE.StartMachineBasicBlock(&MBB);
|
||||||
|
|
||||||
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){
|
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user