Named block arguments

Hi, I’m looking to achieve what the FIRRTL and HW dialects currently do: have the function arguments use a given port name, rather than arg0, arg1, .... For example, the firrtl.module below uses %a, %b instead of %arg0, %arg1.

I’ve used explicit naming for the function signature. However, when I try to do something similar and round-trip it, the region’s single block arguments are arg0, arg1, .... This means trying to refer to an explicit name within the region, such as %a above, doesn’t work.

calyx.component @c (%in : i1) -> () { 
  ^bb0( %arg0 : i1):
  //      ^ I want this to be %in

// Resulting error when trying to use `%in`
// calyx.some_op %arg0 : i1
check:37'0     ~~~~~~~~~~~~
check:37'1      ?  possible intended match

Is there some way to ensure that the block arguments take on the same names as the function’s arguments?

You can print custom SSA names by implementing the OpAsmDialectInterface. See getAsmBlockArgumentNames in the FIRRTL implementation.


Thank you! This is what I was looking for.