| //===------------ mulhi3.S - int16 multiplication -------------------------===// |
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| // See https://llvm.org/LICENSE.txt for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| //===----------------------------------------------------------------------===// |
| // The corresponding C code is something like: |
| // int __mulhi3(int A, int B) { |
| // A = ((unsigned int) A) >> 1; |
| // __mulhi3 has special ABI, as the implementation of libgcc, R25:R24 is used |
| // to return result, while Rtmp/R21/R22/R23 are clobbered. |
| //===----------------------------------------------------------------------===// |
| .type __mulhi3, @function |
| ; Use Rzero:Rtmp to store the result. |
| clr __zero_reg__ ; S = 0; |
| breq __mulhi3_end ; while (A != 0) { |
| breq __mulhi3_loop_a ; if (A & 1) |
| adc __zero_reg__, r23 ; S += B; |
| ror r24 ; A = ((unsigned int) A) >> 1; |
| ; Return the result via R25:R24. |
| ; Restore __zero_reg__ to 0. |