LLVM 22.0.0git
X86MCTargetDesc.h
Go to the documentation of this file.
1//===-- X86MCTargetDesc.h - X86 Target Descriptions -------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides X86 specific target descriptions.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
14#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
15
17#include <cstdint>
18#include <memory>
19#include <string>
20
21namespace llvm {
23class MCAsmBackend;
24class MCCodeEmitter;
25class MCContext;
26class MCInst;
27class MCInstPrinter;
28class MCInstrInfo;
31class MCObjectWriter;
32class MCRegister;
33class MCRegisterInfo;
34class MCStreamer;
35class MCSubtargetInfo;
36class MCTargetOptions;
38class Target;
39class Triple;
40class StringRef;
41
42/// Flavour of dwarf regnumbers
43///
44namespace DWARFFlavour {
45 enum {
47 };
48}
49
50/// Native X86 register numbers
51///
52namespace N86 {
53 enum {
54 EAX = 0, ECX = 1, EDX = 2, EBX = 3, ESP = 4, EBP = 5, ESI = 6, EDI = 7
55 };
56}
57
58namespace X86_MC {
59std::string ParseX86Triple(const Triple &TT);
60
61unsigned getDwarfRegFlavour(const Triple &TT, bool isEH);
62
63void initLLVMToSEHAndCVRegMapping(MCRegisterInfo *MRI);
64
65
66/// Returns true if this instruction has a LOCK prefix.
67bool hasLockPrefix(const MCInst &MI);
68
69/// \param Op operand # of the memory operand.
70///
71/// \returns true if the specified instruction has a 16-bit memory operand.
72bool is16BitMemOperand(const MCInst &MI, unsigned Op,
73 const MCSubtargetInfo &STI);
74
75/// \param Op operand # of the memory operand.
76///
77/// \returns true if the specified instruction has a 32-bit memory operand.
78bool is32BitMemOperand(const MCInst &MI, unsigned Op);
79
80/// \param Op operand # of the memory operand.
81///
82/// \returns true if the specified instruction has a 64-bit memory operand.
83#ifndef NDEBUG
84bool is64BitMemOperand(const MCInst &MI, unsigned Op);
85#endif
86
87/// Returns true if this instruction needs an Address-Size override prefix.
88bool needsAddressSizeOverride(const MCInst &MI, const MCSubtargetInfo &STI,
89 int MemoryOperand, uint64_t TSFlags);
90
91/// Create a X86 MCSubtargetInfo instance. This is exposed so Asm parser, etc.
92/// do not need to go through TargetRegistry.
93MCSubtargetInfo *createX86MCSubtargetInfo(const Triple &TT, StringRef CPU,
94 StringRef FS);
95
96void emitInstruction(MCObjectStreamer &, const MCInst &Inst,
97 const MCSubtargetInfo &STI);
98
99void emitPrefix(MCCodeEmitter &MCE, const MCInst &MI, SmallVectorImpl<char> &CB,
100 const MCSubtargetInfo &STI);
101}
102
104 MCContext &Ctx);
105
107 const MCSubtargetInfo &STI,
108 const MCRegisterInfo &MRI,
109 const MCTargetOptions &Options);
111 const MCSubtargetInfo &STI,
112 const MCRegisterInfo &MRI,
113 const MCTargetOptions &Options);
114
115/// Implements X86-only directives for assembly emission.
118 MCInstPrinter *InstPrinter);
119
120/// Implements X86-only directives for object files.
122 const MCSubtargetInfo &STI);
123
124/// Construct an X86 Windows COFF machine code streamer which will generate
125/// PE/COFF format object files.
126///
127/// Takes ownership of \p AB and \p CE.
129 std::unique_ptr<MCAsmBackend> &&AB,
130 std::unique_ptr<MCObjectWriter> &&OW,
131 std::unique_ptr<MCCodeEmitter> &&CE);
132
134 std::unique_ptr<MCAsmBackend> &&MAB,
135 std::unique_ptr<MCObjectWriter> &&MOW,
136 std::unique_ptr<MCCodeEmitter> &&MCE);
137
138/// Construct an X86 Mach-O object writer.
139std::unique_ptr<MCObjectTargetWriter>
140createX86MachObjectWriter(bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype);
141
142/// Construct an X86 ELF object writer.
143std::unique_ptr<MCObjectTargetWriter>
144createX86ELFObjectWriter(bool IsELF64, uint8_t OSABI, uint16_t EMachine);
145/// Construct an X86 Win COFF object writer.
146std::unique_ptr<MCObjectTargetWriter>
147createX86WinCOFFObjectWriter(bool Is64Bit);
148
149/// \param Reg speicifed register.
150/// \param Size the bit size of returned register.
151/// \param High requires the high register.
152///
153/// \returns the sub or super register of a specific X86 register.
155 bool High = false);
156} // End llvm namespace
157
158
159// Defines symbolic names for X86 registers. This defines a mapping from
160// register name to register number.
161//
162#define GET_REGINFO_ENUM
163#include "X86GenRegisterInfo.inc"
164
165// Defines symbolic names for the X86 instructions.
166//
167#define GET_INSTRINFO_ENUM
168#define GET_INSTRINFO_MC_HELPER_DECLS
169#include "X86GenInstrInfo.inc"
170
171#define GET_SUBTARGETINFO_ENUM
172#include "X86GenSubtargetInfo.inc"
173
174#define GET_X86_MNEMONIC_TABLES_H
175#include "X86GenMnemonicTables.inc"
176
177#endif
unsigned const MachineRegisterInfo * MRI
IRTranslator LLVM IR MI
static LVOptions Options
Definition LVOptions.cpp:25
Register Reg
#define T
uint64_t High
This file defines the SmallVector class.
Generic interface to target specific assembler backends.
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Definition MCContext.h:83
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
Streaming object file generation interface.
Base class for classes that define behaviour that is specific to both the target and the object forma...
Defines the object file and target independent interfaces used by the assembler backend to write nati...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:33
Streaming machine code generation interface.
Definition MCStreamer.h:220
Generic base class for all target subtargets.
Target specific streamer interface.
Definition MCStreamer.h:93
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
Flavour of dwarf regnumbers.
Native X86 register numbers.
bool is32BitMemOperand(const MCInst &MI, unsigned Op)
bool is16BitMemOperand(const MCInst &MI, unsigned Op, const MCSubtargetInfo &STI)
bool hasLockPrefix(const MCInst &MI)
Returns true if this instruction has a LOCK prefix.
void initLLVMToSEHAndCVRegMapping(MCRegisterInfo *MRI)
bool needsAddressSizeOverride(const MCInst &MI, const MCSubtargetInfo &STI, int MemoryOperand, uint64_t TSFlags)
Returns true if this instruction needs an Address-Size override prefix.
void emitPrefix(MCCodeEmitter &MCE, const MCInst &MI, SmallVectorImpl< char > &CB, const MCSubtargetInfo &STI)
std::string ParseX86Triple(const Triple &TT)
void emitInstruction(MCObjectStreamer &, const MCInst &Inst, const MCSubtargetInfo &STI)
MCSubtargetInfo * createX86MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Create a X86 MCSubtargetInfo instance.
bool is64BitMemOperand(const MCInst &MI, unsigned Op)
unsigned getDwarfRegFlavour(const Triple &TT, bool isEH)
This is an optimization pass for GlobalISel generic memory operations.
MCTargetStreamer * createX86ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Implements X86-only directives for object files.
MCRegister getX86SubSuperRegister(MCRegister Reg, unsigned Size, bool High=false)
MCAsmBackend * createX86_64AsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
std::unique_ptr< MCObjectTargetWriter > createX86WinCOFFObjectWriter(bool Is64Bit)
Construct an X86 Win COFF object writer.
MCTargetStreamer * createX86AsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrinter)
Implements X86-only directives for assembly emission.
MCCodeEmitter * createX86MCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
MCStreamer * createX86ELFStreamer(const Triple &T, MCContext &Context, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&MOW, std::unique_ptr< MCCodeEmitter > &&MCE)
MCStreamer * createX86WinCOFFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > &&AB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
Construct an X86 Windows COFF machine code streamer which will generate PE/COFF format object files.
std::unique_ptr< MCObjectTargetWriter > createX86MachObjectWriter(bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
Construct an X86 Mach-O object writer.
DWARFExpression::Operation Op
std::unique_ptr< MCObjectTargetWriter > createX86ELFObjectWriter(bool IsELF64, uint8_t OSABI, uint16_t EMachine)
Construct an X86 ELF object writer.
MCAsmBackend * createX86_32AsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)