URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [epiphany/] [udivsi3-float.S] - Rev 734
Compare with Previous | Blame | View Log
/* Unsigned 32 bit division optimized for Epiphany.Copyright (C) 2009, 2011 Free Software Foundation, Inc.Contributed by Embecosm on behalf of Adapteva, Inc.This file is part of GCC.This file is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation; either version 3, or (at your option) anylater version.This file is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.Under Section 7 of GPL version 3, you are granted additionalpermissions described in the GCC Runtime Library Exception, version3.1, as published by the Free Software Foundation.You should have received a copy of the GNU General Public License anda copy of the GCC Runtime Library Exception along with this program;see the files COPYING3 and COPYING.RUNTIME respectively. If not, see<http://www.gnu.org/licenses/>. */#include "epiphany-asm.h"FSTAB (__udivsi3,T_UINT).global SYM(__udivsi3).balign 4HIDDEN_FUNC(__udivsi3)SYM(__udivsi3):sub TMP0,r0,r1bltu .Lret0float TMP2,r0mov TMP1,%low(0xb0800000) ; ??? this would be faster with small datafloat TMP3,r1movt TMP1,%high(0xb0800000)asr TMP0,r0,8sub TMP0,TMP0,TMP1movt TMP1,%high(0x00810000)movgteu TMP2,TMP0bblt .Lret1sub TMP2,TMP2,TMP1sub TMP2,TMP2,TMP3mov TMP3,0movltu TMP2,TMP3lsr TMP2,TMP2,23lsl r1,r1,TMP2mov TMP0,1lsl TMP0,TMP0,TMP2sub r0,r0,r1bltu .Ladd_backadd TMP3,TMP3,TMP0sub r0,r0,r1bltu .Ladd_back.Lsub_loop:; More than two iterations are rare, so it makes sense to leave; this label here to reduce average branch penalties.add TMP3,TMP3,TMP0sub r0,r0,r1bgteu .Lsub_loop.Ladd_back:add r0,r0,r1sub TMP1,r1,1mov r1,%low(.L0step)movt r1,%high(.L0step)lsl TMP2,TMP2,3sub r1,r1,TMP2jr r1.rep 30lsl r0,r0,1sub.l r1,r0,TMP1movgteu r0,r1.endr.L0step:sub r1,TMP0,1 ; mask result bits from steps ...and r0,r0,r1orr r0,r0,TMP3 ; ... and combine with first bits.rts.Lret0: mov r0,0rts.Lret1: mov r0,1rtsENDFUNC(__udivsi3)
