Skip to content

Commit 46f5eca

Browse files
r41k0uvarun-r-mallya
authored andcommitted
Add _deref_to_depth in expr_pass
1 parent 7081e93 commit 46f5eca

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎pythonbpf/expr_pass.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ def _get_base_type_and_depth(ir_type):
139139
return cur_type, depth
140140

141141

142+
def _deref_to_depth(builder, val, target_depth):
143+
"""Dereference a pointer to a certain depth."""
144+
145+
cur_val = val
146+
for _ in range(target_depth):
147+
if not isinstance(val.type, ir.PointerType):
148+
logger.error("Cannot dereference further, non-pointer type")
149+
return None
150+
cur_val = builder.load(cur_val)
151+
return cur_val
152+
153+
142154
def _normalize_types(builder, lhs, rhs):
143155
"""Normalize types for comparison."""
144156

0 commit comments

Comments
 (0)