Skip to content

Intrinsic for example subincacc instruction #336

Intrinsic for example subincacc instruction

Intrinsic for example subincacc instruction #336

GitHub Actions / Black failed Sep 13, 2024 in 0s

7 errors

Black found 7 errors

Annotations

Check failure on line 85 in /home/runner/work/seal5/seal5/seal5/backends/riscv_intrinsics/writer.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/seal5/seal5/seal5/backends/riscv_intrinsics/writer.py#L25-L85

 
 
 def ir_type_to_text(ir_type: str):
     # needs fleshing out with all likely types
     # probably needs to take into account RISC-V bit width, e.g. does "Li" means 32 bit integer on a 128-bit platform?
-    if ir_type == 'i32':
-        return 'Li'
+    if ir_type == "i32":
+        return "Li"
     raise NotImplementedError(f'Unhandled ir_type "{ir_type}"')
 
 
 def build_target(arch: str, intrinsic: IntrinsicDefn):
 
     # Target couples intrinsic name to argument types and function behaviour
     # Start with return type if not void
-    arg_str = ''
+    arg_str = ""
     if intrinsic.ret_type:
         arg_str += ir_type_to_text(intrinsic.ret_type)
     for arg in intrinsic.args:
         arg_str += ir_type_to_text(arg.arg_type)
 
     target = f'TARGET_BUILTIN(__builtin_{arch}_{intrinsic.intrinsic_name}, "{arg_str}", "nc", "{arch}")'
     return target
 
+
 def ir_type_to_pattern(ir_type: str):
     # needs fleshing out with all likely types
-    if ir_type == 'i32':
-        return 'llvm_i32_ty'
+    if ir_type == "i32":
+        return "llvm_i32_ty"
     raise NotImplementedError(f'Unhandled ir_type "{ir_type}"')
 
+
 def build_attr(arch: str, intrinsic: IntrinsicDefn):
-    uses_mem = False  #@todo
-    ret_types = '(unsupported)' # how to spec void intrinsic?
-    attr = f'  def int_riscv_{intrinsic.intrinsic_name} : Intrinsic<\n    ['
+    uses_mem = False  # @todo
+    ret_types = "(unsupported)"  # how to spec void intrinsic?
+    attr = f"  def int_riscv_{intrinsic.intrinsic_name} : Intrinsic<\n    ["
     if intrinsic.ret_type:
-        attr += f'{ir_type_to_pattern(intrinsic.ret_type)}'
-    attr += '],\n    ['
+        attr += f"{ir_type_to_pattern(intrinsic.ret_type)}"
+    attr += "],\n    ["
     for idx, arg in enumerate(intrinsic.args):
         if idx:
-            attr += ', '
+            attr += ", "
         attr += ir_type_to_pattern(arg.arg_type)
-    attr += '],\n'
-    attr += '    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;'
+    attr += "],\n"
+    attr += "    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;"
     return attr
 
 
 def build_emit(arch: str, intrinsic: IntrinsicDefn):
-    emit = (f'  case RISCV::BI__builtin_{arch}_{intrinsic.intrinsic_name}:\n'
-            f'    ID = Intrinsic::riscv_{intrinsic.intrinsic_name};\n'
-            f'    break;')
+    emit = (
+        f"  case RISCV::BI__builtin_{arch}_{intrinsic.intrinsic_name}:\n"
+        f"    ID = Intrinsic::riscv_{intrinsic.intrinsic_name};\n"
+        f"    break;"
+    )
     return emit
 
 
 @dataclass
 class PatchFrag:
     """Pairs patch contents to location to apply it"""
+
     patchee: str
     tag: str
     contents: str = ""
 
 

Check failure on line 195 in /home/runner/work/seal5/seal5/seal5/backends/riscv_intrinsics/writer.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/seal5/seal5/seal5/backends/riscv_intrinsics/writer.py#L158-L195

             if llvm_settings:
                 llvm_state = llvm_settings.state
                 if llvm_state:
                     llvm_version = llvm_state.version
         patch_frags = {
-            'target': PatchFrag(patchee='clang/include/clang/Basic/BuiltinsRISCV.def', tag='builtins_riscv'),
-            'attr': PatchFrag(patchee='llvm/include/llvm/IR/IntrinsicsRISCV.td', tag='intrinsics_riscv'),
-            'emit': PatchFrag(patchee='clang/lib/CodeGen/CGBuiltin.cpp', tag='cg_builtin')
-                      }
+            "target": PatchFrag(patchee="clang/include/clang/Basic/BuiltinsRISCV.def", tag="builtins_riscv"),
+            "attr": PatchFrag(patchee="llvm/include/llvm/IR/IntrinsicsRISCV.td", tag="intrinsics_riscv"),
+            "emit": PatchFrag(patchee="clang/lib/CodeGen/CGBuiltin.cpp", tag="cg_builtin"),
+        }
         for set_name, set_def in model["sets"].items():
             artifacts[set_name] = []
             metrics["n_sets"] += 1
             ext_settings = set_def.settings
             if ext_settings is None:
                 metrics["n_skipped"] += 1
                 continue
             for intrinsic in settings.intrinsics.intrinsics:
                 metrics["n_success"] += 1
 
