asmkit/x86/features/SKINIT.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/// `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
73impl<'a> Assembler<'a> {
74 /// `CLGI`.
75 ///
76 /// Supported operand variants:
77 ///
78 /// ```text
79 /// +---+----------+
80 /// | # | Operands |
81 /// +---+----------+
82 /// | 1 | (none) |
83 /// +---+----------+
84 /// ```
85 #[inline]
86 pub fn clgi(&mut self)
87 where
88 Assembler<'a>: ClgiEmitter,
89 {
90 <Self as ClgiEmitter>::clgi(self);
91 }
92 /// `SKINIT`.
93 ///
94 /// Supported operand variants:
95 ///
96 /// ```text
97 /// +---+----------+
98 /// | # | Operands |
99 /// +---+----------+
100 /// | 1 | (none) |
101 /// +---+----------+
102 /// ```
103 #[inline]
104 pub fn skinit(&mut self)
105 where
106 Assembler<'a>: SkinitEmitter,
107 {
108 <Self as SkinitEmitter>::skinit(self);
109 }
110 /// `STGI`.
111 ///
112 /// Supported operand variants:
113 ///
114 /// ```text
115 /// +---+----------+
116 /// | # | Operands |
117 /// +---+----------+
118 /// | 1 | (none) |
119 /// +---+----------+
120 /// ```
121 #[inline]
122 pub fn stgi(&mut self)
123 where
124 Assembler<'a>: StgiEmitter,
125 {
126 <Self as StgiEmitter>::stgi(self);
127 }
128}