Skip to content

Commit 19deded

Browse files
committed
Implement BPF_GET_SMP_PROCESSOR_ID helper
1 parent 82cac8f commit 19deded

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pythonbpf/helper/bpf_helper_handler.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,29 @@ def bpf_probe_read_emitter(
514514
return result, ir.IntType(64)
515515

516516

517+
@HelperHandlerRegistry.register("smp_processor_id")
518+
def bpf_get_smp_processor_id_emitter(
519+
call,
520+
map_ptr,
521+
module,
522+
builder,
523+
func,
524+
local_sym_tab=None,
525+
struct_sym_tab=None,
526+
map_sym_tab=None,
527+
):
528+
"""
529+
Emit LLVM IR for bpf_get_smp_processor_id helper function call.
530+
"""
531+
helper_id = ir.Constant(ir.IntType(64), BPFHelperID.BPF_GET_SMP_PROCESSOR_ID.value)
532+
fn_type = ir.FunctionType(ir.IntType(32), [], var_arg=False)
533+
fn_ptr_type = ir.PointerType(fn_type)
534+
fn_ptr = builder.inttoptr(helper_id, fn_ptr_type)
535+
result = builder.call(fn_ptr, [], tail=False)
536+
logger.info("Emitted bpf_get_smp_processor_id call")
537+
return result, ir.IntType(32)
538+
539+
517540
def handle_helper_call(
518541
call,
519542
module,

0 commit comments

Comments
 (0)