[Mlir-commits] [mlir] Fix textual/bytecode roundtrip for SPIRV_LinkageAttributesAttr (PR #82951)

Matteo Franciolini llvmlistbot at llvm.org
Sun Feb 25 20:54:12 PST 2024


mfrancio wrote:

pretty much any attribute in SPIRVAttributes.td? let's take one:
```
def SPIRV_CooperativeMatrixPropertiesKHRAttr :
    SPIRV_Attr<"CooperativeMatrixPropertiesKHR", "coop_matrix_props_khr"> {
  let parameters = (ins
    "uint32_t":$m_size,
    "uint32_t":$n_size,
    "uint32_t":$k_size,
    "mlir::Type":$a_type,
    "mlir::Type":$b_type,
    "mlir::Type":$c_type,
    "mlir::Type":$result_type,
    "bool":$acc_sat,
    "mlir::spirv::ScopeAttr":$scope
  );
  let assemblyFormat = "`<` struct(params) `>`";
}
```
Unless i am missing something, roundtripping such an attribute works just because the overloaded `<<` is coincidentally equal to how the parser executes. For strings, this was not the case (`<<` does not add the string token that the parser would look for).

This seemed like a gap in how SPIRV attributes interact with table-generated print/parse methods.

https://github.com/llvm/llvm-project/pull/82951


More information about the Mlir-commits mailing list