X86 Backend

X86/X64 backend.

Namespace

  • x86 - x86 namespace provides support for X86/X64 code generation.

Emitters

Supported Instructions

  • Emitters:
    • x86::EmitterExplicitT - Provides all instructions that use explicit operands, provides also utility functions. The member functions provided are part of all X86 emitters.
    • x86::EmitterImplicitT - Provides all instructions that use implicit operands, these cannot be used with x86::Compiler.
  • Instruction representation:
    • x86::Inst::Id - Provides instruction identifiers for both X86/X86_64 architectures.
    • InstOptions - Provides generic and X86/X86_64 specific options.

Register Operands

Memory Operands

  • x86::Mem - X86/X64 memory operand that provides support for all X86 and X64 addressing features including absolute addresses, index scales, and segment override prefixes.

Status and Control Words

Predicates (immediate values)

Namespaces

Classes

Macros

Enumerations

Functions

Variables

Enumeration Type Documentation

class x86::CondCode : uint8_tenumstrong◆ 

Condition code.

ConstantDescription
kO 

OF==1.

kNO 

OF==0.

kC 

CF==1.

kB 

CF==1 (unsigned < )

kNAE 

CF==1 (unsigned < )

kNC 

CF==0.

kAE 

CF==0 (unsigned >=)

kNB 

CF==0 (unsigned >=)

kE 

ZF==1 (any_sign ==)

kZ 

ZF==1 (any_sign ==)

kNE 

ZF==0 (any_sign !=)

kNZ 

ZF==0 (any_sign !=)

kBE 

CF==1 | ZF==1 (unsigned <=)

kNA 

CF==1 | ZF==1 (unsigned <=)

kA 

CF==0 & ZF==0 (unsigned > )

kNBE 

CF==0 & ZF==0 (unsigned > )

kS 

SF==1 (is negative)

kNS 

SF==0 (is positive or zero)

kP 

PF==1.

kPE 

PF==1.

kPO 

PF==0.

kNP 

PF==0.

kL 

SF!=OF (signed < )

kNGE 

SF!=OF (signed < )

kGE 

SF==OF (signed >=)

kNL 

SF==OF (signed >=)

kLE 

ZF==1 | SF!=OF (signed <=)

kNG 

ZF==1 | SF!=OF (signed <=)

kG 

ZF==0 & SF==OF (signed > )

kNLE 

ZF==0 & SF==OF (signed > )

kZero 

Zero flag.

kNotZero 

Non-zero flag.

kSign 

Sign flag.

kNotSign 

No sign flag.

kNegative 

Sign flag.

kPositive 

No sign flag.

kOverflow 

Overflow (signed).

kNotOverflow 

Not overflow (signed).

kEqual 

a == b (equal).

kNotEqual 

a != b (not equal).

kSignedLT 

a < b (signed).

kSignedLE 

a <= b (signed).

kSignedGT 

a > b (signed).

kSignedGE 

a >= b (signed).

kUnsignedLT 

a < b (unsigned).

kUnsignedLE 

a <= b (unsigned).

kUnsignedGT 

a > b (unsigned).

kUnsignedGE 

a >= b (unsigned).

kParityEven 

Even parity flag.

kParityOdd 

Odd parity flag.

class x86::FpuStatusWord : uint16_tenumstrong◆ 

FPU status word bits.

ConstantDescription
kNone 

No bits set.

kInvalid 

Invalid operation.

kDenormalized 

Denormalized operand.

kDivByZero 

Division by zero.

kOverflow 

Overflown.

kUnderflow 

Underflown.

kPrecision 

Precision lost.

kStackFault 

Stack fault.

kInterrupt 

Interrupt.

kC0 

C0 flag.

kC1 

C1 flag.

kC2 

C2 flag.

kTopMask 

Top of the stack (mask).

kC3 

C3 flag.

kBusy 

FPU is busy.

class x86::FpuControlWord : uint16_tenumstrong◆ 

FPU control word bits.

ConstantDescription
kNone 

No bits set.

kEM_Mask 

Exception mask (0x3F).

kEM_Invalid 

Invalid operation exception.

