rename decorateName -> DecorateCygMingName, make it assert if not
authorChris Lattner <sabre@nondot.org>
Wed, 15 Jul 2009 04:55:56 +0000 (04:55 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 15 Jul 2009 04:55:56 +0000 (04:55 +0000)
cygming, make the two callers only call it if cygming.  Other minor
cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75744 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h

index f9be9a5c4f0d61987b089fa8bb4be26eeda23c77..2cec3736a38976b8914e3074d62dde5be514f2b4 100644 (file)
@@ -102,15 +102,17 @@ static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
   return Info;
 }
 
-/// decorateName - Query FunctionInfoMap and use this information for various
-/// name decoration.
-void X86ATTAsmPrinter::decorateName(std::string &Name,
-                                    const GlobalValue *GV) {
+/// DecorateCygMingName - Query FunctionInfoMap and use this information for
+/// various name decorations for Cygwin and MingW.
+void X86ATTAsmPrinter::DecorateCygMingName(std::string &Name,
+                                           const GlobalValue *GV) {
+  assert(Subtarget->isTargetCygMing() && "This is only for cygwin and mingw");
+  
   const Function *F = dyn_cast<Function>(GV);
   if (!F) return;
 
   // Save function name for later type emission.
-  if (Subtarget->isTargetCygMing() && F->isDeclaration())
+  if (F->isDeclaration())
     CygMingStubs.insert(Name);
   
   // We don't want to decorate non-stdcall or non-fastcall functions right now
@@ -118,13 +120,10 @@ void X86ATTAsmPrinter::decorateName(std::string &Name,
   if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
     return;
 
-  // Decorate names only when we're targeting Cygwin/Mingw32 targets
-  if (!Subtarget->isTargetCygMing())
-    return;
-
-  FMFInfoMap::const_iterator info_item = FunctionInfoMap.find(F);
 
   const X86MachineFunctionInfo *Info;
+  
+  FMFInfoMap::const_iterator info_item = FunctionInfoMap.find(F);
   if (info_item == FunctionInfoMap.end()) {
     // Calculate apropriate function info and populate map
     FunctionInfoMap[F] = calculateFunctionInfo(F, TM.getTargetData());
@@ -164,7 +163,8 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
   unsigned FnAlign = MF.getAlignment();
   const Function *F = MF.getFunction();
 
-  decorateName(CurrentFnName, F);
+  if (Subtarget->isTargetCygMing())
+    DecorateCygMingName(CurrentFnName, F);
 
   SwitchToSection(TAI->SectionForGlobal(F));
   switch (F->getLinkage()) {
@@ -316,7 +316,8 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
       Suffix = "$non_lazy_ptr";
     
     std::string Name = Mang->getMangledName(GV, Suffix, Suffix[0] != '\0');
-    decorateName(Name, GV);
+    if (Subtarget->isTargetCygMing())
+      DecorateCygMingName(Name, GV);
     
     // Handle dllimport linkage.
     if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
index 9382d599d0d742a2b8e162913469fe13549ad4d3..9721fdcd4b9e426d3945821d02161ce6b3e37007 100644 (file)
@@ -219,7 +219,7 @@ class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
   typedef std::map<const Function*, X86MachineFunctionInfo> FMFInfoMap;
   FMFInfoMap FunctionInfoMap;
 
-  void decorateName(std::string& Name, const GlobalValue* GV);
+  void DecorateCygMingName(std::string &Name, const GlobalValue *GV);
 };
 
 } // end namespace llvm