Use crazy template-based inheritance instead of virtual one.
[oota-llvm.git] / lib / Target / X86 / X86TargetAsmInfo.h
1 //=====-- X86TargetAsmInfo.h - X86 asm properties -------------*- C++ -*--====//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declaration of the X86TargetAsmInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef X86TARGETASMINFO_H
15 #define X86TARGETASMINFO_H
16
17 #include "X86TargetMachine.h"
18 #include "llvm/Target/TargetAsmInfo.h"
19 #include "llvm/Target/ELFTargetAsmInfo.h"
20 #include "llvm/Target/DarwinTargetAsmInfo.h"
21
22 namespace llvm {
23
24   extern const char *const x86_asm_table[];
25
26   template <class BaseTAI>
27   struct X86TargetAsmInfo : public BaseTAI {
28     explicit X86TargetAsmInfo(const X86TargetMachine &TM):
29       BaseTAI(TM) {
30       const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
31
32       BaseTAI::AsmTransCBE = x86_asm_table;
33       BaseTAI::AssemblerDialect = Subtarget->getAsmFlavor();
34     }
35
36     virtual bool ExpandInlineAsm(CallInst *CI) const;
37
38   private:
39     bool LowerToBSwap(CallInst *CI) const;
40   };
41
42   typedef X86TargetAsmInfo<TargetAsmInfo> X86GenericTargetAsmInfo;
43
44   struct X86DarwinTargetAsmInfo : public X86TargetAsmInfo<DarwinTargetAsmInfo> {
45     explicit X86DarwinTargetAsmInfo(const X86TargetMachine &TM);
46     virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
47                                            bool Global) const;
48   };
49
50   struct X86ELFTargetAsmInfo : public X86TargetAsmInfo<ELFTargetAsmInfo> {
51     explicit X86ELFTargetAsmInfo(const X86TargetMachine &TM);
52     virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
53                                            bool Global) const;
54   };
55
56   struct X86COFFTargetAsmInfo : public X86GenericTargetAsmInfo {
57     explicit X86COFFTargetAsmInfo(const X86TargetMachine &TM);
58     virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
59                                            bool Global) const;
60     virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
61                                                SectionKind::Kind kind) const;
62     virtual std::string printSectionFlags(unsigned flags) const;
63   protected:
64     const X86TargetMachine *X86TM;
65   };
66
67   struct X86WinTargetAsmInfo : public X86GenericTargetAsmInfo {
68     explicit X86WinTargetAsmInfo(const X86TargetMachine &TM);
69   };
70
71 } // namespace llvm
72
73 #endif
74