Changes in directory llvm/lib/Target/X86:
X86IntelAsmPrinter.cpp updated: 1.32 -> 1.33 X86IntelAsmPrinter.h updated: 1.16 -> 1.17 --- Log message: Finish support for Microsoft ML/MASM. May still be a few rough edges. --- Diffs of the changes: (+50 -3) X86IntelAsmPrinter.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++--- X86IntelAsmPrinter.h | 2 + 2 files changed, 50 insertions(+), 3 deletions(-) Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.32 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.33 --- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.32 Mon May 1 20:16:28 2006 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon May 1 22:11:50 2006 @@ -36,8 +36,6 @@ Data32bitsDirective = "\t.dd\t"; Data64bitsDirective = "\t.dq\t"; HasDotTypeDotSizeDirective = false; - - O << "\t.686\n\t.model flat\n\toption dotname\n"; } /// runOnMachineFunction - This uses the printMachineInstruction() @@ -57,7 +55,7 @@ EmitConstantPool(MF.getConstantPool()); // Print out labels for the function. - SwitchSection(".code\n", MF.getFunction()); + SwitchSection(".code", MF.getFunction()); EmitAlignment(4); if (MF.getFunction()->getLinkage() == GlobalValue::ExternalLinkage) O << "\tpublic " << CurrentFnName << "\n"; @@ -424,9 +422,56 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) { X86SharedAsmPrinter::doInitialization(M); Mang->markCharUnacceptable('.'); + PrivateGlobalPrefix = "$"; // need this here too :( + O << "\t.686\n\t.model flat\n\n"; + + // Emit declarations for external functions. + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (I->isExternal()) + O << "\textern " << Mang->getValueName(I) << ":near\n"; + + // Emit declarations for external globals. + for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); + I != E; ++I) { + if (I->isExternal()) + O << "\textern " << Mang->getValueName(I) << ":byte\n"; + } + return false; } +bool X86IntelAsmPrinter::doFinalization(Module &M) { + X86SharedAsmPrinter::doFinalization(M); + if (CurrentSection != "") + O << CurrentSection << "\tends\n"; + O << "\tend\n"; + return false; +} + +void X86IntelAsmPrinter::SwitchSection(const char *NewSection, + const GlobalValue *GV) { + if (*NewSection == 0) + return; + + std::string NS; + bool isData = strcmp(NewSection , ".data") == 0; + + if (GV && GV->hasSection()) + NS = GV->getSection(); + else if (isData) + NS = "_data"; + else + NS = "_text"; + + if (CurrentSection != NS) { + if (CurrentSection != "") + O << CurrentSection << "\tends\n"; + CurrentSection = NS; + O << CurrentSection << (isData ? "\tsegment 'DATA'\n" + : "\tsegment 'CODE'\n"); + } +} + void X86IntelAsmPrinter::EmitZeros(uint64_t NumZeros) const { if (NumZeros) { O << "\tdb " << NumZeros << " dup(0)\n"; Index: llvm/lib/Target/X86/X86IntelAsmPrinter.h diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.16 llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.17 --- llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.16 Mon May 1 20:16:28 2006 +++ llvm/lib/Target/X86/X86IntelAsmPrinter.h Mon May 1 22:11:50 2006 @@ -90,7 +90,9 @@ void printPICLabel(const MachineInstr *MI, unsigned Op); bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); + bool doFinalization(Module &M); + virtual void SwitchSection(const char *NewSection, const GlobalValue *GV); virtual void EmitZeros(uint64_t NumZeros) const; virtual void EmitString(const ConstantArray *CVA) const; }; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits