From 08beb99baa5ea339110ef87cffbeae106238456d Mon Sep 17 00:00:00 2001 From: losfair Date: Sun, 17 Nov 2019 05:15:10 +0800 Subject: [PATCH] Fix popcnt. --- lib/singlepass-backend/src/translator_aarch64.rs | 15 +++++++++++---- src/bin/wasmer.rs | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/singlepass-backend/src/translator_aarch64.rs b/lib/singlepass-backend/src/translator_aarch64.rs index 2eedb2072..3a4d3ded1 100644 --- a/lib/singlepass-backend/src/translator_aarch64.rs +++ b/lib/singlepass-backend/src/translator_aarch64.rs @@ -1248,9 +1248,12 @@ impl Emitter for Assembler { self ; mov v_tmp1.S[0], w_tmp1 ; cnt v_tmp1.B16, v_tmp1.B16 - ; mov W(map_gpr(dst).x()), v_tmp1.S[0] - ; add W(map_gpr(dst).x()), W(map_gpr(dst).x()), W(map_gpr(dst).x()), lsr 16 - ; and W(map_gpr(dst).x()), W(map_gpr(dst).x()), 31 + ; mov w_tmp1, v_tmp1.S[0] + ; mov W(map_gpr(dst).x()), w_tmp1 + ; add W(map_gpr(dst).x()), W(map_gpr(dst).x()), w_tmp1, lsr 8 + ; add W(map_gpr(dst).x()), W(map_gpr(dst).x()), w_tmp1, lsr 16 + ; add W(map_gpr(dst).x()), W(map_gpr(dst).x()), w_tmp1, lsr 24 + ; and W(map_gpr(dst).x()), W(map_gpr(dst).x()), 255 ); } _ => unreachable!(), @@ -1283,10 +1286,14 @@ impl Emitter for Assembler { ; cnt v_tmp1.B16, v_tmp1.B16 ; mov x_tmp1, v_tmp1.D[0] ; mov X(map_gpr(dst).x()), x_tmp1 + ; add X(map_gpr(dst).x()), X(map_gpr(dst).x()), x_tmp1, lsr 8 ; add X(map_gpr(dst).x()), X(map_gpr(dst).x()), x_tmp1, lsr 16 + ; add X(map_gpr(dst).x()), X(map_gpr(dst).x()), x_tmp1, lsr 24 ; add X(map_gpr(dst).x()), X(map_gpr(dst).x()), x_tmp1, lsr 32 + ; add X(map_gpr(dst).x()), X(map_gpr(dst).x()), x_tmp1, lsr 40 ; add X(map_gpr(dst).x()), X(map_gpr(dst).x()), x_tmp1, lsr 48 - ; and X(map_gpr(dst).x()), X(map_gpr(dst).x()), 63 + ; add X(map_gpr(dst).x()), X(map_gpr(dst).x()), x_tmp1, lsr 56 + ; and X(map_gpr(dst).x()), X(map_gpr(dst).x()), 255 ); } _ => unreachable!(), diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 340669f68..5c308f42d 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -723,7 +723,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { Some(fun) => fun, _ => "main", }; - instance + let result = instance .dyn_func(&invoke_fn) .map_err(|e| format!("{:?}", e))? .call(&args)