<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/85546>85546</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR][IRDL] Support for concrete attribute values in IRDL
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir:irdl
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mikeurbach
      </td>
    </tr>
</table>

<pre>
    I am trying to use IRDL to define an op like a constant op that takes some attribute and returns some result, like a constant op in many dialects. I've followed the example IRDL in the tests, and have something this:

```
module { 
  irdl.dialect @cmath { 
    irdl.type @complex 
 irdl.operation @const { 
      %0 = irdl.parametric @complex<> 
      %1 = irdl.is i64 
      irdl.attributes {"value" = %1} 
 irdl.operands() 
      irdl.results(%0) 
    } 
}
```

I am trying to build a `cmath.const` op, passing a concrete attribute for the `value`:

```
%0 = "cmath.const"() {value = 1 : i64} : () -> !cmath.complex
```

This fails to verify with:

```
error: expected 'i64' but got '1 : i64'
```

The tests here seem to reflect this as well, in the examples, only a TypeAttr is passed, not an IntegerAttr of the corresponding type: https://github.com/llvm/llvm-project/blob/f2794ccede6d32a6b5ef7a376ced420331e2be27/mlir/test/Dialect/IRDL/testd.mlir#L253

I want my op to express that it requires a TypedAttribute of some type, like `i64`, not that the attribute is a TypeAttr of type `i64`. Is this possible? In other words, I want to be able to pass concrete attribute values and have the types of those attributes checked against the IRDL op definition.

I reviewed the discussion on the original patch, and it seems like this was what was originally implemented but then this was changed. Is there any plan to support this? Or am I using the existing tooling wrong?

cc  @math-fehr @unterumarmung
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVtuO2zgM_RrlhWhgy7fkIQ-ZZg0E6GKBbn9AtmhbO7LkleSk-fsFZafJtNMBFhjEtkRS5OHh0QjvVW8QD6x4YcVpI-YwWHcY1SvOrhHtsGmsvB3OIEYI7qZ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