MCPcopy Index your code
hub / github.com/python/mypy / inline_fixed_width_divide

Method inline_fixed_width_divide

mypyc/irbuild/ll_builder.py:2607–2624  ·  view source on GitHub ↗
(self, type: RType, lhs: Value, rhs: Value, line: int)

Source from the content-addressed store, hash-verified

2605 self.activate_block(ok)
2606
2607 def inline_fixed_width_divide(self, type: RType, lhs: Value, rhs: Value, line: int) -> Value:
2608 # Perform floor division (native division truncates)
2609 res = Register(type)
2610 div = self.int_op(type, lhs, rhs, IntOp.DIV, line)
2611 self.add(Assign(res, div))
2612 same_signs = self.is_same_native_int_signs(type, lhs, rhs, line)
2613 tricky, adjust, done = BasicBlock(), BasicBlock(), BasicBlock()
2614 self.add(Branch(same_signs, done, tricky, Branch.BOOL))
2615 self.activate_block(tricky)
2616 mul = self.int_op(type, res, rhs, IntOp.MUL, line)
2617 mul_eq = self.add(ComparisonOp(mul, lhs, ComparisonOp.EQ, line))
2618 self.add(Branch(mul_eq, done, adjust, Branch.BOOL))
2619 self.activate_block(adjust)
2620 adj = self.int_op(type, res, Integer(1, type), IntOp.SUB, line)
2621 self.add(Assign(res, adj))
2622 self.add(Goto(done))
2623 self.activate_block(done)
2624 return res
2625
2626 def inline_fixed_width_mod(self, type: RType, lhs: Value, rhs: Value, line: int) -> Value:
2627 # Perform floor modulus

Callers 1

fixed_width_int_opMethod · 0.95

Calls 11

int_opMethod · 0.95
addMethod · 0.95
activate_blockMethod · 0.95
RegisterClass · 0.90
AssignClass · 0.90
BasicBlockClass · 0.90
BranchClass · 0.90
ComparisonOpClass · 0.90
IntegerClass · 0.90
GotoClass · 0.90

Tested by

no test coverage detected