[llvm-commits] [llvm] r58624 - in /llvm/trunk: include/llvm/Target/DarwinTargetAsmInfo.h include/llvm/Target/ELFTargetAsmInfo.h include/llvm/Target/TargetAsmInfo.h lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/Alpha/AlphaTargetAsmInfo.cpp lib/Target/CellSPU/SPUTargetAsmInfo.cpp lib/Target/DarwinTargetAsmInfo.cpp lib/Target/ELFTargetAsmInfo.cpp lib/Target/Mips/MipsTargetAsmInfo.cpp lib/Target/PIC16/PIC16TargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.h

Dan Gohman gohman at apple.com
Mon Nov 3 10:22:43 PST 2008


Author: djg
Date: Mon Nov  3 12:22:42 2008
New Revision: 58624

URL: http://llvm.org/viewvc/llvm-project?rev=58624&view=rev
Log:
Refactor various TargetAsmInfo subclasses' TargetMachine members away
adding a TargetMachine member to the base TargetAsmInfo class instead.

Modified:
    llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h
    llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
    llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp
    llvm/trunk/lib/Target/Alpha/AlphaTargetAsmInfo.cpp
    llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp
    llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
    llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
    llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp
    llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
    llvm/trunk/lib/Target/TargetAsmInfo.cpp
    llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
    llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h

Modified: llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h Mon Nov  3 12:22:42 2008
@@ -44,8 +44,6 @@
     const Section* MergeableConstSection(const Type *Ty) const;
     const Section* MergeableStringSection(const GlobalVariable *GV) const;
     const Section* SelectSectionForMachineConst(const Type *Ty) const;
-  protected:
-    const TargetMachine* DTM;
   };
 }
 

Modified: llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/ELFTargetAsmInfo.h Mon Nov  3 12:22:42 2008
@@ -33,8 +33,6 @@
     const Section* MergeableStringSection(const GlobalVariable *GV) const;
     virtual const Section*
     SelectSectionForMachineConst(const Type *Ty) const;
-  protected:
-    const TargetMachine* ETM;
   };
 }
 

Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Mon Nov  3 12:22:42 2008
@@ -126,6 +126,9 @@
     mutable SectionFlags::FlagsStringsMapType FlagsStrings;
     void fillDefaultValues();
   protected:
+    /// TM - The current TargetMachine.
+    const TargetMachine &TM;
+
     //===------------------------------------------------------------------===//
     // Properties to be set by the target writer, used to configure asm printer.
     //
@@ -510,8 +513,7 @@
     const char *const *AsmTransCBE; // Defaults to empty
 
   public:
-    TargetAsmInfo();
-    TargetAsmInfo(const TargetMachine &TM);
+    explicit TargetAsmInfo(const TargetMachine &TM);
     virtual ~TargetAsmInfo();
 
     const Section* getNamedSection(const char *Name,

Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -45,7 +45,7 @@
 
 ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
   ARMTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
-  Subtarget = &DTM->getSubtarget<ARMSubtarget>();
+  Subtarget = &TM.getSubtarget<ARMSubtarget>();
 
   GlobalPrefix = "_";
   PrivateGlobalPrefix = "L";
@@ -93,7 +93,7 @@
 
 ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM):
   ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) {
-  Subtarget = &ETM->getSubtarget<ARMSubtarget>();
+  Subtarget = &TM.getSubtarget<ARMSubtarget>();
 
   NeedsSet = false;
   HasLEB128 = true;

Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Alpha/AlphaTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/Alpha/AlphaTargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -11,11 +11,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "AlphaTargetMachine.h"
 #include "AlphaTargetAsmInfo.h"
 
 using namespace llvm;
 
-AlphaTargetAsmInfo::AlphaTargetAsmInfo(const AlphaTargetMachine &TM) {
+AlphaTargetAsmInfo::AlphaTargetAsmInfo(const AlphaTargetMachine &TM) 
+  : TargetAsmInfo(TM) {
   AlignmentIsInBytes = false;
   PrivateGlobalPrefix = "$";
   JumpTableDirective = ".gprel32";

Modified: llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -16,7 +16,8 @@
 #include "llvm/Function.h"
 using namespace llvm;
 
-SPUTargetAsmInfo::SPUTargetAsmInfo(const SPUTargetMachine &TM) {
+SPUTargetAsmInfo::SPUTargetAsmInfo(const SPUTargetMachine &TM)
+  : TargetAsmInfo(TM) {
   PCSymbol = ".";
   CommentString = "#";
   GlobalPrefix = "";

Modified: llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -24,8 +24,8 @@
 
 using namespace llvm;
 
-DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) {
-  DTM = &TM;
+DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) 
+  : TargetAsmInfo(TM) {
 
   CStringSection_ = getUnnamedSection("\t.cstring",
                                 SectionFlags::Mergeable | SectionFlags::Strings);
@@ -76,7 +76,7 @@
 DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
   SectionKind::Kind Kind = SectionKindForGlobal(GV);
   bool isWeak = GV->mayBeOverridden();
-  bool isNonStatic = (DTM->getRelocationModel() != Reloc::Static);
+  bool isNonStatic = TM.getRelocationModel() != Reloc::Static;
 
   switch (Kind) {
    case SectionKind::Text:
@@ -112,13 +112,12 @@
 
 const Section*
 DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
-  const TargetData *TD = DTM->getTargetData();
+  const TargetData *TD = TM.getTargetData();
   Constant *C = cast<GlobalVariable>(GV)->getInitializer();
   const Type *Type = cast<ConstantArray>(C)->getType()->getElementType();
 
   unsigned Size = TD->getABITypeSize(Type);
   if (Size) {
-    const TargetData *TD = DTM->getTargetData();
     unsigned Align = TD->getPreferredAlignment(GV);
     if (Align <= 32)
       return getCStringSection_();
@@ -136,7 +135,7 @@
 
 inline const Section*
 DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
-  const TargetData *TD = DTM->getTargetData();
+  const TargetData *TD = TM.getTargetData();
 
   unsigned Size = TD->getABITypeSize(Ty);
   if (Size == 4)
@@ -155,7 +154,7 @@
 
   // Handle weird special case, when compiling PIC stuff.
   if (S == getReadOnlySection() &&
-      DTM->getRelocationModel() != Reloc::Static)
+      TM.getRelocationModel() != Reloc::Static)
     return ConstDataSection;
 
   return S;

Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -24,8 +24,8 @@
 
 using namespace llvm;
 
-ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) {
-  ETM = &TM;
+ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
+  : TargetAsmInfo(TM) {
 
   BSSSection_  = getUnnamedSection("\t.bss",
                                    SectionFlags::Writeable | SectionFlags::BSS);
@@ -102,7 +102,7 @@
 
 inline const Section*
 ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const {
-  const TargetData *TD = ETM->getTargetData();
+  const TargetData *TD = TM.getTargetData();
 
   // FIXME: string here is temporary, until stuff will fully land in.
   // We cannot use {Four,Eight,Sixteen}ByteConstantSection here, since it's
@@ -121,7 +121,7 @@
 
 const Section*
 ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
-  const TargetData *TD = ETM->getTargetData();
+  const TargetData *TD = TM.getTargetData();
   Constant *C = cast<GlobalVariable>(GV)->getInitializer();
   const ConstantArray *CVA = cast<ConstantArray>(C);
   const Type *Ty = CVA->getType()->getElementType();
@@ -131,7 +131,6 @@
     assert(getCStringSection() && "Should have string section prefix");
 
     // We also need alignment here
-    const TargetData *TD = ETM->getTargetData();
     unsigned Align = TD->getPrefTypeAlignment(Ty);
     if (Align < Size)
       Align = Size;

Modified: llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -65,7 +65,7 @@
     return K;
 
   if (isa<GlobalVariable>(GV)) {
-    const TargetData *TD = ETM->getTargetData();
+    const TargetData *TD = TM.getTargetData();
     unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
     unsigned Threshold = Subtarget->getSSectionThreshold();
 

Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16TargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -12,12 +12,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "PIC16TargetAsmInfo.h"
+#include "PIC16TargetMachine.h"
 
 using namespace llvm;
 
 PIC16TargetAsmInfo::
-PIC16TargetAsmInfo(const PIC16TargetMachine &TM) 
-{
+PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
+  : TargetAsmInfo(TM) {
   Data16bitsDirective = "\t.half\t";
   Data32bitsDirective = "\t.word\t";
   CommentString = ";";

Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -119,11 +119,8 @@
   DataSection = getUnnamedSection("\t.data", SectionFlags::Writeable);
 }
 
-TargetAsmInfo::TargetAsmInfo() {
-  fillDefaultValues();
-}
-
-TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) {
+TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) 
+  : TM(tm) {
   fillDefaultValues();
 }
 

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Mon Nov  3 12:22:42 2008
@@ -39,7 +39,7 @@
 
 X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
   X86TargetAsmInfo<DarwinTargetAsmInfo>(TM) {
-  const X86Subtarget* Subtarget = &DTM->getSubtarget<X86Subtarget>();
+  const X86Subtarget* Subtarget = &TM.getSubtarget<X86Subtarget>();
   bool is64Bit = Subtarget->is64Bit();
 
   AlignmentIsInBytes = false;
@@ -52,7 +52,7 @@
   LessPrivateGlobalPrefix = "l";  // Marker for some ObjC metadata
   BSSSection = 0;                       // no BSS section.
   ZeroFillDirective = "\t.zerofill\t";  // Uses .zerofill
-  if (DTM->getRelocationModel() != Reloc::Static)
+  if (TM.getRelocationModel() != Reloc::Static)
     ConstantPoolSection = "\t.const_data";
   else
     ConstantPoolSection = "\t.const\n";
@@ -171,17 +171,17 @@
   DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\", at progbits";
 
   // On Linux we must declare when we can use a non-executable stack.
-  if (ETM->getSubtarget<X86Subtarget>().isLinux())
+  if (TM.getSubtarget<X86Subtarget>().isLinux())
     NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\", at progbits";
 }
 
 unsigned
 X86ELFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
                                            bool Global) const {
-  CodeModel::Model CM = ETM->getCodeModel();
-  bool is64Bit = ETM->getSubtarget<X86Subtarget>().is64Bit();
+  CodeModel::Model CM = TM.getCodeModel();
+  bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
 
-  if (ETM->getRelocationModel() == Reloc::PIC_) {
+  if (TM.getRelocationModel() == Reloc::PIC_) {
     unsigned Format = 0;
 
     if (!is64Bit)
@@ -216,7 +216,6 @@
 
 X86COFFTargetAsmInfo::X86COFFTargetAsmInfo(const X86TargetMachine &TM):
   X86GenericTargetAsmInfo(TM) {
-  X86TM = &TM;
 
   GlobalPrefix = "_";
   LCOMMDirective = "\t.lcomm\t";
@@ -251,10 +250,10 @@
 unsigned
 X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
                                             bool Global) const {
-  CodeModel::Model CM = X86TM->getCodeModel();
-  bool is64Bit = X86TM->getSubtarget<X86Subtarget>().is64Bit();
+  CodeModel::Model CM = TM.getCodeModel();
+  bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
 
-  if (X86TM->getRelocationModel() == Reloc::PIC_) {
+  if (TM.getRelocationModel() == Reloc::PIC_) {
     unsigned Format = 0;
 
     if (!is64Bit)

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h?rev=58624&r1=58623&r2=58624&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.h Mon Nov  3 12:22:42 2008
@@ -63,8 +63,6 @@
     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
                                                SectionKind::Kind kind) const;
     virtual std::string printSectionFlags(unsigned flags) const;
-  protected:
-    const X86TargetMachine *X86TM;
   };
 
   struct X86WinTargetAsmInfo : public X86GenericTargetAsmInfo {





More information about the llvm-commits mailing list