llvm-mc/AsmParser: Define match classes in the .td file.
[oota-llvm.git] / lib / Target / X86 / X86TargetAsmInfo.h
index 948a9312db5c57740c7a7db457e8e1cfc52a6761..34599e5a92d238d2a17176d7c2e7aefe50d529d8 100644 (file)
 #ifndef X86TARGETASMINFO_H
 #define X86TARGETASMINFO_H
 
+#include "X86TargetMachine.h"
 #include "llvm/Target/TargetAsmInfo.h"
-#include "llvm/Target/ELFTargetAsmInfo.h"
+#include "llvm/Target/COFFTargetAsmInfo.h"
 #include "llvm/Target/DarwinTargetAsmInfo.h"
+#include "llvm/Support/Compiler.h"
 
 namespace llvm {
 
-  // Forward declaration.
-  class X86TargetMachine;
-  class GlobalVariable;
+  extern const char *const x86_asm_table[];
 
-  struct X86TargetAsmInfo : public virtual TargetAsmInfo {
-    explicit X86TargetAsmInfo(const X86TargetMachine &TM);
-
-    virtual bool ExpandInlineAsm(CallInst *CI) const;
-
-  private:
-    bool LowerToBSwap(CallInst *CI) const;
+  template <class BaseTAI>
+  struct X86TargetAsmInfo : public BaseTAI {
+    explicit X86TargetAsmInfo(const TargetMachine &TM) {
+      BaseTAI::AsmTransCBE = x86_asm_table;
+      BaseTAI::AssemblerDialect =TM.getSubtarget<X86Subtarget>().getAsmFlavor();
+    }
   };
 
-  struct X86DarwinTargetAsmInfo : public X86TargetAsmInfo,
-                                  public DarwinTargetAsmInfo {
+  EXTERN_TEMPLATE_INSTANTIATION(class X86TargetAsmInfo<TargetAsmInfo>);
+
+  struct X86DarwinTargetAsmInfo : public X86TargetAsmInfo<DarwinTargetAsmInfo> {
     explicit X86DarwinTargetAsmInfo(const X86TargetMachine &TM);
-    virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
-                                           bool Global) const;
   };
 
-  struct X86ELFTargetAsmInfo : public X86TargetAsmInfo,
-                               public ELFTargetAsmInfo {
+  struct X86ELFTargetAsmInfo : public X86TargetAsmInfo<TargetAsmInfo> {
     explicit X86ELFTargetAsmInfo(const X86TargetMachine &TM);
-    virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
-                                           bool Global) const;
   };
 
-  struct X86COFFTargetAsmInfo : public X86TargetAsmInfo {
-    explicit X86COFFTargetAsmInfo(const X86TargetMachine &TM);
-    virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
-                                           bool Global) const;
-    virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
-                                               SectionKind::Kind kind) const;
-    virtual std::string PrintSectionFlags(unsigned flags) const;
-  protected:
-    const X86TargetMachine *X86TM;
-  };
+  typedef X86TargetAsmInfo<COFFTargetAsmInfo> X86COFFTargetAsmInfo;
 
-  struct X86WinTargetAsmInfo : public X86TargetAsmInfo {
+  struct X86WinTargetAsmInfo : public X86TargetAsmInfo<TargetAsmInfo> {
     explicit X86WinTargetAsmInfo(const X86TargetMachine &TM);
   };
+
 } // namespace llvm
 
 #endif