Skip to main content

asmkit/x86/features/
GFNI.rs

1use super::super::opcodes::*;
2use crate::core::emitter::*;
3use crate::core::operand::*;
4use crate::x86::assembler::*;
5use crate::x86::operands::*;
6
7/// A dummy operand that represents no register. Here just for simplicity.
8const NOREG: Operand = Operand::new();
9
10/// `GF2P8AFFINEINVQB`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+---------------+
16/// | # | Operands      |
17/// +---+---------------+
18/// | 1 | Xmm, Mem, Imm |
19/// | 2 | Xmm, Xmm, Imm |
20/// +---+---------------+
21/// ```
22pub trait Gf2p8affineinvqbEmitter<A, B, C> {
23    fn gf2p8affineinvqb(&mut self, op0: A, op1: B, op2: C);
24}
25
26impl<'a> Gf2p8affineinvqbEmitter<Xmm, Xmm, Imm> for Assembler<'a> {
27    fn gf2p8affineinvqb(&mut self, op0: Xmm, op1: Xmm, op2: Imm) {
28        self.emit(
29            GF2P8AFFINEINVQBRRI,
30            op0.as_operand(),
31            op1.as_operand(),
32            op2.as_operand(),
33            &NOREG,
34        );
35    }
36}
37
38impl<'a> Gf2p8affineinvqbEmitter<Xmm, Mem, Imm> for Assembler<'a> {
39    fn gf2p8affineinvqb(&mut self, op0: Xmm, op1: Mem, op2: Imm) {
40        self.emit(
41            GF2P8AFFINEINVQBRMI,
42            op0.as_operand(),
43            op1.as_operand(),
44            op2.as_operand(),
45            &NOREG,
46        );
47    }
48}
49
50/// `GF2P8AFFINEQB`.
51///
52/// Supported operand variants:
53///
54/// ```text
55/// +---+---------------+
56/// | # | Operands      |
57/// +---+---------------+
58/// | 1 | Xmm, Mem, Imm |
59/// | 2 | Xmm, Xmm, Imm |
60/// +---+---------------+
61/// ```
62pub trait Gf2p8affineqbEmitter<A, B, C> {
63    fn gf2p8affineqb(&mut self, op0: A, op1: B, op2: C);
64}
65
66impl<'a> Gf2p8affineqbEmitter<Xmm, Xmm, Imm> for Assembler<'a> {
67    fn gf2p8affineqb(&mut self, op0: Xmm, op1: Xmm, op2: Imm) {
68        self.emit(
69            GF2P8AFFINEQBRRI,
70            op0.as_operand(),
71            op1.as_operand(),
72            op2.as_operand(),
73            &NOREG,
74        );
75    }
76}
77
78impl<'a> Gf2p8affineqbEmitter<Xmm, Mem, Imm> for Assembler<'a> {
79    fn gf2p8affineqb(&mut self, op0: Xmm, op1: Mem, op2: Imm) {
80        self.emit(
81            GF2P8AFFINEQBRMI,
82            op0.as_operand(),
83            op1.as_operand(),
84            op2.as_operand(),
85            &NOREG,
86        );
87    }
88}
89
90/// `GF2P8MULB`.
91///
92/// Supported operand variants:
93///
94/// ```text
95/// +---+----------+
96/// | # | Operands |
97/// +---+----------+
98/// | 1 | Xmm, Mem |
99/// | 2 | Xmm, Xmm |
100/// +---+----------+
101/// ```
102pub trait Gf2p8mulbEmitter<A, B> {
103    fn gf2p8mulb(&mut self, op0: A, op1: B);
104}
105
106impl<'a> Gf2p8mulbEmitter<Xmm, Xmm> for Assembler<'a> {
107    fn gf2p8mulb(&mut self, op0: Xmm, op1: Xmm) {
108        self.emit(
109            GF2P8MULBRR,
110            op0.as_operand(),
111            op1.as_operand(),
112            &NOREG,
113            &NOREG,
114        );
115    }
116}
117
118impl<'a> Gf2p8mulbEmitter<Xmm, Mem> for Assembler<'a> {
119    fn gf2p8mulb(&mut self, op0: Xmm, op1: Mem) {
120        self.emit(
121            GF2P8MULBRM,
122            op0.as_operand(),
123            op1.as_operand(),
124            &NOREG,
125            &NOREG,
126        );
127    }
128}
129
130impl<'a> Assembler<'a> {
131    /// `GF2P8AFFINEINVQB`.
132    ///
133    /// Supported operand variants:
134    ///
135    /// ```text
136    /// +---+---------------+
137    /// | # | Operands      |
138    /// +---+---------------+
139    /// | 1 | Xmm, Mem, Imm |
140    /// | 2 | Xmm, Xmm, Imm |
141    /// +---+---------------+
142    /// ```
143    #[inline]
144    pub fn gf2p8affineinvqb<A, B, C>(&mut self, op0: A, op1: B, op2: C)
145    where
146        Assembler<'a>: Gf2p8affineinvqbEmitter<A, B, C>,
147    {
148        <Self as Gf2p8affineinvqbEmitter<A, B, C>>::gf2p8affineinvqb(self, op0, op1, op2);
149    }
150    /// `GF2P8AFFINEQB`.
151    ///
152    /// Supported operand variants:
153    ///
154    /// ```text
155    /// +---+---------------+
156    /// | # | Operands      |
157    /// +---+---------------+
158    /// | 1 | Xmm, Mem, Imm |
159    /// | 2 | Xmm, Xmm, Imm |
160    /// +---+---------------+
161    /// ```
162    #[inline]
163    pub fn gf2p8affineqb<A, B, C>(&mut self, op0: A, op1: B, op2: C)
164    where
165        Assembler<'a>: Gf2p8affineqbEmitter<A, B, C>,
166    {
167        <Self as Gf2p8affineqbEmitter<A, B, C>>::gf2p8affineqb(self, op0, op1, op2);
168    }
169    /// `GF2P8MULB`.
170    ///
171    /// Supported operand variants:
172    ///
173    /// ```text
174    /// +---+----------+
175    /// | # | Operands |
176    /// +---+----------+
177    /// | 1 | Xmm, Mem |
178    /// | 2 | Xmm, Xmm |
179    /// +---+----------+
180    /// ```
181    #[inline]
182    pub fn gf2p8mulb<A, B>(&mut self, op0: A, op1: B)
183    where
184        Assembler<'a>: Gf2p8mulbEmitter<A, B>,
185    {
186        <Self as Gf2p8mulbEmitter<A, B>>::gf2p8mulb(self, op0, op1);
187    }
188}