Skip to main content

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