Skip to content

Commit cdf4f3e

Browse files
Add module-level docstrings and helper utility docstrings
Co-authored-by: varun-r-mallya <100590632+varun-r-mallya@users.noreply.github.com>
1 parent 5b20b08 commit cdf4f3e

22 files changed

+219
-6
lines changed

pythonbpf/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
PythonBPF - A Python frontend for eBPF programs.
3+
4+
This package provides decorators and compilation tools to write BPF programs
5+
in Python syntax and compile them to eBPF bytecode that can run in the kernel.
6+
"""
7+
18
from .decorators import bpf, map, section, bpfglobal, struct
29
from .codegen import compile_to_ir, compile, BPF
310

pythonbpf/binary_ops.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
Binary operations handling for BPF programs.
3+
4+
This module provides functions to handle binary operations (add, subtract,
5+
multiply, etc.) and emit the corresponding LLVM IR instructions.
6+
"""
7+
18
import ast
29
from llvmlite import ir
310
from logging import Logger

pythonbpf/codegen.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""
2+
Code generation module for PythonBPF.
3+
4+
This module handles the conversion of Python BPF programs to LLVM IR and
5+
object files. It provides the main compilation pipeline from Python AST
6+
to BPF bytecode.
7+
"""
8+
19
import ast
210
from llvmlite import ir
311
from .license_pass import license_processing

pythonbpf/decorators.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""
2+
Decorators for marking BPF functions, maps, structs, and globals.
3+
4+
This module provides the core decorators used to annotate Python code
5+
for BPF compilation.
6+
"""
7+
8+
19
def bpf(func):
210
"""Decorator to mark a function for BPF compilation."""
311
func._is_bpf = True

pythonbpf/expr/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Expression evaluation and processing for BPF programs."""
2+
13
from .expr_pass import eval_expr, handle_expr
24
from .type_normalization import convert_to_bool
35

pythonbpf/expr/expr_pass.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""
2+
Expression evaluation and LLVM IR generation.
3+
4+
This module handles the evaluation of Python expressions in BPF programs,
5+
including variables, constants, function calls, comparisons, boolean
6+
operations, and more.
7+
"""
8+
19
import ast
210
from llvmlite import ir
311
from logging import Logger

pythonbpf/expr/type_normalization.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
Type normalization and comparison operations for expressions.
3+
4+
This module provides utilities for normalizing types between expressions,
5+
handling pointer dereferencing, and generating comparison operations.
6+
"""
7+
18
from llvmlite import ir
29
import logging
310
import ast

pythonbpf/functions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""BPF function processing and LLVM IR generation."""
2+
13
from .functions_pass import func_proc
24

35
__all__ = ["func_proc"]

pythonbpf/functions/functions_pass.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""
2+
BPF function processing and LLVM IR generation.
3+
4+
This module handles the core function processing, converting Python function
5+
definitions into LLVM IR for BPF programs. It manages local variables,
6+
control flow, and statement processing.
7+
"""
8+
19
from llvmlite import ir
210
import ast
311
import logging

pythonbpf/globals_pass.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
"""
2+
Global variables and compiler metadata processing.
3+
4+
This module handles BPF global variables and emits the @llvm.compiler.used
5+
metadata to prevent LLVM from optimizing away important symbols.
6+
"""
7+
18
from llvmlite import ir
29
import ast
310

0 commit comments

Comments
 (0)