#include "MCTargetDesc/X86BaseInfo.h"
#include "MCTargetDesc/X86FixupKinds.h"
#include "MCTargetDesc/X86MCTargetDesc.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <cstdint>
#include <cstdlib>
usingnamespacellvm;
#define DEBUG_TYPE …
namespace {
enum PrefixKind { … };
static void emitByte(uint8_t C, SmallVectorImpl<char> &CB) { … }
class X86OpcodePrefixHelper { … };
class X86MCCodeEmitter : public MCCodeEmitter { … };
}
static uint8_t modRMByte(unsigned Mod, unsigned RegOpcode, unsigned RM) { … }
static void emitConstant(uint64_t Val, unsigned Size,
SmallVectorImpl<char> &CB) { … }
static bool isDispOrCDisp8(uint64_t TSFlags, int Value, int &ImmOffset) { … }
static MCFixupKind getImmFixupKind(uint64_t TSFlags) { … }
enum GlobalOffsetTableExprKind { … };
static GlobalOffsetTableExprKind
startsWithGlobalOffsetTable(const MCExpr *Expr) { … }
static bool hasSecRelSymbolRef(const MCExpr *Expr) { … }
static bool isPCRel32Branch(const MCInst &MI, const MCInstrInfo &MCII) { … }
unsigned X86MCCodeEmitter::getX86RegNum(const MCOperand &MO) const { … }
unsigned X86MCCodeEmitter::getX86RegEncoding(const MCInst &MI,
unsigned OpNum) const { … }
void X86MCCodeEmitter::emitImmediate(const MCOperand &DispOp, SMLoc Loc,
unsigned Size, MCFixupKind FixupKind,
uint64_t StartByte,
SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
int ImmOffset) const { … }
void X86MCCodeEmitter::emitRegModRMByte(const MCOperand &ModRMReg,
unsigned RegOpcodeFld,
SmallVectorImpl<char> &CB) const { … }
void X86MCCodeEmitter::emitSIBByte(unsigned SS, unsigned Index, unsigned Base,
SmallVectorImpl<char> &CB) const { … }
void X86MCCodeEmitter::emitMemModRMByte(
const MCInst &MI, unsigned Op, unsigned RegOpcodeField, uint64_t TSFlags,
PrefixKind Kind, uint64_t StartByte, SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups, const MCSubtargetInfo &STI,
bool ForceSIB) const { … }
PrefixKind X86MCCodeEmitter::emitPrefixImpl(unsigned &CurOp, const MCInst &MI,
const MCSubtargetInfo &STI,
SmallVectorImpl<char> &CB) const { … }
PrefixKind
X86MCCodeEmitter::emitVEXOpcodePrefix(int MemOperand, const MCInst &MI,
const MCSubtargetInfo &STI,
SmallVectorImpl<char> &CB) const { … }
PrefixKind X86MCCodeEmitter::emitREXPrefix(int MemOperand, const MCInst &MI,
const MCSubtargetInfo &STI,
SmallVectorImpl<char> &CB) const { … }
void X86MCCodeEmitter::emitSegmentOverridePrefix(
unsigned SegOperand, const MCInst &MI, SmallVectorImpl<char> &CB) const { … }
PrefixKind X86MCCodeEmitter::emitOpcodePrefix(int MemOperand, const MCInst &MI,
const MCSubtargetInfo &STI,
SmallVectorImpl<char> &CB) const { … }
void X86MCCodeEmitter::emitPrefix(const MCInst &MI, SmallVectorImpl<char> &CB,
const MCSubtargetInfo &STI) const { … }
void X86_MC::emitPrefix(MCCodeEmitter &MCE, const MCInst &MI,
SmallVectorImpl<char> &CB, const MCSubtargetInfo &STI) { … }
void X86MCCodeEmitter::encodeInstruction(const MCInst &MI,
SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const { … }
MCCodeEmitter *llvm::createX86MCCodeEmitter(const MCInstrInfo &MCII,
MCContext &Ctx) { … }