kEM_Denormal 

Denormalized operand exception.

kEM_DivByZero 

Division by zero exception.

kEM_Overflow 

Overflow exception.

kEM_Underflow 

Underflow exception.

kEM_Inexact 

Inexact operation exception.

kPC_Mask 

Precision control mask.

kPC_Float 

Single precision (24 bits).

kPC_Reserved 

Reserved.

kPC_Double 

Double precision (53 bits).

kPC_Extended 

Extended precision (64 bits).

kRC_Mask 

Rounding control mask.

kRC_Nearest 

Round to nearest even.

kRC_Down 

Round down (floor).

kRC_Up 

Round up (ceil).

kRC_Truncate 

Round towards zero (truncate).

kIC_Mask 

Infinity control.

kIC_Projective 

Projective (not supported on X64).

kIC_Affine 

Affine (default).

class x86::CmpImm : uint8_tenumstrong◆ 

An immediate value that can be used with CMP[PD|PS|SD|SS] instructions.

ConstantDescription
kEQ 

Equal (Quiet), same as VCmpImm::kEQ_OQ.

kLT 

Less (Signaling), same as VCmpImm::kLT_OS.

kLE 

Less/Equal (Signaling), same as VCmpImm::kLE_OS.

kUNORD 

Unordered (Quiet), same as VCmpImm::kUNORD_Q.

kNEQ 

Not Equal (Quiet), same as VCmpImm::kNEQ_UQ.

kNLT 

Not Less (Signaling), same as VCmpImm::kNLT_US.

kNLE 

Not Less/Equal (Signaling), same as VCmpImm::kNLE_US.

kORD 

Ordered (Quiet), same as VCmpImm::kORD_Q.

class x86::PCmpStrImm : uint8_tenumstrong◆ 

An immediate value that can be used with [V]PCMP[I|E]STR[I|M] instructions.

ConstantDescription
kUB 

The source data format is unsigned bytes.

kUW 

The source data format is unsigned words.

kSB 

The source data format is signed bytes.

kSW 

The source data format is signed words.

kEqualAny 

The arithmetic comparison is "equal".

kRanges 

The arithmetic comparison is "greater than or equal" between even indexed elements and "less than or equal" between odd indexed elements.

kEqualEach 

The arithmetic comparison is "equal".

kEqualOrdered 

The arithmetic comparison is "equal".

kPosPolarity 

IntRes2 = IntRes1.

kNegPolarity 

IntRes2 = -1 XOR IntRes1.

kPosMasked 

IntRes2 = IntRes1.

kNegMasked 

IntRes2[i] = second[i] == invalid ? IntRes1[i] : ~IntRes1[i].

kOutputLSI 

The index returned to ECX is of the least significant set bit in IntRes2.

kOutputMSI 

The index returned to ECX is of the most significant set bit in IntRes2.

kBitMask 

IntRes2 is returned as the mask to the least significant bits of XMM0.

kIndexMask 

IntRes2 is expanded into a byte/word mask and placed in XMM0.

class x86::RoundImm : uint8_tenumstrong◆ 

An immediate value that can be used with ROUND[PD|PS|SD|SS] instructions.

Note
kSuppress is a mask that can be used with any other value.
ConstantDescription
kNearest 

Round to nearest (even).

kDown 

Round to down toward -INF (floor),.

kUp 

Round to up toward +INF (ceil).

kTrunc 

Round toward zero (truncate).

kCurrent 

Round to the current rounding mode set (ignores other RC bits).

kSuppress 

Suppress exceptions (avoids inexact exception, if set).

class x86::VCmpImm : uint8_tenumstrong◆ 

An immediate value that can be used with VCMP[PD|PS|SD|SS] instructions (AVX).

The first 8 values are compatible with CmpImm.

ConstantDescription
kEQ_OQ 

Equal (Quiet , Ordered) , same as CmpImm::kEQ.

kLT_OS 

Less (Signaling, Ordered) , same as CmpImm::kLT.

kLE_OS 

Less/Equal (Signaling, Ordered) , same as CmpImm::kLE.

kUNORD_Q 

