Skip to main content

asmkit/x86/features/
GFNI.rs

1use crate::x86::assembler::*;
2use crate::x86::operands::*;
3use super::super::opcodes::*;
4use crate::core::emitter::*;
5use crate::core::operand::*;
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(GF2P8AFFINEINVQBRRI, op0.as_operand(), op1.as_operand(), op2.as_operand(), &NOREG);
29    }
30}
31
32impl<'a> Gf2p8affineinvqbEmitter<Xmm, Mem, Imm> for Assembler<'a> {
33    fn gf2p8affineinvqb(&mut self, op0: Xmm, op1: Mem, op2: Imm) {
34        self.emit(GF2P8AFFINEINVQBRMI, op0.as_operand(), op1.as_operand(), op2.as_operand(), &NOREG);
35    }
36}
37
38/// `GF2P8AFFINEQB`.
39///
40/// Supported operand variants:
41///
42/// ```text
43/// +---+---------------+
44/// | # | Operands      |
45/// +---+---------------+
46/// | 1 | Xmm, Mem, Imm |
47/// | 2 | Xmm, Xmm, Imm |
48/// +---+---------------+
49/// ```
50pub trait Gf2p8affineqbEmitter<A, B, C> {
51    fn gf2p8affineqb(&mut self, op0: A, op1: B, op2: C);
52}
53
54impl<'a> Gf2p8affineqbEmitter<Xmm, Xmm, Imm> for Assembler<'a> {
55    fn gf2p8affineqb(&mut self, op0: Xmm, op1: Xmm, op2: Imm) {
56        self.emit(GF2P8AFFINEQBRRI, op0.as_operand(), op1.as_operand(), op2.as_operand(), &NOREG);
57    }
58}
59
60impl<'a> Gf2p8affineqbEmitter<Xmm, Mem, Imm> for Assembler<'a> {
61    fn gf2p8affineqb(&mut self, op0: Xmm, op1: Mem, op2: Imm) {
62        self.emit(GF2P8AFFINEQBRMI, op0.as_operand(), op1.as_operand(), op2.as_operand(), &NOREG);
63    }
64}
65
66/// `GF2P8MULB`.
67///
68/// Supported operand variants:
69///
70/// ```text
71/// +---+----------+
72/// | # | Operands |
73/// +---+----------+
74/// | 1 | Xmm, Mem |
75/// | 2 | Xmm, Xmm |
76/// +---+----------+
77/// ```
78pub trait Gf2p8mulbEmitter<A, B> {
79    fn gf2p8mulb(&mut self, op0: A, op1: B);
80}
81
82impl<'a> Gf2p8mulbEmitter<Xmm, Xmm> for Assembler<'a> {
83    fn gf2p8mulb(&mut self, op0: Xmm, op1: Xmm) {
84        self.emit(GF2P8MULBRR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
85    }
86}
87
88impl<'a> Gf2p8mulbEmitter<Xmm, Mem> for Assembler<'a> {
89    fn gf2p8mulb(&mut self, op0: Xmm, op1: Mem) {
90        self.emit(GF2P8MULBRM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
91    }
92}
93
94
95impl<'a> Assembler<'a> {
96    /// `GF2P8AFFINEINVQB`.
97    ///
98    /// Supported operand variants:
99    ///
100    /// ```text
101    /// +---+---------------+
102    /// | # | Operands      |
103    /// +---+---------------+
104    /// | 1 | Xmm, Mem, Imm |
105    /// | 2 | Xmm, Xmm, Imm |
106    /// +---+---------------+
107    /// ```
108    #[inline]
109    pub fn gf2p8affineinvqb<A, B, C>(&mut self, op0: A, op1: B, op2: C)
110    where Assembler<'a>: Gf2p8affineinvqbEmitter<A, B, C> {
111        <Self as Gf2p8affineinvqbEmitter<A, B, C>>::gf2p8affineinvqb(self, op0, op1, op2);
112    }
113    /// `GF2P8AFFINEQB`.
114    ///
115    /// Supported operand variants:
116    ///
117    /// ```text
118    /// +---+---------------+
119    /// | # | Operands      |
120    /// +---+---------------+
121    /// | 1 | Xmm, Mem, Imm |
122    /// | 2 | Xmm, Xmm, Imm |
123    /// +---+---------------+
124    /// ```
125    #[inline]
126    pub fn gf2p8affineqb<A, B, C>(&mut self, op0: A, op1: B, op2: C)
127    where Assembler<'a>: Gf2p8affineqbEmitter<A, B, C> {
128        <Self as Gf2p8affineqbEmitter<A, B, C>>::gf2p8affineqb(self, op0, op1, op2);
129    }
130    /// `GF2P8MULB`.
131    ///
132    /// Supported operand variants:
133    ///
134    /// ```text
135    /// +---+----------+
136    /// | # | Operands |
137    /// +---+----------+
138    /// | 1 | Xmm, Mem |
139    /// | 2 | Xmm, Xmm |
140    /// +---+----------+
141    /// ```
142    #[inline]
143    pub fn gf2p8mulb<A, B>(&mut self, op0: A, op1: B)
144    where Assembler<'a>: Gf2p8mulbEmitter<A, B> {
145        <Self as Gf2p8mulbEmitter<A, B>>::gf2p8mulb(self, op0, op1);
146    }
147}