Instead of yet another enum indicating the "assembly language flavor",
authorBill Wendling <isanbard@gmail.com>
Tue, 16 Jan 2007 09:29:17 +0000 (09:29 +0000)
committerBill Wendling <isanbard@gmail.com>
Tue, 16 Jan 2007 09:29:17 +0000 (09:29 +0000)
just use the one that's in the subtarget.

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

lib/Target/PowerPC/PPCSubtarget.cpp
lib/Target/PowerPC/PPCSubtarget.h
lib/Target/PowerPC/PPCTargetAsmInfo.cpp
lib/Target/X86/X86Subtarget.h
lib/Target/X86/X86TargetAsmInfo.cpp

index eca16c4a38c3a4c448626fc47221fb568d88a470..235b9d591de662bf92b176d060de893b4197b285 100644 (file)
@@ -112,6 +112,9 @@ PPCSubtarget::PPCSubtarget(const TargetMachine &tm, const Module &M,
   // Set up darwin-specific properties.
   if (IsDarwin) {
     HasLazyResolverStubs = true;
+    AsmFlavor = NewMnemonic;
+  } else {
+    AsmFlavor = OldMnemonic;
   }
 }
 
index 65d07d89526780fdd6e2a640e0dacd97335d9ad6..63efe9e96361cd49c39321c538da7294b3c453d0 100644 (file)
@@ -40,6 +40,10 @@ class GlobalValue;
 class TargetMachine;
   
 class PPCSubtarget : public TargetSubtarget {
+public:
+  enum AsmWriterFlavorTy {
+    OldMnemonic, NewMnemonic, Unset
+  };
 protected:
   const TargetMachine &TM;
   
@@ -53,6 +57,9 @@ protected:
   /// Which cpu directive was used.
   unsigned DarwinDirective;
 
+  /// AsmFlavor - Which PPC asm dialect to use.
+  AsmWriterFlavorTy AsmFlavor;
+
   /// Used by the ISel to turn in optimizations for POWER4-derived architectures
   bool IsGigaProcessor;
   bool Has64BitSupport;
@@ -120,8 +127,12 @@ public:
   bool hasSTFIWX() const { return HasSTFIWX; }
   bool hasAltivec() const { return HasAltivec; }
   bool isGigaProcessor() const { return IsGigaProcessor; }
-  
+
   bool isDarwin() const { return IsDarwin; }
+
+  unsigned getAsmFlavor() const {
+    return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0;
+  }
 };
 } // End llvm namespace
 
index 7912f705738aa2b205d40933d7cc67aa76a14fea..b9f5849bdf69660263890f1a4e7bf60f95dd14f0 100644 (file)
 #include "llvm/Function.h"
 using namespace llvm;
 
-// ASM variant to use.
-enum {
-  PPC_OLD_MNEMONICS = 0,
-  PPC_NEW_MNEMONICS = 1
-};
-
 PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
   bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
   
@@ -32,7 +26,7 @@ PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
   LCOMMDirective = "\t.lcomm\t";
   InlineAsmStart = "# InlineAsm Start";
   InlineAsmEnd = "# InlineAsm End";
-  AssemblerDialect = PPC_OLD_MNEMONICS;
+  AssemblerDialect = TM.getSubtargetImpl()->getAsmFlavor();
   
   NeedsSet = true;
   AddressSize = isPPC64 ? 8 : 4;
@@ -63,7 +57,6 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
   UsedDirective = "\t.no_dead_strip\t";
   WeakRefDirective = "\t.weak_reference\t";
   HiddenDirective = "\t.private_extern\t";
-  AssemblerDialect = PPC_NEW_MNEMONICS;
 }
 
 LinuxTargetAsmInfo::LinuxTargetAsmInfo(const PPCTargetMachine &TM)
index 43e850839204b7d9162ebb6f1edf4bb419d763e7..e39c77b23aaf00a9c43572a16a65e51c82aa1030 100644 (file)
@@ -111,6 +111,10 @@ public:
   bool has3DNow() const { return X863DNowLevel >= ThreeDNow; }
   bool has3DNowA() const { return X863DNowLevel >= ThreeDNowA; }
 
+  unsigned getAsmFlavor() const {
+    return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0;
+  }
+
   bool isFlavorAtt() const { return AsmFlavor == ATT; }
   bool isFlavorIntel() const { return AsmFlavor == Intel; }
 
index 97e59a51c260df3bb21c0e62d991815a8c2e1dcc..d80996fe161a6378ace69a7bfc11471b257ee3cc 100644 (file)
 #include "llvm/ADT/StringExtras.h"
 using namespace llvm;
 
-// ASM variant to use.
-enum {
-  X86_ATT   = 0,
-  X86_INTEL = 1
-};
-
 static const char* x86_asm_table[] = {"{si}", "S",
                                       "{di}", "D",
                                       "{ax}", "a",
@@ -44,7 +38,6 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
   // FIXME - Should be simplified.
 
   AsmTransCBE = x86_asm_table;
-  AssemblerDialect = X86_ATT;
   
   switch (Subtarget->TargetType) {
   case X86Subtarget::isDarwin:
@@ -169,9 +162,9 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     TextSectionStartSuffix = "\tsegment 'CODE'";
     DataSectionStartSuffix = "\tsegment 'DATA'";
     SectionEndDirectiveSuffix = "\tends\n";
-
-    AssemblerDialect = X86_INTEL;
   }
+
+  AssemblerDialect = Subtarget->getAsmFlavor();
 }
 
 bool X86TargetAsmInfo::LowerToBSwap(CallInst *CI) const {