Unordered (Quiet) , same as CmpImm::kUNORD.

kNEQ_UQ 

Not Equal (Quiet , Unordered), same as CmpImm::kNEQ.

kNLT_US 

Not Less (Signaling, Unordered), same as CmpImm::kNLT.

kNLE_US 

Not Less/Equal (Signaling, Unordered), same as CmpImm::kNLE.

kORD_Q 

Ordered (Quiet) , same as CmpImm::kORD.

kEQ_UQ 

Equal (Quiet , Unordered).

kNGE_US 

Not Greater/Equal (Signaling, Unordered).

kNGT_US 

Not Greater (Signaling, Unordered).

kFALSE_OQ 

False (Quiet , Ordered).

kNEQ_OQ 

Not Equal (Quiet , Ordered).

kGE_OS 

Greater/Equal (Signaling, Ordered).

kGT_OS 

Greater (Signaling, Ordered).

kTRUE_UQ 

True (Quiet , Unordered).

kEQ_OS 

Equal (Signaling, Ordered).

kLT_OQ 

Less (Quiet , Ordered).

kLE_OQ 

Less/Equal (Quiet , Ordered).

kUNORD_S 

Unordered (Signaling).

kNEQ_US 

Not Equal (Signaling, Unordered).

kNLT_UQ 

Not Less (Quiet , Unordered).

kNLE_UQ 

Not Less/Equal (Quiet , Unordered).

kORD_S 

Ordered (Signaling).

kEQ_US 

Equal (Signaling, Unordered).

kNGE_UQ 

Not Greater/Equal (Quiet , Unordered).

kNGT_UQ 

Not Greater (Quiet , Unordered).

kFALSE_OS 

False (Signaling, Ordered).

kNEQ_OS 

Not Equal (Signaling, Ordered).

kGE_OQ 

Greater/Equal (Quiet , Ordered).

kGT_OQ 

Greater (Quiet , Ordered).

kTRUE_US 

True (Signaling, Unordered).

class x86::VFixupImm : uint8_tenumstrong◆ 

An immediate value that can be used with VFIXUPIMM[PD|PS|SD|SS] instructions (AVX-512).

The final immediate is a combination of all possible control bits.

class x86::VFPClassImm : uint8_tenumstrong◆ 

An immediate value that can be used with VFPCLASS[PD|PS|SD|SS] instructions (AVX-512).

The values can be combined together to form the final 8-bit mask.

ConstantDescription
kQNaN 

Checks for QNaN.

kPZero 

Checks for +0.

kNZero 

Checks for -0.

kPInf 

Checks for +Inf.

kNInf 

Checks for -Inf.

kDenormal 

Checks for denormal.

kNegative 

Checks for negative finite value.

kSNaN 

Checks for SNaN.

class x86::VGetMantImm : uint8_tenumstrong◆ 

An immediate value that can be used with VGETMANT[PD|PS|SD|SS] instructions (AVX-512).

The value is a combination of a normalization interval and a sign control.

ConstantDescription
k1To2 

Normalization interval is [1, 2)

k1Div2To2 

Normalization interval is [0.5, 2)

k1Div2To1 

Normalization interval is [0.5, 1)

k3Div4To3Div2 

Normalization interval is [3/4, 3/2)

kSrcSign 

Source sign.

kNoSign 

Zero sign.

kQNaNIfSign 

QNAN_Indefinite if sign(src) != 0, regardless of kSignSrc or kNoSign.

class x86::VPCmpImm : uint8_tenumstrong◆ 

A predicate used by VPCMP[U][B|W|D|Q] instructions (AVX-512).

ConstantDescription
kEQ 

Equal.

kLT 

Less.

kLE 

Less/Equal.

kFALSE 

False.

kNE 

Not Equal.

kGE 

Greater/Equal.

kGT 

Greater.

kTRUE 

True.

class x86::VPComImm : uint8_tenumstrong◆ 

A predicate used by VPCOM[U][B|W|D|Q] instructions (XOP).

ConstantDescription
kLT 

Less.

kLE 

Less/Equal.

kGT 

Greater.

kGE 

Greater/Equal.

kEQ 

