Skip to content

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

Open
@maerhart

Description

@maerhart
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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RTGInvolving the `rtg` dialectbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions