From eba6b765111cd217e2b5bf9cdca3030daff2c8af Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Tue, 13 Dec 2022 15:08:40 -0800 Subject: [PATCH] aarch64: Use unsigned constants where appropriate (#5423) The Rust type expected in these locations is unsigned, but these constants are negative. ISLE currently emits a Rust expression with extra type conversions in order to make this work as intended. However, across all backends, only these three aarch64 constants use this particular "feature" of ISLE, and I want to make it go away. --- cranelift/codegen/src/isa/aarch64/inst.isle | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cranelift/codegen/src/isa/aarch64/inst.isle b/cranelift/codegen/src/isa/aarch64/inst.isle index 8272067c57..3dfbeab7ce 100644 --- a/cranelift/codegen/src/isa/aarch64/inst.isle +++ b/cranelift/codegen/src/isa/aarch64/inst.isle @@ -3265,14 +3265,14 @@ (fpu_to_int op src)) (rule (fpu_to_int_cvt_sat op src $false (fits_in_16 out_ty)) (let ((result Reg (fpu_to_int op src)) - (max Reg (imm out_ty (ImmExtend.Zero) -1))) + (max Reg (imm out_ty (ImmExtend.Zero) (ty_mask out_ty)))) (with_flags_reg (cmp (OperandSize.Size32) result max) (csel (Cond.Hi) max result)))) (rule (fpu_to_int_cvt_sat op src $true (fits_in_16 out_ty)) (let ((result Reg (fpu_to_int op src)) - (max Reg (imm $I32 (ImmExtend.Sign) (signed_max out_ty))) - (min Reg (imm $I32 (ImmExtend.Sign) (signed_min out_ty))) + (max Reg (signed_max out_ty)) + (min Reg (signed_min out_ty)) (result Reg (with_flags_reg (cmp (operand_size out_ty) result max) (csel (Cond.Gt) max result))) @@ -3281,13 +3281,13 @@ (csel (Cond.Lt) min result)))) result)) -(decl signed_min (Type) u64) -(rule (signed_min $I8) -128) -(rule (signed_min $I16) -32768) +(decl signed_min (Type) Reg) +(rule (signed_min $I8) (imm $I8 (ImmExtend.Sign) 0x80)) +(rule (signed_min $I16) (imm $I16 (ImmExtend.Sign) 0x8000)) -(decl signed_max (Type) u64) -(rule (signed_max $I8) 127) -(rule (signed_max $I16) 32767) +(decl signed_max (Type) Reg) +(rule (signed_max $I8) (imm $I8 (ImmExtend.Sign) 0x7F)) +(rule (signed_max $I16) (imm $I16 (ImmExtend.Sign) 0x7FFF)) (decl fpu_to_int (FpuToIntOp Reg) Reg) (rule (fpu_to_int op src)