MCPcopy
hub / github.com/python/mypy / IntOp

Class IntOp

mypyc/ir/ops.py:1410–1466  ·  view source on GitHub ↗

Binary arithmetic or bitwise op on integer operands (e.g., r1 = r2 + r3). These ops are low-level and are similar to the corresponding C operations. The left and right values must have low-level integer types with compatible representations. Fixed-width integers, short_int_rprimiti

Source from the content-addressed store, hash-verified

1408
1409@final
1410class IntOp(RegisterOp):
1411 """Binary arithmetic or bitwise op on integer operands (e.g., r1 = r2 + r3).
1412
1413 These ops are low-level and are similar to the corresponding C
1414 operations.
1415
1416 The left and right values must have low-level integer types with
1417 compatible representations. Fixed-width integers, short_int_rprimitive,
1418 bool_rprimitive and bit_rprimitive are supported.
1419
1420 For tagged (arbitrary-precision) integer ops look at mypyc.primitives.int_ops.
1421 """
1422
1423 error_kind = ERR_NEVER
1424
1425 # Arithmetic ops
1426 ADD: Final = 0
1427 SUB: Final = 1
1428 MUL: Final = 2
1429 DIV: Final = 3
1430 MOD: Final = 4
1431
1432 # Bitwise ops
1433 AND: Final = 200
1434 OR: Final = 201
1435 XOR: Final = 202
1436 LEFT_SHIFT: Final = 203
1437 RIGHT_SHIFT: Final = 204
1438
1439 op_str: Final = {
1440 ADD: "+",
1441 SUB: "-",
1442 MUL: "*",
1443 DIV: "/",
1444 MOD: "%",
1445 AND: "&",
1446 OR: "|",
1447 XOR: "^",
1448 LEFT_SHIFT: "<<",
1449 RIGHT_SHIFT: ">>",
1450 }
1451
1452 def __init__(self, type: RType, lhs: Value, rhs: Value, op: int, line: int = -1) -> None:
1453 super().__init__(line)
1454 self.type = type
1455 self.lhs = lhs
1456 self.rhs = rhs
1457 self.op = op
1458
1459 def sources(self) -> list[Value]:
1460 return [self.lhs, self.rhs]
1461
1462 def set_sources(self, new: list[Value]) -> None:
1463 self.lhs, self.rhs = new
1464
1465 def accept(self, visitor: OpVisitor[T]) -> T:
1466 return visitor.visit_int_op(self)
1467

Callers 10

vec_createFunction · 0.90
vec_item_typeFunction · 0.90
bool_bitwise_opMethod · 0.90
int_opMethod · 0.90
test_int_opMethod · 0.90
test_int_opMethod · 0.90
buf_init_itemFunction · 0.90
list_item_ptrFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_int_opMethod · 0.72
test_int_opMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…