Skip to main content

asmkit/x86/features/
SNP.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/// `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
94
95impl<'a> Assembler<'a> {
96    /// `PSMASH`.
97    ///
98    /// Supported operand variants:
99    ///
100    /// ```text
101    /// +---+----------+
102    /// | # | Operands |
103    /// +---+----------+
104    /// | 1 | (none)   |
105    /// +---+----------+
106    /// ```
107    #[inline]
108    pub fn psmash(&mut self)
109    where Assembler<'a>: PsmashEmitter {
110        <Self as PsmashEmitter>::psmash(self);
111    }
112    /// `PVALIDATE`.
113    ///
114    /// Supported operand variants:
115    ///
116    /// ```text
117    /// +---+----------+
118    /// | # | Operands |
119    /// +---+----------+
120    /// | 1 | (none)   |
121    /// +---+----------+
122    /// ```
123    #[inline]
124    pub fn pvalidate(&mut self)
125    where Assembler<'a>: PvalidateEmitter {
126        <Self as PvalidateEmitter>::pvalidate(self);
127    }
128    /// `RMPADJUST`.
129    ///
130    /// Supported operand variants:
131    ///
132    /// ```text
133    /// +---+----------+
134    /// | # | Operands |
135    /// +---+----------+
136    /// | 1 | (none)   |
137    /// +---+----------+
138    /// ```
139    #[inline]
140    pub fn rmpadjust(&mut self)
141    where Assembler<'a>: RmpadjustEmitter {
142        <Self as RmpadjustEmitter>::rmpadjust(self);
143    }
144    /// `RMPUPDATE`.
145    ///
146    /// Supported operand variants:
147    ///
148    /// ```text
149    /// +---+----------+
150    /// | # | Operands |
151    /// +---+----------+
152    /// | 1 | (none)   |
153    /// +---+----------+
154    /// ```
155    #[inline]
156    pub fn rmpupdate(&mut self)
157    where Assembler<'a>: RmpupdateEmitter {
158        <Self as RmpupdateEmitter>::rmpupdate(self);
159    }
160}