OSDN Git Service

Eliminate SetDirective, and replace it with HasSetDirective.
authorChris Lattner <sabre@nondot.org>
Tue, 26 Jan 2010 20:40:54 +0000 (20:40 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 26 Jan 2010 20:40:54 +0000 (20:40 +0000)
Default HasSetDirective to true, since most targets have it.

The targets that claim to not have it probably do, or it is
spelled differently. These include Blackfin, Mips, Alpha, and
PIC16.  All of these except pic16 are normal ELF targets, so
they almost certainly have it.

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

20 files changed:
include/llvm/MC/MCAsmInfo.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
lib/MC/MCAsmInfo.cpp
lib/MC/MCAsmInfoCOFF.cpp
lib/MC/MCAsmInfoDarwin.cpp
lib/Target/ARM/ARMMCAsmInfo.cpp
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/Alpha/AlphaMCAsmInfo.cpp
lib/Target/Blackfin/BlackfinMCAsmInfo.cpp
lib/Target/CellSPU/SPUMCAsmInfo.cpp
lib/Target/MSP430/MSP430MCAsmInfo.cpp
lib/Target/Mips/MipsMCAsmInfo.cpp
lib/Target/PIC16/PIC16MCAsmInfo.cpp
lib/Target/PowerPC/PPCMCAsmInfo.cpp
lib/Target/Sparc/SparcMCAsmInfo.cpp
lib/Target/SystemZ/SystemZMCAsmInfo.cpp
lib/Target/X86/X86MCAsmInfo.cpp
lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
lib/Target/XCore/XCoreMCAsmInfo.cpp

index 1703a69..633b601 100644 (file)
@@ -173,13 +173,12 @@ namespace llvm {
     ///
     const char *ExternDirective;             // Defaults to NULL.
     
-    /// SetDirective - This is the name of a directive that can be used to tell
-    /// the assembler to set the value of a variable to some expression.
-    const char *SetDirective;                // Defaults to null.
+    /// HasSetDirective - True if the assembler supports the .set directive.
+    bool HasSetDirective;                    // Defaults to true.
     
     /// HasLCOMMDirective - This is true if the target supports the .lcomm
     /// directive.
-    bool HasLCOMMDirective;              // Defaults to false.
+    bool HasLCOMMDirective;                  // Defaults to false.
     
     /// COMMDirectiveAlignmentIsInBytes - True is COMMDirective's optional
     /// alignment is to be specified in bytes instead of log2(n).
@@ -377,9 +376,7 @@ namespace llvm {
     const char *getExternDirective() const {
       return ExternDirective;
     }
-    const char *getSetDirective() const {
-      return SetDirective;
-    }
+    bool hasSetDirective() const { return HasSetDirective; }
     bool hasLCOMMDirective() const { return HasLCOMMDirective; }
     bool hasDotTypeDotSizeDirective() const {return HasDotTypeDotSizeDirective;}
     bool getCOMMDirectiveAlignmentIsInBytes() const {
index 42bf352..d2c1721 100644 (file)
@@ -318,7 +318,7 @@ bool AsmPrinter::doFinalization(Module &M) {
     }
   }
 
-  if (MAI->getSetDirective()) {
+  if (MAI->hasSetDirective()) {
     OutStreamer.AddBlankLine();
     for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
          I != E; ++I) {
@@ -336,7 +336,7 @@ bool AsmPrinter::doFinalization(Module &M) {
 
       printVisibility(Name, I->getVisibility());
 
-      O << MAI->getSetDirective() << ' ' << *Name << ", " << *Target << '\n';
+      O << "\t.set\t" << *Name << ", " << *Target << '\n';
     }
   }
 
@@ -516,7 +516,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
     // .set directive for each unique entry.  This reduces the number of
     // relocations the assembler will generate for the jump table.
     if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 &&
-        MAI->getSetDirective()) {
+        MAI->hasSetDirective()) {
       SmallPtrSet<const MachineBasicBlock*, 16> EmittedSets;
       const TargetLowering *TLI = TM.getTargetLowering();
       const MCExpr *Base = TLI->getPICJumpTableRelocBaseExpr(&MF, JTI,
@@ -525,7 +525,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
         const MachineBasicBlock *MBB = JTBBs[ii];
         if (!EmittedSets.insert(MBB)) continue;
         
-        O << MAI->getSetDirective() << ' '
+        O << "\t.set\t"
           << *GetJTSetSymbol(JTI, MBB->getNumber()) << ','
           << *MBB->getSymbol(OutContext) << '-' << *Base << '\n';
       }
@@ -584,7 +584,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
     // If we have emitted set directives for the jump table entries, print 
     // them rather than the entries themselves.  If we're emitting PIC, then
     // emit the table entries as differences between two text section labels.
-    if (MAI->getSetDirective()) {
+    if (MAI->hasSetDirective()) {
       // If we used .set, reference the .set's symbol.
       Value = MCSymbolRefExpr::Create(GetJTSetSymbol(UID, MBB->getNumber()),
                                       OutContext);
index 28e0d97..f659c51 100644 (file)
@@ -200,7 +200,7 @@ void DwarfPrinter::EmitReference(const MCSymbol *Sym, bool IsPCRelative,
 void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi,
                                   const char *TagLo, unsigned NumberLo,
                                   bool IsSmall) {
-  if (MAI->getSetDirective() != 0) {
+  if (MAI->hasSetDirective()) {
     O << "\t.set\t";
     PrintLabelName("set", SetCounter, Flavor);
     O << ",";
@@ -231,7 +231,7 @@ void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section,
   else
     printAbsolute = MAI->isAbsoluteDebugSectionOffsets();
 
-  if (MAI->getSetDirective() != 0 && useSet) {
+  if (MAI->hasSetDirective() && useSet) {
     O << "\t.set\t";
     PrintLabelName("set", SetCounter, Flavor);
     O << ",";
index 12d2fcb..74bacfc 100644 (file)
@@ -49,7 +49,7 @@ MCAsmInfo::MCAsmInfo() {
   TextAlignFillValue = 0;
   GPRel32Directive = 0;
   GlobalDirective = "\t.globl\t";
-  SetDirective = 0;
+  HasSetDirective = true;
   HasLCOMMDirective = false;
   COMMDirectiveAlignmentIsInBytes = true;
   HasDotTypeDotSizeDirective = true;
index ab8a585..ace7ba1 100644 (file)
@@ -25,7 +25,6 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() {
   PrivateGlobalPrefix = "L";  // Prefix for private global symbols
   WeakRefDirective = "\t.weak\t";
   LinkOnceDirective = "\t.linkonce same_size\n";
-  SetDirective = "\t.set\t";
   
   // Doesn't support visibility:
   HiddenVisibilityAttr = ProtectedVisibilityAttr = MCSA_Invalid;
index e84131f..da865ad 100644 (file)
@@ -36,7 +36,6 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
   HasMachoZeroFillDirective = true;  // Uses .zerofill
   HasStaticCtorDtorReferenceInStaticMode = true;
-  SetDirective = "\t.set";
   
   HiddenVisibilityAttr = MCSA_PrivateExtern;
   // Doesn't support protected visibility.
index 911a71f..ccd6add 100644 (file)
@@ -62,7 +62,6 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
   AbsoluteDebugSectionOffsets = true;
   PrivateGlobalPrefix = ".L";
   WeakRefDirective = "\t.weak\t";
-  SetDirective = "\t.set\t";
   HasLCOMMDirective = true;
 
   DwarfRequiresFrameSection = false;
index bb6fc2f..2b0b77a 100644 (file)
@@ -939,14 +939,14 @@ void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNum) {
   const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
   const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
   const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
-  bool UseSet= MAI->getSetDirective() && TM.getRelocationModel() == Reloc::PIC_;
+  bool UseSet= MAI->hasSetDirective() && TM.getRelocationModel() == Reloc::PIC_;
   SmallPtrSet<MachineBasicBlock*, 8> JTSets;
   for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
     MachineBasicBlock *MBB = JTBBs[i];
     bool isNew = JTSets.insert(MBB);
 
     if (UseSet && isNew) {
-      O << MAI->getSetDirective() << ' '
+      O << "\t.set\t"
         << *GetARMSetPICJumpTableLabel2(JTI, MO2.getImm(), MBB) << ','
         << *MBB->getSymbol(OutContext) << '-' << *JTISymbol << '\n';
     }
index 0e63582..c67c6a2 100644 (file)
@@ -19,4 +19,5 @@ AlphaMCAsmInfo::AlphaMCAsmInfo(const Target &T, const StringRef &TT) {
   PrivateGlobalPrefix = "$";
   GPRel32Directive = ".gprel32";
   WeakRefDirective = "\t.weak\t";
+  HasSetDirective = false;
 }
index 6d0f66c..31470fb 100644 (file)
@@ -18,4 +18,5 @@ using namespace llvm;
 BlackfinMCAsmInfo::BlackfinMCAsmInfo(const Target &T, const StringRef &TT) {
   GlobalPrefix = "_";
   CommentString = "//";
+  HasSetDirective = false;
 }
index c10b460..5ef3c6b 100644 (file)
@@ -16,7 +16,6 @@ using namespace llvm;
 
 SPULinuxMCAsmInfo::SPULinuxMCAsmInfo(const Target &T, const StringRef &TT) {
   ZeroDirective = "\t.space\t";
-  SetDirective = "\t.set";
   Data64bitsDirective = "\t.quad\t";
   AlignmentIsInBytes = false;
   HasLCOMMDirective = true;
index 516eacb..cfb499d 100644 (file)
@@ -17,7 +17,6 @@ using namespace llvm;
 MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) {
   PrivateGlobalPrefix = ".L";
   WeakRefDirective ="\t.weak\t";
-  SetDirective = "\t.set\t";
   PCSymbol=".";
   CommentString = ";";
 
index c5356f0..89e3e11 100644 (file)
@@ -23,4 +23,5 @@ MipsMCAsmInfo::MipsMCAsmInfo(const Target &T, const StringRef &TT) {
   CommentString               = "#";
   ZeroDirective               = "\t.space\t";
   GPRel32Directive            = "\t.gpword\t";
+  HasSetDirective             = false;
 }
index 827315e..b080542 100644 (file)
@@ -37,7 +37,7 @@ PIC16MCAsmInfo::PIC16MCAsmInfo(const Target &T, const StringRef &TT) {
   RomData8bitsDirective = " dw ";
   RomData16bitsDirective = " rom_di ";
   RomData32bitsDirective = " rom_dl ";
-    
+  HasSetDirective = false;  
     
   // Set it to false because we weed to generate c file name and not bc file
   // name.
index c61627e..b0d04e4 100644 (file)
@@ -49,7 +49,6 @@ PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
   AbsoluteEHSectionOffsets = false;
     
   ZeroDirective = "\t.space\t";
-  SetDirective = "\t.set";
   Data64bitsDirective = is64Bit ? "\t.quad\t" : 0;
   HasLCOMMDirective = true;
   AssemblerDialect = 0;           // Old-Style mnemonics.
index 923181d..53a9bde 100644 (file)
@@ -29,7 +29,6 @@ SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, const StringRef &TT) {
   UsesELFSectionDirectiveForBSS = true;
 
   WeakRefDirective = "\t.weak\t";
-  SetDirective = "\t.set\t";
 
   PrivateGlobalPrefix = ".L";
 }
index 52d4d51..1a09206 100644 (file)
@@ -18,7 +18,6 @@ using namespace llvm;
 SystemZMCAsmInfo::SystemZMCAsmInfo(const Target &T, const StringRef &TT) {
   PrivateGlobalPrefix = ".L";
   WeakRefDirective = "\t.weak\t";
-  SetDirective = "\t.set\t";
   PCSymbol = ".";
 }
 
index c0cab86..d3b0052 100644 (file)
@@ -72,7 +72,6 @@ X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) {
 
   PrivateGlobalPrefix = ".L";
   WeakRefDirective = "\t.weak\t";
-  SetDirective = "\t.set\t";
   PCSymbol = ".";
 
   // Set up DWARF directives
index e955ef9..15b4548 100644 (file)
@@ -106,7 +106,7 @@ void XCoreAsmPrinter::emitArrayBound(const MCSymbol *Sym,
     cast<PointerType>(GV->getType())->getElementType())) {
     O << MAI->getGlobalDirective() << *Sym;
     O << ".globound" << "\n";
-    O << MAI->getSetDirective() << *Sym;
+    O << "\t.set\t" << *Sym;
     O << ".globound" << "," << ATy->getNumElements() << "\n";
     if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
       // TODO Use COMDAT groups for LinkOnceLinkage
index dffdda9..bf78575 100644 (file)
@@ -22,7 +22,6 @@ XCoreMCAsmInfo::XCoreMCAsmInfo(const Target &T, const StringRef &TT) {
   AscizDirective = ".asciiz";
   WeakDefDirective = "\t.weak\t";
   WeakRefDirective = "\t.weak\t";
-  SetDirective = "\t.set\t";
 
   // Debug
   HasLEB128 = true;