From 5df14ca0a1264ace774cc9eb7d6dcb493e8256c4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 21 Nov 2005 22:19:48 +0000 Subject: [PATCH] Add a forELF flag, allowing the removal of forCygwin and simplification of conditionals. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24475 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ATTAsmPrinter.cpp | 2 +- lib/Target/X86/X86AsmPrinter.cpp | 11 ++++++++--- lib/Target/X86/X86AsmPrinter.h | 4 ++-- lib/Target/X86/X86IntelAsmPrinter.cpp | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp index 3a1ac86576f..7420012d70c 100755 --- a/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -35,7 +35,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { SwitchSection("\t.text\n", MF.getFunction()); EmitAlignment(4); // FIXME: This should be parameterized somewhere. O << "\t.globl\t" << CurrentFnName << "\n"; - if (!forCygwin && !forDarwin) + if (forELF) O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 36f4249e223..5b9742bd440 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -39,15 +39,18 @@ AsmWriterFlavor("x86-asm-syntax", cl::init(att)); /// doInitialization -bool X86SharedAsmPrinter::doInitialization(Module& M) { - forCygwin = false; +bool X86SharedAsmPrinter::doInitialization(Module &M) { + bool forCygwin = false; forDarwin = false; + forELF = false; bool forWin32 = false; const std::string& TT = M.getTargetTriple(); if (TT.length() > 5) { forCygwin = TT.find("cygwin") != std::string::npos || TT.find("mingw") != std::string::npos; forDarwin = TT.find("darwin") != std::string::npos; + if (!forDarwin && !forCygwin) + forELF = true; } else if (TT.empty()) { #if defined(__CYGWIN__) || defined(__MINGW32__) forCygwin = true; @@ -55,6 +58,8 @@ bool X86SharedAsmPrinter::doInitialization(Module& M) { forDarwin = true; #elif defined(_WIN32) forWin32 = true; +#else + forELF = true; #endif } @@ -139,7 +144,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { } EmitAlignment(Align); - if (!forCygwin && !forDarwin) { + if (forELF) { O << "\t.type " << name << ",@object\n"; O << "\t.size " << name << "," << Size << "\n"; } diff --git a/lib/Target/X86/X86AsmPrinter.h b/lib/Target/X86/X86AsmPrinter.h index 61dd2f295e7..649ec4d0247 100755 --- a/lib/Target/X86/X86AsmPrinter.h +++ b/lib/Target/X86/X86AsmPrinter.h @@ -29,12 +29,12 @@ extern Statistic<> EmittedInsts; struct X86SharedAsmPrinter : public AsmPrinter { X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM) - : AsmPrinter(O, TM), forCygwin(false), forDarwin(false) { } + : AsmPrinter(O, TM), forELF(false), forDarwin(false) { } bool doInitialization(Module &M); bool doFinalization(Module &M); - bool forCygwin; + bool forELF; bool forDarwin; // Necessary for Darwin to print out the apprioriate types of linker stubs diff --git a/lib/Target/X86/X86IntelAsmPrinter.cpp b/lib/Target/X86/X86IntelAsmPrinter.cpp index 1c9f803a0e1..f4464b3e437 100755 --- a/lib/Target/X86/X86IntelAsmPrinter.cpp +++ b/lib/Target/X86/X86IntelAsmPrinter.cpp @@ -35,7 +35,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) { SwitchSection("\t.text\n", MF.getFunction()); EmitAlignment(4); O << "\t.globl\t" << CurrentFnName << "\n"; - if (!forCygwin && !forDarwin) + if (forELF) O << "\t.type\t" << CurrentFnName << ", @function\n"; O << CurrentFnName << ":\n"; -- 2.34.1