OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [picochip/] [libgccExtras/] [udivmodsi4.asm] - Blame information for rev 301

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
// picoChip ASM file
2
//
3
//   Support for 32-bit unsigned division/modulus.
4
//
5
//   Copyright (C) 2003, 2004, 2005, 2008, 2009  Free Software Foundation, Inc.
6
//   Contributed by picoChip Designs Ltd.
7
//   Maintained by Daniel Towner (daniel.towner@picochip.com)
8
//
9
//   This file is free software; you can redistribute it and/or modify it
10
//   under the terms of the GNU General Public License as published by the
11
//   Free Software Foundation; either version 3, or (at your option) any
12
//   later version.
13
//
14
//   This file is distributed in the hope that it will be useful, but
15
//   WITHOUT ANY WARRANTY; without even the implied warranty of
16
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
//   General Public License for more details.
18
//
19
//   Under Section 7 of GPL version 3, you are granted additional
20
//   permissions described in the GCC Runtime Library Exception, version
21
//   3.1, as published by the Free Software Foundation.
22
//
23
//   You should have received a copy of the GNU General Public License and
24
//   a copy of the GCC Runtime Library Exception along with this program;
25
//   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
26
//   .
27
 
28
.section .text
29
 
30
.align 8
31
.global __udivmodsi4
32
__udivmodsi4:
33
_picoMark_FUNCTION_BEGIN=
34
// picoChip Function Prologue : &__udivmodsi4 = 24 bytes
35
 
36
        // Schedule the register saves alongside the special cases, so that
37
        // if the special cases fail, the registers will have already
38
        // been stored onto the stack.
39
        SUB.0 R3,R1,r15 \ STL R[13:12],(FP)-1
40
        BHS skipCommonCase \ STL R[9:8],(FP)-4
41
=->     SUB.0 R2,1,r15 \ STL R[11:10],(FP)-3
42
 
43
_L2:
44
        // Flags set above, and in _L2 caller.
45
        BNE restOfCode
46
=->     SUB.0 R3,0,r15
47
        BNE restOfCode
48
=->     COPY.0 R0,R4 \ COPY.1 R1,R5
49
        JR (R12)        // Return to caller
50
=->     COPY.0 0,R6 \ COPY.1 0,R7
51
        // Never reach here
52
 
53
skipCommonCase:
54
        SUB.0 R3,R1,r15
55
        BNE _L3 // (Reversed branch)
56
=->     SUB.0 R2,R0,r15 // Must be set in delay slot, so ready by _L9
57
 
58
_L9:
59
        BLO _L2 // (Reversed branch)
60
=->     SUB.0 R2,1,r15
61
 
62
_L3:
63
        SUB.0 R2,R0,r15
64
        BEQ _L10        // (Reversed branch)
65
=->     SUB.0 R1,R3,r15 // Set flags for branch at _L10
66
 
67
_L4:
68
        // greater than
69
        COPY.0 0,R4 \ COPY.1 0,R5 \ JR (R12)    // Return to caller
70
=->     COPY.0 R0,R6 \ COPY.1 R1,R7
71
        // Doesn't reach here.
72
 
73
_L10:
74
        // Flags set in _L10 call delay slot.
75
        BNE _L4
76
=->     COPY.0 1,R4 \ COPY.1 0,R5
77
        JR (R12)        // Return to caller
78
=->     COPY.0 0,R6 \ COPY.1 0,R7
79
 
80
restOfCode:
81
 
82
// Prologue
83
 
84
        // Register saves scheduled alongside special cases above.
85
        ADD.0 FP,-20,FP \ STW R14,(FP)-4
86
 
87
        // The following can be scheduled together.
88
        // dividend in R[9:8] (from R[1:0])
89
        // divisor in R[7:6] (from R[3:2])
90
        // R14 := clzsi2 (dividend)
91
        // R0 := clzsi2 (divisor)
92
        JL (&__clzsi2) \ COPY.0 R0,R8 \ COPY.1 R1,R9
93
=->     COPY.0 R2,R6 \ COPY.1 R3,R7
94
        COPY.0 R0,R14 \ JL (&__clzsi2)
95
=->     COPY.0 R6,R0 \ COPY.1 R7,R1
96
 
97
        // R14 := R0 - R14
98
        SUB.0 R0,R14,R14
99
 
100
        ADD.0 R14,1,R0  // R0 := R14 + 1 (HI)
101
 
102
        // R[11:10] = R[7,6] << R14
103
        SUB.0 15,R14,r15
104
        LSL.0 R6,R14,R11 \ BLT setupDivstepLoop
