⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppc_fcmpd.s

📁 powerpc 405 优化过的硬浮点库
💻 S
字号:
/* fpopt/ppc_fcmpd.S, pl_FPE_common, pl_linux 11/24/03 16:17:28                                                                  */
/*----------------------------------------------------------------------------- */
/*  Copyright (c) 2003, IBM Corporation                                         */
/*  All rights reserved.                                                        */
/*                                                                              */
/*  Redistribution and use in source and binary forms, with or                  */
/*  without modification, are permitted provided that the following             */
/*  conditions are met:                                                         */
/*                                                                              */
/*    * Redistributions of source code must retain the above                    */
/*      copyright notice, this list of conditions and the following             */
/*      disclaimer.                                                             */
/*    * Redistributions in binary form must reproduce the above                 */
/*      copyright notice, this list of conditions and the following             */
/*      disclaimer in the documentation and/or other materials                  */
/*      provided with the distribution.                                         */
/*    * Neither the name of IBM nor the names of its contributors               */
/*      may be used to endorse or promote products derived from this            */
/*      software without specific prior written permission.                     */
/*                                                                              */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND                      */
/*  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,                 */
/*  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF                    */
/*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE                    */
/*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS           */
/*  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,         */
/*  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,                    */
/*  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR          */
/*  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY         */
/*  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT                */
/*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE           */
/*  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    */
/*                                                                              */
/*                                                                              */
/*----------------------------------------------------------------------------- */
/*                                                                              */
/* Function: compare two double floating point numbers.                         */
/* Input:    r3,r4(fra)                                                         */
/*           r5,r6(frb)                                                         */
/* Output:   r3, value as defined below                                         */
/*           equal   ->  0                                                      */
/*           a > b   ->  1                                                      */
/*           a < b   -> -1                                                      */
/* Notes:   1. No stack frame is created for this function, so the following    */
/*             registers must be preserved, as required by ABI specification:   */
/*               LR, CR0, R1, R2, R13-R31                                       */
/*          2. operation performed according to IEEE754-1985 standard with      */
/*             rounding mode = nearest even.                                    */
/*                                                                              */
/*----------------------------------------------------------------------------- */

#include <ppc4xx.inc>
#include "fpeLib.inc"

function_prolog(__gedf2)
function_prolog(__gtdf2)
     li      r8,-1                  /* return value in NAN case */
     b       start
function_prolog(__eqdf2)        
function_prolog(__nedf2)
function_prolog(__ledf2)
function_prolog(__ltdf2)
/*function_prolog(__cmpdf2)
     li      r8,1 */                 /* return value in NAN case */
start:    
     mfcr    r11                      /* save cr */
     rlwinm  r9,r3,0,0x7FFFFFFF     /* pull high word A, ignoring sign */
     rlwinm  r10,r5,0,0x7FFFFFFF    /* pull high word B, ignoring sign */
     cmpw    cr1,r9,r10             /* compare high words */
     beq     cr1,slowpath           /* exception case */
/* high words different here, cr1 has the right sense of comparison             */
/* for same sign + and opposite sense for same sign - .  If signs are           */
/* different, magnitude of exponents doesn't matter (except to check the        */
/* largest one for a NAN                                                        */
     cmpwi   cr2,r3,0               /* cr2[LT] set if sign is 1 */
     cmpwi   cr3,r5,0               /* cr3[LT] set if sign is 1 */
     lis     r7,0x7FF0              /* build comparison mask */
     blt     cr1,FRA_LESS           /* FRA is less */
/* FRA greater here - check if for DEXPMAX                                      */
     cmpw    cr0,r9,r7              /* check FRA against DEXPMAX */
     bge     slowpath               /* NaN or Infinity (sort out later) */
     blt     cr2,set_CR_LT          /* FRA GT and neg (FRB sign immaterial) */
/* FRA greater and positive here (sign of FRB immaterial)                       */
set_CR_GT:
     li      r3,1                   /* FRA > FRB */
     mtcr    r11                    /* restore cr */
     blr
FRA_LESS:
/* FRB greater here - check if for DEXPMAX                                      */
     cmpw    cr0,r10,r7             /* check against DEXPMAX */
     bge     slowpath               /* NaN or Infinity (sort out later) */
     blt     cr3,set_CR_GT          /* FRB greater and negative  */
/* FRB greater and positive here (sign of FRA immaterial)                       */
set_CR_LT:
     li      r3,-1                  /* FRA < FRB */
     mtcr    r11                    /* restore cr */
     blr
/* need to sort out more detail if here                                         */
slowpath:
/* Do NAN tests                                                                 */
     lis     r12,0x7FF0             /* Build comparison mask  */
     cmpw    cr0,r9,r12
     blt     FRB_NAN
     rlwinm  r7,r3,0,0x000FFFFF     /* Check for non zero fraction */
     or.     r7,r7,r4
     bne     set_CR_SO              /* exponent is DEXPMAX and lofrac != 0 */
FRB_NAN:
     cmpw    cr0,r10,r12
     blt     sign_test
     rlwinm  r7,r5,0,0x000FFFFF     /* Check for non zero fraction */
     or.     r7,r7,r6               /* set condition for zero test */
     bne     set_CR_SO              /* exponent is DEXPMAX and lofrac != 0 */
sign_test:
     xor.    r12,r3,r5              /* msb will be 1 if signs are different */
     bnl     same_sign
/* if signs different special test for -0 = + 0                                 */
     or.     r12,r4,r6              /* OR loFractions */
     bne     lsk0
     or      r12,r3,r5              /* OR high words of FRA and FRB */
     rlwinm. r12,r12,0,0x7FFFFFFF   /* ignore sign bit */
     beq     set_CR_EQ
lsk0:
     or.     r3,r3,r3               /* set condition */
     blt     set_CR_LT
     b       set_CR_GT
same_sign:
/* clear signs and compare                                                      */
     cmpw    cr1,r9,r10
     or.     r3,r3,r3               /* Sets cr0[LT] to indicate sign */
     beq     cr1,same_hifrac
     blt     cr1,cond_CR_LT         /* conditionally less than (sign?) */
     b       cond_CR_GT
same_hifrac:
     cmplw   cr1,r4,r6              /* compare low fractions */
     beq     cr1,set_CR_EQ
     blt     cr1,cond_CR_LT         /* conditionally less than (sign?) */
cond_CR_GT:
     bnl     set_CR_GT
     b       set_CR_LT
cond_CR_LT:
     bnl     set_CR_LT              /* ruling stands */
     b       set_CR_GT
set_CR_EQ:
     li      r3,0
     b       set_cc
set_CR_SO:                          /* unordered case */
     mr      r3,r8                    
set_cc:
     mtcr    r11
     blr
 
function_epilog(__eqdf2)
function_epilog(__nedf2)
function_epilog(__ledf2)
function_epilog(__ltdf2)
function_epilog(__gedf2)
function_epilog(__gtdf2)
/*function_epilog(__cmpdf2)*/
 
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -