Skip to content

Commit 783b4cb

Browse files
committed
[UR] Use dict for functions in loader script templates
The `get_loader_functions()` template helper now returns `list[dict]` instead of `list[str]`, this enables passing additional information into the loader script templates.
1 parent c5ce3a2 commit 783b4cb

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

unified-runtime/scripts/templates/api_funcs.def.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _UR_API(${th.make_func_name(n, tags, obj)})
3232
%endfor
3333
%endfor
3434
%for obj in th.get_loader_functions(specs, meta, n, tags):
35-
%if n + "Loader" in obj:
36-
_UR_API(${obj})
35+
%if n + "Loader" in obj['name']:
36+
_UR_API(${obj['name']})
3737
%endif
3838
%endfor

unified-runtime/scripts/templates/helper.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,29 +721,33 @@ def get_adapter_manifests(specs: List[dict]) -> List[dict]:
721721

722722
def get_loader_functions(
723723
specs: List[dict], meta: dict, namespace: str, tags
724-
) -> List[str]:
724+
) -> List[dict]:
725725
"""
726726
Public:
727727
returns a list of all loader API functions' names
728728
"""
729-
func_names = []
729+
funcs = []
730730

731731
# Main API functions
732732
for s in specs:
733733
for obj in s["objects"]:
734734
if obj_traits.is_function(obj):
735-
func_names.append(make_func_name(namespace, tags, obj))
735+
func = {"name": make_func_name(namespace, tags, obj)}
736+
funcs.append(func)
737+
736738
# Process address tables functions
737739
for tbl in get_pfntables(specs, meta, namespace, tags):
738-
func_names.append(tbl["export"]["name"])
740+
func = {"name": tbl["export"]["name"]}
741+
funcs.append(func)
739742

740743
# Print functions
741744
api_types_funcs = get_api_types_funcs(specs, meta, namespace, tags)
742745
for func in api_types_funcs:
743-
func_names.append(func.c_name)
744-
func_names.append(f"{tags['$x']}PrintFunctionParams")
746+
func = {"name": func.c_name}
747+
funcs.append(func)
748+
funcs.append({"name": f"{tags['$x']}PrintFunctionParams"})
745749

746-
return sorted(func_names)
750+
return sorted(funcs, key=lambda func: func["name"])
747751

748752

749753
def _remove_const(name: str) -> str:

unified-runtime/scripts/templates/loader.def.in.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ from templates import helper as th
66
%>\
77
LIBRARY @TARGET_LIBNAME@
88
EXPORTS
9-
%for line in th.get_loader_functions(specs, meta, n, tags):
10-
${line}
9+
%for func in th.get_loader_functions(specs, meta, n, tags):
10+
${func['name']}
1111
%endfor

unified-runtime/scripts/templates/loader.map.in.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ from templates import helper as th
66
%>\
77
@TARGET_LIBNAME@ {
88
global:
9-
%for line in th.get_loader_functions(specs, meta, n, tags):
10-
${line};
9+
%for func in th.get_loader_functions(specs, meta, n, tags):
10+
${func['name']};
1111
%endfor
1212
local:
1313
*;

0 commit comments

Comments
 (0)