Skip to main content

asmkit/x86/features/
UINTR.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/// `CLUI`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | (none)   |
19/// +---+----------+
20/// ```
21pub trait CluiEmitter {
22    fn clui(&mut self);
23}
24
25impl<'a> CluiEmitter for Assembler<'a> {
26    fn clui(&mut self) {
27        self.emit(CLUI, &NOREG, &NOREG, &NOREG, &NOREG);
28    }
29}
30
31/// `SENDUIPI`.
32///
33/// Supported operand variants:
34///
35/// ```text
36/// +---+----------+
37/// | # | Operands |
38/// +---+----------+
39/// | 1 | Gpq      |
40/// +---+----------+
41/// ```
42pub trait SenduipiEmitter<A> {
43    fn senduipi(&mut self, op0: A);
44}
45
46impl<'a> SenduipiEmitter<Gpq> for Assembler<'a> {
47    fn senduipi(&mut self, op0: Gpq) {
48        self.emit(SENDUIPIR, op0.as_operand(), &NOREG, &NOREG, &NOREG);
49    }
50}
51
52/// `STUI`.
53///
54/// Supported operand variants:
55///
56/// ```text
57/// +---+----------+
58/// | # | Operands |
59/// +---+----------+
60/// | 1 | (none)   |
61/// +---+----------+
62/// ```
63pub trait StuiEmitter {
64    fn stui(&mut self);
65}
66
67impl<'a> StuiEmitter for Assembler<'a> {
68    fn stui(&mut self) {
69        self.emit(STUI, &NOREG, &NOREG, &NOREG, &NOREG);
70    }
71}
72
73/// `TESTUI`.
74///
75/// Supported operand variants:
76///
77/// ```text
78/// +---+----------+
79/// | # | Operands |
80/// +---+----------+
81/// | 1 | (none)   |
82/// +---+----------+
83/// ```
84pub trait TestuiEmitter {
85    fn testui(&mut self);
86}
87
88impl<'a> TestuiEmitter for Assembler<'a> {
89    fn testui(&mut self) {
90        self.emit(TESTUI, &NOREG, &NOREG, &NOREG, &NOREG);
91    }
92}
93
94/// `UIRET`.
95///
96/// Supported operand variants:
97///
98/// ```text
99/// +---+----------+
100/// | # | Operands |
101/// +---+----------+
102/// | 1 | (none)   |
103/// +---+----------+
104/// ```
105pub trait UiretEmitter {
106    fn uiret(&mut self);
107}
108
109impl<'a> UiretEmitter for Assembler<'a> {
110    fn uiret(&mut self) {
111        self.emit(UIRET, &NOREG, &NOREG, &NOREG, &NOREG);
112    }
113}
114
115impl<'a> Assembler<'a> {
116    /// `CLUI`.
117    ///
118    /// Supported operand variants:
119    ///
120    /// ```text
121    /// +---+----------+
122    /// | # | Operands |
123    /// +---+----------+
124    /// | 1 | (none)   |
125    /// +---+----------+
126    /// ```
127    #[inline]
128    pub fn clui(&mut self)
129    where
130        Assembler<'a>: CluiEmitter,
131    {
132        <Self as CluiEmitter>::clui(self);
133    }
134    /// `SENDUIPI`.
135    ///
136    /// Supported operand variants:
137    ///
138    /// ```text
139    /// +---+----------+
140    /// | # | Operands |
141    /// +---+----------+
142    /// | 1 | Gpq      |
143    /// +---+----------+
144    /// ```
145    #[inline]
146    pub fn senduipi<A>(&mut self, op0: A)
147    where
148        Assembler<'a>: SenduipiEmitter<A>,
149    {
150        <Self as SenduipiEmitter<A>>::senduipi(self, op0);
151    }
152    /// `STUI`.
153    ///
154    /// Supported operand variants:
155    ///
156    /// ```text
157    /// +---+----------+
158    /// | # | Operands |
159    /// +---+----------+
160    /// | 1 | (none)   |
161    /// +---+----------+
162    /// ```
163    #[inline]
164    pub fn stui(&mut self)
165    where
166        Assembler<'a>: StuiEmitter,
167    {
168        <Self as StuiEmitter>::stui(self);
169    }
170    /// `TESTUI`.
171    ///
172    /// Supported operand variants:
173    ///
174    /// ```text
175    /// +---+----------+
176    /// | # | Operands |
177    /// +---+----------+
178    /// | 1 | (none)   |
179    /// +---+----------+
180    /// ```
181    #[inline]
182    pub fn testui(&mut self)
183    where
184        Assembler<'a>: TestuiEmitter,
185    {
186        <Self as TestuiEmitter>::testui(self);
187    }
188    /// `UIRET`.
189    ///
190    /// Supported operand variants:
191    ///
192    /// ```text
193    /// +---+----------+
194    /// | # | Operands |
195    /// +---+----------+
196    /// | 1 | (none)   |
197    /// +---+----------+
198    /// ```
199    #[inline]
200    pub fn uiret(&mut self)
201    where
202        Assembler<'a>: UiretEmitter,
203    {
204        <Self as UiretEmitter>::uiret(self);
205    }
206}