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