blob: e7fb93930aae2e287ec5af7b3f358b459676f9db [file] [log] [blame]
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001From c2a6652176751bc95e2f990179e90cfe58026feb Mon Sep 17 00:00:00 2001
Brad Bishop286d45c2018-10-02 15:21:57 -04002From: Mahesh Bodapati <mbodapat@xilinx.com>
Brad Bishop26bdd442019-08-16 17:08:17 -04003Date: Thu, 12 Jan 2017 17:36:16 +0530
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05004Subject: [PATCH 15/58] [Patch, microblaze]: Removed moddi3 routinue
5
6Using the default moddi3 function as the existing implementation has many bugs
Brad Bishop286d45c2018-10-02 15:21:57 -04007
Brad Bishop26bdd442019-08-16 17:08:17 -04008Signed-off-by:Nagaraju <nmekala@xilix.com>
Andrew Geissler84ad7c52020-06-27 00:00:16 -05009
10Conflicts:
11 libgcc/config/microblaze/moddi3.S
Brad Bishop286d45c2018-10-02 15:21:57 -040012---
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050013 libgcc/config/microblaze/moddi3.S | 121 --------------------------
Brad Bishop286d45c2018-10-02 15:21:57 -040014 libgcc/config/microblaze/t-microblaze | 3 +-
Brad Bishop26bdd442019-08-16 17:08:17 -040015 2 files changed, 1 insertion(+), 123 deletions(-)
Brad Bishop286d45c2018-10-02 15:21:57 -040016 delete mode 100644 libgcc/config/microblaze/moddi3.S
17
18diff --git a/libgcc/config/microblaze/moddi3.S b/libgcc/config/microblaze/moddi3.S
19deleted file mode 100644
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050020index d0e24fdb89d..00000000000
Brad Bishop286d45c2018-10-02 15:21:57 -040021--- a/libgcc/config/microblaze/moddi3.S
22+++ /dev/null
Brad Bishop26bdd442019-08-16 17:08:17 -040023@@ -1,121 +0,0 @@
Brad Bishop286d45c2018-10-02 15:21:57 -040024-###################################
25-#
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050026-# Copyright (C) 2009-2020 Free Software Foundation, Inc.
Brad Bishop286d45c2018-10-02 15:21:57 -040027-#
28-# Contributed by Michael Eager <eager@eagercon.com>.
29-#
30-# This file is free software; you can redistribute it and/or modify it
31-# under the terms of the GNU General Public License as published by the
32-# Free Software Foundation; either version 3, or (at your option) any
33-# later version.
34-#
35-# GCC is distributed in the hope that it will be useful, but WITHOUT
36-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
37-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
38-# License for more details.
39-#
40-# Under Section 7 of GPL version 3, you are granted additional
41-# permissions described in the GCC Runtime Library Exception, version
42-# 3.1, as published by the Free Software Foundation.
43-#
44-# You should have received a copy of the GNU General Public License and
45-# a copy of the GCC Runtime Library Exception along with this program;
46-# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
47-# <http://www.gnu.org/licenses/>.
48-#
49-# modsi3.S
50-#
51-# modulo operation for 64 bit integers.
52-#
53-#######################################
54-
55-
Brad Bishop26bdd442019-08-16 17:08:17 -040056-/* An executable stack is *not* required for these functions. */
57-#ifdef __linux__
58-.section .note.GNU-stack,"",%progbits
59-.previous
60-#endif
61-
Brad Bishop286d45c2018-10-02 15:21:57 -040062- .globl __moddi3
63- .ent __moddi3
64-__moddi3:
65- .frame r1,0,r15
66-
67-#Change the stack pointer value and Save callee saved regs
68- addik r1,r1,-24
69- swi r25,r1,0
70- swi r26,r1,4
71- swi r27,r1,8 # used for sign
72- swi r28,r1,12 # used for loop count
73- swi r29,r1,16 # Used for div value High
74- swi r30,r1,20 # Used for div value Low
75-
76-#Check for Zero Value in the divisor/dividend
77- OR r9,r5,r6 # Check for the op1 being zero
78- BEQID r9,$LaResult_Is_Zero # Result is zero
79- OR r9,r7,r8 # Check for the dividend being zero
80- BEQI r9,$LaDiv_By_Zero # Div_by_Zero # Division Error
81- BGEId r5,$La1_Pos
82- XOR r27,r5,r7 # Get the sign of the result
83- RSUBI r6,r6,0 # Make dividend positive
84- RSUBIC r5,r5,0 # Make dividend positive
85-$La1_Pos:
86- BGEI r7,$La2_Pos
87- RSUBI r8,r8,0 # Make Divisor Positive
88- RSUBIC r9,r9,0 # Make Divisor Positive
89-$La2_Pos:
90- ADDIK r4,r0,0 # Clear mod low
91- ADDIK r3,r0,0 # Clear mod high
92- ADDIK r29,r0,0 # clear div high
93- ADDIK r30,r0,0 # clear div low
94- ADDIK r28,r0,64 # Initialize the loop count
95- # First part try to find the first '1' in the r5/r6
96-$LaDIV1:
97- ADD r6,r6,r6
98- ADDC r5,r5,r5 # left shift logical r5
99- BGEID r5,$LaDIV1
100- ADDIK r28,r28,-1
101-$LaDIV2:
102- ADD r6,r6,r6
103- ADDC r5,r5,r5 # left shift logical r5/r6 get the '1' into the Carry
104- ADDC r4,r4,r4 # Move that bit into the Mod register
105- ADDC r3,r3,r3 # Move carry into high mod register
106- rsub r18,r7,r3 # Compare the High Parts of Mod and Divisor
107- bnei r18,$L_High_EQ
108- rsub r18,r6,r4 # Compare Low Parts only if Mod[h] == Divisor[h]
109-$L_High_EQ:
110- rSUB r26,r8,r4 # Subtract divisor[L] from Mod[L]
111- rsubc r25,r7,r3 # Subtract divisor[H] from Mod[H]
112- BLTi r25,$LaMOD_TOO_SMALL
113- OR r3,r0,r25 # move r25 to mod [h]
114- OR r4,r0,r26 # move r26 to mod [l]
115- ADDI r30,r30,1
116- ADDC r29,r29,r0
117-$LaMOD_TOO_SMALL:
118- ADDIK r28,r28,-1
119- BEQi r28,$LaLOOP_END
120- ADD r30,r30,r30 # Shift in the '1' into div [low]
121- ADDC r29,r29,r29 # Move the carry generated into high
122- BRI $LaDIV2 # Div2
123-$LaLOOP_END:
124- BGEI r27,$LaRETURN_HERE
125- rsubi r30,r30,0
126- rsubc r29,r29,r0
127- BRI $LaRETURN_HERE
128-$LaDiv_By_Zero:
129-$LaResult_Is_Zero:
130- or r29,r0,r0 # set result to 0 [High]
131- or r30,r0,r0 # set result to 0 [Low]
132-$LaRETURN_HERE:
133-# Restore values of CSRs and that of r29 and the divisor and the dividend
134-
135- lwi r25,r1,0
136- lwi r26,r1,4
137- lwi r27,r1,8
138- lwi r28,r1,12
139- lwi r29,r1,16
140- lwi r30,r1,20
141- rtsd r15,8
142- addik r1,r1,24
143- .end __moddi3
144-
145diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
Andrew Geisslera9ff2b32020-10-16 10:11:54 -0500146index 96959f0292b..8d954a49575 100644
Brad Bishop286d45c2018-10-02 15:21:57 -0400147--- a/libgcc/config/microblaze/t-microblaze
148+++ b/libgcc/config/microblaze/t-microblaze
149@@ -1,8 +1,7 @@
150-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _moddi3 _mulsi3 _udivsi3 _umodsi3
151+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
152
153 LIB2ADD += \
154 $(srcdir)/config/microblaze/divsi3.S \
155- $(srcdir)/config/microblaze/moddi3.S \
156 $(srcdir)/config/microblaze/modsi3.S \
157 $(srcdir)/config/microblaze/muldi3_hard.S \
158 $(srcdir)/config/microblaze/mulsi3.S \
159--
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001602.17.1
Brad Bishop286d45c2018-10-02 15:21:57 -0400161