18c2ecf20Sopenharmony_ci;; SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci;; Copyright 2010 Free Software Foundation, Inc. 38c2ecf20Sopenharmony_ci;; Contributed by Bernd Schmidt <bernds@codesourcery.com>. 48c2ecf20Sopenharmony_ci;; 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/linkage.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci ;; ABI considerations for the divide functions 98c2ecf20Sopenharmony_ci ;; The following registers are call-used: 108c2ecf20Sopenharmony_ci ;; __c6xabi_divi A0,A1,A2,A4,A6,B0,B1,B2,B4,B5 118c2ecf20Sopenharmony_ci ;; __c6xabi_divu A0,A1,A2,A4,A6,B0,B1,B2,B4 128c2ecf20Sopenharmony_ci ;; __c6xabi_remi A1,A2,A4,A5,A6,B0,B1,B2,B4 138c2ecf20Sopenharmony_ci ;; __c6xabi_remu A1,A4,A5,A7,B0,B1,B2,B4 148c2ecf20Sopenharmony_ci ;; 158c2ecf20Sopenharmony_ci ;; In our implementation, divu and remu are leaf functions, 168c2ecf20Sopenharmony_ci ;; while both divi and remi call into divu. 178c2ecf20Sopenharmony_ci ;; A0 is not clobbered by any of the functions. 188c2ecf20Sopenharmony_ci ;; divu does not clobber B2 either, which is taken advantage of 198c2ecf20Sopenharmony_ci ;; in remi. 208c2ecf20Sopenharmony_ci ;; divi uses B5 to hold the original return address during 218c2ecf20Sopenharmony_ci ;; the call to divu. 228c2ecf20Sopenharmony_ci ;; remi uses B2 and A5 to hold the input values during the 238c2ecf20Sopenharmony_ci ;; call to divu. It stores B3 in on the stack. 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci .text 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciENTRY(__c6xabi_remi) 288c2ecf20Sopenharmony_ci stw .d2t2 B3, *B15--[2] 298c2ecf20Sopenharmony_ci|| cmpgt .l1 0, A4, A1 308c2ecf20Sopenharmony_ci|| cmpgt .l2 0, B4, B2 318c2ecf20Sopenharmony_ci|| mv .s1 A4, A5 328c2ecf20Sopenharmony_ci|| call .s2 __c6xabi_divu 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci [A1] neg .l1 A4, A4 358c2ecf20Sopenharmony_ci|| [B2] neg .l2 B4, B4 368c2ecf20Sopenharmony_ci|| xor .s2x B2, A1, B0 378c2ecf20Sopenharmony_ci|| mv .d2 B4, B2 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci [B0] addkpc .s2 _divu_ret_1, B3, 1 408c2ecf20Sopenharmony_ci [!B0] addkpc .s2 _divu_ret_2, B3, 1 418c2ecf20Sopenharmony_ci nop 2 428c2ecf20Sopenharmony_ci_divu_ret_1: 438c2ecf20Sopenharmony_ci neg .l1 A4, A4 448c2ecf20Sopenharmony_ci_divu_ret_2: 458c2ecf20Sopenharmony_ci ldw .d2t2 *++B15[2], B3 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci mpy32 .m1x A4, B2, A6 488c2ecf20Sopenharmony_ci nop 3 498c2ecf20Sopenharmony_ci ret .s2 B3 508c2ecf20Sopenharmony_ci sub .l1 A5, A6, A4 518c2ecf20Sopenharmony_ci nop 4 528c2ecf20Sopenharmony_ciENDPROC(__c6xabi_remi) 53