105
=->     SUB.0 0,R14,R4 \ COPY.1 0,R10
106
 
107
        // Zero shift is a special case. Shifting by zero within a 16-bit
108
        // source object is fine, but don't execute the OR of the right-shift
109
        // into the final result.
110
        LSL.0 R7,R14,R11 \ BEQ setupDivstepLoop
111
=->     LSL.0 R6,R14,R10
112
 
113
        LSR.0 R6,R4,R4
114
        OR.0 R11,R4,R11
115
 
116
setupDivstepLoop:
117
 
118
        // R[5:4] := R[9:8] (SI)
119
        COPY.0 R8,R4 \ COPY.1 R9,R5
120
        COPY.0 0,R6 \ COPY.1 R0,R8
121
 
122
        // Store original value of loopCount for use after the loop.
123
        // The Subtraction is handled in the tail of the loop iteration
124
        // after this point.
125
        SUB.0 R4,R10,R0 \ COPY.1 R8,R14
126
 
127
        // workingResult in R4,5,6
128
        // temps in r0,1,2 and r7
129
        // alignedDivisor in R10,11
130
        // loopCount in r8
131
        // r3, r9 scratch, used for renaming.
132
 
133
loopStart:
134
        // R0 := R4 - zeroExtend (R10) - only need 33-bits (i.e., 48-bits)
135
        SUBB.0 R5,R11,R1 \ LSR.1 R0,15,R3
136
        SUBB.0 R6,0,R2 \ LSR.1 R1,15,R6
137
 
138
        // if (carry) goto shiftOnly
139
        SUB.0 R8,1,R8 \ BNE shiftOnly
140
=->     LSR.0 R4,15,R7 \ LSL.1 R1,1,R9
141
 
142
        OR.0 [LSL R0,1],1,R4 \ BNE loopStart
143
=->     SUB.0 R4,R10,R0 \ OR.1 R9,R3,R5
144
 
145
        BRA loopEnd
146
 
147
shiftOnly:
148
 
149
        OR.0 [LSL R5,1],R7,R5 \ BNE loopStart \ LSR.1 R5,15,R6
150
=->     SUB.0 [LSL R4,1],R10,R0 \LSL.1 R4,1,R4
151
 
152
// End of loop
153
loopEnd:
154
 
155
        // Schedule the computation of the upper word after shifting
156
        // alongside the decision over whether to branch, and the register
157
        // restores.
158
        // R10 is filled with a useful constant.
159
        SUB.0 15,r14,r15 \ LDL (FP)4,R[13:12]
160
        SUB.1 0,R14,R1 // Don't set flags!
161
        LSL.0 R6,R1,R3 \ LDL (FP)-4,R[9:8]
162
 
163
        BLT remainderHasMoreThan16Bits \ LSR.0 R5,R14,R7 \ COPY.1 -1,R10
164
=->     LSL.0 R5,R1,R2 \ OR.1 R7,R3,R3
165
 
166
        LSR.0 R4,R14,R3 \ COPY.1 R3,R7
167
        BRA epilogue \ LSR.0 -1,R1,R0 \ COPY.1 0,R5
168
=->     OR.0 R3,R2,R6 \ AND.1 R0,R4,R4
169
 
170
remainderHasMoreThan16Bits:
171
 
172
        LSL.0 R10,R14,R1 \ COPY.1 R3,R6
173
        XOR.0 R10,R1,R1 \ COPY.1 0,R7
174
        AND.0 R1,R5,R5
175
 
176
epilogue:
177
 
178
        JR (R12) \ LDW (FP)-4,R14
179
=->     LDL (FP)-3,R[11:10]
180
 
181
_picoMark_FUNCTION_END=
182
 
183
// picoChip Function Epilogue : udivmodsi4
184
 
185
//============================================================================
186
// All DWARF information between this marker, and the END OF DWARF
187
// marker should be included in the source file. Search for
188
// FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
189
// provide the relevent information. Add markers called
190
// _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
191
// function in question.
192
//============================================================================
193
 
194
//============================================================================
195
// Frame information.
196
//============================================================================
197
 
198
.section .debug_frame
199
_picoMark_DebugFrame=
200
 
201
// Common CIE header.
202
.unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
203
_picoMark_CieBegin=
204
.unalignedInitLong 0xffffffff
205
.initByte 0x1   // CIE Version
206
.ascii 16#0#    // CIE Augmentation
207
.uleb128 0x1    // CIE Code Alignment Factor
208
.sleb128 2      // CIE Data Alignment Factor
209
.initByte 0xc   // CIE RA Column
210
.initByte 0xc   // DW_CFA_def_cfa
211
.uleb128 0xd
212
.uleb128 0x0
213
.align 2
214
_picoMark_CieEnd=
215
 
