| 1 |
// Capstone definitions fix for X86 LLVM instructions. |
| 2 |
|
| 3 |
let Defs = [EFLAGS] in |
| 4 |
def INT1 : I<0xf1, RawFrm, (outs), (ins), "int1", []>; |
| 5 |
|
| 6 |
def FSETPM : I<0xDB, MRM_E4, (outs), (ins), "fsetpm", []>; |
| 7 |
|
| 8 |
// Capstone: comment out below lines for X86 Reduce mode |
| 9 |
|
| 10 |
// X87 Floating Point Stack. |
| 11 |
//include "X86InstrFPStack.td" |
| 12 |
|
| 13 |
// SIMD support (SSE, MMX and AVX) |
| 14 |
//include "X86InstrFragmentsSIMD.td" |
| 15 |
|
| 16 |
// FMA - Fused Multiply-Add support (requires FMA) |
| 17 |
//include "X86InstrFMA.td" |
| 18 |
|
| 19 |
// XOP |
| 20 |
//include "X86InstrXOP.td" |
| 21 |
|
| 22 |
// SSE, MMX and 3DNow! vector support. |
| 23 |
//include "X86InstrSSE.td" |
| 24 |
//include "X86InstrAVX512.td" |
| 25 |
//include "X86InstrMMX.td" |
| 26 |
//include "X86Instr3DNow.td" |
| 27 |
|
| 28 |
// MPX instructions |
| 29 |
//include "X86InstrMPX.td" |
| 30 |
|
| 31 |
//include "X86InstrTSX.td" |
| 32 |
//include "X86InstrSGX.td" |
| 33 |
|
| 34 |
// Various unary fpstack operations default to operating on ST1. |
| 35 |
// For example, "fxch" -> "fxch %st(1)" |
| 36 |
//def : InstAlias<"faddp", (ADD_FPrST0 ST1), 0>; |
| 37 |
//def: InstAlias<"fadd", (ADD_FPrST0 ST1), 0>; |
| 38 |
//def : InstAlias<"fsub{|r}p", (SUBR_FPrST0 ST1), 0>; |
| 39 |
//def : InstAlias<"fsub{r|}p", (SUB_FPrST0 ST1), 0>; |
| 40 |
//def : InstAlias<"fmul", (MUL_FPrST0 ST1), 0>; |
| 41 |
//def : InstAlias<"fmulp", (MUL_FPrST0 ST1), 0>; |
| 42 |
//def : InstAlias<"fdiv{|r}p", (DIVR_FPrST0 ST1), 0>; |
| 43 |
//def : InstAlias<"fdiv{r|}p", (DIV_FPrST0 ST1), 0>; |
| 44 |
//def : InstAlias<"fxch", (XCH_F ST1), 0>; |
| 45 |
//def : InstAlias<"fcom", (COM_FST0r ST1), 0>; |
| 46 |
//def : InstAlias<"fcomp", (COMP_FST0r ST1), 0>; |
| 47 |
//def : InstAlias<"fcomi", (COM_FIr ST1), 0>; |
| 48 |
//def : InstAlias<"fcompi", (COM_FIPr ST1), 0>; |
| 49 |
//def : InstAlias<"fucom", (UCOM_Fr ST1), 0>; |
| 50 |
//def : InstAlias<"fucomp", (UCOM_FPr ST1), 0>; |
| 51 |
//def : InstAlias<"fucomi", (UCOM_FIr ST1), 0>; |
| 52 |
//def : InstAlias<"fucompi", (UCOM_FIPr ST1), 0>; |
| 53 |
|
| 54 |
// Handle fmul/fadd/fsub/fdiv instructions with explicitly written st(0) op. |
| 55 |
// For example, "fadd %st(4), %st(0)" -> "fadd %st(4)". We also disambiguate |
| 56 |
// instructions like "fadd %st(0), %st(0)" as "fadd %st(0)" for consistency with |
| 57 |
// gas. |
| 58 |
multiclass FpUnaryAlias<string Mnemonic, Instruction Inst, bit EmitAlias = 1> { |
| 59 |
def : InstAlias<!strconcat(Mnemonic, "\t{$op, %st(0)|st(0), $op}"), |
| 60 |
(Inst RST:$op), EmitAlias>; |
| 61 |
def : InstAlias<!strconcat(Mnemonic, "\t{%st(0), %st(0)|st(0), st(0)}"), |
| 62 |
(Inst ST0), EmitAlias>; |
| 63 |
} |
| 64 |
|
| 65 |
//defm : FpUnaryAlias<"fadd", ADD_FST0r>; |
| 66 |
//defm : FpUnaryAlias<"faddp", ADD_FPrST0, 0>; |
| 67 |
//defm : FpUnaryAlias<"fsub", SUB_FST0r>; |
| 68 |
//defm : FpUnaryAlias<"fsub{|r}p", SUBR_FPrST0>; |
| 69 |
//defm : FpUnaryAlias<"fsubr", SUBR_FST0r>; |
| 70 |
//defm : FpUnaryAlias<"fsub{r|}p", SUB_FPrST0>; |
| 71 |
//defm : FpUnaryAlias<"fmul", MUL_FST0r>; |
| 72 |
//defm : FpUnaryAlias<"fmulp", MUL_FPrST0>; |
| 73 |
//defm : FpUnaryAlias<"fdiv", DIV_FST0r>; |
| 74 |
//defm : FpUnaryAlias<"fdiv{|r}p", DIVR_FPrST0>; |
| 75 |
//defm : FpUnaryAlias<"fdivr", DIVR_FST0r>; |
| 76 |
//defm : FpUnaryAlias<"fdiv{r|}p", DIV_FPrST0>; |
| 77 |
//defm : FpUnaryAlias<"fcomi", COM_FIr, 0>; |
| 78 |
//defm : FpUnaryAlias<"fucomi", UCOM_FIr, 0>; |
| 79 |
//defm : FpUnaryAlias<"fcompi", COM_FIPr>; |
| 80 |
//defm : FpUnaryAlias<"fucompi", UCOM_FIPr>; |
| 81 |
|
| 82 |
|
| 83 |
// Handle "f{mulp,addp} st(0), $op" the same as "f{mulp,addp} $op", since they |
| 84 |
// commute. We also allow fdiv[r]p/fsubrp even though they don't commute, |
| 85 |
// solely because gas supports it. |
| 86 |
//def : InstAlias<"faddp\t{%st(0), $op|$op, st(0)}", (ADD_FPrST0 RST:$op), 0>; |
| 87 |
//def : InstAlias<"fmulp\t{%st(0), $op|$op, st(0)}", (MUL_FPrST0 RST:$op)>; |
| 88 |
//def : InstAlias<"fsub{|r}p\t{%st(0), $op|$op, st(0)}", (SUBR_FPrST0 RST:$op)>; |
| 89 |
//def : InstAlias<"fsub{r|}p\t{%st(0), $op|$op, st(0)}", (SUB_FPrST0 RST:$op)>; |
| 90 |
//def : InstAlias<"fdiv{|r}p\t{%st(0), $op|$op, st(0)}", (DIVR_FPrST0 RST:$op)>; |
| 91 |
//def : InstAlias<"fdiv{r|}p\t{%st(0), $op|$op, st(0)}", (DIV_FPrST0 RST:$op)>; |
| 92 |
// |
| 93 |
//def : InstAlias<"fnstsw" , (FNSTSW16r), 0>; |
| 94 |
|
| 95 |
// Match 'movd GR64, MMX' as an alias for movq to be compatible with gas, |
| 96 |
// which supports this due to an old AMD documentation bug when 64-bit mode was |
| 97 |
// created. |
| 98 |
//def : InstAlias<"movd\t{$src, $dst|$dst, $src}", |
| 99 |
// (MMX_MOVD64to64rr VR64:$dst, GR64:$src), 0>; |
| 100 |
//def : InstAlias<"movd\t{$src, $dst|$dst, $src}", |
| 101 |
// (MMX_MOVD64from64rr GR64:$dst, VR64:$src), 0>; |