Skip to main content

asmkit/x86/features/
SKINIT.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/// `CLGI`.
11///
12/// Supported operand variants:
13///
14/// ```text
15/// +---+----------+
16/// | # | Operands |
17/// +---+----------+
18/// | 1 | (none)   |
19/// +---+----------+
20/// ```
21pub trait ClgiEmitter {
22    fn clgi(&mut self);
23}
24
25impl<'a> ClgiEmitter for Assembler<'a> {
26    fn clgi(&mut self) {
27        self.emit(CLGI, &NOREG, &NOREG, &NOREG, &NOREG);
28    }
29}
30
31/// `SKINIT`.
32///
33/// Supported operand variants:
34///
35/// ```text
36/// +---+----------+
37/// | # | Operands |
38/// +---+----------+
39/// | 1 | (none)   |
40/// +---+----------+
41/// ```
42pub trait SkinitEmitter {
43    fn skinit(&mut self);
44}
45
46impl<'a> SkinitEmitter for Assembler<'a> {
47    fn skinit(&mut self) {
48        self.emit(SKINIT, &NOREG, &NOREG, &NOREG, &NOREG);
49    }
50}
51
52/// `STGI`.
53///
54/// Supported operand variants:
55///
56/// ```text
57/// +---+----------+
58/// | # | Operands |
59/// +---+----------+
60/// | 1 | (none)   |
61/// +---+----------+
62/// ```
63pub trait StgiEmitter {
64    fn stgi(&mut self);
65}
66
67impl<'a> StgiEmitter for Assembler<'a> {
68    fn stgi(&mut self) {
69        self.emit(STGI, &NOREG, &NOREG, &NOREG, &NOREG);
70    }
71}
72
73
74impl<'a> Assembler<'a> {
75    /// `CLGI`.
76    ///
77    /// Supported operand variants:
78    ///
79    /// ```text
80    /// +---+----------+
81    /// | # | Operands |
82    /// +---+----------+
83    /// | 1 | (none)   |
84    /// +---+----------+
85    /// ```
86    #[inline]
87    pub fn clgi(&mut self)
88    where Assembler<'a>: ClgiEmitter {
89        <Self as ClgiEmitter>::clgi(self);
90    }
91    /// `SKINIT`.
92    ///
93    /// Supported operand variants:
94    ///
95    /// ```text
96    /// +---+----------+
97    /// | # | Operands |
98    /// +---+----------+
99    /// | 1 | (none)   |
100    /// +---+----------+
101    /// ```
102    #[inline]
103    pub fn skinit(&mut self)
104    where Assembler<'a>: SkinitEmitter {
105        <Self as SkinitEmitter>::skinit(self);
106    }
107    /// `STGI`.
108    ///
109    /// Supported operand variants:
110    ///
111    /// ```text
112    /// +---+----------+
113    /// | # | Operands |
114    /// +---+----------+
115    /// | 1 | (none)   |
116    /// +---+----------+
117    /// ```
118    #[inline]
119    pub fn stgi(&mut self)
120    where Assembler<'a>: StgiEmitter {
121        <Self as StgiEmitter>::stgi(self);
122    }
123}