Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform CircuitForms are Ambiguous #1165

Closed
seldridge opened this issue Aug 23, 2019 · 1 comment
Closed

Transform CircuitForms are Ambiguous #1165

seldridge opened this issue Aug 23, 2019 · 1 comment

Comments

@seldridge
Copy link
Member

tl;dr: when you specify LowForm or HighForm as your inputForm/outputForm in a custom transform, you may either be inadvertently writing a transform that relies on ResolveAndCheck or your transform may not be portable between -X low and -X verilog.

This weirdness is preserved in #1123.

High Form Ambiguity

For a custom transform that outputs HighForm, the re-lowering (or lack thereof) is a function of the inputForm due to getLoweringTransforms logic.

  • inputForm == HighForm will result in no re-lowering
  • inputForm < HighForm will result in IrToWorkingIr, ResolveAndCheck, and Dedup

This effectively defines HighForm as either (up through) Dedup or ChirrtlToHighFirrtl.

Consequently, a user writing a {Low, Mid} -> High transform may be relying on this re-lowering, e.g., they emit unresolved types.

Going forward, the dependency API port redefines HighForm to mean Deduped, but preserves backwards compatibility for transforms that output HighForm without overriding the dependency API methods.

Low Form Ambiguity

By the current definition of mergeTransforms a custom transform will run after the last transform which has an outputForm equal to its inputForm. However, the last transform which has outputForm == LowForm is a function of the chosen compiler/emitter. Concretely a LowForm transform, for the chosen compiler, has the following behavior:

  • -X low: transform runs after MiddleFirtlToLowFirrtl
  • -X mverilog: runs after MinimumLowFirrtlOptimizations
  • -X verilog: runs after LowFirrtlOptimizations

This has implications in that a user can write a LowForm transform that works with -X verilog, but fails for -X low. (Consider a transform that will match error on IsInvalid. This transform will error for -X low, but work for -X verilog because RemoveValidIf is an optimization transform. h/t @jackkoenig)

This behavior is preserved in how dependency API dependencies are derived from inputForm/outputForm for users that do not override dependency API methods.

Metadata

Type of issue: bug report

If the current behavior is a bug, please provide the steps to reproduce the problem:

  • What is the current behavior?

A LowForm transform will run in different places for different compilers.

  • What is the expected behavior?

A LowForm should run in the same location, regardless of compiler.

  • Please tell us about your environment:
    (examples)

master

What is the use case for changing the behavior?

This can cause subtle bugs where LowForm transforms don't work on LowForm.

Impact: unknown

Development Phase: request

@seldridge
Copy link
Member Author

Closed via #1534. This behavior is capable of being expressed if a user wants it in the new Dependency API. Alternatively, this behavior is the default if a user does not migrate to the new Dependency API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant