mutable const Function *LastFn;
mutable unsigned Counter;
- // Private state for processDebugLock()
+ // Private state for processDebugLoc()
mutable DebugLocTuple PrevDLT;
protected:
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
/// processDebugLoc - Processes the debug information of each machine
- /// instruction's DebugLoc.
- void processDebugLoc(const MachineInstr *MI);
+ /// instruction's DebugLoc.
+ void processDebugLoc(const MachineInstr *MI, bool BeforePrintingInsn);
/// printInlineAsm - This method formats and prints the specified machine
/// instruction that is an inline asm.
/// MachineInstruction. This is called before emitting any bytes associated
/// with the instruction. Even if successive instructions have the same debug
/// location, this method will be called for each one.
- virtual void processDebugLoc(DebugLoc DL) {}
+ virtual void processDebugLoc(DebugLoc DL, bool BeforePrintintInsn) {}
/// emitLabel - Emits a label
virtual void emitLabel(uint64_t LabelID) = 0;
/// processDebugLoc - Processes the debug information of each machine
/// instruction's DebugLoc.
-void AsmPrinter::processDebugLoc(const MachineInstr *MI) {
+void AsmPrinter::processDebugLoc(const MachineInstr *MI,
+ bool BeforePrintingInsn) {
if (!MAI || !DW)
return;
DebugLoc DL = MI->getDebugLoc();
if (MAI->doesSupportDebugInformation() && DW->ShouldEmitDwarfDebug()) {
if (!DL.isUnknown()) {
DebugLocTuple CurDLT = MF->getDebugLocTuple(DL);
-
- if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) {
- printLabel(DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,
- CurDLT.CompileUnit));
- O << '\n';
+ if (BeforePrintingInsn) {
+ if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT) {
+ printLabel(DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,
+ CurDLT.CompileUnit));
+ O << '\n';
+ }
}
PrevDLT = CurDLT;
void Emitter<CodeEmitter>::emitInstruction(const MachineInstr &MI) {
DEBUG(errs() << "JIT: " << (void*)MCE.getCurrentPCValue() << ":\t" << MI);
- MCE.processDebugLoc(MI.getDebugLoc());
+ MCE.processDebugLoc(MI.getDebugLoc(), true);
NumEmitted++; // Keep track of the # of mi's emitted
switch (MI.getDesc().TSFlags & ARMII::FormMask) {
emitMiscInstruction(MI);
break;
}
+ MCE.processDebugLoc(MI.getDebugLoc(), false);
}
template<class CodeEmitter>
}}
// Call the autogenerated instruction printer routines.
- processDebugLoc(MI);
+ processDebugLoc(MI, true);
printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
O << '\n';
+ processDebugLoc(MI, false);
}
void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
I != E; ++I) {
const MachineInstr &MI = *I;
- MCE.processDebugLoc(MI.getDebugLoc());
+ MCE.processDebugLoc(MI.getDebugLoc(), true);
switch(MI.getOpcode()) {
default:
MCE.emitWordLE(getBinaryCodeForInstr(*I));
case TargetInstrInfo::KILL:
break; //skip these
}
+ MCE.processDebugLoc(MI.getDebugLoc(), false);
}
}
II != E; ++II) {
// Print the assembly for the instruction.
++EmittedInsts;
- processDebugLoc(II);
-
+ processDebugLoc(II, true);
printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown())
EmitComments(*II);
O << '\n';
+ processDebugLoc(II, false);
}
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
- processDebugLoc(II);
+ processDebugLoc(II, true);
printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown())
EmitComments(*II);
O << '\n';
+ processDebugLoc(II, false);
++EmittedInsts;
}
}
///
void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
- processDebugLoc(MI);
+ processDebugLoc(MI, true);
printInstruction(MI);
-
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
+ processDebugLoc(MI, false);
O << '\n';
}
void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
- processDebugLoc(MI);
+ processDebugLoc(MI, true);
// Call the autogenerated instruction printer routines.
printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
O << '\n';
+
+ processDebugLoc(MI, false);
}
void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
- processDebugLoc(II);
+ processDebugLoc(II, true);
// Print the assembly for the instruction.
printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown())
EmitComments(*II);
O << '\n';
-
+
+ processDebugLoc(II, false);
++EmittedInsts;
}
}
bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
- processDebugLoc(MI);
-
+ processDebugLoc(MI, true);
printInstruction(MI);
-
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
O << '\n';
+ processDebugLoc(MI, false);
return true;
}
void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
- processDebugLoc(MI);
+ processDebugLoc(MI, true);
// Check for slwi/srwi mnemonics.
if (MI->getOpcode() == PPC::RLWINM) {
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
O << '\n';
+
+ processDebugLoc(MI, false);
}
/// runOnMachineFunction - This uses the printMachineInstruction()
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){
const MachineInstr &MI = *I;
- MCE.processDebugLoc(MI.getDebugLoc());
+ MCE.processDebugLoc(MI.getDebugLoc(), true);
switch (MI.getOpcode()) {
default:
MCE.emitWordBE(getBinaryCodeForInstr(MI));
MCE.emitWordBE(0x48000005); // bl 1
break;
}
+ MCE.processDebugLoc(MI.getDebugLoc(), false);
}
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
- processDebugLoc(II);
+ processDebugLoc(II, true);
printInstruction(II);
if (VerboseAsm && !II->getDebugLoc().isUnknown())
EmitComments(*II);
O << '\n';
-
+ processDebugLoc(II, false);
++EmittedInsts;
}
}
void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
- processDebugLoc(MI);
+ processDebugLoc(MI, true);
// Call the autogenerated instruction printer routines.
printInstruction(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
O << '\n';
+
+ processDebugLoc(MI, false);
}
void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum){
void X86AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
- processDebugLoc(MI);
+ processDebugLoc(MI, true);
printInstructionThroughMCStreamer(MI);
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
O << '\n';
+
+ processDebugLoc(MI, false);
}
void X86AsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
const TargetInstrDesc *Desc) {
DEBUG(errs() << MI);
- MCE.processDebugLoc(MI.getDebugLoc());
+ MCE.processDebugLoc(MI.getDebugLoc(), true);
unsigned Opcode = Desc->Opcode;
#endif
llvm_unreachable(0);
}
+
+ MCE.processDebugLoc(MI.getDebugLoc(), false);
}
// Adapt the Emitter / CodeEmitter interfaces to MCCodeEmitter.
void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
- processDebugLoc(MI);
+ processDebugLoc(MI, true);
// Check for mov mnemonic
unsigned src, dst, srcSR, dstSR;
if (VerboseAsm && !MI->getDebugLoc().isUnknown())
EmitComments(*MI);
O << '\n';
+
+ processDebugLoc(MI, false);
}
// Force static initialization.