OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc2/] [gcc/] [config/] [mcore/] [lib1.asm] - Diff between revs 282 and 384

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 282 Rev 384
/* libgcc routines for the MCore.
/* libgcc routines for the MCore.
   Copyright (C) 1993, 1999, 2000, 2009 Free Software Foundation, Inc.
   Copyright (C) 1993, 1999, 2000, 2009 Free Software Foundation, Inc.
This file is part of GCC.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
Free Software Foundation; either version 3, or (at your option) any
later version.
later version.
This file is distributed in the hope that it will be useful, but
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
.  */
.  */
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
#define CONCAT2(a, b) a ## b
/* Use the right prefix for global labels.  */
/* Use the right prefix for global labels.  */
#define SYM(x) CONCAT1 (__, x)
#define SYM(x) CONCAT1 (__, x)
#ifdef __ELF__
#ifdef __ELF__
#define TYPE(x) .type SYM (x),@function
#define TYPE(x) .type SYM (x),@function
#define SIZE(x) .size SYM (x), . - SYM (x)
#define SIZE(x) .size SYM (x), . - SYM (x)
#else
#else
#define TYPE(x)
#define TYPE(x)
#define SIZE(x)
#define SIZE(x)
#endif
#endif
.macro FUNC_START name
.macro FUNC_START name
        .text
        .text
        .globl SYM (\name)
        .globl SYM (\name)
        TYPE (\name)
        TYPE (\name)
SYM (\name):
SYM (\name):
.endm
.endm
.macro FUNC_END name
.macro FUNC_END name
        SIZE (\name)
        SIZE (\name)
.endm
.endm
#ifdef  L_udivsi3
#ifdef  L_udivsi3
FUNC_START udiv32
FUNC_START udiv32
FUNC_START udivsi32
FUNC_START udivsi32
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        cmpnei  r3,0            // look for 0 divisor
        cmpnei  r3,0            // look for 0 divisor
        bt      9f
        bt      9f
        trap    3               // divide by 0
        trap    3               // divide by 0
9:
9:
        // control iterations; skip across high order 0 bits in dividend
        // control iterations; skip across high order 0 bits in dividend
        mov     r7,r2
        mov     r7,r2
        cmpnei  r7,0
        cmpnei  r7,0
        bt      8f
        bt      8f
        movi    r2,0            // 0 dividend
        movi    r2,0            // 0 dividend
        jmp     r15             // quick return
        jmp     r15             // quick return
8:
8:
        ff1     r7              // figure distance to skip
        ff1     r7              // figure distance to skip
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r2,r7           // and the low 32 bits of numerator
        lsl     r2,r7           // and the low 32 bits of numerator
// appears to be wrong...
// appears to be wrong...
// tested out incorrectly in our OS work...
// tested out incorrectly in our OS work...
//      mov     r7,r3           // looking at divisor
//      mov     r7,r3           // looking at divisor
//      ff1     r7              // I can move 32-r7 more bits to left.
//      ff1     r7              // I can move 32-r7 more bits to left.
//      addi    r7,1            // ok, one short of that...
//      addi    r7,1            // ok, one short of that...
//      mov     r1,r2
//      mov     r1,r2
//      lsr     r1,r7           // bits that came from low order...
//      lsr     r1,r7           // bits that came from low order...
//      rsubi   r7,31           // r7 == "32-n" == LEFT distance
//      rsubi   r7,31           // r7 == "32-n" == LEFT distance
//      addi    r7,1            // this is (32-n)
//      addi    r7,1            // this is (32-n)
//      lsl     r4,r7           // fixes the high 32 (quotient)
//      lsl     r4,r7           // fixes the high 32 (quotient)
//      lsl     r2,r7
//      lsl     r2,r7
//      cmpnei  r4,0
//      cmpnei  r4,0
//      bf      4f              // the sentinel went away...
//      bf      4f              // the sentinel went away...
        // run the remaining bits
        // run the remaining bits
1:      lslc    r2,1            // 1 bit left shift of r1-r2
1:      lslc    r2,1            // 1 bit left shift of r1-r2
        addc    r1,r1
        addc    r1,r1
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        bf      2f
        bf      2f
        sub     r1,r3           // if yes, subtract divisor
        sub     r1,r3           // if yes, subtract divisor
