Add map_sym_tab

This commit is contained in:
Pragyansh Chaturvedi
2025-09-08 22:48:09 +05:30
parent ed37aa01d2
commit a5a671133c

View File

@ -2,6 +2,9 @@ import ast
from llvmlite import ir from llvmlite import ir
from .type_deducer import ctypes_to_ir from .type_deducer import ctypes_to_ir
map_sym_tab = {}
def maps_proc(tree, module, chunks): def maps_proc(tree, module, chunks):
for func_node in chunks: for func_node in chunks:
# Check if this function is a map # Check if this function is a map
@ -33,14 +36,16 @@ def create_bpf_map(module, map_name, map_params):
map_global.global_constant = False map_global.global_constant = False
# Initialize with zeroinitializer (all null pointers) # Initialize with zeroinitializer (all null pointers)
map_global.initializer = ir.Constant(map_struct_type, None) #type: ignore map_global.initializer = ir.Constant(map_struct_type, None) # type: ignore
map_global.section = ".maps" map_global.section = ".maps"
map_global.align = 8 # type: ignore map_global.align = 8 # type: ignore
print(f"Created BPF map: {map_name}") print(f"Created BPF map: {map_name}")
map_sym_tab[map_name] = map_global
return map_global return map_global
def process_hash_map(map_name, rval, module): def process_hash_map(map_name, rval, module):
print(f"Creating HashMap map: {map_name}") print(f"Creating HashMap map: {map_name}")
map_params: dict[str, object] = {"map_type": "HASH"} map_params: dict[str, object] = {"map_type": "HASH"}