[Mlir-commits] [mlir] [mlir][spirv] Fix tablegen generator script's stripping of prefixes (PR #101378)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jul 31 11:46:57 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r 6d3317e5389d3041c4a0ae588919d7a2fe2764f0...4d2b11b60bce9cc6c2532eb03068ae1492ed3a81 mlir/utils/spirv/gen_spirv_dialect.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- gen_spirv_dialect.py	2024-07-31 18:39:20.000000 +0000
+++ gen_spirv_dialect.py	2024-07-31 18:46:26.112744 +0000
@@ -535,11 +535,13 @@
         content = f.read()
 
     content = content.split(AUTOGEN_OPCODE_SECTION_MARKER)
 
     prefix = "def SPIRV_OC_"
-    existing_opcodes = [k[len(prefix):] for k in re.findall(prefix + "\w+", content[1])]
+    existing_opcodes = [
+        k[len(prefix) :] for k in re.findall(prefix + "\w+", content[1])
+    ]
     existing_instructions = list(
         filter(lambda inst: (inst["opname"] in existing_opcodes), instructions)
     )
 
     instructions_opnames = [inst["opname"] for inst in instructions]
@@ -638,11 +640,14 @@
     assert len(content) == 3
 
     # Extend filter list with existing enum definitions
     prefix = "def SPIRV_"
     suffix = "Attr"
-    existing_kinds = [k[len(prefix):-len(suffix)] for k in re.findall(prefix + "\w+" + suffix, content[1])]
+    existing_kinds = [
+        k[len(prefix) : -len(suffix)]
+        for k in re.findall(prefix + "\w+" + suffix, content[1])
+    ]
     filter_list.extend(existing_kinds)
 
     capability_mapping = get_capability_mapping(operand_kinds)
 
     # Generate definitions for all enums in filter list
@@ -962,17 +967,22 @@
       - A dict containing potential manually specified sections
     """
     # Get opname
     prefix = "def SPIRV_"
     suffix = "Op"
-    opname = [o[len(prefix):-len(suffix)] for o in re.findall(prefix + "\w+" + suffix, op_def)]
+    opname = [
+        o[len(prefix) : -len(suffix)]
+        for o in re.findall(prefix + "\w+" + suffix, op_def)
+    ]
     assert len(opname) == 1, "more than one ops in the same section!"
     opname = opname[0]
 
     # Get instruction category
     prefix = "SPIRV_"
-    inst_category = [o[len(prefix):] for o in re.findall(prefix + "\w+Op", op_def.split(":", 1)[1])]
+    inst_category = [
+        o[len(prefix) :] for o in re.findall(prefix + "\w+Op", op_def.split(":", 1)[1])
+    ]
     assert len(inst_category) <= 1, "more than one ops in the same section!"
     inst_category = inst_category[0] if len(inst_category) == 1 else "Op"
 
     # Get category_args
     op_tmpl_params, _ = get_string_between_nested(op_def, "<", ">")

``````````

</details>


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


More information about the Mlir-commits mailing list