2:      addc    r4,r4           // shift by 1 and count subtracts
2:      addc    r4,r4           // shift by 1 and count subtracts
        bf      1b              // if sentinel falls out of quotient, stop
        bf      1b              // if sentinel falls out of quotient, stop
4:      mov     r2,r4           // return quotient
4:      mov     r2,r4           // return quotient
        mov     r3,r1           // and piggyback the remainder
        mov     r3,r1           // and piggyback the remainder
        jmp     r15
        jmp     r15
FUNC_END udiv32
FUNC_END udiv32
FUNC_END udivsi32
FUNC_END udivsi32
#endif
#endif
#ifdef  L_umodsi3
#ifdef  L_umodsi3
FUNC_START urem32
FUNC_START urem32
FUNC_START umodsi3
FUNC_START umodsi3
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        cmpnei  r3,0            // look for 0 divisor
        cmpnei  r3,0            // look for 0 divisor
        bt      9f
        bt      9f
        trap    3               // divide by 0
        trap    3               // divide by 0
9:
9:
        // control iterations; skip across high order 0 bits in dividend
        // control iterations; skip across high order 0 bits in dividend
        mov     r7,r2
        mov     r7,r2
        cmpnei  r7,0
        cmpnei  r7,0
        bt      8f
        bt      8f
        movi    r2,0            // 0 dividend
        movi    r2,0            // 0 dividend
        jmp     r15             // quick return
        jmp     r15             // quick return
8:
8:
        ff1     r7              // figure distance to skip
        ff1     r7              // figure distance to skip
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r2,r7           // and the low 32 bits of numerator
        lsl     r2,r7           // and the low 32 bits of numerator
1:      lslc    r2,1            // 1 bit left shift of r1-r2
1:      lslc    r2,1            // 1 bit left shift of r1-r2
        addc    r1,r1
        addc    r1,r1
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        bf      2f
        bf      2f
        sub     r1,r3           // if yes, subtract divisor
        sub     r1,r3           // if yes, subtract divisor
2:      addc    r4,r4           // shift by 1 and count subtracts
2:      addc    r4,r4           // shift by 1 and count subtracts
        bf      1b              // if sentinel falls out of quotient, stop
        bf      1b              // if sentinel falls out of quotient, stop
        mov     r2,r1           // return remainder
        mov     r2,r1           // return remainder
        jmp     r15
        jmp     r15
FUNC_END urem32
FUNC_END urem32
FUNC_END umodsi3
FUNC_END umodsi3
#endif
#endif
#ifdef  L_divsi3
#ifdef  L_divsi3
FUNC_START div32
FUNC_START div32
FUNC_START divsi3
FUNC_START divsi3
        mov     r5,r2           // calc sign of quotient
        mov     r5,r2           // calc sign of quotient
        xor     r5,r3
        xor     r5,r3
        abs     r2              // do unsigned divide
        abs     r2              // do unsigned divide
        abs     r3
        abs     r3
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        cmpnei  r3,0            // look for 0 divisor
        cmpnei  r3,0            // look for 0 divisor
        bt      9f
        bt      9f
        trap    3               // divide by 0
        trap    3               // divide by 0
9:
9:
        // control iterations; skip across high order 0 bits in dividend
        // control iterations; skip across high order 0 bits in dividend
        mov     r7,r2
        mov     r7,r2
        cmpnei  r7,0
        cmpnei  r7,0
        bt      8f
        bt      8f
        movi    r2,0            // 0 dividend
        movi    r2,0            // 0 dividend
        jmp     r15             // quick return
        jmp     r15             // quick return
8:
8:
        ff1     r7              // figure distance to skip
        ff1     r7              // figure distance to skip
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r2,r7           // and the low 32 bits of numerator
        lsl     r2,r7           // and the low 32 bits of numerator
// tested out incorrectly in our OS work...
// tested out incorrectly in our OS work...
//      mov     r7,r3           // looking at divisor
//      mov     r7,r3           // looking at divisor
//      ff1     r7              // I can move 32-r7 more bits to left.
//      ff1     r7              // I can move 32-r7 more bits to left.
//      addi    r7,1            // ok, one short of that...
//      addi    r7,1            // ok, one short of that...
//      mov     r1,r2
//      mov     r1,r2
//      lsr     r1,r7           // bits that came from low order...
//      lsr     r1,r7           // bits that came from low order...
//      rsubi   r7,31           // r7 == "32-n" == LEFT distance
//      rsubi   r7,31           // r7 == "32-n" == LEFT distance
//      addi    r7,1            // this is (32-n)
//      addi    r7,1            // this is (32-n)
//      lsl     r4,r7           // fixes the high 32 (quotient)
//      lsl     r4,r7           // fixes the high 32 (quotient)
//      lsl     r2,r7
//      lsl     r2,r7
//      cmpnei  r4,0
//      cmpnei  r4,0
//      bf      4f              // the sentinel went away...
//      bf      4f              // the sentinel went away...
        // run the remaining bits
        // run the remaining bits
