-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
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 implementDebug, 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?)