pass down structs_sym_tab

This commit is contained in:
Pragyansh Chaturvedi
2025-09-21 15:20:41 +05:30
parent 69a86c2433
commit 3c976b88d3
2 changed files with 8 additions and 8 deletions

View File

@ -16,7 +16,7 @@ def bpf_ktime_get_ns_emitter(call, map_ptr, module, builder, func, local_sym_tab
return result return result
def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None): def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
""" """
Emit LLVM IR for bpf_map_lookup_elem helper function call. Emit LLVM IR for bpf_map_lookup_elem helper function call.
""" """
@ -172,7 +172,7 @@ def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None)
ir.IntType(32), len(fmt_str))], tail=True) ir.IntType(32), len(fmt_str))], tail=True)
def bpf_map_update_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None): def bpf_map_update_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
""" """
Emit LLVM IR for bpf_map_update_elem helper function call. Emit LLVM IR for bpf_map_update_elem helper function call.
Expected call signature: map.update(key, value, flags=0) Expected call signature: map.update(key, value, flags=0)
@ -268,7 +268,7 @@ def bpf_map_update_elem_emitter(call, map_ptr, module, builder, local_sym_tab=No
return result return result
def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None): def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
""" """
Emit LLVM IR for bpf_map_delete_elem helper function call. Emit LLVM IR for bpf_map_delete_elem helper function call.
Expected call signature: map.delete(key) Expected call signature: map.delete(key)
@ -340,7 +340,7 @@ def bpf_get_current_pid_tgid_emitter(call, map_ptr, module, builder, func, local
return pid return pid
def bpf_perf_event_output_handler(call, map_ptr, module, builder, local_sym_tab=None): def bpf_perf_event_output_handler(call, map_ptr, module, builder, local_sym_tab=None, struct_sym_tab=None):
pass pass
@ -355,7 +355,7 @@ helper_func_list = {
} }
def handle_helper_call(call, module, builder, func, local_sym_tab=None, map_sym_tab=None): def handle_helper_call(call, module, builder, func, local_sym_tab=None, map_sym_tab=None, struct_sym_tab=None):
if isinstance(call.func, ast.Name): if isinstance(call.func, ast.Name):
func_name = call.func.id func_name = call.func.id
if func_name in helper_func_list: if func_name in helper_func_list:
@ -373,7 +373,7 @@ def handle_helper_call(call, module, builder, func, local_sym_tab=None, map_sym_
map_ptr = map_sym_tab[map_name] map_ptr = map_sym_tab[map_name]
if method_name in helper_func_list: if method_name in helper_func_list:
return helper_func_list[method_name]( return helper_func_list[method_name](
call, map_ptr, module, builder, local_sym_tab) call, map_ptr, module, builder, local_sym_tab, struct_sym_tab)
else: else:
raise NotImplementedError( raise NotImplementedError(
f"Map method {method_name} is not implemented as a helper function.") f"Map method {method_name} is not implemented as a helper function.")

View File

@ -100,7 +100,7 @@ def handle_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab, struc
# var = builder.alloca(ir.IntType(64), name=var_name) # var = builder.alloca(ir.IntType(64), name=var_name)
# var.align = 8 # var.align = 8
val = handle_helper_call( val = handle_helper_call(
rval, module, builder, None, local_sym_tab, map_sym_tab) rval, module, builder, None, local_sym_tab, map_sym_tab, structs_sym_tab)
builder.store(val, local_sym_tab[var_name]) builder.store(val, local_sym_tab[var_name])
# local_sym_tab[var_name] = var # local_sym_tab[var_name] = var
print(f"Assigned constant {rval.func.id} to {var_name}") print(f"Assigned constant {rval.func.id} to {var_name}")
@ -139,7 +139,7 @@ def handle_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab, struc
map_ptr = map_sym_tab[map_name] map_ptr = map_sym_tab[map_name]
if method_name in helper_func_list: if method_name in helper_func_list:
val = handle_helper_call( val = handle_helper_call(
rval, module, builder, func, local_sym_tab, map_sym_tab) rval, module, builder, func, local_sym_tab, map_sym_tab, structs_sym_tab)
# var = builder.alloca(ir.IntType(64), name=var_name) # var = builder.alloca(ir.IntType(64), name=var_name)
# var.align = 8 # var.align = 8
builder.store(val, local_sym_tab[var_name]) builder.store(val, local_sym_tab[var_name])