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

[RTG][Elaboration] Each virtual register should only be materialized once and every user should use it #8193

Open
maerhart opened this issue Feb 5, 2025 · 0 comments
Labels
bug Something isn't working RTG Involving the `rtg` dialect

Comments

@maerhart
Copy link
Member

maerhart commented Feb 5, 2025

rtg.sequence @virtRegSeq(%reg: !rtgtest.ireg) {
  %imm = rtgtest.immediate #rtgtest.imm12<0>
  rtgtest.rv32i.jalr %reg, %reg, %imm
}

rtg.test @virtualRegisters() {
  %r0 = rtg.virtual_reg [#rtgtest.a0, #rtgtest.a1]
  %imm = rtgtest.immediate #rtgtest.imm12<0>
  rtgtest.rv32i.jalr %r0, %r0, %imm
  %s0 = rtg.get_sequence @virtRegSeq : !rtg.sequence<!rtgtest.ireg>
  %s1 = rtg.substitute_sequence %s0(%r0) : !rtg.sequence<!rtgtest.ireg>
  %s2 = rtg.randomize_sequence %s1
  rtg.embed_sequence %s2

Elaborates to

  rtg.test @virtualRegisters() {
    %0 = rtg.virtual_reg [#rtgtest.a0 : !rtgtest.ireg, #rtgtest.a1 : !rtgtest.ireg]
    %2 = rtgtest.immediate #rtgtest.imm12<0> : !rtgtest.imm12
    rtgtest.rv32i.jalr %0, %0, %2
    rtgtest.rv32i.jalr %0, %0, %2
    %3 = rtg.virtual_reg [#rtgtest.a0 : !rtgtest.ireg, #rtgtest.a1 : !rtgtest.ireg]
    %4 = rtgtest.immediate #rtgtest.imm12<0> : !rtgtest.imm12
    rtgtest.rv32i.jalr %3, %3, %4
}

The second register shouldn't be materialized, but instead the first one should be reused.

@maerhart maerhart added bug Something isn't working RTG Involving the `rtg` dialect labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working RTG Involving the `rtg` dialect
Projects
None yet
Development

No branches or pull requests

1 participant