@@ -47,8 +47,6 @@ type enhanced_memory_info = {
47
47
(* * Variable name to enhanced memory info mapping *)
48
48
type memory_info_map = (string , enhanced_memory_info ) Hashtbl .t
49
49
50
- type bounds_hint = { verified : bool ; size_hint : int }
51
-
52
50
(* * Detect memory region type from IR value semantics *)
53
51
let detect_memory_region_type ir_val =
54
52
match ir_val.value_desc with
@@ -58,11 +56,6 @@ let detect_memory_region_type ir_val =
58
56
| IRTempVariable _ -> RegularMemory (* Temporary variables *)
59
57
| _ -> RegularMemory
60
58
61
- (* * Check if IR value represents packet data *)
62
- let is_packet_data_value ir_val =
63
- match detect_memory_region_type ir_val with
64
- | PacketData -> true
65
- | _ -> false
66
59
67
60
(* * Check if IR value represents map-derived data - heuristic approach *)
68
61
let is_map_value_parameter ir_val =
@@ -76,12 +69,6 @@ let is_map_value_parameter ir_val =
76
69
| _ -> false )
77
70
| _ -> false
78
71
79
- (* * Check if IR value is local stack memory *)
80
- let is_local_stack_value ir_val =
81
- match detect_memory_region_type ir_val with
82
- | LocalStack -> true
83
- | _ -> false
84
-
85
72
(* * Enhanced memory region detection using provided memory info *)
86
73
let detect_memory_region_enhanced ?(memory_info_map =None ) ir_val =
87
74
match memory_info_map with
@@ -103,21 +90,6 @@ let detect_memory_region_enhanced ?(memory_info_map=None) ir_val =
103
90
(* Fallback to heuristic detection *)
104
91
detect_memory_region_type ir_val
105
92
106
- (* * Get enhanced bounds information *)
107
- let get_enhanced_bounds_info ?(memory_info_map =None ) ir_val =
108
- match memory_info_map with
109
- | Some info_map ->
110
- (match ir_val.value_desc with
111
- | IRVariable var_name ->
112
- (try
113
- let info = Hashtbl. find info_map var_name in
114
- Some { verified = info.bounds_verified; size_hint =
115
- match info.size_hint with Some s -> s | None -> 0 }
116
- with
117
- | Not_found -> None )
118
- | _ -> None )
119
- | None -> None
120
-
121
93
(* * C code generation context *)
122
94
type c_context = {
123
95
(* Generated C code lines *)
@@ -2393,38 +2365,8 @@ let generate_ringbuf_operation ctx ringbuf_val op =
2393
2365
(* on_event is userspace-only operation *)
2394
2366
failwith " Ring buffer on_event() operation is not supported in eBPF programs - it's userspace-only"
2395
2367
2396
- (* * Generate C code for IR instruction *)
2397
-
2398
- (* * Helper function to convert AST expressions to C code for bpf_loop callbacks *)
2399
- let rec generate_ast_expr_to_c (expr : Ast.expr ) counter_var =
2400
- match expr.Ast. expr_desc with
2401
- | Ast. Literal (Ast. IntLit (i , _ )) -> Ast.IntegerValue. to_string i
2402
- | Ast. Literal (Ast. BoolLit b ) -> if b then " true" else " false"
2403
- | Ast. Identifier name when name = " i" -> counter_var (* Map loop variable to counter *)
2404
- | Ast. Identifier name -> name
2405
- | Ast. BinaryOp (left , op , right ) ->
2406
- let left_c = generate_ast_expr_to_c left counter_var in
2407
- let right_c = generate_ast_expr_to_c right counter_var in
2408
- let op_c = match op with
2409
- | Ast. Add -> " +"
2410
- | Ast. Sub -> " -"
2411
- | Ast. Mul -> " *"
2412
- | Ast. Div -> " /"
2413
- | Ast. Mod -> " %"
2414
- | Ast. Eq -> " =="
2415
- | Ast. Ne -> " !="
2416
- | Ast. Lt -> " <"
2417
- | Ast. Le -> " <="
2418
- | Ast. Gt -> " >"
2419
- | Ast. Ge -> " >="
2420
- | Ast. And -> " &&"
2421
- | Ast. Or -> " ||"
2422
- in
2423
- sprintf " (%s %s %s)" left_c op_c right_c
2424
- | _ -> " /* complex expr */"
2425
-
2426
2368
(* * Generate assignment instruction with optional const keyword *)
2427
- and generate_assignment ctx dest_val expr is_const =
2369
+ let generate_assignment ctx dest_val expr is_const =
2428
2370
let assignment_prefix = if is_const then " const " else " " in
2429
2371
2430
2372
(* Check if this is a pinned global variable assignment *)
@@ -3455,16 +3397,6 @@ let generate_c_function ctx ir_func =
3455
3397
emit_line ctx " }" ;
3456
3398
emit_blank_line ctx
3457
3399
3458
- (* * Helper function to compile C code to eBPF object *)
3459
- let compile_c_to_ebpf c_filename obj_filename =
3460
- let cmd = sprintf " clang -target bpf -O2 -g -c %s -o %s" c_filename obj_filename in
3461
- let exit_code = Sys. command cmd in
3462
- if exit_code = 0 then
3463
- Ok obj_filename
3464
- else
3465
- Error (sprintf " Compilation failed with exit code %d" exit_code)
3466
-
3467
-
3468
3400
(* * Generate ProgArray map for tail calls *)
3469
3401
let generate_prog_array_map ctx prog_array_size =
3470
3402
if prog_array_size > 0 then (
0 commit comments