Skip to main content

asmkit/x86/features/
SNP.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/// `PSMASH`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | (none)   |
19/// +---+----------+
20/// ```
21pub trait PsmashEmitter {
22    fn psmash(&mut self);
23}
24
25impl<'a> PsmashEmitter for Assembler<'a> {
26    fn psmash(&mut self) {
27        self.emit(PSMASH, &NOREG, &NOREG, &NOREG, &NOREG);
28    }
29}
30
31/// `PVALIDATE`.
32///
33/// Supported operand variants:
34///
35/// ```text
36/// +---+----------+
37/// | # | Operands |
38/// +---+----------+
39/// | 1 | (none)   |
40/// +---+----------+
41/// ```
42pub trait PvalidateEmitter {
43    fn pvalidate(&mut self);
44}
45
46impl<'a> PvalidateEmitter for Assembler<'a> {
47    fn pvalidate(&mut self) {
48        self.emit(PVALIDATE, &NOREG, &NOREG, &NOREG, &NOREG);
49    }
50}
51
52/// `RMPADJUST`.
53///
54/// Supported operand variants:
55///
56/// ```text
57/// +---+----------+
58/// | # | Operands |
59/// +---+----------+
60/// | 1 | (none)   |
61/// +---+----------+
62/// ```
63pub trait RmpadjustEmitter {
64    fn rmpadjust(&mut self);
65}
66
67impl<'a> RmpadjustEmitter for Assembler<'a> {
68    fn rmpadjust(&mut self) {
69        self.emit(RMPADJUST, &NOREG, &NOREG, &NOREG, &NOREG);
70    }
71}
72
73/// `RMPUPDATE`.
74///
75/// Supported operand variants:
76///
77/// ```text
78/// +---+----------+
79/// | # | Operands |
80/// +---+----------+
81/// | 1 | (none)   |
82/// +---+----------+
83/// ```
84pub trait RmpupdateEmitter {
85    fn rmpupdate(&mut self);
86}
87
88impl<'a> RmpupdateEmitter for Assembler<'a> {
89    fn rmpupdate(&mut self) {
90        self.emit(RMPUPDATE, &NOREG, &NOREG, &NOREG, &NOREG);
91    }
92}
93
94impl<'a> Assembler<'a> {
95    /// `PSMASH`.
96    ///
97    /// Supported operand variants:
98    ///
99    /// ```text
100    /// +---+----------+
101    /// | # | Operands |
102    /// +---+----------+
103    /// | 1 | (none)   |
104    /// +---+----------+
105    /// ```
106    #[inline]
107    pub fn psmash(&mut self)
108    where
109        Assembler<'a>: PsmashEmitter,
110    {
111        <Self as PsmashEmitter>::psmash(self);
112    }
113    /// `PVALIDATE`.
114    ///
115    /// Supported operand variants:
116    ///
117    /// ```text
118    /// +---+----------+
119    /// | # | Operands |
120    /// +---+----------+
121    /// | 1 | (none)   |
122    /// +---+----------+
123    /// ```
124    #[inline]
125    pub fn pvalidate(&mut self)
126    where
127        Assembler<'a>: PvalidateEmitter,
128    {
129        <Self as PvalidateEmitter>::pvalidate(self);
130    }
131    /// `RMPADJUST`.
132    ///
133    /// Supported operand variants:
134    ///
135    /// ```text
136    /// +---+----------+
137    /// | # | Operands |
138    /// +---+----------+
139    /// | 1 | (none)   |
140    /// +---+----------+
141    /// ```
142    #[inline]
143    pub fn rmpadjust(&mut self)
144    where
145        Assembler<'a>: RmpadjustEmitter,
146    {
147        <Self as RmpadjustEmitter>::rmpadjust(self);
148    }
149    /// `RMPUPDATE`.
150    ///
151    /// Supported operand variants:
152    ///
153    /// ```text
154    /// +---+----------+
155    /// | # | Operands |
156    /// +---+----------+
157    /// | 1 | (none)   |
158    /// +---+----------+
159    /// ```
160    #[inline]
161    pub fn rmpupdate(&mut self)
162    where
163        Assembler<'a>: RmpupdateEmitter,
164    {
165        <Self as RmpupdateEmitter>::rmpupdate(self);
166    }
167}