mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Remove debug prints and add @bpfglobal support
This commit is contained in:
@ -84,8 +84,6 @@ def process_bpf_chunk(func_node, module, return_type):
|
|||||||
|
|
||||||
process_func_body(module, builder, func_node, func, ret_type)
|
process_func_body(module, builder, func_node, func, ret_type)
|
||||||
|
|
||||||
print(func)
|
|
||||||
print(module)
|
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,9 +16,6 @@ def emit_globals(module: ir.Module, names: list[str]):
|
|||||||
g = module.get_global(name)
|
g = module.get_global(name)
|
||||||
else:
|
else:
|
||||||
g = ir.GlobalValue(module, ptr_ty, name)
|
g = ir.GlobalValue(module, ptr_ty, name)
|
||||||
print("global emitted:", name)
|
|
||||||
print(isinstance(g, ir.GlobalVariable))
|
|
||||||
print(isinstance(g, ir.Function))
|
|
||||||
elems.append(g.bitcast(ptr_ty))
|
elems.append(g.bitcast(ptr_ty))
|
||||||
|
|
||||||
gv = ir.GlobalVariable(module, used_array_ty, "llvm.compiler.used")
|
gv = ir.GlobalVariable(module, used_array_ty, "llvm.compiler.used")
|
||||||
@ -31,16 +28,19 @@ def globals_processing(tree, module: ir.Module):
|
|||||||
collected = ["LICENSE"]
|
collected = ["LICENSE"]
|
||||||
|
|
||||||
for node in tree.body:
|
for node in tree.body:
|
||||||
if isinstance(node, ast.FunctionDef) and len(node.decorator_list) == 2:
|
if isinstance(node, ast.FunctionDef):
|
||||||
dec = node.decorator_list[1]
|
for dec in node.decorator_list:
|
||||||
if (
|
if (
|
||||||
isinstance(dec, ast.Call)
|
isinstance(dec, ast.Call)
|
||||||
and isinstance(dec.func, ast.Name)
|
and isinstance(dec.func, ast.Name)
|
||||||
and dec.func.id == "section"
|
and dec.func.id == "section"
|
||||||
and len(dec.args) == 1
|
and len(dec.args) == 1
|
||||||
and isinstance(dec.args[0], ast.Constant)
|
and isinstance(dec.args[0], ast.Constant)
|
||||||
and isinstance(dec.args[0].value, str)
|
and isinstance(dec.args[0].value, str)
|
||||||
):
|
):
|
||||||
collected.append(node.name)
|
collected.append(node.name)
|
||||||
|
|
||||||
|
elif isinstance(dec, ast.Name) and dec.id == "bpfglobal":
|
||||||
|
collected.append(node.name)
|
||||||
|
|
||||||
emit_globals(module, collected)
|
emit_globals(module, collected)
|
||||||
|
|||||||
Reference in New Issue
Block a user