1 //===-- PPC32CodeEmitter.cpp - JIT Code Emitter for PowerPC32 -----*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #include "PPC32JITInfo.h"
14 #include "PPC32TargetMachine.h"
15 #include "llvm/CodeGen/MachineCodeEmitter.h"
16 #include "llvm/CodeGen/MachineFunctionPass.h"
17 #include "llvm/CodeGen/Passes.h"
18 #include "Support/Debug.h"
23 class PPC32CodeEmitter : public MachineFunctionPass {
25 MachineCodeEmitter &MCE;
28 PPC32CodeEmitter(TargetMachine &T, MachineCodeEmitter &M)
31 const char *getPassName() const { return "PowerPC Machine Code Emitter"; }
33 /// runOnMachineFunction - emits the given MachineFunction to memory
35 bool runOnMachineFunction(MachineFunction &MF);
37 /// emitBasicBlock - emits the given MachineBasicBlock to memory
39 void emitBasicBlock(MachineBasicBlock &MBB);
41 /// emitWord - write a 32-bit word to memory at the current PC
43 void emitWord(unsigned w) { MCE.emitWord(w); }
45 unsigned getValueBit(int64_t Val, unsigned bit);
47 /// getBinaryCodeForInstr - returns the assembled code for an instruction
49 unsigned getBinaryCodeForInstr(MachineInstr &MI) { return 0; }
53 /// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
54 /// machine code emitted. This uses a MachineCodeEmitter object to handle
55 /// actually outputting the machine code and resolving things like the address
56 /// of functions. This method should returns true if machine code emission is
59 bool PPC32TargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
60 MachineCodeEmitter &MCE) {
61 // Machine code emitter pass for PowerPC
62 PM.add(new PPC32CodeEmitter(*this, MCE));
63 // Delete machine code for this function after emitting it:
64 PM.add(createMachineCodeDeleter());
65 // We don't yet support machine code emission
69 bool PPC32CodeEmitter::runOnMachineFunction(MachineFunction &MF) {
70 MCE.startFunction(MF);
71 MCE.emitConstantPool(MF.getConstantPool());
72 for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
74 MCE.finishFunction(MF);
78 void PPC32CodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
79 for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I)
80 emitWord(getBinaryCodeForInstr(*I));
83 unsigned PPC32CodeEmitter::getValueBit(int64_t Val, unsigned bit) {
88 void *PPC32JITInfo::getJITStubForFunction(Function *F,
89 MachineCodeEmitter &MCE) {
90 assert (0 && "PPC32JITInfo::getJITStubForFunction not implemented");
94 void PPC32JITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
95 assert (0 && "PPC32JITInfo::replaceMachineCodeForFunction not implemented");
98 //#include "PowerPCGenCodeEmitter.inc"
100 } // end llvm namespace