8000 [FIRRTL] DropConst pass by trilorez · Pull Request #5152 · llvm/circt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[FIRRTL] DropConst pass #5152

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

Merged
merged 11 commits into from
May 25, 2023
Merged

[FIRRTL] DropConst pass #5152

merged 11 commits into from
May 25, 2023

Conversation

trilorez
Copy link
Contributor
@trilorez trilorez commented May 8, 2023

Builds on #5151.

Added DropConst pass that checks const usage in when blocks, then drops all
const modifiers from types.

@trilorez trilorez requested review from darthscsi and dtzSiFive May 8, 2023 20:55
@trilorez trilorez force-pushed the dev/trilorez/const-cast branch 2 times, most recently from 4941449 to 54c0555 Compare May 9, 2023 02:22
@trilorez trilorez force-pushed the dev/trilorez/drop-const branch 2 times, most recently from 8ec32fd to 07766f4 Compare May 15, 2023 17:47
@trilorez trilorez force-pushed the dev/trilorez/const-cast branch from 084edfe to 029a445 Compare May 15, 2023 17:48
@trilorez trilorez force-pushed the dev/trilorez/drop-const branch from 07766f4 to 2b34d86 Compare May 16, 2023 01:13
@trilorez trilorez requested a review from youngar May 16, 2023 20:29
Copy link
Member
@youngar youngar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move the when op checking to a verifier, then you could probably re-write this very generically:

op->walk([](op){
  if (op.isa<ConstCast>())
    .... 
  for (region : op.getRegion)
    for (block : region.getBlocks)
      for (blarg : block.getArguments)
        blarg.setType(updateType(blarg.getType));
  for (result : op.getResult())
    result.setType(updateType(result.getType());

We need to start thinking about how enumeration types and const are going to work.

@trilorez trilorez force-pushed the dev/trilorez/const-cast branch 2 times, most recently from 313216c to 3e54136 Compare May 17, 2023 18:53
Base automatically changed from dev/trilorez/const-cast to main May 17, 2023 19:41
@trilorez trilorez force-pushed the dev/trilorez/drop-const branch 2 times, most recently from 65ec10d to 9649220 10000 Compare May 17, 2023 22:20
@trilorez trilorez marked this pull request as ready for review May 17, 2023 22:23
@trilorez trilorez force-pushed the dev/trilorez/drop-const branch from a0839b7 to 9649220 Compare May 17, 2023 22:28
@trilorez trilorez force-pushed the dev/trilorez/drop-const branch from b9304aa to 92cdb80 Compare May 23, 2023 15:45
Copy link
Member
@youngar youngar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't review this as closely as before. I think you can merge this, or if you want to increase your commit count, split it up into 3 commits for DropConst pass, const drop type changes + SubAccess::inferReturnType, connect verifier.

Do we properly handle the error detection in this case?

module Foo:
  input i : UInt<4>
  output c : const UInt<8>[16]
  ; It is an error to use a non-const index to drive a value to a const
  c[i] <= UInt<8>(10)

Would be nice if we didn't walk the subaccess chain twice in the connect verifier, but we can iterate on it. We have also talked about moving the flow verification on to the module, as it might be faster to do it as a dataflow pass. We could do something similar with the const correctness verification.

@trilorez
Copy link
Contributor Author

Do we properly handle the error detection in this case?

module Foo:
  input i : UInt<4>
  output c : const UInt<8>[16]
  ; It is an error to use a non-const index to drive a value to a const
  c[i] <= UInt<8>(10)

I believe these tests cover the subaccess cases:

// Test that subaccess of a const vector is checked as if the field is const.

// Test that subaccess of a flipped const vector is checked as if the field is const.

@trilorez
Copy link
Contributor Author

Updated to disallow any assignment to a subaccess that drops const

@trilorez trilorez merged commit 31770e1 into main May 25, 2023
@trilorez trilorez deleted the dev/trilorez/drop-const branch May 25, 2023 18:51
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

Successfully merging this pull request may close these issues.

2 participants
0