Make target asm info a property of the target machine.
authorJim Laskey <jlaskey@mac.com>
Thu, 7 Sep 2006 22:06:40 +0000 (22:06 +0000)
committerJim Laskey <jlaskey@mac.com>
Thu, 7 Sep 2006 22:06:40 +0000 (22:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30162 91177308-0d34-0410-b5e6-96231b3b80d8

25 files changed:
include/llvm/CodeGen/AsmPrinter.h
include/llvm/CodeGen/DwarfWriter.h
include/llvm/Target/TargetAsmInfo.h
include/llvm/Target/TargetMachine.h
lib/CodeGen/AsmPrinter.cpp
lib/CodeGen/DwarfWriter.cpp
lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/ARMTargetMachine.h
lib/Target/Alpha/AlphaAsmPrinter.cpp
lib/Target/Alpha/AlphaTargetMachine.cpp
lib/Target/Alpha/AlphaTargetMachine.h
lib/Target/IA64/IA64AsmPrinter.cpp
lib/Target/IA64/IA64TargetMachine.h
lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCTargetMachine.h
lib/Target/Sparc/SparcAsmPrinter.cpp
lib/Target/Sparc/SparcTargetMachine.h
lib/Target/TargetMachine.cpp
lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86ATTAsmPrinter.h
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.h
lib/Target/X86/X86IntelAsmPrinter.cpp
lib/Target/X86/X86IntelAsmPrinter.h
lib/Target/X86/X86TargetMachine.h

index 042e1d3f021d40ecce68d6337983f3c04f7bada7..52a621d0d82fda44e6337aac6ec92c8073259439 100644 (file)
@@ -49,7 +49,7 @@ namespace llvm {
     
     /// Target Asm Printer information.
     ///
-    TargetAsmInfo *TAI;
+    const TargetAsmInfo *TAI;
 
     /// Name-mangler for global names.
     ///
@@ -65,7 +65,7 @@ namespace llvm {
     std::string CurrentSection;
   
   protected:
-    AsmPrinter(std::ostream &o, TargetMachine &TM, TargetAsmInfo *T);
+    AsmPrinter(std::ostream &o, TargetMachine &TM, const TargetAsmInfo *T);
     
   public:
     /// SwitchToTextSection - Switch to the specified section of the executable
index 1b5cd8f6c462f7478152340a7ea68e1beb0a26a0..bd95fe24d051a0ad36b1a516fa45aa6904f99ecf 100644 (file)
@@ -88,7 +88,7 @@ private:
   AsmPrinter *Asm;
   
   /// TAI - Target Asm Printer.
-  TargetAsmInfo *TAI;
+  const TargetAsmInfo *TAI;
   
   /// TD - Target data.
   const TargetData *TD;
@@ -387,12 +387,12 @@ private:
 
 public:
   
-  DwarfWriter(std::ostream &OS, AsmPrinter *A, TargetAsmInfo *T);
+  DwarfWriter(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
   virtual ~DwarfWriter();
   
   // Accessors.
   //
-  TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
+  const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
   
   /// SetDebugInfo - Set DebugInfo when it's known that pass manager has
   /// created it.  Set by the target AsmPrinter.
index 56c25179c78f39ce0884f2f68a22f781f2dcbd77..6f63ba3a31ab40ea2dce55380205d8a23f60d03c 100644 (file)
@@ -21,6 +21,9 @@
 
 namespace llvm {
 
+  // Forward declaration.
+  class TargetMachine;
+
   /// TargetAsmInfo - This class is intended to be used as a base class for asm
   /// properties and features specific to the target.
   class TargetAsmInfo {
@@ -266,7 +269,7 @@ namespace llvm {
     unsigned getAddressSize() const {
       return AddressSize;
     }
-    bool getNeedsSet() const {
+    bool needsSet() const {
       return NeedsSet;
     }
     const char *getCommentString() const {
index 2a41d5ec3d0dccc3c0ca4fd563ce08224b977b72..6b5efd41496cda7355cbbb1265f40bf027da35cd 100644 (file)
@@ -20,6 +20,7 @@
 
 namespace llvm {
 
+class TargetAsmInfo;
 class TargetData;
 class TargetSubtarget;
 class TargetInstrInfo;
@@ -65,11 +66,16 @@ class TargetMachine {
   TargetMachine(const TargetMachine &);   // DO NOT IMPLEMENT
   void operator=(const TargetMachine &);  // DO NOT IMPLEMENT
 protected: // Can only create subclasses.
-  TargetMachine() { }
+  TargetMachine() : AsmInfo(NULL) { }
 
   /// getSubtargetImpl - virtual method implemented by subclasses that returns
   /// a reference to that target's TargetSubtarget-derived member variable.
   virtual const TargetSubtarget *getSubtargetImpl() const { return 0; }
+  
+  /// AsmInfo - Contains target specific asm information.
+  ///
+  mutable const TargetAsmInfo *AsmInfo;
+  
 public:
   virtual ~TargetMachine();
 
@@ -96,6 +102,18 @@ public:
   virtual const TargetFrameInfo        *getFrameInfo() const { return 0; }
   virtual       TargetLowering    *getTargetLowering() const { return 0; }
   virtual const TargetData            *getTargetData() const { return 0; }
+  
+  
+  /// getTargetAsmInfo - Return target specific asm information.
+  ///
+  const TargetAsmInfo *getTargetAsmInfo() const {
+    if (!AsmInfo) AsmInfo = createTargetAsmInfo();
+    return AsmInfo;
+  }
+  
+  /// createTargetAsmInfo - Create a new instance of target specific asm
+  /// information.
+  virtual const TargetAsmInfo *createTargetAsmInfo() const { return NULL; }
 
   /// getSubtarget - This method returns a pointer to the specified type of
   /// TargetSubtarget.  In debug builds, it verifies that the object being
index e6d56244c9c5e8c441c3d4f156192638b52c86ea..5af89c79c801da16b29d8d09e07ceff2b8014ff1 100644 (file)
@@ -27,7 +27,8 @@
 #include <cerrno>
 using namespace llvm;
 
-AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm, TargetAsmInfo *T)
+AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
+                       const TargetAsmInfo *T)
 : FunctionNumber(0), O(o), TM(tm), TAI(T)
 {}
 
index 9c4726ebc7823dd6ad33fd90a5b515ab028083ca..22d67449e1744740ce57e2d56521541cf2e6be3b 100644 (file)
@@ -574,24 +574,24 @@ void DIEAbbrev::Emit(const DwarfWriter &DW) const {
 }
 
 #ifndef NDEBUG
-  void DIEAbbrev::print(std::ostream &O) {
-    O << "Abbreviation @"
-      << std::hex << (intptr_t)this << std::dec
+void DIEAbbrev::print(std::ostream &O) {
+  O << "Abbreviation @"
+    << std::hex << (intptr_t)this << std::dec
+    << "  "
+    << TagString(Tag)
+    << " "
+    << ChildrenString(ChildrenFlag)
+    << "\n";
+  
+  for (unsigned i = 0, N = Data.size(); i < N; ++i) {
+    O << "  "
+      << AttributeString(Data[i].getAttribute())
       << "  "
-      << TagString(Tag)
-      << " "
-      << ChildrenString(ChildrenFlag)
+      << FormEncodingString(Data[i].getForm())
       << "\n";
-    
-    for (unsigned i = 0, N = Data.size(); i < N; ++i) {
-      O << "  "
-        << AttributeString(Data[i].getAttribute())
-        << "  "
-        << FormEncodingString(Data[i].getForm())
-        << "\n";
-    }
   }
-  void DIEAbbrev::dump() { print(std::cerr); }
+}
+void DIEAbbrev::dump() { print(std::cerr); }
 #endif
 
 //===----------------------------------------------------------------------===//
@@ -1160,7 +1160,7 @@ void DwarfWriter::EmitReference(const std::string &Name) const {
 /// is an option (needsSet) to use an intermediary 'set' expression.
 void DwarfWriter::EmitDifference(const char *TagHi, unsigned NumberHi,
                                  const char *TagLo, unsigned NumberLo) const {
-  if (TAI->getNeedsSet()) {
+  if (TAI->needsSet()) {
     static unsigned SetCounter = 0;
     
     O << "\t.set\t";
@@ -2467,7 +2467,8 @@ void DwarfWriter::ConstructSubprogramDIEs() {
 // Main entry points.
 //
   
-DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A, TargetAsmInfo *T)
+DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A,
+  const TargetAsmInfo *T)
 : O(OS)
 , Asm(A)
 , TAI(T)
index 98c37904cfd7d92634e327928c3860259269c3c2..2a0c4042ba3e2100201444257e11f21045af2c62 100644 (file)
@@ -38,20 +38,8 @@ using namespace llvm;
 namespace {
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
 
-  struct VISIBILITY_HIDDEN ARMTargetAsmInfo : public TargetAsmInfo {
-    ARMTargetAsmInfo() {
-      Data16bitsDirective = "\t.half\t";
-      Data32bitsDirective = "\t.word\t";
-      Data64bitsDirective = 0;
-      ZeroDirective = "\t.skip\t";
-      CommentString = "@";
-      ConstantPoolSection = "\t.text\n";
-      AlignmentIsInBytes = false;
-    }
-  };
-
   struct VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
-    ARMAsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
+    ARMAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
       : AsmPrinter(O, TM, T) {
     }
 
@@ -113,8 +101,7 @@ namespace {
 ///
 FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o,
                                                TargetMachine &tm) {
-  ARMTargetAsmInfo *TAI = new ARMTargetAsmInfo();
-  return new ARMAsmPrinter(o, tm, TAI);
+  return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
 }
 
 /// runOnMachineFunction - This uses the printMachineInstruction()
index f09b92b8f39fc360f8fa4e724ba220e26331d924..bf8deba9c3bd1840c34716ad6b8371afa95f02fd 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "ARMInstrInfo.h"
 #include "ARMFrameInfo.h"
+#include "ARMTargetAsmInfo.h"
 
 namespace llvm {
 
@@ -40,6 +41,10 @@ public:
   virtual const TargetData       *getTargetData() const { return &DataLayout; }
   static unsigned getModuleMatchQuality(const Module &M);
 
+  virtual const TargetAsmInfo *createTargetAsmInfo() const {
+    return static_cast<const TargetAsmInfo *>(new ARMTargetAsmInfo(*this));
+  }
+
   // Pass Pipeline Configuration
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
   virtual bool addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
index d709ed7342ccb1663c2210a0123683782af64ed5..2ce4865404bd00a15e3f811806077ec6f20b588b 100644 (file)
@@ -29,20 +29,13 @@ using namespace llvm;
 namespace {
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
   
-  struct VISIBILITY_HIDDEN AlphaTargetAsmInfo : public TargetAsmInfo {
-    AlphaTargetAsmInfo() {
-      AlignmentIsInBytes = false;
-      PrivateGlobalPrefix = "$";
-    }
-  };
-
   struct VISIBILITY_HIDDEN AlphaAsmPrinter : public AsmPrinter {
 
     /// Unique incrementer for label values for referencing Global values.
     ///
     unsigned LabelNumber;
 
-    AlphaAsmPrinter(std::ostream &o, TargetMachine &tm, TargetAsmInfo *T)
+    AlphaAsmPrinter(std::ostream &o, TargetMachine &tm, const TargetAsmInfo *T)
        : AsmPrinter(o, tm, T), LabelNumber(0) {
     }
 
@@ -82,8 +75,7 @@ namespace {
 ///
 FunctionPass *llvm::createAlphaCodePrinterPass (std::ostream &o,
                                                   TargetMachine &tm) {
-  AlphaTargetAsmInfo *TAI = new AlphaTargetAsmInfo();
-  return new AlphaAsmPrinter(o, tm, TAI);
+  return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo());
 }
 
 #include "AlphaGenAsmWriter.inc"
index 9c9f52dcf137cc303b1a9a520c301ebaf90c3116..cbe0cdbf4d7304cf8d05ee553dd1923c5c174cd8 100644 (file)
@@ -53,7 +53,8 @@ AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
   : DataLayout("e"),
     FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
     JITInfo(*this),
-    Subtarget(M, FS) {
+    Subtarget(M, FS),
+    AsmInfo(NULL) {
 }
 
 
index d71c7cec72db382e956d9a3ee63da76fc5a678c7..d47ca8215c9fa663343e50a3c55684fc4f5afaec 100644 (file)
@@ -20,6 +20,7 @@
 #include "AlphaInstrInfo.h"
 #include "AlphaJITInfo.h"
 #include "AlphaSubtarget.h"
+#include "AlphaTargetAsmInfo.h"
 
 namespace llvm {
 
@@ -31,9 +32,13 @@ class AlphaTargetMachine : public LLVMTargetMachine {
   TargetFrameInfo FrameInfo;
   AlphaJITInfo JITInfo;
   AlphaSubtarget Subtarget;
+  AlphaTargetAsmInfo *AsmInfo;
   
 public:
   AlphaTargetMachine(const Module &M, const std::string &FS);
+  ~AlphaTargetMachine() {
+    if (AsmInfo) delete AsmInfo;
+  }
 
   virtual const AlphaInstrInfo *getInstrInfo() const { return &InstrInfo; }
   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
@@ -46,6 +51,10 @@ public:
     return &JITInfo;
   }
 
+  virtual const TargetAsmInfo *createTargetAsmInfo() const {
+    return static_cast<const TargetAsmInfo *>(new AlphaTargetAsmInfo(*this));
+  }
+
   static unsigned getJITMatchQuality();
   static unsigned getModuleMatchQuality(const Module &M);
   
index 1de12153e273552f6c7912953b395bc280dbd1d7..4a16777f9bbbd3c72f5032686e377652ee90aeaf 100644 (file)
@@ -23,8 +23,8 @@
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetAsmInfo.h"
+#include "llvm/Target/TargetMachine.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/ADT/Statistic.h"
 #include <iostream>
@@ -32,31 +32,11 @@ using namespace llvm;
 
 namespace {
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
-
-  struct VISIBILITY_HIDDEN IA64TargetAsmInfo : public TargetAsmInfo {
-    IA64TargetAsmInfo() {
-      CommentString = "//";
-      Data8bitsDirective = "\tdata1\t";     // FIXME: check that we are
-      Data16bitsDirective = "\tdata2.ua\t"; // disabling auto-alignment
-      Data32bitsDirective = "\tdata4.ua\t"; // properly
-      Data64bitsDirective = "\tdata8.ua\t";
-      ZeroDirective = "\t.skip\t";
-      AsciiDirective = "\tstring\t";
-
-      GlobalVarAddrPrefix="";
-      GlobalVarAddrSuffix="";
-      FunctionAddrPrefix="@fptr(";
-      FunctionAddrSuffix=")";
-      
-      // FIXME: would be nice to have rodata (no 'w') when appropriate?
-      ConstantPoolSection = "\n\t.section .data, \"aw\", \"progbits\"\n";
-    }
-  };
   
   struct IA64AsmPrinter : public AsmPrinter {
     std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
 
-    IA64AsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
+    IA64AsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
       : AsmPrinter(O, TM, T) {
     }
 
@@ -366,8 +346,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) {
 ///
 FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,
                                               IA64TargetMachine &tm) {
-  IA64TargetAsmInfo *TAI = new IA64TargetAsmInfo();
-  return new IA64AsmPrinter(o, tm, TAI);
+  return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo());
 }
 
 
index 5a4b6b6995757a6098847e18fa131eb83e1b273d..61ac05f6a2bf4c12e46f65a662200f261c07c0f4 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "IA64InstrInfo.h"
 #include "IA64ISelLowering.h"
+#include "IA64TargetAsmInfo.h"
 
 namespace llvm {
 
@@ -40,6 +41,10 @@ public:
     return &InstrInfo.getRegisterInfo();
   }
   virtual const TargetData       *getTargetData() const { return &DataLayout; }
+  
+  virtual const TargetAsmInfo *createTargetAsmInfo() const {
+    return static_cast<const TargetAsmInfo *>(new IA64TargetAsmInfo(*this));
+  }
 
   static unsigned getModuleMatchQuality(const Module &M);
 
index 9ec7106c32ac8f667c52cb83eb0a92467d4e1ccf..b50fc45959994dbd3f993ffca605b4a7b2fd792c 100644 (file)
@@ -50,7 +50,7 @@ namespace {
   struct VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter {
     std::set<std::string> FnStubs, GVStubs;
     
-    PPCAsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
+    PPCAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
       : AsmPrinter(O, TM, T) {}
 
     virtual const char *getPassName() const {
@@ -239,49 +239,14 @@ namespace {
     
   };
 
-  struct VISIBILITY_HIDDEN DarwinTargetAsmInfo : public TargetAsmInfo {
-    DarwinTargetAsmInfo(PPCTargetMachine &TM) {
-      bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
-
-      CommentString = ";";
-      GlobalPrefix = "_";
-      PrivateGlobalPrefix = "L";
-      ZeroDirective = "\t.space\t";
-      SetDirective = "\t.set";
-      Data64bitsDirective = isPPC64 ? ".quad\t" : 0;  
-      AlignmentIsInBytes = false;
-      ConstantPoolSection = "\t.const\t";
-      JumpTableDataSection = ".const";
-      JumpTableTextSection = "\t.text";
-      LCOMMDirective = "\t.lcomm\t";
-      StaticCtorsSection = ".mod_init_func";
-      StaticDtorsSection = ".mod_term_func";
-      InlineAsmStart = "# InlineAsm Start";
-      InlineAsmEnd = "# InlineAsm End";
-      
-      NeedsSet = true;
-      AddressSize = isPPC64 ? 8 : 4;
-      DwarfAbbrevSection = ".section __DWARF,__debug_abbrev";
-      DwarfInfoSection = ".section __DWARF,__debug_info";
-      DwarfLineSection = ".section __DWARF,__debug_line";
-      DwarfFrameSection = ".section __DWARF,__debug_frame";
-      DwarfPubNamesSection = ".section __DWARF,__debug_pubnames";
-      DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes";
-      DwarfStrSection = ".section __DWARF,__debug_str";
-      DwarfLocSection = ".section __DWARF,__debug_loc";
-      DwarfARangesSection = ".section __DWARF,__debug_aranges";
-      DwarfRangesSection = ".section __DWARF,__debug_ranges";
-      DwarfMacInfoSection = ".section __DWARF,__debug_macinfo";
-    }
-  };
-
   /// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
   /// X
   struct VISIBILITY_HIDDEN DarwinAsmPrinter : public PPCAsmPrinter {
   
     DwarfWriter DW;
 
-    DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM, TargetAsmInfo *T)
+    DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM,
+                     const TargetAsmInfo *T)
       : PPCAsmPrinter(O, TM, T), DW(O, this, T) {
       bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
     }
@@ -309,8 +274,7 @@ namespace {
 ///
 FunctionPass *llvm::createDarwinCodePrinterPass(std::ostream &o,
                                                 PPCTargetMachine &tm) {
-  TargetAsmInfo *TAI = new DarwinTargetAsmInfo(tm);
-  return new DarwinAsmPrinter(o, tm, TAI);
+  return new DarwinAsmPrinter(o, tm, tm.getTargetAsmInfo());
 }
 
 // Include the auto-generated portion of the assembly writer
index 9a77a4fcb89a320791071965e96b69d48265f90c..d11f0158a02d793661f9b81a82adffc3c2eeebf5 100644 (file)
@@ -19,6 +19,7 @@
 #include "PPCJITInfo.h"
 #include "PPCInstrInfo.h"
 #include "PPCISelLowering.h"
+#include "PPCTargetAsmInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetData.h"
 
@@ -55,6 +56,9 @@ public:
     return InstrItins;
   }
   
+  virtual const TargetAsmInfo *createTargetAsmInfo() const {
+    return static_cast<const TargetAsmInfo *>(new DarwinTargetAsmInfo(*this));
+  }
   
   // Pass Pipeline Configuration
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
index 2bc6f6332e6aac954b15ee4c897bbbbd0e4d669c..1e6efcbeaf288de5cfd46417ea7c42a340fe212f 100644 (file)
@@ -37,19 +37,8 @@ using namespace llvm;
 namespace {
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
 
-  struct VISIBILITY_HIDDEN SparcTargetAsmInfo : public TargetAsmInfo {
-    SparcTargetAsmInfo() {
-      Data16bitsDirective = "\t.half\t";
-      Data32bitsDirective = "\t.word\t";
-      Data64bitsDirective = 0;  // .xword is only supported by V9.
-      ZeroDirective = "\t.skip\t";
-      CommentString = "!";
-      ConstantPoolSection = "\t.section \".rodata\",#alloc\n";
-    }
-  };
-
   struct VISIBILITY_HIDDEN SparcAsmPrinter : public AsmPrinter {
-    SparcAsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
+    SparcAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
       : AsmPrinter(O, TM, T) {
     }
 
@@ -85,8 +74,7 @@ namespace {
 ///
 FunctionPass *llvm::createSparcCodePrinterPass(std::ostream &o,
                                                TargetMachine &tm) {
-  SparcTargetAsmInfo *TAI = new SparcTargetAsmInfo();
-  return new SparcAsmPrinter(o, tm, TAI);
+  return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo());
 }
 
 /// runOnMachineFunction - This uses the printMachineInstruction()
index e377afa085314e26ed0700bbd2cbb754b5526947..995d346f92440254395a29c10e15e1230b1388c6 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "SparcInstrInfo.h"
 #include "SparcSubtarget.h"
+#include "SparcTargetAsmInfo.h"
 
 namespace llvm {
 
@@ -41,6 +42,9 @@ public:
   virtual const TargetData       *getTargetData() const { return &DataLayout; }
   static unsigned getModuleMatchQuality(const Module &M);
 
+  virtual const TargetAsmInfo *createTargetAsmInfo() const {
+    return static_cast<const TargetAsmInfo *>(new SparcTargetAsmInfo(*this));
+  }
   
   // Pass Pipeline Configuration
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
index 3a9c8b30c438ecacc3bd2bf85dc64482a38ad219..3ca64c44edba1099e640cb47069192ad41fdb208 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Support/CommandLine.h"
@@ -95,6 +96,7 @@ namespace {
 //
 
 TargetMachine::~TargetMachine() {
+  if (AsmInfo) delete AsmInfo;
 }
 
 /// getRelocationModel - Returns the code generation relocation model. The
index 6c54d6954995271b2de604fe0f1364fd45135b08..e3653e4920e261c9a692df24f0b63823e1b3fbfa 100755 (executable)
 #include "X86ATTAsmPrinter.h"
 #include "X86.h"
 #include "X86TargetMachine.h"
+#include "X86TargetAsmInfo.h"
 #include "llvm/Module.h"
 #include "llvm/Support/Mangler.h"
+#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetOptions.h"
 #include <iostream>
 using namespace llvm;
index e06015034c35f43b7a490f34f70e9cb14428b665..ff707caee68dca39426b53f5686d8031855d95b2 100755 (executable)
@@ -20,7 +20,7 @@
 namespace llvm {
 
 struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
- X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM, TargetAsmInfo *T)
+ X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM, const TargetAsmInfo *T)
     : X86SharedAsmPrinter(O, TM, T) { }
 
   virtual const char *getPassName() const {
index 2e32f34506b6253d0adfbf44e68cc28935df5259..4a54e5914dab8a482129a205569f354da77dda8f 100644 (file)
 #include "llvm/Type.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Support/Mangler.h"
+#include "llvm/Target/TargetAsmInfo.h"
 using namespace llvm;
 
 Statistic<> llvm::EmittedInsts("asm-printer",
                                "Number of machine instrs printed");
 
-X86TargetAsmInfo::X86TargetAsmInfo(X86TargetMachine &TM) {
-  const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
-  
-  //FIXME - Should to be simplified.
-   
-  switch (Subtarget->TargetType) {
-  case X86Subtarget::isDarwin:
-    AlignmentIsInBytes = false;
-    GlobalPrefix = "_";
-    Data64bitsDirective = 0;       // we can't emit a 64-bit unit
-    ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
-    PrivateGlobalPrefix = "L";     // Marker for constant pool idxs
-    ConstantPoolSection = "\t.const\n";
-    JumpTableDataSection = "\t.const\n"; // FIXME: depends on PIC mode
-    FourByteConstantSection = "\t.literal4\n";
-    EightByteConstantSection = "\t.literal8\n";
-    LCOMMDirective = "\t.lcomm\t";
-    COMMDirectiveTakesAlignment = false;
-    HasDotTypeDotSizeDirective = false;
-    StaticCtorsSection = ".mod_init_func";
-    StaticDtorsSection = ".mod_term_func";
-    InlineAsmStart = "# InlineAsm Start";
-    InlineAsmEnd = "# InlineAsm End";
-    SetDirective = "\t.set";
-    
-    NeedsSet = true;
-    DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
-    DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
-    DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
-    DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
-    DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
-    DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
-    DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
-    DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
-    DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
-    DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
-    DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
-    break;
-  case X86Subtarget::isCygwin:
-    GlobalPrefix = "_";
-    COMMDirectiveTakesAlignment = false;
-    HasDotTypeDotSizeDirective = false;
-    StaticCtorsSection = "\t.section .ctors,\"aw\"";
-    StaticDtorsSection = "\t.section .dtors,\"aw\"";
-    break;
-  case X86Subtarget::isWindows:
-    GlobalPrefix = "_";
-    HasDotTypeDotSizeDirective = false;
-    break;
-  default: break;
-  }
-  
-  if (Subtarget->isFlavorIntel()) {
-    GlobalPrefix = "_";
-    CommentString = ";";
-  
-    PrivateGlobalPrefix = "$";
-    AlignDirective = "\talign\t";
-    ZeroDirective = "\tdb\t";
-    ZeroDirectiveSuffix = " dup(0)";
-    AsciiDirective = "\tdb\t";
-    AscizDirective = 0;
-    Data8bitsDirective = "\tdb\t";
-    Data16bitsDirective = "\tdw\t";
-    Data32bitsDirective = "\tdd\t";
-    Data64bitsDirective = "\tdq\t";
-    HasDotTypeDotSizeDirective = false;
-    
-    TextSection = "_text";
-    DataSection = "_data";
-    SwitchToSectionDirective = "";
-    TextSectionStartSuffix = "\tsegment 'CODE'";
-    DataSectionStartSuffix = "\tsegment 'DATA'";
-    SectionEndDirectiveSuffix = "\tends\n";
-  }
-}
-
 /// doInitialization
 bool X86SharedAsmPrinter::doInitialization(Module &M) {  
   if (Subtarget->isTargetDarwin()) {
@@ -255,11 +179,10 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
 FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,
                                              X86TargetMachine &tm) {
   const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
-  TargetAsmInfo *TAI = new X86TargetAsmInfo(tm);
 
   if (Subtarget->isFlavorIntel()) {
-    return new X86IntelAsmPrinter(o, tm, TAI);
+    return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo());
   } else {
-    return new X86ATTAsmPrinter(o, tm, TAI);
+    return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo());
   }
 }
index aa8129bd219b42df31ffb6c61eddaba3e368e9e5..8d32f59d8b17d9cb7a500808a3ff2ac4f37d0c70 100755 (executable)
@@ -22,7 +22,6 @@
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineDebugInfo.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Target/TargetAsmInfo.h"
 #include <set>
 
 
@@ -30,15 +29,11 @@ namespace llvm {
 
 extern Statistic<> EmittedInsts;
 
-struct VISIBILITY_HIDDEN X86TargetAsmInfo : public TargetAsmInfo {
-  X86TargetAsmInfo(X86TargetMachine &TM);
-};
-
 struct VISIBILITY_HIDDEN X86SharedAsmPrinter : public AsmPrinter {
   DwarfWriter DW;
 
   X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM,
-                      TargetAsmInfo *T)
+                      const TargetAsmInfo *T)
     : AsmPrinter(O, TM, T), DW(O, this, T) {
     Subtarget = &TM.getSubtarget<X86Subtarget>();
   }
index 7be50e7fa8cad1abbfc4ca8aa19f1f0324ec1dd6..ddf807f7687c59da8101dab93162c1a9f2fe256f 100755 (executable)
 //===----------------------------------------------------------------------===//
 
 #include "X86IntelAsmPrinter.h"
+#include "X86TargetAsmInfo.h"
 #include "X86.h"
 #include "llvm/Constants.h"
 #include "llvm/Module.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Support/Mangler.h"
+#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetOptions.h"
 using namespace llvm;
 
index 8e0e8ba9858321f6911ae27ac16d87dcd2a1c940..ef0af2a6b58d8edc456495d79b051f466845d514 100755 (executable)
@@ -21,7 +21,8 @@
 namespace llvm {
 
 struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
-  X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM, TargetAsmInfo *T)
+  X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM,
+                     const TargetAsmInfo *T)
       : X86SharedAsmPrinter(O, TM, T) {
   }
 
index 9b50c7e408db114796209252751407d8eea597de..0bbef0582ff44627fe121a895c9b2d40ba748b08 100644 (file)
@@ -21,6 +21,7 @@
 #include "X86InstrInfo.h"
 #include "X86JITInfo.h"
 #include "X86Subtarget.h"
+#include "X86TargetAsmInfo.h"
 #include "X86ISelLowering.h"
 
 namespace llvm {
@@ -50,6 +51,9 @@ public:
   static unsigned getModuleMatchQuality(const Module &M);
   static unsigned getJITMatchQuality();
   
+  virtual const TargetAsmInfo *createTargetAsmInfo() const {
+    return static_cast<const TargetAsmInfo *>(new X86TargetAsmInfo(*this));
+  }
   
   // Set up the pass pipeline.
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);