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])