Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
X86MCInstLower.cpp File Reference
#include "MCTargetDesc/X86ATTInstPrinter.h"
#include "MCTargetDesc/X86BaseInfo.h"
#include "MCTargetDesc/X86EncodingOptimization.h"
#include "MCTargetDesc/X86InstComments.h"
#include "MCTargetDesc/X86MCAsmInfo.h"
#include "MCTargetDesc/X86ShuffleDecode.h"
#include "MCTargetDesc/X86TargetStreamer.h"
#include "X86AsmPrinter.h"
#include "X86MachineFunctionInfo.h"
#include "X86RegisterInfo.h"
#include "X86ShuffleDecodeConstantPool.h"
#include "X86Subtarget.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Mangler.h"
#include "llvm/MC/MCAsmInfo.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/MCInstBuilder.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/CFGuard.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizerCommon.h"
#include <string>

Go to the source code of this file.

Classes

struct  NoAutoPaddingScope
 A RAII helper which defines a region of instructions which can't have padding added between them for correctness. More...

Macros

#define INSTR_CASE(Prefix, Instr, Suffix, Postfix)
#define CASE_ARITH_RM(Instr)
#define MASK_AVX512_CASE(Instr)
#define MOV_CASE(Prefix, Suffix)
#define MOV_AVX512_CASE(Suffix, Postfix)
#define CASE_128_MOV_RM()
#define CASE_256_MOV_RM()
#define CASE_512_MOV_RM()
#define MOVX_CASE(Prefix, Ext, Type, Suffix, Postfix)
#define CASE_MOVX_RM(Ext, Type)

Functions

static void emitX86Nops (MCStreamer &OS, unsigned NumBytes, const X86Subtarget *Subtarget)
 Emit the optimal amount of multi-byte nops on X86.
static unsigned getRetOpcode (const X86Subtarget &Subtarget)
static unsigned convertTailJumpOpcode (unsigned Opcode)
static unsigned emitNop (MCStreamer &OS, unsigned NumBytes, const X86Subtarget *Subtarget)
 Emit the largest nop instruction smaller than or equal to NumBytes bytes.
static unsigned getSrcIdx (const MachineInstr *MI, unsigned SrcIdx)
static void printDstRegisterName (raw_ostream &CS, const MachineInstr *MI, unsigned SrcOpIdx)
static void printShuffleMask (raw_ostream &CS, StringRef Src1Name, StringRef Src2Name, ArrayRef< int > Mask)
static std::string getShuffleComment (const MachineInstr *MI, unsigned SrcOp1Idx, unsigned SrcOp2Idx, ArrayRef< int > Mask)
static void printConstant (const APInt &Val, raw_ostream &CS, bool PrintZero=false)
static void printConstant (const APFloat &Flt, raw_ostream &CS, bool PrintZero=false)
static void printConstant (const Constant *COp, unsigned BitWidth, raw_ostream &CS, bool PrintZero=false)
static void printZeroUpperMove (const MachineInstr *MI, MCStreamer &OutStreamer, int SclWidth, int VecWidth, const char *ShuffleComment)
static void printBroadcast (const MachineInstr *MI, MCStreamer &OutStreamer, int Repeats, int BitWidth)
static bool printExtend (const MachineInstr *MI, MCStreamer &OutStreamer, int SrcEltBits, int DstEltBits, bool IsSext)
static void printSignExtend (const MachineInstr *MI, MCStreamer &OutStreamer, int SrcEltBits, int DstEltBits)
static void printZeroExtend (const MachineInstr *MI, MCStreamer &OutStreamer, int SrcEltBits, int DstEltBits)
static void addConstantComments (const MachineInstr *MI, MCStreamer &OutStreamer)
bool isImportedFunction (const MachineOperand &MO)
bool isCallToCFGuardFunction (const MachineInstr *MI)
bool hasJumpTableInfoInBlock (const llvm::MachineInstr *MI)

Variables

static cl::opt< boolEnableBranchHint ("enable-branch-hint", cl::desc("Enable branch hint."), cl::init(false), cl::Hidden)
static cl::opt< unsignedBranchHintProbabilityThreshold ("branch-hint-probability-threshold", cl::desc("The probability threshold of enabling branch hint."), cl::init(50), cl::Hidden)

Macro Definition Documentation

◆ CASE_128_MOV_RM