Equal.

kNE 

Not Equal.

kFALSE 

False.

kTRUE 

True.

class x86::VRangeImm : uint8_tenumstrong◆ 

A predicate used by VRANGE[PD|PS|SD|SS] instructions (AVX-512).

ConstantDescription
kSelectMin 

Select minimum value.

kSelectMax 

Select maximum value.

kSelectAbsMin 

Select minimum absolute value.

kSelectAbsMax 

Select maximum absolute value.

kSignSrc1 

Select sign of SRC1.

kSignSrc2 

Select sign of SRC2.

kSign0 

Set sign to 0.

kSign1 

Set sign to 1.

class x86::VReduceImm : uint8_tenumstrong◆ 

A predicate used by VREDUCE[PD|PS|SD|SS] instructions (AVX-512).

ConstantDescription
kRoundEven 

Round to nearest even.

kRoundDown 

Round down.

kRoundUp 

Round up.

kRoundTrunc 

Truncate.

kRoundCurrent 

Round to the current mode set.

kSuppress 

Suppress exceptions.

kFixedImmMask 

Fixed length value mask.

class x86::TLogImm : uint8_tenumstrong◆ 

A predicate that can be used as an immediate value with VPTERNLOG[D|Q] instruction.

There are 3 inputs to the instruction (kA, kB, kC). Ternary logic can define any combination that would be performed on these 3 inputs to get the desired output - any combination of AND, OR, XOR, NOT is possible.

See also
tLogFromBits and fLogIfElse
ConstantDescription
k0 

0 value.

k1 

1 value.

kA 

A value.

kB 

B value.

kC 

C value.

kNotA 

!A expression.

kNotB 

!B expression.

kNotC 

!C expression.

kAB 

A & B expression.

kAC 

A & C expression.

kBC 

B & C expression.

kNotAB 

!(A & B) expression.

kNotAC 

!(A & C) expression.

kNotBC 

!(B & C) expression.

kABC 

A & B & C expression.

kNotABC 

!(A & B & C) expression.

Function Documentation

CondCode x86::reverseCond(CondCode cond)constexprstaticconstexprnoexcept◆ 

Reverses a condition code (reverses the corresponding operands of a comparison).

CondCode x86::negateCond(CondCode cond)constexprstaticconstexprnoexcept◆ 

Negates a condition code.

VReduceImm x86::vReduceImm(VReduceImm flags, uint32_t fixedPointLength)constexprstaticconstexprnoexcept◆ 

Creates a VReduceImm from a combination of flags and fixedPointLength.

TLogImm x86::tLogFromBits(uint8_t b000, uint8_t b001, uint8_t b010, uint8_t b011, uint8_t b100, uint8_t b101, uint8_t b110, uint8_t b111)constexprstaticconstexprnoexcept◆ 

Creates an immediate that can be used by VPTERNLOG[D|Q] instructions.

TLogImm x86::fLogIfElse(TLogImm condition, TLogImm a, TLogImm b)constexprstaticconstexprnoexcept◆ 

Creates an if/else logic that can be used by VPTERNLOG[D|Q] instructions.

uint32_t x86::shuffleImm(uint32_t a, uint32_t b)constexprstaticconstexprnoexcept[1/2]◆ 

Creates a shuffle immediate value that be used with SSE/AVX/AVX-512 instructions to shuffle 2 elements in a vector.

Parameters
aPosition of the first component [0, 1].
bPosition of the second component [0, 1].

Shuffle constants can be used to encode an immediate for these instructions:

  • shufpd|vshufpd

uint32_t x86::shuffleImm(uint32_t a, uint32_t b, uint32_t c, uint32_t d)constexprstaticconstexprnoexcept[2/2]◆ 

Creates a shuffle immediate value that be used with SSE/AVX/AVX-512 instructions to shuffle 4 elements in a vector.

Parameters
aPosition of the first component [0, 3].
bPosition of the second component [0, 3].
cPosition of the third component [0, 3].
dPosition of the fourth component [0, 3].

Shuffle constants can be used to encode an immediate for these instructions:

  • pshufw
  • pshuflw|vpshuflw
  • pshufhw|vpshufhw
  • pshufd|vpshufd
  • shufps|vshufps

