Add _deref_to_depth in expr_pass

This commit is contained in:
Pragyansh Chaturvedi
2025-10-08 03:12:17 +05:30
committed by varun-r-mallya
parent 7081e939fb
commit 46f5eca33d

View File

@ -139,6 +139,18 @@ def _get_base_type_and_depth(ir_type):
return cur_type, depth return cur_type, depth
def _deref_to_depth(builder, val, target_depth):
"""Dereference a pointer to a certain depth."""
cur_val = val
for _ in range(target_depth):
if not isinstance(val.type, ir.PointerType):
logger.error("Cannot dereference further, non-pointer type")
return None
cur_val = builder.load(cur_val)
return cur_val
def _normalize_types(builder, lhs, rhs): def _normalize_types(builder, lhs, rhs):
"""Normalize types for comparison.""" """Normalize types for comparison."""