LLVM 22.0.0git
X86EncodingOptimization.cpp File Reference
#include "X86EncodingOptimization.h"
#include "MCTargetDesc/X86MCAsmInfo.h"
#include "X86BaseInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Support/Casting.h"
#include "X86EncodingOptimizationForImmediate.def"

Go to the source code of this file.

Macros

#define FROM_TO(FROM, TO, IDX1, IDX2)
#define TO_REV(FROM)
#define TO_REV(FROM)
#define TO_IMM1(FROM)
#define TO_IMM1(FROM)
#define FROM_TO(FROM, TO1, TO2)
#define FROM_TO(FROM, TO, R0, R1)
#define FROM_TO(FROM, TO)
#define ENTRY(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRY(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRY(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRYS(LONG, SHORT)
#define ENTRYS(LONG, SHORT)

Functions

static bool isARegister (MCRegister Reg)
static bool optimizeToFixedRegisterForm (MCInst &MI)
 Simplify FOO $imm, %{al,ax,eax,rax} to FOO $imm, for instruction with a short fixed-register form.
static bool optimizeToShortImmediateForm (MCInst &MI)

Macro Definition Documentation

◆ ENTRY [1/3]

#define ENTRY ( LONG,
SHORT )
Value:
case X86::LONG: \
return X86::SHORT;

◆ ENTRY [2/3]

#define ENTRY ( LONG,
SHORT )
Value:
case X86::SHORT: \
return X86::LONG;

◆ ENTRY [3/3]

#define ENTRY ( LONG,
SHORT )
Value:
case X86::LONG: \
NewOpc = X86::SHORT; \
break;

◆ ENTRYS [1/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_NF, SHORT##_NF) \
ENTRY(LONG##_ND, SHORT##_ND) \
ENTRY(LONG##_NF_ND, SHORT##_NF_ND)

◆ ENTRYS [2/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_NF, SHORT##_NF) \
ENTRY(LONG##_ND, SHORT##_ND) \
ENTRY(LONG##_NF_ND, SHORT##_NF_ND)

◆ ENTRYS [3/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_NF, SHORT##_NF) \
ENTRY(LONG##_ND, SHORT##_ND) \
ENTRY(LONG##_NF_ND, SHORT##_NF_ND)

◆ ENTRYS [4/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_NF, SHORT##_NF)

◆ ENTRYS [5/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_NF, SHORT##_NF)

◆ ENTRYS [6/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_NF, SHORT##_NF)

◆ ENTRYS [7/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_ND, SHORT##_ND)

◆ ENTRYS [8/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_ND, SHORT##_ND)

◆ ENTRYS [9/9]

#define ENTRYS ( LONG,
SHORT )
Value:
ENTRY(LONG, SHORT) \
ENTRY(LONG##_EVEX, SHORT##_EVEX) \
ENTRY(LONG##_ND, SHORT##_ND)

◆ FROM_TO [1/4]

#define FROM_TO ( FROM,
TO )
Value:
case X86::FROM: \
NewOpc = X86::TO; \
break;

◆ FROM_TO [2/4]

#define FROM_TO ( FROM,
TO,
IDX1,
IDX2 )

◆ FROM_TO [3/4]

#define FROM_TO ( FROM,
TO,
R0,
R1 )
Value:
case X86::FROM: \
if (MI.getOperand(0).getReg() != X86::R0 || \
MI.getOperand(1).getReg() != X86::R1) \
return false; \
NewOpc = X86::TO; \
break;
IRTranslator LLVM IR MI

◆ FROM_TO [4/4]

#define FROM_TO ( FROM,
TO1,
TO2 )
Value:
case X86::FROM: \
Opc1 = X86::TO1; \
Opc2 = X86::TO2; \
break;

◆ TO_IMM1 [1/2]

#define TO_IMM1 ( FROM)
Value:
case X86::FROM##i: \
NewOpc = X86::FROM##1; \
break; \
case X86::FROM##i_EVEX: \
NewOpc = X86::FROM##1_EVEX; \
break; \
case X86::FROM##i_ND: \
NewOpc = X86::FROM##1_ND; \
break;

Referenced by llvm::X86::optimizeShiftRotateWithImmediateOne().

◆ TO_IMM1 [2/2]

#define TO_IMM1 ( FROM)
Value:
case X86::FROM##i: \
NewOpc = X86::FROM##1; \
break; \
case X86::FROM##i_EVEX: \
NewOpc = X86::FROM##1_EVEX; \
break; \
case X86::FROM##i_NF: \
NewOpc = X86::FROM##1_NF; \
break; \
case X86::FROM##i_ND: \
NewOpc = X86::FROM##1_ND; \
break; \
case X86::FROM##i_NF_ND: \
NewOpc = X86::FROM##1_NF_ND; \
break;

◆ TO_REV [1/2]

#define TO_REV ( FROM)
Value:
FROM_TO(FROM, FROM##_REV, 0, 1)
#define FROM_TO(FROM, TO)

Referenced by llvm::X86::optimizeInstFromVEX3ToVEX2().

◆ TO_REV [2/2]

#define TO_REV ( FROM)
Value:
FROM_TO(FROM, FROM##_REV, 0, 2)

Function Documentation

◆ isARegister()

bool isARegister ( MCRegister Reg)
static

Definition at line 333 of file X86EncodingOptimization.cpp.

References Reg.

Referenced by llvm::X86::optimizeMOV(), and optimizeToFixedRegisterForm().

◆ optimizeToFixedRegisterForm()

bool optimizeToFixedRegisterForm ( MCInst & MI)
static

Simplify FOO $imm, %{al,ax,eax,rax} to FOO $imm, for instruction with a short fixed-register form.

Definition at line 397 of file X86EncodingOptimization.cpp.

References FROM_TO, isARegister(), MI, Reg, and Saved.

Referenced by llvm::X86::optimizeToFixedRegisterOrShortImmediateForm().

◆ optimizeToShortImmediateForm()