LLVM  15.0.0git
Macros | Enumerations | Functions
X86MCCodeEmitter.cpp File Reference
#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 "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <cstdlib>
Include dependency graph for X86MCCodeEmitter.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "mccodeemitter"
 

Enumerations

enum  GlobalOffsetTableExprKind { GOT_None, GOT_Normal, GOT_SymDiff }
 

Functions

static uint8_t modRMByte (unsigned Mod, unsigned RegOpcode, unsigned RM)
 
static void emitByte (uint8_t C, raw_ostream &OS)
 
static void emitConstant (uint64_t Val, unsigned Size, raw_ostream &OS)
 
static bool isDispOrCDisp8 (uint64_t TSFlags, int Value, int &ImmOffset)
 Determine if this immediate can fit in a disp8 or a compressed disp8 for EVEX instructions. More...
 
static MCFixupKind getImmFixupKind (uint64_t TSFlags)
 
static GlobalOffsetTableExprKind startsWithGlobalOffsetTable (const MCExpr *Expr)
 Check if this expression starts with GLOBAL_OFFSET_TABLE and if it is of the form GLOBAL_OFFSET_TABLE-symbol. More...
 
static bool hasSecRelSymbolRef (const MCExpr *Expr)
 
static bool isPCRel32Branch (const MCInst &MI, const MCInstrInfo &MCII)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "mccodeemitter"

Definition at line 36 of file X86MCCodeEmitter.cpp.

Enumeration Type Documentation

◆ GlobalOffsetTableExprKind

Enumerator
GOT_None 
GOT_Normal 
GOT_SymDiff 

Definition at line 159 of file X86MCCodeEmitter.cpp.

Function Documentation

◆ emitByte()

static void emitByte ( uint8_t  C,
raw_ostream OS 
)
static

Definition at line 108 of file X86MCCodeEmitter.cpp.

Referenced by emitConstant().

◆ emitConstant()

static void emitConstant ( uint64_t  Val,
unsigned  Size,
raw_ostream OS 
)
static

Definition at line 110 of file X86MCCodeEmitter.cpp.

References emitByte(), and i.

◆ getImmFixupKind()

static MCFixupKind getImmFixupKind ( uint64_t  TSFlags)
static
Returns
the appropriate fixup kind to use for an immediate in an instruction with the specified TSFlags.

Definition at line 144 of file X86MCCodeEmitter.cpp.

References llvm::MCFixup::getKindForSize(), llvm::X86II::getSizeOfImm(), llvm::X86II::isImmPCRel(), llvm::X86II::isImmSigned(), isPCRel(), llvm_unreachable, and llvm::X86::reloc_signed_4byte.

Referenced by isPCRel32Branch().

◆ hasSecRelSymbolRef()

static bool hasSecRelSymbolRef ( const MCExpr Expr)
static

◆ isDispOrCDisp8()

static bool isDispOrCDisp8 ( uint64_t  TSFlags,
int  Value,
int ImmOffset 
)
static

Determine if this immediate can fit in a disp8 or a compressed disp8 for EVEX instructions.

will be set to the value to pass to the ImmOffset parameter of emitImmediate.

Definition at line 121 of file X86MCCodeEmitter.cpp.

References assert(), llvm::X86II::CD8_Scale_Mask, llvm::X86II::CD8_Scale_Shift, llvm::X86II::EncodingMask, llvm::X86II::EVEX, llvm::isInt< 8 >(), and llvm::isPowerOf2_32().

◆ isPCRel32Branch()

static bool isPCRel32Branch ( const MCInst MI,
const MCInstrInfo MCII 
)
static

◆ modRMByte()

static uint8_t modRMByte ( unsigned  Mod,
unsigned  RegOpcode,
unsigned  RM 
)
static

Definition at line 103 of file X86MCCodeEmitter.cpp.

References assert(), Mod, and llvm::AArch64::RM.

◆ startsWithGlobalOffsetTable()

static GlobalOffsetTableExprKind startsWithGlobalOffsetTable ( const MCExpr Expr)
static

Check if this expression starts with GLOBAL_OFFSET_TABLE and if it is of the form GLOBAL_OFFSET_TABLE-symbol.

This is needed to support PIC on ELF i386 as GLOBAL_OFFSET_TABLE is magical. We check only simple case that are know to be used: GLOBAL_OFFSET_TABLE by itself or at the start of a binary expression.

Definition at line 167 of file X86MCCodeEmitter.cpp.

References llvm::MCExpr::Binary, llvm::MCExpr::getKind(), llvm::MCBinaryExpr::getLHS(), llvm::MCBinaryExpr::getRHS(), GOT_None, GOT_Normal, GOT_SymDiff, llvm::Ref, RHS, S, and llvm::MCExpr::SymbolRef.