Skip to content

Commit

Permalink
aarch64: ineg spec (bytecodealliance#124)
Browse files Browse the repository at this point in the history
Specify and verify `ineg` on AArch64.

Updates avanhatt#34
  • Loading branch information
mmcloughlin authored Oct 9, 2024
1 parent 230d96c commit a9bb0eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions cranelift/codegen/src/inst_specs.isle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@

;;;; Common Term Forms ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(form
bv_unary_8_to_64
((args (bv 8)) (ret (bv 8)))
((args (bv 16)) (ret (bv 16)))
((args (bv 32)) (ret (bv 32)))
((args (bv 64)) (ret (bv 64)))
)

(form
bv_ternary_8_to_64
((args (bv 8) (bv 8) (bv 8)) (ret (bv 8)))
Expand Down Expand Up @@ -68,6 +76,10 @@
((args (bv 64) (bv 64)) (ret (bv 64)))
)

(spec (ineg x)
(provide (= result (bvneg x))))
(instantiate ineg bv_unary_8_to_64)

(spec (imul x y)
(provide (= result (bvmul x y))))
(instantiate imul
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/aarch64/lower.isle
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@
;;;; Rules for `ineg` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; `i64` and smaller.
(rule 1 (lower (has_type (fits_in_64 ty) (ineg x)))
(rule ineg_base_case 1 (lower (has_type (fits_in_64 ty) (ineg x)))
(sub ty (zero_reg) x))

;; `i128`
Expand Down

0 comments on commit a9bb0eb

Please sign in to comment.