X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FAsmPrinter.cpp;h=b718958f974f579f72215a878bb92a7618ae8804;hb=d497d9fab6e90499c703f3e672ec001dbfa074f9;hp=0f7f6f1dc9ffd7057ab7b33a3910151dfa2ba228;hpb=9e3304900ff69c4920fea7369c9c36916c4a6a6a;p=oota-llvm.git diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index 0f7f6f1dc9f..b718958f974 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -16,8 +16,11 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Module.h" +#include "llvm/CodeGen/Collector.h" +#include "llvm/CodeGen/CollectorMetadata.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" +#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" @@ -93,9 +96,20 @@ void AsmPrinter::SwitchToDataSection(const char *NewSection, } +void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { + MachineFunctionPass::getAnalysisUsage(AU); + AU.addRequired(); +} + bool AsmPrinter::doInitialization(Module &M) { Mang = new Mangler(M, TAI->getGlobalPrefix()); + CollectorModuleMetadata *CMM = getAnalysisToUpdate(); + assert(CMM && "AsmPrinter didn't require CollectorModuleMetadata?"); + for (CollectorModuleMetadata::iterator I = CMM->begin(), + E = CMM->end(); I != E; ++I) + (*I)->beginAssembly(O, *this, *TAI); + if (!M.getModuleInlineAsm().empty()) O << TAI->getCommentString() << " Start of file scope inline assembly\n" << M.getModuleInlineAsm() @@ -104,9 +118,8 @@ bool AsmPrinter::doInitialization(Module &M) { SwitchToDataSection(""); // Reset back to no section. - if (MachineModuleInfo *MMI = getAnalysisToUpdate()) { - MMI->AnalyzeModule(M); - } + MMI = getAnalysisToUpdate(); + if (MMI) MMI->AnalyzeModule(M); return false; } @@ -144,7 +157,7 @@ bool AsmPrinter::doFinalization(Module &M) { else if (!I->hasInternalLinkage()) assert(0 && "Invalid alias linkage"); - O << TAI->getSetDirective() << Name << ", " << Target << "\n"; + O << TAI->getSetDirective() << ' ' << Name << ", " << Target << "\n"; // If the aliasee has external weak linkage it can be referenced only by // alias itself. In this case it can be not in ExtWeakSymbols list. Emit @@ -157,6 +170,12 @@ bool AsmPrinter::doFinalization(Module &M) { } } + CollectorModuleMetadata *CMM = getAnalysisToUpdate(); + assert(CMM && "AsmPrinter didn't require CollectorModuleMetadata?"); + for (CollectorModuleMetadata::iterator I = CMM->end(), + E = CMM->begin(); I != E; ) + (*--I)->finishAssembly(O, *this, *TAI); + delete Mang; Mang = 0; return false; } @@ -919,10 +938,13 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) { // api needed to prevent premature destruction APInt api = CFP->getValueAPF().convertToAPInt(); const uint64_t *p = api.getRawData(); + APFloat DoubleVal = CFP->getValueAPF(); + DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven); if (TD->isBigEndian()) { O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48) << "\t" << TAI->getCommentString() - << " long double most significant halfword\n"; + << " long double most significant halfword of ~" + << DoubleVal.convertToDouble() << "\n"; O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32) << "\t" << TAI->getCommentString() << " long double next halfword\n"; @@ -938,7 +960,8 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, bool Packed) { } else { O << TAI->getData16bitsDirective() << uint16_t(p[1]) << "\t" << TAI->getCommentString() - << " long double least significant halfword\n"; + << " long double least significant halfword of ~" + << DoubleVal.convertToDouble() << "\n"; O << TAI->getData16bitsDirective() << uint16_t(p[0]) << "\t" << TAI->getCommentString() << " long double next halfword\n"; @@ -1084,9 +1107,10 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { // Disassemble the AsmStr, printing out the literal pieces, the operands, etc. const char *AsmStr = MI->getOperand(NumDefs).getSymbolName(); - // If this asmstr is empty, don't bother printing the #APP/#NOAPP markers. + // If this asmstr is empty, just print the #APP/#NOAPP markers. + // These are useful to see where empty asm's wound up. if (AsmStr[0] == 0) { - O << "\n"; // Tab already printed, avoid double indenting next instr. + O << TAI->getInlineAsmStart() << "\n\t" << TAI->getInlineAsmEnd() << "\n"; return; } @@ -1226,7 +1250,7 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { ++OpNo; // Skip over the ID number. if (Modifier[0]=='l') // labels are target independent - printBasicBlockLabel(MI->getOperand(OpNo).getMachineBasicBlock(), + printBasicBlockLabel(MI->getOperand(OpNo).getMBB(), false, false); else { AsmPrinter *AP = const_cast(this); @@ -1256,10 +1280,24 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { /// printLabel - This method prints a local label used by debug and /// exception handling tables. void AsmPrinter::printLabel(const MachineInstr *MI) const { - O << "\n" << TAI->getPrivateGlobalPrefix() + O << TAI->getPrivateGlobalPrefix() << "label" << MI->getOperand(0).getImm() << ":\n"; } +void AsmPrinter::printLabel(unsigned Id) const { + O << TAI->getPrivateGlobalPrefix() << "label" << Id << ":\n"; +} + +/// printDeclare - This method prints a local variable declaration used by +/// debug tables. +/// FIXME: It doesn't really print anything rather it inserts a DebugVariable +/// entry into dwarf table. +void AsmPrinter::printDeclare(const MachineInstr *MI) const { + int FI = MI->getOperand(0).getIndex(); + GlobalValue *GV = MI->getOperand(1).getGlobal(); + MMI->RecordVariable(GV, FI); +} + /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM /// instruction, using the specified assembler variant. Targets should /// overried this to format as appropriate.