44 void *MovePCtoLROffset;
57 unsigned RelocID)
const;
63 unsigned get_crbitm_encoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
64 unsigned getDirectBrEncoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
65 unsigned getCondBrEncoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
68 unsigned getAbsCondBrEncoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
70 unsigned getImm16Encoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
71 unsigned getMemRIEncoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
72 unsigned getMemRIXEncoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
73 unsigned getTLSRegEncoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
74 unsigned getTLSCallEncoding(
const MachineInstr &
MI,
unsigned OpNo)
const;
76 const char *getPassName()
const {
return "PowerPC Machine Code Emitter"; }
94 return new PPCCodeEmitter(TM, JCE);
100 "JIT relocation model must be set to static or default!");
102 MMI = &getAnalysis<MachineModuleInfo>();
103 MCE.setModuleInfo(MMI);
105 MovePCtoLROffset = 0;
106 MCE.startFunction(MF);
109 }
while (MCE.finishFunction(MF));
115 MCE.StartMachineBasicBlock(&MBB);
122 MCE.emitWordBE(getBinaryCodeForInstr(MI));
131 case PPC::MovePCtoLR:
132 case PPC::MovePCtoLR8:
134 MovePCtoLROffset = (
void*)MCE.getCurrentPCValue();
135 MCE.emitWordBE(0x48000005);
142 unsigned PPCCodeEmitter::get_crbitm_encoding(
const MachineInstr &MI,
143 unsigned OpNo)
const {
148 return 0x80 >>
TM.getRegisterInfo()->getEncodingValue(MO.
getReg());
152 unsigned RelocID)
const {
160 assert(MovePCtoLROffset &&
"MovePCtoLR not seen yet?");
161 Cst = -(
intptr_t)MovePCtoLROffset - 4;
184 unsigned PPCCodeEmitter::getDirectBrEncoding(
const MachineInstr &MI,
185 unsigned OpNo)
const {
187 if (MO.
isReg() || MO.
isImm())
return getMachineOpValue(MI, MO);
193 unsigned PPCCodeEmitter::getCondBrEncoding(
const MachineInstr &MI,
194 unsigned OpNo)
const {
200 unsigned PPCCodeEmitter::getAbsDirectBrEncoding(
const MachineInstr &MI,
201 unsigned OpNo)
const {
203 if (MO.
isReg() || MO.
isImm())
return getMachineOpValue(MI, MO);
205 llvm_unreachable(
"Absolute branch relocations unsupported on the old JIT.");
208 unsigned PPCCodeEmitter::getAbsCondBrEncoding(
const MachineInstr &MI,
209 unsigned OpNo)
const {
210 llvm_unreachable(
"Absolute branch relocations unsupported on the old JIT.");
213 unsigned PPCCodeEmitter::getImm16Encoding(
const MachineInstr &MI,
214 unsigned OpNo)
const {
216 if (MO.
isReg() || MO.
isImm())
return getMachineOpValue(MI, MO);
225 MCE.addRelocation(GetRelocation(MO, RelocID));
229 unsigned PPCCodeEmitter::getMemRIEncoding(
const MachineInstr &MI,
230 unsigned OpNo)
const {
234 unsigned RegBits = getMachineOpValue(MI, MI.
getOperand(OpNo+1)) << 16;
238 return (getMachineOpValue(MI, MO) & 0xFFFF) | RegBits;
245 unsigned PPCCodeEmitter::getMemRIXEncoding(
const MachineInstr &MI,
246 unsigned OpNo)
const {
250 unsigned RegBits = getMachineOpValue(MI, MI.
getOperand(OpNo+1)) << 14;
254 return ((getMachineOpValue(MI, MO) >> 2) & 0x3FFF) | RegBits;
261 unsigned PPCCodeEmitter::getTLSRegEncoding(
const MachineInstr &MI,
262 unsigned OpNo)
const {
267 unsigned PPCCodeEmitter::getTLSCallEncoding(
const MachineInstr &MI,
268 unsigned OpNo)
const {
273 unsigned PPCCodeEmitter::getMachineOpValue(
const MachineInstr &MI,
282 return TM.getRegisterInfo()->getEncodingValue(MO.
getReg());
286 "Relocation required in an instruction that we cannot encode!");
290 #include "PPCGenCodeEmitter.inc"
const GlobalValue * getGlobal() const
Reloc::Model getRelocationModel() const
MachineBasicBlock * getMBB() const
MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
const char * getSymbolName() const
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
AnalysisUsage & addRequired()
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
ID
LLVM Calling Convention Representation.
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
FunctionPass * createPPCJITCodeEmitterPass(PPCTargetMachine &TM, JITCodeEmitter &MCE)
static MachineRelocation getBB(uintptr_t offset, unsigned RelocationType, MachineBasicBlock *MBB, intptr_t cst=0)
bundle_iterator< MachineInstr, instr_iterator > iterator
unsigned getTargetFlags() const
const MachineOperand & getOperand(unsigned i) const
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
The next are not flags but distinct values.
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
static MachineRelocation getGV(uintptr_t offset, unsigned RelocationType, GlobalValue *GV, intptr_t cst=0, bool MayNeedFarStub=0, bool GOTrelative=0)
virtual void getAnalysisUsage(AnalysisUsage &AU) const
IMPLICIT_DEF - This is the MachineInstr-level equivalent of undef.
MCSymbol * getMCSymbol() const
const TargetMachine & getTarget() const
static MachineRelocation getJumpTable(uintptr_t offset, unsigned RelocationType, unsigned JTI, intptr_t cst=0, bool letTargetResolve=false)
unsigned getReg() const
getReg - Returns the register number.
static MachineRelocation getConstPool(uintptr_t offset, unsigned RelocationType, unsigned CPI, intptr_t cst=0, bool letTargetResolve=false)
BasicBlockListType::iterator iterator
static MachineRelocation getExtSym(uintptr_t offset, unsigned RelocationType, const char *ES, intptr_t cst=0, bool GOTrelative=0, bool NeedStub=true)
DebugLoc getDebugLoc() const