What could be the reason for a missing mnemonic in a type in some situations?

What could be the reason for a missing mnemonic in a type in some situations only?

I get the following where %14 is of type !fir.heap<!fir.char<1,?>>

fir.freemem %14 : <!fir.char<1,?>>

I see that the !fir.heap mnemonic gets printed correctly in other situations. It is only with fir.freemem operation that this happens. fir.freemem has an assembly format as follows, (llvm-project/FIROps.td at 1458458b558d3cbce5a8b1845ed43bbe141db2fd · llvm/llvm-project · GitHub)

  let assemblyFormat = "$heapref attr-dict `:` type($heapref)";

It seems that the places where a custom printer/parser is used for Ops, the heap type seems to print correctly.

The heap type printer is defined as follows, (llvm-project/FIRType.cpp at 1458458b558d3cbce5a8b1845ed43bbe141db2fd · llvm/llvm-project · GitHub)

void fir::HeapType::print(mlir::AsmPrinter &printer) const {
  printer << "<" << getEleTy() << '>';
}

The declarative assembly format elides mnemonics in some cases now, but using qualified(type($heapref)) instead should get the previous behaviour back: Operation Definition Specification (ODS) - MLIR

2 Likes

It happens because fir.freemem operand is defined to be of !fir.heap type, so it is unambiguous to elide it. If it does not happen on other operation it would be because they accept multiple different types.

1 Like

Thanks, @mehdi_amini @troggo, makes sense to elide it in this case.