mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Fix calling conventions changed by structs
This commit is contained in:
@ -3,7 +3,7 @@ from llvmlite import ir
|
|||||||
from .expr_pass import eval_expr
|
from .expr_pass import eval_expr
|
||||||
|
|
||||||
|
|
||||||
def bpf_ktime_get_ns_emitter(call, map_ptr, module, builder, func, local_sym_tab=None):
|
def bpf_ktime_get_ns_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, local_var_metadata=None):
|
||||||
"""
|
"""
|
||||||
Emit LLVM IR for bpf_ktime_get_ns helper function call.
|
Emit LLVM IR for bpf_ktime_get_ns helper function call.
|
||||||
"""
|
"""
|
||||||
@ -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, func, local_sym_tab=None, struct_sym_tab=None):
|
def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None, local_var_metadata=None):
|
||||||
"""
|
"""
|
||||||
Emit LLVM IR for bpf_map_lookup_elem helper function call.
|
Emit LLVM IR for bpf_map_lookup_elem helper function call.
|
||||||
"""
|
"""
|
||||||
@ -63,7 +63,7 @@ def bpf_map_lookup_elem_emitter(call, map_ptr, module, builder, func, local_sym_
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None):
|
def bpf_printk_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, local_var_metadata=None):
|
||||||
if not hasattr(func, "_fmt_counter"):
|
if not hasattr(func, "_fmt_counter"):
|
||||||
func._fmt_counter = 0
|
func._fmt_counter = 0
|
||||||
|
|
||||||
@ -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, func, local_sym_tab=None, struct_sym_tab=None):
|
def bpf_map_update_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None, local_var_metadata=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, func, local_sym_
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None):
|
def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, struct_sym_tab=None, local_var_metadata=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)
|
||||||
@ -323,7 +323,7 @@ def bpf_map_delete_elem_emitter(call, map_ptr, module, builder, func, local_sym_
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def bpf_get_current_pid_tgid_emitter(call, map_ptr, module, builder, func, local_sym_tab=None):
|
def bpf_get_current_pid_tgid_emitter(call, map_ptr, module, builder, func, local_sym_tab=None, local_var_metadata=None):
|
||||||
"""
|
"""
|
||||||
Emit LLVM IR for bpf_get_current_pid_tgid helper function call.
|
Emit LLVM IR for bpf_get_current_pid_tgid helper function call.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -222,7 +222,7 @@ def handle_cond(func, module, builder, cond, local_sym_tab, map_sym_tab):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab):
|
def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab, structs_sym_tab=None):
|
||||||
"""Handle if statements in the function body."""
|
"""Handle if statements in the function body."""
|
||||||
print("Handling if statement")
|
print("Handling if statement")
|
||||||
start = builder.block.parent
|
start = builder.block.parent
|
||||||
@ -243,7 +243,7 @@ def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab):
|
|||||||
builder.position_at_end(then_block)
|
builder.position_at_end(then_block)
|
||||||
for s in stmt.body:
|
for s in stmt.body:
|
||||||
process_stmt(func, module, builder, s,
|
process_stmt(func, module, builder, s,
|
||||||
local_sym_tab, map_sym_tab, False)
|
local_sym_tab, map_sym_tab, structs_sym_tab, False)
|
||||||
if not builder.block.is_terminated:
|
if not builder.block.is_terminated:
|
||||||
builder.branch(merge_block)
|
builder.branch(merge_block)
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab):
|
|||||||
builder.position_at_end(else_block)
|
builder.position_at_end(else_block)
|
||||||
for s in stmt.orelse:
|
for s in stmt.orelse:
|
||||||
process_stmt(func, module, builder, s,
|
process_stmt(func, module, builder, s,
|
||||||
local_sym_tab, map_sym_tab, False)
|
local_sym_tab, map_sym_tab, structs_sym_tab, False)
|
||||||
if not builder.block.is_terminated:
|
if not builder.block.is_terminated:
|
||||||
builder.branch(merge_block)
|
builder.branch(merge_block)
|
||||||
|
|
||||||
@ -269,7 +269,8 @@ def process_stmt(func, module, builder, stmt, local_sym_tab, map_sym_tab, struct
|
|||||||
elif isinstance(stmt, ast.AugAssign):
|
elif isinstance(stmt, ast.AugAssign):
|
||||||
raise SyntaxError("Augmented assignment not supported")
|
raise SyntaxError("Augmented assignment not supported")
|
||||||
elif isinstance(stmt, ast.If):
|
elif isinstance(stmt, ast.If):
|
||||||
handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab)
|
handle_if(func, module, builder, stmt, map_sym_tab,
|
||||||
|
local_sym_tab, structs_sym_tab)
|
||||||
elif isinstance(stmt, ast.Return):
|
elif isinstance(stmt, ast.Return):
|
||||||
if stmt.value is None:
|
if stmt.value is None:
|
||||||
builder.ret(ir.Constant(ir.IntType(32), 0))
|
builder.ret(ir.Constant(ir.IntType(32), 0))
|
||||||
|
|||||||
Reference in New Issue
Block a user