15 #define DEBUG_TYPE "jit"
28 STATISTIC(NumEmitted,
"Number of machine instructions emitted");
39 const std::vector<MachineConstantPoolEntry> *MCPEs;
52 TM(tm), MCE(mce), MCPEs(0),
53 IsPIC(
TM.getRelocationModel() == Reloc::
PIC_) {}
57 virtual const char *getPassName()
const {
58 return "Sparc Machine Code Emitter";
75 void emitWord(
unsigned Word);
80 void emitGlobalAddress(
const GlobalValue *GV,
unsigned Reloc)
const;
81 void emitExternalSymbolAddress(
const char *ES,
unsigned Reloc)
const;
82 void emitConstPoolAddress(
unsigned CPI,
unsigned Reloc)
const;
98 JTI->Initialize(MF, IsPIC);
99 MCE.setModuleInfo(&getAnalysis<MachineModuleInfo> ());
104 MCE.startFunction(MF);
108 MCE.StartMachineBasicBlock(MBB);
110 E = MBB->instr_end();
I != E;)
111 emitInstruction(*
I++, *MBB);
113 }
while (MCE.finishFunction(MF));
120 DEBUG(
errs() <<
"JIT: " << (
void*)MCE.getCurrentPCValue() <<
":\t" << *
MI);
122 MCE.processDebugLoc(MI->getDebugLoc(),
true);
126 switch (MI->getOpcode()) {
128 emitWord(getBinaryCodeForInstr(*MI));
134 if (MI->getOperand(0).getSymbolName()[0]) {
141 MCE.emitLabel(MI->getOperand(0).getMCSymbol());
155 MCE.processDebugLoc(MI->getDebugLoc(),
false);
158 void SparcCodeEmitter::emitWord(
unsigned Word) {
161 MCE.emitWordBE(Word);
166 unsigned SparcCodeEmitter::getMachineOpValue(
const MachineInstr &MI,
169 return TM.getRegisterInfo()->getEncodingValue(MO.
getReg());
171 return static_cast<unsigned>(MO.
getImm());
173 emitGlobalAddress(MO.
getGlobal(), getRelocation(MI, MO));
175 emitExternalSymbolAddress(MO.
getSymbolName(), getRelocation(MI, MO));
177 emitConstPoolAddress(MO.
getIndex(), getRelocation(MI, MO));
179 emitMachineBasicBlock(MO.
getMBB(), getRelocation(MI, MO));
184 unsigned SparcCodeEmitter::getRelocation(
const MachineInstr &MI,
197 case SPII::MO_HM: assert(0 &&
"FIXME: Implement Medium/Large code model.");
212 void SparcCodeEmitter::emitGlobalAddress(
const GlobalValue *GV,
213 unsigned Reloc)
const {
219 void SparcCodeEmitter::
220 emitExternalSymbolAddress(
const char *ES,
unsigned Reloc)
const {
225 void SparcCodeEmitter::
226 emitConstPoolAddress(
unsigned CPI,
unsigned Reloc)
const {
228 Reloc, CPI, 0,
false));
232 unsigned Reloc)
const {
242 return new SparcCodeEmitter(TM, JCE);
245 #include "SparcGenCodeEmitter.inc"
const GlobalValue * getGlobal() const
MachineBasicBlock * getMBB() const
const char * getSymbolName() const
Instructions::iterator instr_iterator
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
FunctionPass * createSparcJITCodeEmitterPass(SparcTargetMachine &TM, JITCodeEmitter &JCE)
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.
virtual const SparcInstrInfo * getInstrInfo() const
raw_ostream & write_hex(unsigned long long N)
write_hex - Output N in hexadecimal, without any prefix or padding.
static MachineRelocation getBB(uintptr_t offset, unsigned RelocationType, MachineBasicBlock *MBB, intptr_t cst=0)
unsigned getTargetFlags() const
STATISTIC(NumEmitted,"Number of machine instructions emitted")
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
MachineConstantPool * getConstantPool()
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.
const TargetMachine & getTarget() const
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
virtual SparcJITInfo * getJITInfo()
const std::vector< MachineConstantPoolEntry > & getConstants() const
virtual const DataLayout * getDataLayout() const
StringRef getName() const
static MachineRelocation getExtSym(uintptr_t offset, unsigned RelocationType, const char *ES, intptr_t cst=0, bool GOTrelative=0, bool NeedStub=true)
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD