[llvm-commits] [llvm] r42419 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86RegisterInfo.cpp

Dan Gohman djg at cray.com
Thu Sep 27 16:12:31 PDT 2007


Author: djg
Date: Thu Sep 27 18:12:31 2007
New Revision: 42419

URL: http://llvm.org/viewvc/llvm-project?rev=42419&view=rev
Log:
TargetAsmInfo::getAddressSize() was incorrect for x86-64 and 64-bit targets
other than PPC64. Instead of fixing it, just remove it and fix all the
places that use it to use TargetData::getPointerSize() instead, as there
aren't very many. Most of the references were in DwarfWriter.cpp.

Modified:
    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
    llvm/trunk/lib/CodeGen/DwarfWriter.cpp
    llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
    llvm/trunk/lib/Target/TargetAsmInfo.cpp
    llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp

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

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Thu Sep 27 18:12:31 2007
@@ -56,10 +56,6 @@
     /// section on this target.  Null if this target doesn't support zerofill.
     const char *ZeroFillDirective;        // Default is null.
     
-    /// AddressSize - Size of addresses used in file.
-    ///
-    unsigned AddressSize;                 // Defaults to 4.
-    
     /// NeedsSet - True if target asm can't compute addresses on data
     /// directives.
     bool NeedsSet;                        // Defaults to false.
@@ -400,9 +396,6 @@
     const char *getZeroFillDirective() const {
       return ZeroFillDirective;
     }
-    unsigned getAddressSize() const {
-      return AddressSize;
-    }
     bool needsSet() const {
       return NeedsSet;
     }

Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=42419&r1=42418&r2=42419&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Thu Sep 27 18:12:31 2007
@@ -829,12 +829,13 @@
   AsmPrinter *getAsm() const { return Asm; }
   MachineModuleInfo *getMMI() const { return MMI; }
   const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
+  const TargetData *getTargetData() const { return TD; }
 
   void PrintRelDirective(bool Force32Bit = false, bool isInSection = false)
                                                                          const {
     if (isInSection && TAI->getDwarfSectionOffsetDirective())
       O << TAI->getDwarfSectionOffsetDirective();
-    else if (Force32Bit || TAI->getAddressSize() == sizeof(int32_t))
+    else if (Force32Bit || TD->getPointerSize() == sizeof(int32_t))
       O << TAI->getData32bitsDirective();
     else
       O << TAI->getData64bitsDirective();
@@ -969,7 +970,7 @@
     int stackGrowth =
         Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
           TargetFrameInfo::StackGrowsUp ?
-            TAI->getAddressSize() : -TAI->getAddressSize();
+            TD->getPointerSize() : -TD->getPointerSize();
     bool IsLocal = BaseLabel && strcmp(BaseLabel, "label") == 0;
 
     for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
@@ -1392,7 +1393,7 @@
   ///
   DIE *ConstructPointerType(CompileUnit *Unit, const std::string &Name) {
     DIE Buffer(DW_TAG_pointer_type);
-    AddUInt(&Buffer, DW_AT_byte_size, 0, TAI->getAddressSize());
+    AddUInt(&Buffer, DW_AT_byte_size, 0, TD->getPointerSize());
     if (!Name.empty()) AddString(&Buffer, DW_AT_name, DW_FORM_string, Name);
     return Unit->AddDie(Buffer);
   }
@@ -2146,7 +2147,7 @@
     Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF version number");
     EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false);
     Asm->EOL("Offset Into Abbrev. Section");
-    Asm->EmitInt8(TAI->getAddressSize()); Asm->EOL("Address Size (in bytes)");
+    Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
   
     EmitDIE(Die);
     // FIXME - extra padding for gdb bug.
@@ -2297,7 +2298,7 @@
 
         // Define the line address.
         Asm->EmitInt8(0); Asm->EOL("Extended Op");
-        Asm->EmitInt8(TAI->getAddressSize() + 1); Asm->EOL("Op size");
+        Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
         Asm->EmitInt8(DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
         EmitReference("label",  LabelID); Asm->EOL("Location label");
         
@@ -2335,7 +2336,7 @@
 
       // Define last address of section.
       Asm->EmitInt8(0); Asm->EOL("Extended Op");
-      Asm->EmitInt8(TAI->getAddressSize() + 1); Asm->EOL("Op size");
+      Asm->EmitInt8(TD->getPointerSize() + 1); Asm->EOL("Op size");
       Asm->EmitInt8(DW_LNE_set_address); Asm->EOL("DW_LNE_set_address");
       EmitReference("section_end", j + 1); Asm->EOL("Section end label");
 
@@ -2359,7 +2360,7 @@
     int stackGrowth =
         Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
           TargetFrameInfo::StackGrowsUp ?
-        TAI->getAddressSize() : -TAI->getAddressSize();
+        TD->getPointerSize() : -TD->getPointerSize();
 
     // Start the dwarf frame section.
     Asm->SwitchToDataSection(TAI->getDwarfFrameSection());
@@ -2517,7 +2518,7 @@
     EmitReference("info_begin", Unit->getID());
     Asm->EOL("Offset of Compilation Unit Info");
 
-    Asm->EmitInt8(TAI->getAddressSize()); Asm->EOL("Size of Address");
+    Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Size of Address");
 
     Asm->EmitInt8(0); Asm->EOL("Size of Segment Descriptor");
 
@@ -2781,7 +2782,7 @@
     int stackGrowth =
         Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
           TargetFrameInfo::StackGrowsUp ?
-        TAI->getAddressSize() : -TAI->getAddressSize();
+        TD->getPointerSize() : -TD->getPointerSize();
 
     // Begin eh frame section.
     Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection());
@@ -2898,7 +2899,7 @@
         
         if (EHFrameInfo.hasLandingPads) {
           EmitReference("exception", EHFrameInfo.Number, true);
-        } else if(TAI->getAddressSize() == 8) {
+        } else if (TD->getPointerSize() == 8) {
           Asm->EmitInt64((int)0);
         } else {
           Asm->EmitInt32((int)0);
@@ -3183,7 +3184,7 @@
     for (unsigned i = 0, e = CallSites.size(); i < e; ++i)
       SizeSites += Asm->SizeULEB128(CallSites[i].Action);
 
-    unsigned SizeTypes = TypeInfos.size() * TAI->getAddressSize();
+    unsigned SizeTypes = TypeInfos.size() * TD->getPointerSize();
 
     unsigned TypeOffset = sizeof(int8_t) + // Call site format
                           Asm->SizeULEB128(SizeSites) + // Call-site table length
@@ -3244,7 +3245,7 @@
       Asm->EOL("Region length");
 
       if (!S.PadLabel) {
-        if (TAI->getAddressSize() == sizeof(int32_t))
+        if (TD->getPointerSize() == sizeof(int32_t))
           Asm->EmitInt32(0);
         else
           Asm->EmitInt64(0);
@@ -3484,7 +3485,7 @@
 /// SizeOf - Determine size of label value in bytes.
 ///
 unsigned DIEDwarfLabel::SizeOf(const DwarfDebug &DD, unsigned Form) const {
-  return DD.getTargetAsmInfo()->getAddressSize();
+  return DD.getTargetData()->getPointerSize();
 }
 
 //===----------------------------------------------------------------------===//
@@ -3498,7 +3499,7 @@
 /// SizeOf - Determine size of label value in bytes.
 ///
 unsigned DIEObjectLabel::SizeOf(const DwarfDebug &DD, unsigned Form) const {
-  return DD.getTargetAsmInfo()->getAddressSize();
+  return DD.getTargetData()->getPointerSize();
 }
     
 //===----------------------------------------------------------------------===//
@@ -3514,7 +3515,7 @@
 ///
 unsigned DIEDelta::SizeOf(const DwarfDebug &DD, unsigned Form) const {
   if (Form == DW_FORM_data4) return 4;
-  return DD.getTargetAsmInfo()->getAddressSize();
+  return DD.getTargetData()->getPointerSize();
 }
 
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=42419&r1=42418&r2=42419&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Thu Sep 27 18:12:31 2007
@@ -29,7 +29,6 @@
   AssemblerDialect = TM.getSubtargetImpl()->getAsmFlavor();
   
   NeedsSet = true;
-  AddressSize = isPPC64 ? 8 : 4;
   DwarfEHFrameSection =
   ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
   DwarfExceptionSection = ".section __DATA,__gcc_except_tab";

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

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Thu Sep 27 18:12:31 2007
@@ -25,7 +25,6 @@
   TLSDataSection("\t.section .tdata,\"awT\", at progbits"),
   TLSBSSSection("\t.section .tbss,\"awT\", at nobits"),
   ZeroFillDirective(0),
-  AddressSize(4),
   NeedsSet(false),
   MaxInstLength(4),
   PCSymbol("$"),

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Thu Sep 27 18:12:31 2007
@@ -1508,13 +1508,13 @@
 
   if (MMI && MMI->needsFrameInfo()) {
     std::vector<MachineMove> &Moves = MMI->getFrameMoves();
-    const TargetAsmInfo *TAI = MF.getTarget().getTargetAsmInfo();
+    const TargetData *TD = MF.getTarget().getTargetData();
 
     // Calculate amount of bytes used for return address storing
     int stackGrowth =
       (MF.getTarget().getFrameInfo()->getStackGrowthDirection() ==
        TargetFrameInfo::StackGrowsUp ?
-       TAI->getAddressSize() : -TAI->getAddressSize());
+       TD->getPointerSize() : -TD->getPointerSize());
 
     if (StackSize) {
       // Show update of SP.





More information about the llvm-commits mailing list