-                patch_frags['target'].contents += build_target(arch=ext_settings.get_arch(), intrinsic=intrinsic)
-                patch_frags['attr'].contents += build_attr(arch=ext_settings.get_arch(), intrinsic=intrinsic)
-                patch_frags['emit'].contents += build_emit(arch=ext_settings.get_arch(), intrinsic=intrinsic)
+                patch_frags["target"].contents += build_target(arch=ext_settings.get_arch(), intrinsic=intrinsic)
+                patch_frags["attr"].contents += build_attr(arch=ext_settings.get_arch(), intrinsic=intrinsic)
+                patch_frags["emit"].contents += build_emit(arch=ext_settings.get_arch(), intrinsic=intrinsic)
 
         for id, frag in patch_frags.items():
             contents = frag.contents
             if len(contents) > 0:
-                if id == 'target':
-                    contents = f'// {ext_settings.get_arch()}\n{contents}\n'
-                elif id == 'attr':
+                if id == "target":
+                    contents = f"// {ext_settings.get_arch()}\n{contents}\n"
+                elif id == "attr":
                     contents = f'let TargetPrefix = "riscv" in {{\n{contents}\n}}'
                 (root, ext) = os.path.splitext(out_path)
-                patch_path = root + '_' + id + ext
+                patch_path = root + "_" + id + ext
                 with open(patch_path, "w") as f:
                     f.write(contents)
                 key = frag.tag
                 if ext_settings.experimental:
                     key += "_experimental"

Check failure on line 229 in /home/runner/work/seal5/seal5/seal5/backends/riscv_instr_info/writer.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/seal5/seal5/seal5/backends/riscv_instr_info/writer.py#L219-L229

         formats=formats,
         compressed_pat=compressed_pat,
     )
     return tablegen_str
 
+
 def gen_intrinsic_pattern(instr, intrinsic: IntrinsicDefn):
     pat = f"""class Pat_{instr.name}<SDPatternOperator OpNode, Instruction Inst>
 : Pat<(OpNode {instr.llvm_ins_str}), (Inst {instr.llvm_ins_str})>;
 def : Pat_{instr.name}<int_riscv_{intrinsic.intrinsic_name}, {instr.name}>;"""
     return pat

Check failure on line 250 in /home/runner/work/seal5/seal5/seal5/backends/riscv_instr_info/writer.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/seal5/seal5/seal5/backends/riscv_instr_info/writer.py#L239-L250

     parser.add_argument("--splitted", action="store_true", help="Split per set")
     parser.add_argument("--formats", action="store_true", help="Also generate instruction formats")
     parser.add_argument("--metrics", default=None, help="Output metrics to file")
     parser.add_argument("--index", default=None, help="Output index to file")
     parser.add_argument("--ext", type=str, default="td", help="Default file extension (if using --splitted)")
-    parser.add_argument("--no-add-intrinsics", dest='add_intrinsics', default=True, action='store_false', help="Suppress patterns for intrinsic functions")
+    parser.add_argument(
+        "--no-add-intrinsics",
+        dest="add_intrinsics",
+        default=True,
+        action="store_false",
+        help="Suppress patterns for intrinsic functions",
+    )
     args = parser.parse_args()
 
     # initialize logging
     logging.basicConfig(level=getattr(logging, args.log.upper()))
 

Check failure on line 169 in /home/runner/work/seal5/seal5/seal5/settings.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/seal5/seal5/seal5/settings.py#L155-L169

             "ref": None,
             # "clone_depth": None,
             "clone_depth": 1,
             "sparse_checkout": False,
         },
-   },
-    "intrinsics": {
-    },
- }
+    },
+    "intrinsics": {},
+}
 
 ALLOWED_YAML_TYPES = (int, float, str, bool)
 
 
 def check_supported_types(data):

Check failure on line 591 in /home/runner/work/seal5/seal5/seal5/settings.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/seal5/seal5/seal5/settings.py#L570-L591

 class ToolsSettings(YAMLSettings):
     """Seal5 tools settings."""
 
     pattern_gen: Optional[PatternGenSettings] = None
 
+
 @dataclass
 class IntrinsicArg(YAMLSettings):
     arg_name: str
     arg_type: str
+
 
 @dataclass
 class IntrinsicDefn(YAMLSettings):
     instr_name: str
     intrinsic_name: str
     ret_type: Optional[str] = None
     args: Optional[List[IntrinsicArg]] = None
+
 
 @dataclass
 class IntrinsicsSettings(YAMLSettings):
     intrinsics: Optional[List[IntrinsicDefn]] = None
 

Check failure on line 176 in /home/runner/work/seal5/seal5/seal5/flow.py

See this annotation in the file changed.

@github-actions github-actions / Black

/home/runner/work/seal5/seal5/seal5/flow.py#L166-L176

     utils.copy(src, dest)
 
 
 class Seal5Flow:
     """Seal5 Flow."""
+
     def __init__(
         self, directory: Optional[Path] = None, meta_dir: Optional[Union[str, Path]] = None, name: Optional[str] = None
     ):
         self.directory: Path = handle_directory(directory)
         self.meta_dir: Path = handle_meta_dir(meta_dir, directory, name)