From 23c67fd1e89109233528edb2e7147058e5b88a3f Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 23 Nov 2022 13:03:56 +0100 Subject: [PATCH 1/2] Added the actual LZCNT / TZCNT implementation, somehow missing from #3302 --- lib/compiler-singlepass/src/emitter_x64.rs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/compiler-singlepass/src/emitter_x64.rs b/lib/compiler-singlepass/src/emitter_x64.rs index 0b45f562b8b..e25f48c8775 100644 --- a/lib/compiler-singlepass/src/emitter_x64.rs +++ b/lib/compiler-singlepass/src/emitter_x64.rs @@ -946,6 +946,43 @@ impl EmitterX64 for AssemblerX64 { Ok(()) } + fn arch_has_xzcnt(&self) -> bool { + match &self.target { + Some(target) => { + target.cpu_features().contains(CpuFeature::LZCNT) + && target.cpu_features().contains(CpuFeature::BMI1) + } + None => false, + } + } + + fn arch_emit_lzcnt( + &mut self, + sz: Size, + src: Location, + dst: Location, + ) -> Result<(), CompileError> { + binop_gpr_gpr!(lzcnt, self, sz, src, dst, { + binop_mem_gpr!(lzcnt, self, sz, src, dst, { + codegen_error!("singlepass cannot emit lzcnt") + }) + }); + Ok(()) + } + fn arch_emit_tzcnt( + &mut self, + sz: Size, + src: Location, + dst: Location, + ) -> Result<(), CompileError> { + binop_gpr_gpr!(tzcnt, self, sz, src, dst, { + binop_mem_gpr!(tzcnt, self, sz, src, dst, { + codegen_error!("singlepass cannot emit tzcnt") + }) + }); + Ok(()) + } + fn emit_u64(&mut self, x: u64) -> Result<(), CompileError> { self.push_u64(x); Ok(()) From 0ec859d437656ad4167630286b329f0ede0e3c9b Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 24 Nov 2022 08:53:00 +0100 Subject: [PATCH 2/2] Added missing new line --- lib/compiler-singlepass/src/emitter_x64.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/compiler-singlepass/src/emitter_x64.rs b/lib/compiler-singlepass/src/emitter_x64.rs index e25f48c8775..2034a0669d3 100644 --- a/lib/compiler-singlepass/src/emitter_x64.rs +++ b/lib/compiler-singlepass/src/emitter_x64.rs @@ -969,6 +969,7 @@ impl EmitterX64 for AssemblerX64 { }); Ok(()) } + fn arch_emit_tzcnt( &mut self, sz: Size,