ec30d9975c9707871f11c808c9380c33eb587e41
[oota-llvm.git] / lib / Target / X86 / MCTargetDesc / X86MCTargetDesc.h
1 //===-- X86MCTargetDesc.h - X86 Target Descriptions -------------*- 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 provides X86 specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
15 #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
16
17 #include "llvm/Support/DataTypes.h"
18 #include <string>
19
20 namespace llvm {
21 class MCAsmBackend;
22 class MCCodeEmitter;
23 class MCContext;
24 class MCInstrInfo;
25 class MCObjectWriter;
26 class MCRegisterInfo;
27 class MCSubtargetInfo;
28 class MCRelocationInfo;
29 class MCStreamer;
30 class Target;
31 class Triple;
32 class StringRef;
33 class raw_ostream;
34
35 extern Target TheX86_32Target, TheX86_64Target;
36
37 /// Flavour of dwarf regnumbers
38 ///
39 namespace DWARFFlavour {
40   enum {
41     X86_64 = 0, X86_32_DarwinEH = 1, X86_32_Generic = 2
42   };
43 }
44
45 ///  Native X86 register numbers
46 ///
47 namespace N86 {
48   enum {
49     EAX = 0, ECX = 1, EDX = 2, EBX = 3, ESP = 4, EBP = 5, ESI = 6, EDI = 7
50   };
51 }
52
53 namespace X86_MC {
54   std::string ParseX86Triple(StringRef TT);
55
56   unsigned getDwarfRegFlavour(Triple TT, bool isEH);
57
58   void InitLLVM2SEHRegisterMapping(MCRegisterInfo *MRI);
59
60   /// Create a X86 MCSubtargetInfo instance. This is exposed so Asm parser, etc.
61   /// do not need to go through TargetRegistry.
62   MCSubtargetInfo *createX86MCSubtargetInfo(StringRef TT, StringRef CPU,
63                                             StringRef FS);
64 }
65
66 MCCodeEmitter *createX86MCCodeEmitter(const MCInstrInfo &MCII,
67                                       const MCRegisterInfo &MRI,
68                                       MCContext &Ctx);
69
70 MCAsmBackend *createX86_32AsmBackend(const Target &T, const MCRegisterInfo &MRI,
71                                      StringRef TT, StringRef CPU);
72 MCAsmBackend *createX86_64AsmBackend(const Target &T, const MCRegisterInfo &MRI,
73                                      StringRef TT, StringRef CPU);
74
75 /// Construct an X86 Windows COFF machine code streamer which will generate
76 /// PE/COFF format object files.
77 ///
78 /// Takes ownership of \p AB and \p CE.
79 MCStreamer *createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
80                                      raw_ostream &OS, MCCodeEmitter *CE,
81                                      bool RelaxAll);
82
83 /// Construct an X86 Mach-O object writer.
84 MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS, bool Is64Bit,
85                                           uint32_t CPUType,
86                                           uint32_t CPUSubtype);
87
88 /// Construct an X86 ELF object writer.
89 MCObjectWriter *createX86ELFObjectWriter(raw_ostream &OS, bool IsELF64,
90                                          uint8_t OSABI, uint16_t EMachine);
91 /// Construct an X86 Win COFF object writer.
92 MCObjectWriter *createX86WinCOFFObjectWriter(raw_ostream &OS, bool Is64Bit);
93
94 /// Construct X86-64 Mach-O relocation info.
95 MCRelocationInfo *createX86_64MachORelocationInfo(MCContext &Ctx);
96
97 /// Construct X86-64 ELF relocation info.
98 MCRelocationInfo *createX86_64ELFRelocationInfo(MCContext &Ctx);
99 } // End llvm namespace
100
101
102 // Defines symbolic names for X86 registers.  This defines a mapping from
103 // register name to register number.
104 //
105 #define GET_REGINFO_ENUM
106 #include "X86GenRegisterInfo.inc"
107
108 // Defines symbolic names for the X86 instructions.
109 //
110 #define GET_INSTRINFO_ENUM
111 #include "X86GenInstrInfo.inc"
112
113 #define GET_SUBTARGETINFO_ENUM
114 #include "X86GenSubtargetInfo.inc"
115
116 #endif