mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
Core: Type comparison and boolean results as unsigned i1
A comparison's descriptor was a plain i1, which reads as signed, so storing or returning a truth value would sign-extend true to -1. C's relational operators yield int 0 or 1; give the results an unsigned descriptor so any widening zero-extends. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
This commit is contained in:
@ -421,7 +421,7 @@ def _handle_unary_op(
|
||||
if isinstance(expr.op, ast.Not):
|
||||
true_const = ir.Constant(ir.IntType(1), 1)
|
||||
result = builder.xor(convert_to_bool(builder, operand), true_const)
|
||||
return result, ir.IntType(1)
|
||||
return result, IntTy(1, False)
|
||||
elif isinstance(expr.op, ast.USub):
|
||||
if isinstance(operand, ir.Constant) and isinstance(operand.constant, int):
|
||||
# -2 parses as USub(Constant 2); fold it so it is a literal like
|
||||
@ -491,7 +491,7 @@ def _handle_and_op(func, builder, expr, local_sym_tab, compilation_context):
|
||||
phi.add_incoming(val, block)
|
||||
|
||||
logger.debug(f"Generated 'and' with {len(incoming_values)} incoming values")
|
||||
return phi, ir.IntType(1)
|
||||
return phi, IntTy(1, False)
|
||||
|
||||
|
||||
def _handle_or_op(func, builder, expr, local_sym_tab, compilation_context):
|
||||
@ -544,7 +544,7 @@ def _handle_or_op(func, builder, expr, local_sym_tab, compilation_context):
|
||||
phi.add_incoming(val, block)
|
||||
|
||||
logger.debug(f"Generated 'or' with {len(incoming_values)} incoming values")
|
||||
return phi, ir.IntType(1)
|
||||
return phi, IntTy(1, False)
|
||||
|
||||
|
||||
def _handle_boolean_op(
|
||||
|
||||
Reference in New Issue
Block a user