#define CASE_128_MOV_RM ( )
Value:
MOV_CASE(, ) /* SSE */ \
MOV_CASE(V, ) /* AVX-128 */ \
MOV_AVX512_CASE(Z128, ) \
MOV_AVX512_CASE(Z128, k) \
MOV_AVX512_CASE(Z128, kz)
#define MOV_CASE(Prefix, Suffix)

Referenced by addConstantComments().

◆ CASE_256_MOV_RM

#define CASE_256_MOV_RM ( )
Value:
MOV_CASE(V, Y) /* AVX-256 */ \
MOV_AVX512_CASE(Z256, ) \
MOV_AVX512_CASE(Z256, k) \
MOV_AVX512_CASE(Z256, kz) \
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")

Referenced by addConstantComments().

◆ CASE_512_MOV_RM

#define CASE_512_MOV_RM ( )
Value:
MOV_AVX512_CASE(Z, k) \
MOV_AVX512_CASE(Z, kz) \
#define MOV_AVX512_CASE(Suffix, Postfix)

Referenced by addConstantComments().

◆ CASE_ARITH_RM

#define CASE_ARITH_RM ( Instr)
Value:
INSTR_CASE(, Instr, , ) /* SSE */ \
INSTR_CASE(V, Instr, , ) /* AVX-128 */ \
INSTR_CASE(V, Instr, Y, ) /* AVX-256 */ \
INSTR_CASE(V, Instr, Z128, ) \
INSTR_CASE(V, Instr, Z128, k) \
INSTR_CASE(V, Instr, Z128, kz) \
INSTR_CASE(V, Instr, Z256, ) \
INSTR_CASE(V, Instr, Z256, k) \
INSTR_CASE(V, Instr, Z256, kz) \
INSTR_CASE(V, Instr, Z, ) \
INSTR_CASE(V, Instr, Z, k) \
INSTR_CASE(V, Instr, Z, kz)
#define INSTR_CASE(Prefix, Instr, Suffix, Postfix)

Referenced by addConstantComments().

◆ CASE_MOVX_RM

#define CASE_MOVX_RM ( Ext,
Type )
Value:
MOVX_CASE(, Ext, Type, , ) \
MOVX_CASE(V, Ext, Type, , ) \
MOVX_CASE(V, Ext, Type, Y, ) \
MOVX_CASE(V, Ext, Type, Z128, ) \
MOVX_CASE(V, Ext, Type, Z128, k ) \
MOVX_CASE(V, Ext, Type, Z128, kz ) \
MOVX_CASE(V, Ext, Type, Z256, ) \
MOVX_CASE(V, Ext, Type, Z256, k ) \
MOVX_CASE(V, Ext, Type, Z256, kz ) \
MOVX_CASE(V, Ext, Type, Z, ) \
MOVX_CASE(V, Ext, Type, Z, k ) \
MOVX_CASE(V, Ext, Type, Z, kz )
#define MOVX_CASE(Prefix, Ext, Type, Suffix, Postfix)
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45

Referenced by addConstantComments().

◆ INSTR_CASE

#define INSTR_CASE ( Prefix,
Instr,
Suffix,
Postfix )
Value:
case X86::Prefix##Instr##Suffix##rm##Postfix:

◆ MASK_AVX512_CASE

#define MASK_AVX512_CASE ( Instr)
Value:
case Instr: \
case Instr##k: \
case Instr##kz:

Referenced by addConstantComments().

◆ MOV_AVX512_CASE

#define MOV_AVX512_CASE ( Suffix,
Postfix )
Value:
case X86::VMOVDQA64##Suffix##rm##Postfix: \
case X86::VMOVDQA32##Suffix##rm##Postfix: \
case X86::VMOVDQU64##Suffix##rm##Postfix: \
case X86::VMOVDQU32##Suffix##rm##Postfix: \
case X86::VMOVDQU16##Suffix##rm##Postfix: \
case X86::VMOVDQU8##Suffix##rm##Postfix: \
case X86::VMOVAPS##Suffix##rm##Postfix: \
case X86::VMOVAPD##Suffix##rm##Postfix: \
case X86::VMOVUPS##Suffix##rm##Postfix: \
case X86::VMOVUPD##Suffix##rm##Postfix:

◆ MOV_CASE