216
// FDE
217
_picoMark_LSFDE0I900821033007563=
218
.unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
219
_picoMark_FdeBegin=
220
.unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
221
.unalignedInitWord _picoMark_FUNCTION_BEGIN     // FDE initial location
222
.unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
223
.initByte 0xe   // DW_CFA_def_cfa_offset
224
.uleb128 0x18   // <-- FUNCTION_STACK_SIZE_GOES_HERE
225
.initByte 0x4   // DW_CFA_advance_loc4
226
.unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
227
.initByte 0xe   // DW_CFA_def_cfa_offset
228
.uleb128 0x0
229
.align 2
230
_picoMark_FdeEnd=
231
 
232
//============================================================================
233
// Abbrevation information.
234
//============================================================================
235
 
236
.section .debug_abbrev
237
_picoMark_ABBREVIATIONS=
238
 
239
.section .debug_abbrev
240
        .uleb128 0x1    // (abbrev code)
241
        .uleb128 0x11   // (TAG: DW_TAG_compile_unit)
242
        .initByte 0x1   // DW_children_yes
243
        .uleb128 0x10   // (DW_AT_stmt_list)
244
        .uleb128 0x6    // (DW_FORM_data4)
245
        .uleb128 0x12   // (DW_AT_high_pc)
246
        .uleb128 0x1    // (DW_FORM_addr)
247
        .uleb128 0x11   // (DW_AT_low_pc)
248
        .uleb128 0x1    // (DW_FORM_addr)
249
        .uleb128 0x25   // (DW_AT_producer)
250
        .uleb128 0x8    // (DW_FORM_string)
251
        .uleb128 0x13   // (DW_AT_language)
252
        .uleb128 0x5    // (DW_FORM_data2)
253
        .uleb128 0x3    // (DW_AT_name)
254
        .uleb128 0x8    // (DW_FORM_string)
255
.initByte 0x0
256
.initByte 0x0
257
 
258
        .uleb128 0x2    ;# (abbrev code)
259
        .uleb128 0x2e   ;# (TAG: DW_TAG_subprogram)
260
.initByte 0x0   ;# DW_children_no
261
        .uleb128 0x3    ;# (DW_AT_name)
262
        .uleb128 0x8    ;# (DW_FORM_string)
263
        .uleb128 0x11   ;# (DW_AT_low_pc)
264
        .uleb128 0x1    ;# (DW_FORM_addr)
265
        .uleb128 0x12   ;# (DW_AT_high_pc)
266
        .uleb128 0x1    ;# (DW_FORM_addr)
267
.initByte 0x0
268
.initByte 0x0
269
 
270
.initByte 0x0
271
 
272
//============================================================================
273
// Line information. DwarfLib requires this to be present, but it can
274
// be empty.
275
//============================================================================
276
 
277
.section .debug_line
278
_picoMark_LINES=
279
 
280
//============================================================================
281
// Debug Information
282
//============================================================================
283
.section .debug_info
284
 
285
//Fixed header.
286
.unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
287
_picoMark_DEBUG_INFO_BEGIN=
288
.unalignedInitWord 0x2
289
.unalignedInitLong _picoMark_ABBREVIATIONS
290
.initByte 0x2
291
 
292
// Compile unit information.
293
.uleb128 0x1    // (DIE 0xb) DW_TAG_compile_unit)
294
.unalignedInitLong _picoMark_LINES
295
.unalignedInitWord _picoMark_FUNCTION_END
296
.unalignedInitWord _picoMark_FUNCTION_BEGIN
297
// Producer is `picoChip'
298
.ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
299
.unalignedInitWord 0xcafe // ASM language
300
.ascii 16#0# // Name. DwarfLib expects this to be present.
301
 
302
.uleb128 0x2    ;# (DIE DW_TAG_subprogram)
303
 
304
// FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
305
// digit is specified using the format 16#XX#
306
.ascii 16#5f# 16#75# 16#64# 16#69# 16#76# 16#6d# 16#6f# 16#64# 16#73# 16#69# 16#34# 16#0# // Function name `_udivmodsi4'
307
.unalignedInitWord _picoMark_FUNCTION_BEGIN     // DW_AT_low_pc
308
.unalignedInitWord _picoMark_FUNCTION_END       // DW_AT_high_pc
309
 
310
.initByte 0x0   // end of compile unit children.
311
 
312
_picoMark_DEBUG_INFO_END=
313
 
314
//============================================================================
315
// END OF DWARF
316
//============================================================================
317
.section .endFile
318
// End of picoChip ASM file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.