(self, type: RType, lhs: Value, rhs: Value, line: int)
| 2624 | return res |
| 2625 | |
| 2626 | def inline_fixed_width_mod(self, type: RType, lhs: Value, rhs: Value, line: int) -> Value: |
| 2627 | # Perform floor modulus |
| 2628 | res = Register(type) |
| 2629 | mod = self.int_op(type, lhs, rhs, IntOp.MOD, line) |
| 2630 | self.add(Assign(res, mod)) |
| 2631 | same_signs = self.is_same_native_int_signs(type, lhs, rhs, line) |
| 2632 | tricky, adjust, done = BasicBlock(), BasicBlock(), BasicBlock() |
| 2633 | self.add(Branch(same_signs, done, tricky, Branch.BOOL)) |
| 2634 | self.activate_block(tricky) |
| 2635 | is_zero = self.add(ComparisonOp(res, Integer(0, type), ComparisonOp.EQ, line)) |
| 2636 | self.add(Branch(is_zero, done, adjust, Branch.BOOL)) |
| 2637 | self.activate_block(adjust) |
| 2638 | adj = self.int_op(type, res, rhs, IntOp.ADD, line) |
| 2639 | self.add(Assign(res, adj)) |
| 2640 | self.add(Goto(done)) |
| 2641 | self.activate_block(done) |
| 2642 | return res |
| 2643 | |
| 2644 | def is_same_native_int_signs(self, type: RType, a: Value, b: Value, line: int) -> Value: |
| 2645 | neg1 = self.add(ComparisonOp(a, Integer(0, type), ComparisonOp.SLT, line)) |
no test coverage detected