LLVM 19.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 <cassert>
#include <cstdint>
#include <cstdlib>

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 emitConstant (uint64_t Val, unsigned Size, SmallVectorImpl< char > &CB)
 
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.
 
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.
 
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 35 of file X86MCCodeEmitter.cpp.

Enumeration Type Documentation

◆ GlobalOffsetTableExprKind

Enumerator
GOT_None 
GOT_Normal 
GOT_SymDiff 

Definition at line 454 of file X86MCCodeEmitter.cpp.

Function Documentation

◆ emitConstant()

static void emitConstant ( uint64_t  Val,
unsigned  Size,
SmallVectorImpl< char > &  CB 
)
static

Definition at line 403 of file X86MCCodeEmitter.cpp.

References Size.

◆ 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 439 of file X86MCCodeEmitter.cpp.

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

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 415 of file X86MCCodeEmitter.cpp.

References assert(), llvm::X86II::CD8_Scale_Mask, llvm::X86II::CD8_Scale_Shift, llvm::X86II::EncodingMask, llvm::X86II::EVEX, 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 398 of file X86MCCodeEmitter.cpp.

References assert(), and Mod.

◆ 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 462 of file X86MCCodeEmitter.cpp.

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