Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/cranelift/assembler-x64/meta/src/instructions/fma.rs
1693 views
1
use crate::dsl::{Feature::*, Inst, Length::*, Location::*};
2
use crate::dsl::{fmt, inst, r, rw, vex};
3
4
#[rustfmt::skip] // Keeps instructions on a single line.
5
pub fn list() -> Vec<Inst> {
6
let single_ops = [rw(xmm1), r(xmm2), r(xmm_m32)];
7
let double_ops = [rw(xmm1), r(xmm2), r(xmm_m64)];
8
let packed_ops = [rw(xmm1), r(xmm2), r(xmm_m128)];
9
let enc = || vex(LIG)._66()._0f38();
10
vec![
11
// Fused Multiply-Add (FMA) instructions. The digits in the instruction
12
// mnemonic correspond to the combination of operands (`op*`): e.g.,
13
// - `132` means `op1 * op2 + op3`,
14
// - `213` means `op2 * op1 + op3`, and
15
// - `231` means `op2 * op3 + op1`.
16
inst("vfmadd132ss", fmt("A", single_ops), enc().w0().op(0x99).r(), (_64b | compat) & fma),
17
inst("vfmadd213ss", fmt("A", single_ops), enc().w0().op(0xA9).r(), (_64b | compat) & fma),
18
inst("vfmadd231ss", fmt("A", single_ops), enc().w0().op(0xB9).r(), (_64b | compat) & fma),
19
inst("vfmadd132sd", fmt("A", double_ops), enc().w1().op(0x99).r(), (_64b | compat) & fma),
20
inst("vfmadd213sd", fmt("A", double_ops), enc().w1().op(0xA9).r(), (_64b | compat) & fma),
21
inst("vfmadd231sd", fmt("A", double_ops), enc().w1().op(0xB9).r(), (_64b | compat) & fma),
22
inst("vfmadd132ps", fmt("A", packed_ops), enc().w0().op(0x98).r(), (_64b | compat) & fma),
23
inst("vfmadd213ps", fmt("A", packed_ops), enc().w0().op(0xA8).r(), (_64b | compat) & fma),
24
inst("vfmadd231ps", fmt("A", packed_ops), enc().w0().op(0xB8).r(), (_64b | compat) & fma),
25
inst("vfmadd132pd", fmt("A", packed_ops), enc().w1().op(0x98).r(), (_64b | compat) & fma),
26
inst("vfmadd213pd", fmt("A", packed_ops), enc().w1().op(0xA8).r(), (_64b | compat) & fma),
27
inst("vfmadd231pd", fmt("A", packed_ops), enc().w1().op(0xB8).r(), (_64b | compat) & fma),
28
// Fused Negative Multiply-Add (FNMA); like FMA, but with the
29
// multiplication result negated.
30
inst("vfnmadd132ss", fmt("A", single_ops), enc().w0().op(0x9D).r(), (_64b | compat) & fma),
31
inst("vfnmadd213ss", fmt("A", single_ops), enc().w0().op(0xAD).r(), (_64b | compat) & fma),
32
inst("vfnmadd231ss", fmt("A", single_ops), enc().w0().op(0xBD).r(), (_64b | compat) & fma),
33
inst("vfnmadd132sd", fmt("A", double_ops), enc().w1().op(0x9D).r(), (_64b | compat) & fma),
34
inst("vfnmadd213sd", fmt("A", double_ops), enc().w1().op(0xAD).r(), (_64b | compat) & fma),
35
inst("vfnmadd231sd", fmt("A", double_ops), enc().w1().op(0xBD).r(), (_64b | compat) & fma),
36
inst("vfnmadd132ps", fmt("A", packed_ops), enc().w0().op(0x9C).r(), (_64b | compat) & fma),
37
inst("vfnmadd213ps", fmt("A", packed_ops), enc().w0().op(0xAC).r(), (_64b | compat) & fma),
38
inst("vfnmadd231ps", fmt("A", packed_ops), enc().w0().op(0xBC).r(), (_64b | compat) & fma),
39
inst("vfnmadd132pd", fmt("A", packed_ops), enc().w1().op(0x9C).r(), (_64b | compat) & fma),
40
inst("vfnmadd213pd", fmt("A", packed_ops), enc().w1().op(0xAC).r(), (_64b | compat) & fma),
41
inst("vfnmadd231pd", fmt("A", packed_ops), enc().w1().op(0xBC).r(), (_64b | compat) & fma),
42
// Fused Multiply-Subtract (FMS); like FMA, but subtracting
43
// from the multiplication result.
44
inst("vfmsub132ss", fmt("A", single_ops), enc().w0().op(0x9B).r(), (_64b | compat) & fma),
45
inst("vfmsub213ss", fmt("A", single_ops), enc().w0().op(0xAB).r(), (_64b | compat) & fma),
46
inst("vfmsub231ss", fmt("A", single_ops), enc().w0().op(0xBB).r(), (_64b | compat) & fma),
47
inst("vfmsub132sd", fmt("A", double_ops), enc().w1().op(0x9B).r(), (_64b | compat) & fma),
48
inst("vfmsub213sd", fmt("A", double_ops), enc().w1().op(0xAB).r(), (_64b | compat) & fma),
49
inst("vfmsub231sd", fmt("A", double_ops), enc().w1().op(0xBB).r(), (_64b | compat) & fma),
50
inst("vfmsub132ps", fmt("A", packed_ops), enc().w0().op(0x9A).r(), (_64b | compat) & fma),
51
inst("vfmsub213ps", fmt("A", packed_ops), enc().w0().op(0xAA).r(), (_64b | compat) & fma),
52
inst("vfmsub231ps", fmt("A", packed_ops), enc().w0().op(0xBA).r(), (_64b | compat) & fma),
53
inst("vfmsub132pd", fmt("A", packed_ops), enc().w1().op(0x9A).r(), (_64b | compat) & fma),
54
inst("vfmsub213pd", fmt("A", packed_ops), enc().w1().op(0xAA).r(), (_64b | compat) & fma),
55
inst("vfmsub231pd", fmt("A", packed_ops), enc().w1().op(0xBA).r(), (_64b | compat) & fma),
56
// Fused Negative Multiply-Subtract (FNMS).
57
inst("vfnmsub132ss", fmt("A", single_ops), enc().w0().op(0x9F).r(), (_64b | compat) & fma),
58
inst("vfnmsub213ss", fmt("A", single_ops), enc().w0().op(0xAF).r(), (_64b | compat) & fma),
59
inst("vfnmsub231ss", fmt("A", single_ops), enc().w0().op(0xBF).r(), (_64b | compat) & fma),
60
inst("vfnmsub132sd", fmt("A", double_ops), enc().w1().op(0x9F).r(), (_64b | compat) & fma),
61
inst("vfnmsub213sd", fmt("A", double_ops), enc().w1().op(0xAF).r(), (_64b | compat) & fma),
62
inst("vfnmsub231sd", fmt("A", double_ops), enc().w1().op(0xBF).r(), (_64b | compat) & fma),
63
inst("vfnmsub132ps", fmt("A", packed_ops), enc().w0().op(0x9E).r(), (_64b | compat) & fma),
64
inst("vfnmsub213ps", fmt("A", packed_ops), enc().w0().op(0xAE).r(), (_64b | compat) & fma),
65
inst("vfnmsub231ps", fmt("A", packed_ops), enc().w0().op(0xBE).r(), (_64b | compat) & fma),
66
inst("vfnmsub132pd", fmt("A", packed_ops), enc().w1().op(0x9E).r(), (_64b | compat) & fma),
67
inst("vfnmsub213pd", fmt("A", packed_ops), enc().w1().op(0xAE).r(), (_64b | compat) & fma),
68
inst("vfnmsub231pd", fmt("A", packed_ops), enc().w1().op(0xBE).r(), (_64b | compat) & fma),
69
]
70
}
71
72