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

📄 ppc_fcmps.s

📁 powerpc 405 优化过的硬浮点库
💻 S
字号:
/* fpopt/ppc_fcmps.S, pl_FPE_common, pl_linux 11/24/03 16:17:29                                                                  */
/*----------------------------------------------------------------------------- */
/*  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 single floating point numbers.                         */
/* Input:    r3(fra), r4(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(__gesf2)
function_prolog(__gtsf2)
     li      r8,-1                   /* return value in NAN case */
     b       start
function_prolog(__eqsf2)        
function_prolog(__nesf2)
function_prolog(__lesf2)
function_prolog(__ltsf2)
/*function_prolog(__cmpsf2)
     li      r8,1   */                /* return value in NAN case */
start:    
     mfcr    r11                     /* save cr */
     rlwinm  r9,r3,0,0x7FFFFFFF      /* pull FRA, ignoring sign */
     rlwinm  r10,r4,0,0x7FFFFFFF     /* pull FRB, ignoring sign */
     cmpw    cr1,r9,r10              /* compare FRA,FRB */
     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,r4,0                /* cr3[LT] set if sign is 1 */
     lis     r7,0x7F80               /* 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,0x7F80              /* Build comparison mask  */
     cmpw    cr0,r9,r12
     blt     FRB_NAN
     rlwinm. r7,r3,0,0x007FFFFF      /* Check for non zero fraction */
     bne     set_CR_SO               /* exponent is DEXPMAX and lofrac != 0 */
FRB_NAN:
     cmpw    cr0,r10,r12
     blt     sign_test
     rlwinm. r7,r4,0,0x007FFFFF      /* Check for non zero fraction */
     bne     set_CR_SO               /* exponent is DEXPMAX and lofrac != 0 */
sign_test:
     xor.    r12,r3,r4               /* msb will be 1 if signs are different */
     bnl     same_sign
/* if signs different special test for -0 = + 0                                 */
     or.     r12,r9,r10              /* test for FRA=FRB=0 (ignoring sign) */
     beq     set_CR_EQ
     
     or.     r3,r3,r3                /* set condition based on sign */
     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,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:
     mr      r3,r8                    /* unordered case */
set_cc:
     mtcr    r11
     blr
 
function_epilog(__eqsf2)
function_epilog(__nesf2)
function_epilog(__lesf2)
function_epilog(__ltsf2)
function_epilog(__gesf2)
function_epilog(__gtsf2)
/*function_epilog(__cmpsf2)*/
 
  

⌨️ 快捷键说明

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