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
| 1408 | |
| 1409 | @final |
| 1410 | class 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 |
no outgoing calls
searching dependent graphs…