Stream: cranelift

Topic: ✔ ISLE pattern synonyms


view this post on Zulip kmeakin (Mar 21 2023 at 00:21):

Can you define pattern synonyms in ISLE?
eg being able to use (ugt x y) as shorthand for (icmp (fits_in_64 (ty_int ty)) (IntCC.UnsignedGreaterThan) x y)

view this post on Zulip Jamey Sharp (Mar 21 2023 at 00:29):

Yes! We call them "internal extractors," because… well, there's a reason but it doesn't matter. Look for (extractor …) for the actual pattern synonyms, and for each one you'll also find an associated decl.

view this post on Zulip fitzgen (he/him) (Mar 21 2023 at 15:46):

yes, you can define any term you want and add extractors (for matching in the LHS of rules) and constructors (for making things in the RHS of rules) for the term. see the language reference for details: https://github.com/bytecodealliance/wasmtime/blob/861220c433e70599ce51fb1c041c03fa9c7766ae/cranelift/isle/docs/language-reference.md#constructors-and-extractors

for example, there is nothing special/built-in about the existing icmp term as far as ISLE the language goes, it is just automatically generated by the meta crate: https://github.com/bytecodealliance/wasmtime/blob/861220c433e70599ce51fb1c041c03fa9c7766ae/cranelift/codegen/meta/src/gen_inst.rs#L1412

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.
A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

view this post on Zulip fitzgen (he/him) (Mar 21 2023 at 15:47):

and for the record, I think having (ugt x y) et al helpers would be great! the term declaration and extractor definition would go in the common prelude, and the constructors would go in the mid-end specific prelude (since the backend lowerings wouldn't ever construct new clif)

view this post on Zulip Notification Bot (Mar 21 2023 at 20:45):

kmeakin has marked this topic as resolved.


Last updated: Dec 23 2024 at 12:05 UTC