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