Skip to main content

asmkit/x86/features/
SSE4A.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/// `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(SSE_EXTRQRI, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
29    }
30}
31
32impl<'a> SseExtrqEmitter<Xmm, Xmm> for Assembler<'a> {
33    fn sse_extrq(&mut self, op0: Xmm, op1: Xmm) {
34        self.emit(SSE_EXTRQRR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
35    }
36}
37
38/// `SSE_INSERTQ`.
39///
40/// Supported operand variants:
41///
42/// ```text
43/// +---+----------+
44/// | # | Operands |
45/// +---+----------+
46/// | 1 | Xmm, Xmm |
47/// +---+----------+
48/// ```
49pub trait SseInsertqEmitter_2<A, B> {
50    fn sse_insertq_2(&mut self, op0: A, op1: B);
51}
52
53impl<'a> SseInsertqEmitter_2<Xmm, Xmm> for Assembler<'a> {
54    fn sse_insertq_2(&mut self, op0: Xmm, op1: Xmm) {
55        self.emit(SSE_INSERTQRR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
56    }
57}
58
59/// `SSE_INSERTQ`.
60///
61/// Supported operand variants:
62///
63/// ```text
64/// +---+---------------+
65/// | # | Operands      |
66/// +---+---------------+
67/// | 1 | Xmm, Xmm, Imm |
68/// +---+---------------+
69/// ```
70pub trait SseInsertqEmitter_3<A, B, C> {
71    fn sse_insertq_3(&mut self, op0: A, op1: B, op2: C);
72}
73
74impl<'a> SseInsertqEmitter_3<Xmm, Xmm, Imm> for Assembler<'a> {
75    fn sse_insertq_3(&mut self, op0: Xmm, op1: Xmm, op2: Imm) {
76        self.emit(SSE_INSERTQRRI, op0.as_operand(), op1.as_operand(), op2.as_operand(), &NOREG);
77    }
78}
79
80
81impl<'a> Assembler<'a> {
82    /// `SSE_EXTRQ`.
83    ///
84    /// Supported operand variants:
85    ///
86    /// ```text
87    /// +---+----------+
88    /// | # | Operands |
89    /// +---+----------+
90    /// | 1 | Xmm, Imm |
91    /// | 2 | Xmm, Xmm |
92    /// +---+----------+
93    /// ```
94    #[inline]
95    pub fn sse_extrq<A, B>(&mut self, op0: A, op1: B)
96    where Assembler<'a>: SseExtrqEmitter<A, B> {
97        <Self as SseExtrqEmitter<A, B>>::sse_extrq(self, op0, op1);
98    }
99    /// `SSE_INSERTQ`.
100    ///
101    /// Supported operand variants:
102    ///
103    /// ```text
104    /// +---+----------+
105    /// | # | Operands |
106    /// +---+----------+
107    /// | 1 | Xmm, Xmm |
108    /// +---+----------+
109    /// ```
110    #[inline]
111    pub fn sse_insertq_2<A, B>(&mut self, op0: A, op1: B)
112    where Assembler<'a>: SseInsertqEmitter_2<A, B> {
113        <Self as SseInsertqEmitter_2<A, B>>::sse_insertq_2(self, op0, op1);
114    }
115    /// `SSE_INSERTQ`.
116    ///
117    /// Supported operand variants:
118    ///
119    /// ```text
120    /// +---+---------------+
121    /// | # | Operands      |
122    /// +---+---------------+
123    /// | 1 | Xmm, Xmm, Imm |
124    /// +---+---------------+
125    /// ```
126    #[inline]
127    pub fn sse_insertq_3<A, B, C>(&mut self, op0: A, op1: B, op2: C)
128    where Assembler<'a>: SseInsertqEmitter_3<A, B, C> {
129        <Self as SseInsertqEmitter_3<A, B, C>>::sse_insertq_3(self, op0, op1, op2);
130    }
131}