2006-07-05

__divsi3

When we hacking C code, found that c code in the disassembly window, the for() loop was be translated to __divsi3. Thus, we hacking the "__divsi3" in the cygwin.

After I hacked the gcc-core source code, at gcc-4.1.1/gcc/config/ia64/lib1funcs.asm, as below:


---

#ifdef L__divsi3
// Compute a 32-bit integer quotient.
//
// From the Intel IA-64 Optimization Guide, choose the minimum latency
// alternative.
//
// in0 holds the dividend. in1 holds the divisor.

.text
.align 16
.global __divsi3
.proc __divsi3
__divsi3:
.regstk 2,0,0,0
// Check divide by zero.
cmp.ne.unc p0,p7=0,in1
sxt4 in0 = in0
sxt4 in1 = in1
;;
setf.sig f8 = in0
setf.sig f9 = in1
(p7) break 1
;;
mov r2 = 0x0ffdd
fcvt.xf f8 = f8
fcvt.xf f9 = f9
;;
setf.exp f11 = r2
frcpa.s1 f10, p6 = f8, f9
;;
(p6) fmpy.s1 f8 = f8, f10
(p6) fnma.s1 f9 = f9, f10, f1
;;
(p6) fma.s1 f8 = f9, f8, f8
(p6) fma.s1 f9 = f9, f9, f11
;;
(p6) fma.s1 f10 = f9, f8, f8
;;
fcvt.fx.trunc.s1 f10 = f10
;;
getf.sig ret0 = f10
br.ret.sptk rp
;;
.endp __divsi3
#endif

---

Inside of the "config" sub-directory, there has more plaform implement the __divsi3 function. Thus, many platform need the function, but used different their assembly instruction.

--
a2n@ubuntu-en:config$ grep -r "__divsi3" *
alpha/alpha.c: /* Prevent gcc from generating calls to __divsi3. */
arc/lib1funcs.asm: .global ___divsi3
arc/lib1funcs.asm:___divsi3:
arm/lib1funcs.asm: bl SYM(__divsi3)
arm/lib1funcs.asm: bl SYM(__divsi3)
bfin/lib1funcs.asm:.global ___divsi3;
bfin/lib1funcs.asm:.type ___divsi3, STT_FUNC;
bfin/lib1funcs.asm:___divsi3:
bfin/lib1funcs.asm: CALL ___divsi3;
divmod.c:__divsi3 (long a, long b)
h8300/lib1funcs.asm: .global ___divsi3
h8300/lib1funcs.asm:___divsi3:
h8300/h8300.c: "__divsi3",
ia64/lib1funcs.asm:#ifdef L__divsi3
ia64/lib1funcs.asm: .global __divsi3
ia64/lib1funcs.asm: .proc __divsi3
ia64/lib1funcs.asm:__divsi3:
ia64/lib1funcs.asm: .endp __divsi3
ia64/ia64.c: set_optab_libfunc (sdiv_optab, SImode, "__divsi3");
ia64/t-ia64: __divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal m32c/m32c-lib2.c:SItype __divsi3 (SItype a, SItype b);
m32c/m32c-lib2.c:__divsi3 (SItype a, SItype b)
m68k/lb1sf68.asm: .globl SYM (__divsi3)
m68k/lb1sf68.asm:SYM (__divsi3):
m68k/lb1sf68.asm: PICCALL SYM (__divsi3)
mt/lib2extra-funcs.c:__divsi3 (SItype a, SItype b)
stormy16/stormy16-lib2.c:extern SItype __divsi3 (SItype, SItype);
stormy16/stormy16-lib2.c:__divsi3 (SItype a, SItype b)
v850/lib1funcs.asm: .globl ___divsi3
v850/lib1funcs.asm: .type ___divsi3,@function
v850/lib1funcs.asm:___divsi3:
v850/lib1funcs.asm: .size ___divsi3,.-___divsi3
v850/lib1funcs.asm: jarl ___divsi3,r31
xtensa/lib1funcs.asm: .global __divsi3
xtensa/lib1funcs.asm: .type __divsi3,@function
xtensa/lib1funcs.asm:__divsi3:
xtensa/lib1funcs.asm: .size __divsi3,.-__divsi3
--

沒有留言: