Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 28 additions & 46 deletions cranelift/codegen/src/isa/aarch64/inst.isle
Original file line number Diff line number Diff line change
Expand Up @@ -4528,23 +4528,34 @@
(decl lower_icmp_into_flags (IntCC Value Value Type) FlagsAndCC)

(spec (lower_icmp_const c x y in_ty)
(provide
(= result
(bvor (bvshl (zero_ext 12
(extract 67 64
(if (and (bvuge c #x02) (bvule c #x05))
(if (<= in_ty 32)
(subs 32 (sign_ext 64 x) y)
(subs 64 (sign_ext 64 x) y))
(if (<= in_ty 32)
(subs 32 (zero_ext 64 x) y)
(subs 64 (zero_ext 64 x) y)))))
#x008)
(zero_ext 12 c))))
(require
(bvule c #x09)
(or (= in_ty 32) (= in_ty 64))
(= in_ty (widthof x))))
(provide
(= result
(concat (extract 67 64
(if (or (= c (IntCC.SignedGreaterThanOrEqual))
(= c (IntCC.SignedGreaterThan))
(= c (IntCC.SignedLessThanOrEqual))
(= c (IntCC.SignedLessThan)))
(if (<= in_ty 32)
(subs 32 (sign_ext 64 x) y)
(subs 64 (sign_ext 64 x) y))
(if (<= in_ty 32)
(subs 32 (zero_ext 64 x) y)
(subs 64 (zero_ext 64 x) y))))
c)))
(require
(or
(= c (IntCC.Equal))
(= c (IntCC.NotEqual))
(= c (IntCC.UnsignedGreaterThanOrEqual))
(= c (IntCC.UnsignedGreaterThan))
(= c (IntCC.UnsignedLessThanOrEqual))
(= c (IntCC.UnsignedLessThan))
(= c (IntCC.SignedGreaterThanOrEqual))
(= c (IntCC.SignedGreaterThan))
(= c (IntCC.SignedLessThanOrEqual))
(= c (IntCC.SignedLessThan)))
(or (= in_ty 32) (= in_ty 64))
(= in_ty (widthof x))))
(instantiate lower_icmp_const
((args (bv 8) (bv 8) (bv 64) Int) (ret (bv 12)) (canon (bv 8)))
((args (bv 8) (bv 16) (bv 64) Int) (ret (bv 12)) (canon (bv 16)))
Expand Down Expand Up @@ -4603,35 +4614,6 @@
(if (ty_int_ref_scalar_64 ty))
(flags_and_cc (cmp (operand_size ty) rn rm) cond))

(spec (lower_icmp_const c x y in_ty)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avanhatt Which of the specs should be kept?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On first glance, they look equivalent, but the one with the specific enum names (the one deleted here) is a little cleaner to read IMO. Let's keep this one instead.

(provide
(= result
(concat (extract 67 64
(if (or (= c (IntCC.SignedGreaterThanOrEqual))
(= c (IntCC.SignedGreaterThan))
(= c (IntCC.SignedLessThanOrEqual))
(= c (IntCC.SignedLessThan)))
(if (<= in_ty 32)
(subs 32 (sign_ext 64 x) y)
(subs 64 (sign_ext 64 x) y))
(if (<= in_ty 32)
(subs 32 (zero_ext 64 x) y)
(subs 64 (zero_ext 64 x) y))))
c)))
(require
(or
(= c (IntCC.Equal))
(= c (IntCC.NotEqual))
(= c (IntCC.UnsignedGreaterThanOrEqual))
(= c (IntCC.UnsignedGreaterThan))
(= c (IntCC.UnsignedLessThanOrEqual))
(= c (IntCC.UnsignedLessThan))
(= c (IntCC.SignedGreaterThanOrEqual))
(= c (IntCC.SignedGreaterThan))
(= c (IntCC.SignedLessThanOrEqual))
(= c (IntCC.SignedLessThan)))
(or (= in_ty 32) (= in_ty 64))
(= in_ty (widthof x))))
;; We get better encodings when testing against an immediate that's even instead
;; of odd, so rewrite comparisons to use even immediates:
;;
Expand Down
6 changes: 5 additions & 1 deletion cranelift/isle/veri/veri_engine/src/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ pub fn parse_annotations(defs: &Defs, termenv: &TermEnv, typeenv: &TypeEnv) -> A
match def {
&ast::Def::Spec(ref spec) => {
let term_id = termenv.get_term_by_name(typeenv, &spec.term).unwrap();
// dbg!(&termname);
assert!(
!annotation_map.contains_key(&term_id),
"duplicate spec for {}",
spec.term.0
);
let sig = TermSignature {
args: spec
.args
Expand Down