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)
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
.
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
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)
kmeakin has marked this topic as resolved.
Last updated: Dec 23 2024 at 12:05 UTC