Skip to content

ISLE: debugging feature to emit logging in the generated code #11971

@fitzgen

Description

@fitzgen

To assist with debugging ISLE (e.g. you expect a rule to match but it doesn't), the isle crate should have an option to emit log macro invocations in the generated code.

I'm imagining we would emit the following logs, or something similar:

  • log::debug!(...) at the start of a constructor, logging which constructor we are executing. (Ideally, we would also log the arguments given, but that would require that we know that the arguments implement Debug, which I don't think we do? Failing that, if we wanted to get real fancy, we could do the thing where you approximate specialization by making impls for &T, &&T, etc...)

  • Each predicate we test as part of a term's rules' LHSes would have an associated log::trace!(...) that details which predicate is executing and then whether it matched or not.

  • In each rule's RHS we would log::debug!(...) which rule we end up executing.

  • Possibly, if none of a term's rules match, we log that fact as well. Not sure if we have erased this information by the time we emit code or not though, so it might not be possible.

To make this even more readable when debugging, it would be nice if we kept a thread-local or something containing the ISLE stack depth and indented our logs by that amount, so that you could see which constructor invocations were nested within others.

Anyways, once we had this knob in the ISLE compiler, we should add a cargo feature to cranelift-codegen which enables/disables it. (Or maybe we just reuse the existing trace-log feature?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    cranelift:E-compiler-easyBeginner–Intermediate compiler issues.good first issueIssues that are good for new contributors to tackle!isleRelated to the ISLE domain-specific language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions