Path: blob/main/contrib/llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
35294 views
//===-- X86MCTargetDesc.h - X86 Target Descriptions -------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file provides X86 specific target descriptions.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H13#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H1415#include "llvm/ADT/SmallVector.h"16#include <memory>17#include <string>1819namespace llvm {20class formatted_raw_ostream;21class MCAsmBackend;22class MCCodeEmitter;23class MCContext;24class MCInst;25class MCInstPrinter;26class MCInstrInfo;27class MCObjectStreamer;28class MCObjectTargetWriter;29class MCObjectWriter;30class MCRegister;31class MCRegisterInfo;32class MCStreamer;33class MCSubtargetInfo;34class MCTargetOptions;35class MCTargetStreamer;36class Target;37class Triple;38class StringRef;3940/// Flavour of dwarf regnumbers41///42namespace DWARFFlavour {43enum {44X86_64 = 0, X86_32_DarwinEH = 1, X86_32_Generic = 245};46}4748/// Native X86 register numbers49///50namespace N86 {51enum {52EAX = 0, ECX = 1, EDX = 2, EBX = 3, ESP = 4, EBP = 5, ESI = 6, EDI = 753};54}5556namespace X86_MC {57std::string ParseX86Triple(const Triple &TT);5859unsigned getDwarfRegFlavour(const Triple &TT, bool isEH);6061void initLLVMToSEHAndCVRegMapping(MCRegisterInfo *MRI);626364/// Returns true if this instruction has a LOCK prefix.65bool hasLockPrefix(const MCInst &MI);6667/// \param Op operand # of the memory operand.68///69/// \returns true if the specified instruction has a 16-bit memory operand.70bool is16BitMemOperand(const MCInst &MI, unsigned Op,71const MCSubtargetInfo &STI);7273/// \param Op operand # of the memory operand.74///75/// \returns true if the specified instruction has a 32-bit memory operand.76bool is32BitMemOperand(const MCInst &MI, unsigned Op);7778/// \param Op operand # of the memory operand.79///80/// \returns true if the specified instruction has a 64-bit memory operand.81#ifndef NDEBUG82bool is64BitMemOperand(const MCInst &MI, unsigned Op);83#endif8485/// Returns true if this instruction needs an Address-Size override prefix.86bool needsAddressSizeOverride(const MCInst &MI, const MCSubtargetInfo &STI,87int MemoryOperand, uint64_t TSFlags);8889/// Create a X86 MCSubtargetInfo instance. This is exposed so Asm parser, etc.90/// do not need to go through TargetRegistry.91MCSubtargetInfo *createX86MCSubtargetInfo(const Triple &TT, StringRef CPU,92StringRef FS);9394void emitInstruction(MCObjectStreamer &, const MCInst &Inst,95const MCSubtargetInfo &STI);9697void emitPrefix(MCCodeEmitter &MCE, const MCInst &MI, SmallVectorImpl<char> &CB,98const MCSubtargetInfo &STI);99}100101MCCodeEmitter *createX86MCCodeEmitter(const MCInstrInfo &MCII,102MCContext &Ctx);103104MCAsmBackend *createX86_32AsmBackend(const Target &T,105const MCSubtargetInfo &STI,106const MCRegisterInfo &MRI,107const MCTargetOptions &Options);108MCAsmBackend *createX86_64AsmBackend(const Target &T,109const MCSubtargetInfo &STI,110const MCRegisterInfo &MRI,111const MCTargetOptions &Options);112113/// Implements X86-only directives for assembly emission.114MCTargetStreamer *createX86AsmTargetStreamer(MCStreamer &S,115formatted_raw_ostream &OS,116MCInstPrinter *InstPrinter);117118/// Implements X86-only directives for object files.119MCTargetStreamer *createX86ObjectTargetStreamer(MCStreamer &S,120const MCSubtargetInfo &STI);121122/// Construct an X86 Windows COFF machine code streamer which will generate123/// PE/COFF format object files.124///125/// Takes ownership of \p AB and \p CE.126MCStreamer *createX86WinCOFFStreamer(MCContext &C,127std::unique_ptr<MCAsmBackend> &&AB,128std::unique_ptr<MCObjectWriter> &&OW,129std::unique_ptr<MCCodeEmitter> &&CE);130131MCStreamer *createX86ELFStreamer(const Triple &T, MCContext &Context,132std::unique_ptr<MCAsmBackend> &&MAB,133std::unique_ptr<MCObjectWriter> &&MOW,134std::unique_ptr<MCCodeEmitter> &&MCE);135136/// Construct an X86 Mach-O object writer.137std::unique_ptr<MCObjectTargetWriter>138createX86MachObjectWriter(bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype);139140/// Construct an X86 ELF object writer.141std::unique_ptr<MCObjectTargetWriter>142createX86ELFObjectWriter(bool IsELF64, uint8_t OSABI, uint16_t EMachine);143/// Construct an X86 Win COFF object writer.144std::unique_ptr<MCObjectTargetWriter>145createX86WinCOFFObjectWriter(bool Is64Bit);146147/// \param Reg speicifed register.148/// \param Size the bit size of returned register.149/// \param High requires the high register.150///151/// \returns the sub or super register of a specific X86 register.152MCRegister getX86SubSuperRegister(MCRegister Reg, unsigned Size,153bool High = false);154} // End llvm namespace155156157// Defines symbolic names for X86 registers. This defines a mapping from158// register name to register number.159//160#define GET_REGINFO_ENUM161#include "X86GenRegisterInfo.inc"162163// Defines symbolic names for the X86 instructions.164//165#define GET_INSTRINFO_ENUM166#define GET_INSTRINFO_MC_HELPER_DECLS167#include "X86GenInstrInfo.inc"168169#define GET_SUBTARGETINFO_ENUM170#include "X86GenSubtargetInfo.inc"171172#define GET_X86_MNEMONIC_TABLES_H173#include "X86GenMnemonicTables.inc"174175#endif176177178