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

[HGLDD] Emit HW struct and array types #6816

Open
fabianschuiki opened this issue Mar 12, 2024 · 5 comments
Open

[HGLDD] Emit HW struct and array types #6816

fabianschuiki opened this issue Mar 12, 2024 · 5 comments
Labels
Debug good first issue Good for newcomers

Comments

@fabianschuiki
Copy link
Contributor

The EmitHGLDD target can emit the necessary HGLDD JSON bits to encode arrays and structs when it sees dbg.array and dbg.struct operations, but it ignores dbg.variable ops with !hw.array and !hw.struct types. Supporting these native HW types and creating the corresponding JSON structures should be fairly straightforward.

@Nerotos
Copy link

Nerotos commented May 6, 2024

Hello, I would be interested in giving this a shot.

@fabianschuiki
Copy link
Contributor Author

That sounds great! You'll probably want to look at the part of HGLDD emission that handles the StructOp from the debug dialect, and do more or less the same thing for VariableOps that have an !hw.struct type.

@Nerotos
Copy link

Nerotos commented May 22, 2024

Finally had a chance to look into it. Just make sure I understand it correctly, I would have to make a check like this here:

  if (auto variableOp = dyn_cast<debug::VariableOp>(op)){
    // Only tracked structs are considered here
    if (isa<hw::StructType>(variableOp.getValue().getType())){
      auto value= dyn_cast<hw::StructType>(variableOp.getValue());
      auto name = variableOp.getName();
    }
  }

Or am I misunderstanding the VariableOp here?

@Nerotos
Copy link

Nerotos commented May 26, 2024

@fabianschuiki Could you give me a hint how I can access the underlying hw.struct ? Using op.getValue() just returns a general mlir::Value and I can't figure out how to use that to access the fields.

@fabianschuiki
Copy link
Contributor Author

You can use dedicated operations like hw.struct_extract to take that general Value and access a field of the struct. By looking at the struct type, you can get a list of all fields that you might want to extract and look at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Debug good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants