asmkit/x86/features/
LZCNT.rs1use crate::x86::assembler::*;
2use crate::x86::operands::*;
3use super::super::opcodes::*;
4use crate::core::emitter::*;
5use crate::core::operand::*;
6
7const NOREG: Operand = Operand::new();
9
10pub trait LzcntEmitter<A, B> {
31 fn lzcnt(&mut self, op0: A, op1: B);
32}
33
34impl<'a> LzcntEmitter<Gpw, Gpw> for Assembler<'a> {
35 fn lzcnt(&mut self, op0: Gpw, op1: Gpw) {
36 self.emit(LZCNT16RR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
37 }
38}
39
40impl<'a> LzcntEmitter<Gpw, Mem> for Assembler<'a> {
41 fn lzcnt(&mut self, op0: Gpw, op1: Mem) {
42 self.emit(LZCNT16RM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
43 }
44}
45
46impl<'a> LzcntEmitter<Gpd, Gpd> for Assembler<'a> {
47 fn lzcnt(&mut self, op0: Gpd, op1: Gpd) {
48 self.emit(LZCNT32RR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
49 }
50}
51
52impl<'a> LzcntEmitter<Gpd, Mem> for Assembler<'a> {
53 fn lzcnt(&mut self, op0: Gpd, op1: Mem) {
54 self.emit(LZCNT32RM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
55 }
56}
57
58impl<'a> LzcntEmitter<Gpq, Gpq> for Assembler<'a> {
59 fn lzcnt(&mut self, op0: Gpq, op1: Gpq) {
60 self.emit(LZCNT64RR, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
61 }
62}
63
64impl<'a> LzcntEmitter<Gpq, Mem> for Assembler<'a> {
65 fn lzcnt(&mut self, op0: Gpq, op1: Mem) {
66 self.emit(LZCNT64RM, op0.as_operand(), op1.as_operand(), &NOREG, &NOREG);
67 }
68}
69
70
71impl<'a> Assembler<'a> {
72 #[inline]
93 pub fn lzcnt<A, B>(&mut self, op0: A, op1: B)
94 where Assembler<'a>: LzcntEmitter<A, B> {
95 <Self as LzcntEmitter<A, B>>::lzcnt(self, op0, op1);
96 }
97}