5 from __future__
import annotations
6 from typing
import Dict, List, Tuple, Union
8 from .
import handshake
9 from ._handshake_ops_gen
import *
10 from ._handshake_ops_gen
import _Dialect
12 from ..dialects._ods_common
import _cext
as _ods_cext
13 from ..ir
import ArrayAttr, Attribute, FunctionType, StringAttr, Type, TypeAttr
15 from ._ods_common
import (
16 equally_sized_accessor
as _ods_equally_sized_accessor,
17 get_default_loc_context
as _ods_get_default_loc_context,
18 get_op_result_or_op_results
as _get_op_result_or_op_results,
19 get_op_result_or_value
as _get_op_result_or_value,
20 get_op_results_or_values
as _get_op_results_or_values,
21 segmented_accessor
as _ods_segmented_accessor,
24 _ods_ir = _ods_cext.ir
27 @_ods_cext.register_operation(_Dialect, replace=True)
31 def create(sym_name: Union[StringAttr, str],
32 args: List[Tuple[str, Type]],
33 results: List[Tuple[str, Type]],
34 attributes: Dict[str, Attribute] = {},
37 if isinstance(sym_name, str):
38 sym_name = StringAttr.get(sym_name)
39 input_types = [t
for _, t
in args]
40 res_types = [t
for _, t
in results]
41 func_type = FunctionType.get(input_types, res_types)
42 func_type_attr = TypeAttr.get(func_type)
43 funcop =
FuncOp(func_type_attr, loc=loc, ip=ip)
44 for k, v
in attributes.items():
45 funcop.attributes[k] = v
46 funcop.attributes[
"sym_name"] = sym_name
47 funcop.attributes[
"argNames"] = ArrayAttr.get(
48 [StringAttr.get(name)
for name, _
in args])
49 funcop.attributes[
"resNames"] = ArrayAttr.get(
50 [StringAttr.get(name)
for name, _
in results])
54 self.body.blocks.append(*self.function_type.value.inputs)
55 return self.body.blocks[0]
def add_entry_block(self)
FuncOp create(Union[StringAttr, str] sym_name, List[Tuple[str, Type]] args, List[Tuple[str, Type]] results, Dict[str, Attribute] attributes={}, loc=None, ip=None)