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