mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-22 11:39:35 +00:00
Stub definition of the PowerPC CodeEmitter class; this isn't functional (yet).
llvm-svn: 15600
This commit is contained in:
parent
3da9167cc4
commit
d345cd9090
@ -11,9 +11,44 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "PowerPCTargetMachine.h"
|
#include "PowerPCTargetMachine.h"
|
||||||
|
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
|
#include "llvm/CodeGen/Passes.h"
|
||||||
|
#include "Support/Debug.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class PowerPCCodeEmitter : public MachineFunctionPass {
|
||||||
|
TargetMachine &TM;
|
||||||
|
MachineCodeEmitter &MCE;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PowerPCCodeEmitter(TargetMachine &T, MachineCodeEmitter &M)
|
||||||
|
: TM(T), MCE(M) {}
|
||||||
|
|
||||||
|
const char *getPassName() const { return "PowerPC Machine Code Emitter"; }
|
||||||
|
|
||||||
|
/// runOnMachineFunction - emits the given MachineFunction to memory
|
||||||
|
///
|
||||||
|
bool runOnMachineFunction(MachineFunction &MF);
|
||||||
|
|
||||||
|
/// emitBasicBlock - emits the given MachineBasicBlock to memory
|
||||||
|
///
|
||||||
|
void emitBasicBlock(MachineBasicBlock &MBB);
|
||||||
|
|
||||||
|
/// emitWord - write a 32-bit word to memory at the current PC
|
||||||
|
///
|
||||||
|
void emitWord(unsigned w) { MCE.emitWord(w); }
|
||||||
|
|
||||||
|
unsigned getValueBit(int64_t Val, unsigned bit);
|
||||||
|
|
||||||
|
/// getBinaryCodeForInstr - returns the assembled code for an instruction
|
||||||
|
///
|
||||||
|
unsigned getBinaryCodeForInstr(MachineInstr &MI) { return 0; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
|
||||||
/// machine code emitted. This uses a MachineCodeEmitter object to handle
|
/// machine code emitted. This uses a MachineCodeEmitter object to handle
|
||||||
/// actually outputting the machine code and resolving things like the address
|
/// actually outputting the machine code and resolving things like the address
|
||||||
@ -22,11 +57,31 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
bool PowerPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
|
bool PowerPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
|
||||||
MachineCodeEmitter &MCE) {
|
MachineCodeEmitter &MCE) {
|
||||||
return true;
|
// Machine code emitter pass for PowerPC
|
||||||
// It should go something like this:
|
PM.add(new PowerPCCodeEmitter(*this, MCE));
|
||||||
// PM.add(new Emitter(MCE)); // Machine code emitter pass for PowerPC
|
|
||||||
// Delete machine code for this function after emitting it:
|
// Delete machine code for this function after emitting it:
|
||||||
// PM.add(createMachineCodeDeleter());
|
PM.add(createMachineCodeDeleter());
|
||||||
|
// We don't yet support machine code emission
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PowerPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
|
MCE.startFunction(MF);
|
||||||
|
MCE.emitConstantPool(MF.getConstantPool());
|
||||||
|
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
|
||||||
|
emitBasicBlock(*I);
|
||||||
|
MCE.finishFunction(MF);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerPCCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
|
||||||
|
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I)
|
||||||
|
emitWord(getBinaryCodeForInstr(*I));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned PowerPCCodeEmitter::getValueBit(int64_t Val, unsigned bit) {
|
||||||
|
Val >>= bit;
|
||||||
|
return (Val & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *PowerPCJITInfo::getJITStubForFunction(Function *F,
|
void *PowerPCJITInfo::getJITStubForFunction(Function *F,
|
||||||
@ -39,5 +94,7 @@ void PowerPCJITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
|
|||||||
assert (0 && "PowerPCJITInfo::replaceMachineCodeForFunction not implemented");
|
assert (0 && "PowerPCJITInfo::replaceMachineCodeForFunction not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#include "PowerPCGenCodeEmitter.inc"
|
||||||
|
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
|
||||||
|
@ -11,9 +11,44 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "PowerPCTargetMachine.h"
|
#include "PowerPCTargetMachine.h"
|
||||||
|
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
|
#include "llvm/CodeGen/Passes.h"
|
||||||
|
#include "Support/Debug.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class PowerPCCodeEmitter : public MachineFunctionPass {
|
||||||
|
TargetMachine &TM;
|
||||||
|
MachineCodeEmitter &MCE;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PowerPCCodeEmitter(TargetMachine &T, MachineCodeEmitter &M)
|
||||||
|
: TM(T), MCE(M) {}
|
||||||
|
|
||||||
|
const char *getPassName() const { return "PowerPC Machine Code Emitter"; }
|
||||||
|
|
||||||
|
/// runOnMachineFunction - emits the given MachineFunction to memory
|
||||||
|
///
|
||||||
|
bool runOnMachineFunction(MachineFunction &MF);
|
||||||
|
|
||||||
|
/// emitBasicBlock - emits the given MachineBasicBlock to memory
|
||||||
|
///
|
||||||
|
void emitBasicBlock(MachineBasicBlock &MBB);
|
||||||
|
|
||||||
|
/// emitWord - write a 32-bit word to memory at the current PC
|
||||||
|
///
|
||||||
|
void emitWord(unsigned w) { MCE.emitWord(w); }
|
||||||
|
|
||||||
|
unsigned getValueBit(int64_t Val, unsigned bit);
|
||||||
|
|
||||||
|
/// getBinaryCodeForInstr - returns the assembled code for an instruction
|
||||||
|
///
|
||||||
|
unsigned getBinaryCodeForInstr(MachineInstr &MI) { return 0; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
|
||||||
/// machine code emitted. This uses a MachineCodeEmitter object to handle
|
/// machine code emitted. This uses a MachineCodeEmitter object to handle
|
||||||
/// actually outputting the machine code and resolving things like the address
|
/// actually outputting the machine code and resolving things like the address
|
||||||
@ -22,11 +57,31 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
bool PowerPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
|
bool PowerPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
|
||||||
MachineCodeEmitter &MCE) {
|
MachineCodeEmitter &MCE) {
|
||||||
return true;
|
// Machine code emitter pass for PowerPC
|
||||||
// It should go something like this:
|
PM.add(new PowerPCCodeEmitter(*this, MCE));
|
||||||
// PM.add(new Emitter(MCE)); // Machine code emitter pass for PowerPC
|
|
||||||
// Delete machine code for this function after emitting it:
|
// Delete machine code for this function after emitting it:
|
||||||
// PM.add(createMachineCodeDeleter());
|
PM.add(createMachineCodeDeleter());
|
||||||
|
// We don't yet support machine code emission
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PowerPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
|
MCE.startFunction(MF);
|
||||||
|
MCE.emitConstantPool(MF.getConstantPool());
|
||||||
|
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
|
||||||
|
emitBasicBlock(*I);
|
||||||
|
MCE.finishFunction(MF);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PowerPCCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
|
||||||
|
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I)
|
||||||
|
emitWord(getBinaryCodeForInstr(*I));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned PowerPCCodeEmitter::getValueBit(int64_t Val, unsigned bit) {
|
||||||
|
Val >>= bit;
|
||||||
|
return (Val & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *PowerPCJITInfo::getJITStubForFunction(Function *F,
|
void *PowerPCJITInfo::getJITStubForFunction(Function *F,
|
||||||
@ -39,5 +94,7 @@ void PowerPCJITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
|
|||||||
assert (0 && "PowerPCJITInfo::replaceMachineCodeForFunction not implemented");
|
assert (0 && "PowerPCJITInfo::replaceMachineCodeForFunction not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#include "PowerPCGenCodeEmitter.inc"
|
||||||
|
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user