Skip to main content

asmkit/x86/features/
SEAM.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/// `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
94impl<'a> Assembler<'a> {
95    /// `SEAMCALL`.
96    ///
97    /// Supported operand variants:
98    ///
99    /// ```text
100    /// +---+----------+
101    /// | # | Operands |
102    /// +---+----------+
103    /// | 1 | (none)   |
104    /// +---+----------+
105    /// ```
106    #[inline]
107    pub fn seamcall(&mut self)
108    where
109        Assembler<'a>: SeamcallEmitter,
110    {
111        <Self as SeamcallEmitter>::seamcall(self);
112    }
113    /// `SEAMOPS`.
114    ///
115    /// Supported operand variants:
116    ///
117    /// ```text
118    /// +---+----------+
119    /// | # | Operands |
120    /// +---+----------+
121    /// | 1 | (none)   |
122    /// +---+----------+
123    /// ```
124    #[inline]
125    pub fn seamops(&mut self)
126    where
127        Assembler<'a>: SeamopsEmitter,
128    {
129        <Self as SeamopsEmitter>::seamops(self);
130    }
131    /// `SEAMRET`.
132    ///
133    /// Supported operand variants:
134    ///
135    /// ```text
136    /// +---+----------+
137    /// | # | Operands |
138    /// +---+----------+
139    /// | 1 | (none)   |
140    /// +---+----------+
141    /// ```
142    #[inline]
143    pub fn seamret(&mut self)
144    where
145        Assembler<'a>: SeamretEmitter,
146    {
147        <Self as SeamretEmitter>::seamret(self);
148    }
149    /// `TDCALL`.
150    ///
151    /// Supported operand variants:
152    ///
153    /// ```text
154    /// +---+----------+
155    /// | # | Operands |
156    /// +---+----------+
157    /// | 1 | (none)   |
158    /// +---+----------+
159    /// ```
160    #[inline]
161    pub fn tdcall(&mut self)
162    where
163        Assembler<'a>: TdcallEmitter,
164    {
165        <Self as TdcallEmitter>::tdcall(self);
166    }
167}