GpbLo x86::gpb(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates an 8-bit low GPB register operand.

GpbLo x86::gpb_lo(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates an 8-bit low GPB register operand.

GpbHi x86::gpb_hi(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates an 8-bit high GPB register operand.

Gpw x86::gpw(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 16-bit GPW register operand.

Gpd x86::gpd(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 32-bit GPD register operand.

Gpq x86::gpq(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 64-bit GPQ register operand (64-bit).

Xmm x86::xmm(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 128-bit XMM register operand.

Ymm x86::ymm(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 256-bit YMM register operand.

Zmm x86::zmm(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 512-bit ZMM register operand.

Mm x86::mm(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 64-bit Mm register operand.

KReg x86::k(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 64-bit K register operand.

CReg x86::cr(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 32-bit or 64-bit control register operand.

DReg x86::dr(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 32-bit or 64-bit debug register operand.

St x86::st(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates an 80-bit st register operand.

Bnd x86::bnd(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a 128-bit bound register operand.

Tmm x86::tmm(uint32_t rId)constexprstaticconstexprnoexcept◆ 

Creates a TMM register operand.

Mem x86::ptr(const Gp& base, int32_t offset = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[1/10]◆ 

Creates [base.reg + offset] memory operand.

Mem x86::ptr(const Gp& base, const Gp& index, uint32_t shift = 0, int32_t offset = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[2/10]◆ 

Creates [base.reg + (index << shift) + offset] memory operand (scalar index).

Mem x86::ptr(const Gp& base, const Vec& index, uint32_t shift = 0, int32_t offset = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[3/10]◆ 

Creates [base.reg + (index << shift) + offset] memory operand (vector index).

Mem x86::ptr(const Label& base, int32_t offset = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[4/10]◆ 

Creates [base + offset] memory operand.

Mem x86::ptr(const Label& base, const Gp& index, uint32_t shift = 0, int32_t offset = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[5/10]◆ 

Creates [base + (index << shift) + offset] memory operand.

Mem x86::ptr(const Label& base, const Vec& index, uint32_t shift = 0, int32_t offset = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[6/10]◆ 

Creates [base + (index << shift) + offset] memory operand.

Mem x86::ptr(const Rip& rip_, int32_t offset = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[7/10]◆ 

Creates [rip + offset] memory operand.

Mem x86::ptr(uint64_t base, uint32_t size = 0)constexprstaticconstexprnoexcept[8/10]◆ 

Creates [base] absolute memory operand.

Mem x86::ptr(uint64_t base, const Reg& index, uint32_t shift = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[9/10]◆ 

Creates [base + (index.reg << shift)] absolute memory operand.

Mem x86::ptr(uint64_t base, const Vec& index, uint32_t shift = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[10/10]◆ 

Creates [base + (index.reg << shift)] absolute memory operand.

Mem x86::ptr_abs(uint64_t base, uint32_t size = 0)constexprstaticconstexprnoexcept[1/3]◆ 

Creates [base] absolute memory operand (absolute).

Mem x86::ptr_abs(uint64_t base, const Reg& index, uint32_t shift = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[2/3]◆ 

Creates [base + (index.reg << shift)] absolute memory operand (absolute).

Mem x86::ptr_abs(uint64_t base, const Vec& index, uint32_t shift = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[3/3]◆ 

Creates [base + (index.reg << shift)] absolute memory operand (absolute).

Mem x86::ptr_rel(uint64_t base, uint32_t size = 0)constexprstaticconstexprnoexcept[1/3]◆ 

Creates [base] relative memory operand (relative).

Mem x86::ptr_rel(uint64_t base, const Reg& index, uint32_t shift = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[2/3]◆ 

Creates [base + (index.reg << shift)] relative memory operand (relative).

Mem x86::ptr_rel(uint64_t base, const Vec& index, uint32_t shift = 0, uint32_t size = 0)constexprstaticconstexprnoexcept[3/3]◆ 

Creates [base + (index.reg << shift)] relative memory operand (relative).