#define MOV_CASE ( Prefix,
Suffix )
Value:
case X86::Prefix##MOVAPD##Suffix##rm: \
case X86::Prefix##MOVAPS##Suffix##rm: \
case X86::Prefix##MOVUPD##Suffix##rm: \
case X86::Prefix##MOVUPS##Suffix##rm: \
case X86::Prefix##MOVDQA##Suffix##rm: \
case X86::Prefix##MOVDQU##Suffix##rm:

◆ MOVX_CASE

#define MOVX_CASE ( Prefix,
Ext,
Type,
Suffix,
Postfix )
Value:
case X86::Prefix##PMOV##Ext##Type##Suffix##rm##Postfix:

Function Documentation

◆ addConstantComments()

◆ convertTailJumpOpcode()

unsigned convertTailJumpOpcode ( unsigned Opcode)
static

Definition at line 373 of file X86MCInstLower.cpp.

◆ emitNop()

unsigned emitNop ( MCStreamer & OS,
unsigned NumBytes,
const X86Subtarget * Subtarget )
static

Emit the largest nop instruction smaller than or equal to NumBytes bytes.

Return the size of nop emitted.

Definition at line 659 of file X86MCInstLower.cpp.

References assert(), llvm::MCStreamer::emitBytes(), llvm::MCStreamer::emitInstruction(), llvm_unreachable, and Opc.

Referenced by llvm::X86AsmPrinter::emitInstruction(), and emitX86Nops().

◆ emitX86Nops()

void emitX86Nops ( MCStreamer & OS,
unsigned NumBytes,
const X86Subtarget * Subtarget )
static

Emit the optimal amount of multi-byte nops on X86.

Definition at line 776 of file X86MCInstLower.cpp.

References assert(), and emitNop().

◆ getRetOpcode()

unsigned getRetOpcode ( const X86Subtarget & Subtarget)
static

Definition at line 335 of file X86MCInstLower.cpp.

Referenced by llvm::X86AsmPrinter::emitInstruction().

◆ getShuffleComment()

◆ getSrcIdx()

◆ hasJumpTableInfoInBlock()

bool hasJumpTableInfoInBlock ( const llvm::MachineInstr * MI)

Definition at line 2220 of file X86MCInstLower.cpp.

References E(), I, MBB, and MI.

Referenced by llvm::X86AsmPrinter::emitInstruction().

◆ isCallToCFGuardFunction()

◆ isImportedFunction()

◆ printBroadcast()

◆ printConstant() [1/3]

void printConstant ( const APFloat & Flt,
raw_ostream & CS,
bool PrintZero = false )
static

Definition at line 1542 of file X86MCInstLower.cpp.

References Flt, llvm::APFloat::getZero(), and llvm::APFloat::toString().

◆ printConstant() [2/3]

◆ printConstant() [3/3]

◆ printDstRegisterName()

◆ printExtend()

◆ printShuffleMask()

void printShuffleMask ( raw_ostream & CS,
StringRef Src1Name,
StringRef Src2Name,
ArrayRef< int > Mask )
static

Definition at line 1465 of file X86MCInstLower.cpp.

References llvm::SM_SentinelUndef, and llvm::SM_SentinelZero.

Referenced by getShuffleComment(), and printZeroExtend().

◆ printSignExtend()

void printSignExtend ( const MachineInstr * MI,
MCStreamer & OutStreamer,
int SrcEltBits,
int DstEltBits )
static

Definition at line 1686 of file X86MCInstLower.cpp.

References MI, and printExtend().

Referenced by addConstantComments().

◆ printZeroExtend()

◆ printZeroUpperMove()

void printZeroUpperMove ( const MachineInstr * MI,
MCStreamer & OutStreamer,
int SclWidth,
int VecWidth,
const char * ShuffleComment )
static

Variable Documentation

◆ BranchHintProbabilityThreshold

cl::opt< unsigned > BranchHintProbabilityThreshold("branch-hint-probability-threshold", cl::desc("The probability threshold of enabling branch hint."), cl::init(50), cl::Hidden) ( "branch-hint-probability-threshold" ,
cl::desc("The probability threshold of enabling branch hint.") ,
cl::init(50) ,
cl::Hidden  )
static

◆ EnableBranchHint

cl::opt< bool > EnableBranchHint("enable-branch-hint", cl::desc("Enable branch hint."), cl::init(false), cl::Hidden) ( "enable-branch-hint" ,
cl::desc("Enable branch hint.") ,
cl::init(false) ,
cl::Hidden  )
static