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_ciENTRY(__c6xabi_divi) 278c2ecf20Sopenharmony_ci call .s2 __c6xabi_divu 288c2ecf20Sopenharmony_ci|| mv .d2 B3, B5 298c2ecf20Sopenharmony_ci|| cmpgt .l1 0, A4, A1 308c2ecf20Sopenharmony_ci|| cmpgt .l2 0, B4, B1 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci [A1] neg .l1 A4, A4 338c2ecf20Sopenharmony_ci|| [B1] neg .l2 B4, B4 348c2ecf20Sopenharmony_ci|| xor .s1x A1, B1, A1 358c2ecf20Sopenharmony_ci [A1] addkpc .s2 _divu_ret, B3, 4 368c2ecf20Sopenharmony_ci_divu_ret: 378c2ecf20Sopenharmony_ci neg .l1 A4, A4 388c2ecf20Sopenharmony_ci|| mv .l2 B3,B5 398c2ecf20Sopenharmony_ci|| ret .s2 B5 408c2ecf20Sopenharmony_ci nop 5 418c2ecf20Sopenharmony_ciENDPROC(__c6xabi_divi) 42