1:      lslc    r2,1            // 1 bit left shift of r1-r2
1:      lslc    r2,1            // 1 bit left shift of r1-r2
        addc    r1,r1
        addc    r1,r1
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        bf      2f
        bf      2f
        sub     r1,r3           // if yes, subtract divisor
        sub     r1,r3           // if yes, subtract divisor
2:      addc    r4,r4           // shift by 1 and count subtracts
2:      addc    r4,r4           // shift by 1 and count subtracts
        bf      1b              // if sentinel falls out of quotient, stop
        bf      1b              // if sentinel falls out of quotient, stop
4:      mov     r2,r4           // return quotient
4:      mov     r2,r4           // return quotient
        mov     r3,r1           // piggyback the remainder
        mov     r3,r1           // piggyback the remainder
        btsti   r5,31           // after adjusting for sign
        btsti   r5,31           // after adjusting for sign
        bf      3f
        bf      3f
        rsubi   r2,0
        rsubi   r2,0
        rsubi   r3,0
        rsubi   r3,0
3:      jmp     r15
3:      jmp     r15
FUNC_END div32
FUNC_END div32
FUNC_END divsi3
FUNC_END divsi3
#endif
#endif
#ifdef  L_modsi3
#ifdef  L_modsi3
FUNC_START rem32
FUNC_START rem32
FUNC_START modsi3
FUNC_START modsi3
        mov     r5,r2           // calc sign of remainder
        mov     r5,r2           // calc sign of remainder
        abs     r2              // do unsigned divide
        abs     r2              // do unsigned divide
        abs     r3
        abs     r3
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r1,0            // r1-r2 form 64 bit dividend
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        movi    r4,1            // r4 is quotient (1 for a sentinel)
        cmpnei  r3,0            // look for 0 divisor
        cmpnei  r3,0            // look for 0 divisor
        bt      9f
        bt      9f
        trap    3               // divide by 0
        trap    3               // divide by 0
9:
9:
        // control iterations; skip across high order 0 bits in dividend
        // control iterations; skip across high order 0 bits in dividend
        mov     r7,r2
        mov     r7,r2
        cmpnei  r7,0
        cmpnei  r7,0
        bt      8f
        bt      8f
        movi    r2,0            // 0 dividend
        movi    r2,0            // 0 dividend
        jmp     r15             // quick return
        jmp     r15             // quick return
8:
8:
        ff1     r7              // figure distance to skip
        ff1     r7              // figure distance to skip
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r4,r7           // move the sentinel along (with 0's behind)
        lsl     r2,r7           // and the low 32 bits of numerator
        lsl     r2,r7           // and the low 32 bits of numerator
1:      lslc    r2,1            // 1 bit left shift of r1-r2
1:      lslc    r2,1            // 1 bit left shift of r1-r2
        addc    r1,r1
        addc    r1,r1
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        cmphs   r1,r3           // upper 32 of dividend >= divisor?
        bf      2f
        bf      2f
        sub     r1,r3           // if yes, subtract divisor
        sub     r1,r3           // if yes, subtract divisor
2:      addc    r4,r4           // shift by 1 and count subtracts
2:      addc    r4,r4           // shift by 1 and count subtracts
        bf      1b              // if sentinel falls out of quotient, stop
        bf      1b              // if sentinel falls out of quotient, stop
        mov     r2,r1           // return remainder
        mov     r2,r1           // return remainder
        btsti   r5,31           // after adjusting for sign
        btsti   r5,31           // after adjusting for sign
        bf      3f
        bf      3f
        rsubi   r2,0
        rsubi   r2,0
