1 //===-- X86MCTargetDesc.h - X86 Target Descriptions -------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file provides X86 specific target descriptions.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
14 #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
16 #include "llvm/MC/MCStreamer.h"
17 #include "llvm/Support/DataTypes.h"
25 class MCObjectTargetWriter
;
28 class MCSubtargetInfo
;
29 class MCRelocationInfo
;
30 class MCTargetOptions
;
35 class raw_pwrite_stream
;
37 /// Flavour of dwarf regnumbers
39 namespace DWARFFlavour
{
41 X86_64
= 0, X86_32_DarwinEH
= 1, X86_32_Generic
= 2
45 /// Native X86 register numbers
49 EAX
= 0, ECX
= 1, EDX
= 2, EBX
= 3, ESP
= 4, EBP
= 5, ESI
= 6, EDI
= 7
54 std::string
ParseX86Triple(const Triple
&TT
);
56 unsigned getDwarfRegFlavour(const Triple
&TT
, bool isEH
);
58 void initLLVMToSEHAndCVRegMapping(MCRegisterInfo
*MRI
);
60 /// Create a X86 MCSubtargetInfo instance. This is exposed so Asm parser, etc.
61 /// do not need to go through TargetRegistry.
62 MCSubtargetInfo
*createX86MCSubtargetInfo(const Triple
&TT
, StringRef CPU
,
66 MCCodeEmitter
*createX86MCCodeEmitter(const MCInstrInfo
&MCII
,
67 const MCRegisterInfo
&MRI
,
70 MCAsmBackend
*createX86_32AsmBackend(const Target
&T
,
71 const MCSubtargetInfo
&STI
,
72 const MCRegisterInfo
&MRI
,
73 const MCTargetOptions
&Options
);
74 MCAsmBackend
*createX86_64AsmBackend(const Target
&T
,
75 const MCSubtargetInfo
&STI
,
76 const MCRegisterInfo
&MRI
,
77 const MCTargetOptions
&Options
);
79 /// Implements X86-only directives for assembly emission.
80 MCTargetStreamer
*createX86AsmTargetStreamer(MCStreamer
&S
,
81 formatted_raw_ostream
&OS
,
82 MCInstPrinter
*InstPrint
,
85 /// Implements X86-only directives for object files.
86 MCTargetStreamer
*createX86ObjectTargetStreamer(MCStreamer
&OS
,
87 const MCSubtargetInfo
&STI
);
89 /// Construct an X86 Windows COFF machine code streamer which will generate
90 /// PE/COFF format object files.
92 /// Takes ownership of \p AB and \p CE.
93 MCStreamer
*createX86WinCOFFStreamer(MCContext
&C
,
94 std::unique_ptr
<MCAsmBackend
> &&AB
,
95 std::unique_ptr
<MCObjectWriter
> &&OW
,
96 std::unique_ptr
<MCCodeEmitter
> &&CE
,
98 bool IncrementalLinkerCompatible
);
100 /// Construct an X86 Mach-O object writer.
101 std::unique_ptr
<MCObjectTargetWriter
>
102 createX86MachObjectWriter(bool Is64Bit
, uint32_t CPUType
, uint32_t CPUSubtype
);
104 /// Construct an X86 ELF object writer.
105 std::unique_ptr
<MCObjectTargetWriter
>
106 createX86ELFObjectWriter(bool IsELF64
, uint8_t OSABI
, uint16_t EMachine
);
107 /// Construct an X86 Win COFF object writer.
108 std::unique_ptr
<MCObjectTargetWriter
>
109 createX86WinCOFFObjectWriter(bool Is64Bit
);
111 /// Returns the sub or super register of a specific X86 register.
112 /// e.g. getX86SubSuperRegister(X86::EAX, 16) returns X86::AX.
114 unsigned getX86SubSuperRegister(unsigned, unsigned, bool High
=false);
116 /// Returns the sub or super register of a specific X86 register.
117 /// Like getX86SubSuperRegister() but returns 0 on error.
118 unsigned getX86SubSuperRegisterOrZero(unsigned, unsigned,
121 } // End llvm namespace
124 // Defines symbolic names for X86 registers. This defines a mapping from
125 // register name to register number.
127 #define GET_REGINFO_ENUM
128 #include "X86GenRegisterInfo.inc"
130 // Defines symbolic names for the X86 instructions.
132 #define GET_INSTRINFO_ENUM
133 #define GET_INSTRINFO_MC_HELPER_DECLS
134 #include "X86GenInstrInfo.inc"
136 #define GET_SUBTARGETINFO_ENUM
137 #include "X86GenSubtargetInfo.inc"