[Mlir-commits] [mlir] [mlir][spirv] Ignore extra comma for category_args in gen_spirv_dialect.py (PR #111776)

Caio Oliveira llvmlistbot at llvm.org
Thu Oct 10 14:00:58 PDT 2024


================
@@ -988,6 +988,7 @@ def extract_td_op_info(op_def):
     op_tmpl_params, _ = get_string_between_nested(op_def, "<", ">")
     opstringname, rest = get_string_between(op_tmpl_params, '"', '"')
     category_args = rest.split("[", 1)[0]
+    category_args = category_args.rsplit(",", 1)[0]
----------------
cmarcelo wrote:

For example, when the function is looking at the following `op_def` (showing just the start):

```
def SPIRV_VectorTimesScalarOp : SPIRV_Op<"VectorTimesScalar", [Pure]> {
```

- `rest` is `, [Pure]`
- we want `category_args` to be empty

And in this other `op_def` (again just the start):

```
def SPIRV_UDivOp : SPIRV_ArithmeticBinaryOp<"UDiv",
                                        SPIRV_Integer, [UnsignedOp, UsableInSpecConstantOp]> {
```

- `rest` is `, SPIRV_Integer, [UsableInSpecConstantOp]`  (whitespace compressed for clarity)
- we want `category_args` to be `, SPIRV_Integer`.

---

There are different ways to handle this, e.g. store category args as an array and re-join at its users, but would've been larger changes without clear extra benefit.



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


More information about the Mlir-commits mailing list