LLVM 20.0.0git
Classes | Macros | Functions | Variables
X86MCInstLower.cpp File Reference
#include "MCTargetDesc/X86ATTInstPrinter.h"
#include "MCTargetDesc/X86BaseInfo.h"
#include "MCTargetDesc/X86EncodingOptimization.h"
#include "MCTargetDesc/X86InstComments.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/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/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)    case X86::Prefix##Instr##Suffix##rm##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)    case X86::Prefix##PMOV##Ext##Type##Suffix##rm##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 MachineBasicBlock::const_iterator PrevCrossBBInst (MachineBasicBlock::const_iterator MBBI)
 
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)
 

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)

◆ 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 GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")

◆ 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)

◆ 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)

◆ 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

◆ INSTR_CASE

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

◆ MASK_AVX512_CASE

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

◆ 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 
)     case X86::Prefix##PMOV##Ext##Type##Suffix##rm##Postfix:

Function Documentation

◆ addConstantComments()

static void addConstantComments ( const MachineInstr MI,
MCStreamer OutStreamer 
)
static

◆ convertTailJumpOpcode()

static unsigned convertTailJumpOpcode ( unsigned  Opcode)
static

Definition at line 374 of file X86MCInstLower.cpp.

◆ emitNop()

static 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 663 of file X86MCInstLower.cpp.

References assert(), llvm_unreachable, and OS.

Referenced by emitX86Nops().

◆ emitX86Nops()

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

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

Definition at line 780 of file X86MCInstLower.cpp.

References assert(), emitNop(), and OS.

◆ getRetOpcode()

static unsigned getRetOpcode ( const X86Subtarget Subtarget)
static

Definition at line 332 of file X86MCInstLower.cpp.

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

◆ getShuffleComment()

static std::string getShuffleComment ( const MachineInstr MI,
unsigned  SrcOp1Idx,
unsigned  SrcOp2Idx,
ArrayRef< int >  Mask 
)
static

◆ getSrcIdx()

static unsigned getSrcIdx ( const MachineInstr MI,
unsigned  SrcIdx 
)
static

◆ PrevCrossBBInst()

◆ printBroadcast()

static void printBroadcast ( const MachineInstr MI,
MCStreamer OutStreamer,
int  Repeats,
int  BitWidth 
)
static

◆ printConstant() [1/3]

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

Definition at line 1562 of file X86MCInstLower.cpp.

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

◆ printConstant() [2/3]

static void printConstant ( const APInt Val,
raw_ostream CS,
bool  PrintZero = false 
)
static

◆ printConstant() [3/3]

static void printConstant ( const Constant COp,
unsigned  BitWidth,
raw_ostream CS,
bool  PrintZero = false 
)
static

◆ printDstRegisterName()

static void printDstRegisterName ( raw_ostream CS,
const MachineInstr MI,
unsigned  SrcOpIdx 
)
static

◆ printExtend()

static bool printExtend ( const MachineInstr MI,
MCStreamer OutStreamer,
int  SrcEltBits,
int  DstEltBits,
bool  IsSext 
)
static

◆ printShuffleMask()

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

◆ printSignExtend()

static 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()

static void printZeroExtend ( const MachineInstr MI,
MCStreamer OutStreamer,
int  SrcEltBits,
int  DstEltBits 
)
static

◆ printZeroUpperMove()

static 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