3:      jmp     r15
3:      jmp     r15
FUNC_END rem32
FUNC_END rem32
FUNC_END modsi3
FUNC_END modsi3
#endif
#endif
/* GCC expects that {__eq,__ne,__gt,__ge,__le,__lt}{df2,sf2}
/* GCC expects that {__eq,__ne,__gt,__ge,__le,__lt}{df2,sf2}
   will behave as __cmpdf2. So, we stub the implementations to
   will behave as __cmpdf2. So, we stub the implementations to
   jump on to __cmpdf2 and __cmpsf2.
   jump on to __cmpdf2 and __cmpsf2.
   All of these shortcircuit the return path so that __cmp{sd}f2
   All of these shortcircuit the return path so that __cmp{sd}f2
   will go directly back to the caller.  */
   will go directly back to the caller.  */
.macro  COMPARE_DF_JUMP name
.macro  COMPARE_DF_JUMP name
        .import SYM (cmpdf2)
        .import SYM (cmpdf2)
FUNC_START \name
FUNC_START \name
        jmpi SYM (cmpdf2)
        jmpi SYM (cmpdf2)
FUNC_END \name
FUNC_END \name
.endm
.endm
#ifdef  L_eqdf2
#ifdef  L_eqdf2
COMPARE_DF_JUMP eqdf2
COMPARE_DF_JUMP eqdf2
#endif /* L_eqdf2 */
#endif /* L_eqdf2 */
#ifdef  L_nedf2
#ifdef  L_nedf2
COMPARE_DF_JUMP nedf2
COMPARE_DF_JUMP nedf2
#endif /* L_nedf2 */
#endif /* L_nedf2 */
#ifdef  L_gtdf2
#ifdef  L_gtdf2
COMPARE_DF_JUMP gtdf2
COMPARE_DF_JUMP gtdf2
#endif /* L_gtdf2 */
#endif /* L_gtdf2 */
#ifdef  L_gedf2
#ifdef  L_gedf2
COMPARE_DF_JUMP gedf2
COMPARE_DF_JUMP gedf2
#endif /* L_gedf2 */
#endif /* L_gedf2 */
#ifdef  L_ltdf2
#ifdef  L_ltdf2
COMPARE_DF_JUMP ltdf2
COMPARE_DF_JUMP ltdf2
#endif /* L_ltdf2 */
#endif /* L_ltdf2 */
#ifdef  L_ledf2
#ifdef  L_ledf2
COMPARE_DF_JUMP ledf2
COMPARE_DF_JUMP ledf2
#endif /* L_ledf2 */
#endif /* L_ledf2 */
/* SINGLE PRECISION FLOATING POINT STUBS */
/* SINGLE PRECISION FLOATING POINT STUBS */
.macro  COMPARE_SF_JUMP name
.macro  COMPARE_SF_JUMP name
        .import SYM (cmpsf2)
        .import SYM (cmpsf2)
FUNC_START \name
FUNC_START \name
        jmpi SYM (cmpsf2)
        jmpi SYM (cmpsf2)
FUNC_END \name
FUNC_END \name
.endm
.endm
#ifdef  L_eqsf2
#ifdef  L_eqsf2
COMPARE_SF_JUMP eqsf2
COMPARE_SF_JUMP eqsf2
#endif /* L_eqsf2 */
#endif /* L_eqsf2 */
#ifdef  L_nesf2
#ifdef  L_nesf2
COMPARE_SF_JUMP nesf2
COMPARE_SF_JUMP nesf2
#endif /* L_nesf2 */
#endif /* L_nesf2 */
#ifdef  L_gtsf2
#ifdef  L_gtsf2
COMPARE_SF_JUMP gtsf2
COMPARE_SF_JUMP gtsf2
#endif /* L_gtsf2 */
#endif /* L_gtsf2 */
#ifdef  L_gesf2
#ifdef  L_gesf2
COMPARE_SF_JUMP __gesf2
COMPARE_SF_JUMP __gesf2
#endif /* L_gesf2 */
#endif /* L_gesf2 */
#ifdef  L_ltsf2
#ifdef  L_ltsf2
COMPARE_SF_JUMP __ltsf2
COMPARE_SF_JUMP __ltsf2
#endif /* L_ltsf2 */
#endif /* L_ltsf2 */
#ifdef  L_lesf2
#ifdef  L_lesf2
COMPARE_SF_JUMP lesf2
COMPARE_SF_JUMP lesf2
#endif /* L_lesf2 */
#endif /* L_lesf2 */
 
 

powered by: WebSVN 2.1.0

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