Skip to main content

asmkit/x86/features/
ENQCMD.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/// `ENQCMD`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | Gpd, Mem |
19/// | 2 | Gpq, Mem |
20/// +---+----------+
21/// ```
22pub trait EnqcmdEmitter<A, B> {
23    fn enqcmd(&mut self, op0: A, op1: B);
24}
25
26impl<'a> EnqcmdEmitter<Gpd, Mem> for Assembler<'a> {
27    fn enqcmd(&mut self, op0: Gpd, op1: Mem) {
28        self.emit(ENQCMD32RM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
29    }
30}
31
32impl<'a> EnqcmdEmitter<Gpq, Mem> for Assembler<'a> {
33    fn enqcmd(&mut self, op0: Gpq, op1: Mem) {
34        self.emit(ENQCMD64RM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
35    }
36}
37
38/// `ENQCMDS`.
39///
40/// Supported operand variants:
41///
42/// ```text
43/// +---+----------+
44/// | # | Operands |
45/// +---+----------+
46/// | 1 | Gpd, Mem |
47/// | 2 | Gpq, Mem |
48/// +---+----------+
49/// ```
50pub trait EnqcmdsEmitter<A, B> {
51    fn enqcmds(&mut self, op0: A, op1: B);
52}
53
54impl<'a> EnqcmdsEmitter<Gpd, Mem> for Assembler<'a> {
55    fn enqcmds(&mut self, op0: Gpd, op1: Mem) {
56        self.emit(ENQCMDS32RM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
57    }
58}
59
60impl<'a> EnqcmdsEmitter<Gpq, Mem> for Assembler<'a> {
61    fn enqcmds(&mut self, op0: Gpq, op1: Mem) {
62        self.emit(ENQCMDS64RM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
63    }
64}
65
66
67impl<'a> Assembler<'a> {
68    /// `ENQCMD`.
69    ///
70    /// Supported operand variants:
71    ///
72    /// ```text
73    /// +---+----------+
74    /// | # | Operands |
75    /// +---+----------+
76    /// | 1 | Gpd, Mem |
77    /// | 2 | Gpq, Mem |
78    /// +---+----------+
79    /// ```
80    #[inline]
81    pub fn enqcmd<A, B>(&mut self, op0: A, op1: B)
82    where Assembler<'a>: EnqcmdEmitter<A, B> {
83        <Self as EnqcmdEmitter<A, B>>::enqcmd(self, op0, op1);
84    }
85    /// `ENQCMDS`.
86    ///
87    /// Supported operand variants:
88    ///
89    /// ```text
90    /// +---+----------+
91    /// | # | Operands |
92    /// +---+----------+
93    /// | 1 | Gpd, Mem |
94    /// | 2 | Gpq, Mem |
95    /// +---+----------+
96    /// ```
97    #[inline]
98    pub fn enqcmds<A, B>(&mut self, op0: A, op1: B)
99    where Assembler<'a>: EnqcmdsEmitter<A, B> {
100        <Self as EnqcmdsEmitter<A, B>>::enqcmds(self, op0, op1);
101    }
102}