diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp index eca16c4a38c3..235b9d591de6 100644 --- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp @@ -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; } } diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.h b/llvm/lib/Target/PowerPC/PPCSubtarget.h index 65d07d895267..63efe9e96361 100644 --- a/llvm/lib/Target/PowerPC/PPCSubtarget.h +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.h @@ -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 diff --git a/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp index 7912f705738a..b9f5849bdf69 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp @@ -16,12 +16,6 @@ #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) diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h index 43e850839204..e39c77b23aaf 100644 --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -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; } diff --git a/llvm/lib/Target/X86/X86TargetAsmInfo.cpp b/llvm/lib/Target/X86/X86TargetAsmInfo.cpp index 97e59a51c260..d80996fe161a 100644 --- a/llvm/lib/Target/X86/X86TargetAsmInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetAsmInfo.cpp @@ -21,12 +21,6 @@ #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 {