Path: blob/master/arch/sparc/math-emu/sfp-util_32.h
10818 views
#include <linux/kernel.h>1#include <linux/sched.h>2#include <linux/types.h>3#include <asm/byteorder.h>45#define add_ssaaaa(sh, sl, ah, al, bh, bl) \6__asm__ ("addcc %r4,%5,%1\n\t" \7"addx %r2,%3,%0\n" \8: "=r" ((USItype)(sh)), \9"=&r" ((USItype)(sl)) \10: "%rJ" ((USItype)(ah)), \11"rI" ((USItype)(bh)), \12"%rJ" ((USItype)(al)), \13"rI" ((USItype)(bl)) \14: "cc")15#define sub_ddmmss(sh, sl, ah, al, bh, bl) \16__asm__ ("subcc %r4,%5,%1\n\t" \17"subx %r2,%3,%0\n" \18: "=r" ((USItype)(sh)), \19"=&r" ((USItype)(sl)) \20: "rJ" ((USItype)(ah)), \21"rI" ((USItype)(bh)), \22"rJ" ((USItype)(al)), \23"rI" ((USItype)(bl)) \24: "cc")2526#define umul_ppmm(w1, w0, u, v) \27__asm__ ("! Inlined umul_ppmm\n\t" \28"wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr\n\t" \29"sra %3,31,%%g2 ! Don't move this insn\n\t" \30"and %2,%%g2,%%g2 ! Don't move this insn\n\t" \31"andcc %%g0,0,%%g1 ! Don't move this insn\n\t" \32"mulscc %%g1,%3,%%g1\n\t" \33"mulscc %%g1,%3,%%g1\n\t" \34"mulscc %%g1,%3,%%g1\n\t" \35"mulscc %%g1,%3,%%g1\n\t" \36"mulscc %%g1,%3,%%g1\n\t" \37"mulscc %%g1,%3,%%g1\n\t" \38"mulscc %%g1,%3,%%g1\n\t" \39"mulscc %%g1,%3,%%g1\n\t" \40"mulscc %%g1,%3,%%g1\n\t" \41"mulscc %%g1,%3,%%g1\n\t" \42"mulscc %%g1,%3,%%g1\n\t" \43"mulscc %%g1,%3,%%g1\n\t" \44"mulscc %%g1,%3,%%g1\n\t" \45"mulscc %%g1,%3,%%g1\n\t" \46"mulscc %%g1,%3,%%g1\n\t" \47"mulscc %%g1,%3,%%g1\n\t" \48"mulscc %%g1,%3,%%g1\n\t" \49"mulscc %%g1,%3,%%g1\n\t" \50"mulscc %%g1,%3,%%g1\n\t" \51"mulscc %%g1,%3,%%g1\n\t" \52"mulscc %%g1,%3,%%g1\n\t" \53"mulscc %%g1,%3,%%g1\n\t" \54"mulscc %%g1,%3,%%g1\n\t" \55"mulscc %%g1,%3,%%g1\n\t" \56"mulscc %%g1,%3,%%g1\n\t" \57"mulscc %%g1,%3,%%g1\n\t" \58"mulscc %%g1,%3,%%g1\n\t" \59"mulscc %%g1,%3,%%g1\n\t" \60"mulscc %%g1,%3,%%g1\n\t" \61"mulscc %%g1,%3,%%g1\n\t" \62"mulscc %%g1,%3,%%g1\n\t" \63"mulscc %%g1,%3,%%g1\n\t" \64"mulscc %%g1,0,%%g1\n\t" \65"add %%g1,%%g2,%0\n\t" \66"rd %%y,%1\n" \67: "=r" ((USItype)(w1)), \68"=r" ((USItype)(w0)) \69: "%rI" ((USItype)(u)), \70"r" ((USItype)(v)) \71: "%g1", "%g2", "cc")7273/* It's quite necessary to add this much assembler for the sparc.74The default udiv_qrnnd (in C) is more than 10 times slower! */75#define udiv_qrnnd(q, r, n1, n0, d) \76__asm__ ("! Inlined udiv_qrnnd\n\t" \77"mov 32,%%g1\n\t" \78"subcc %1,%2,%%g0\n\t" \79"1: bcs 5f\n\t" \80"addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n\t" \81"sub %1,%2,%1 ! this kills msb of n\n\t" \82"addx %1,%1,%1 ! so this can't give carry\n\t" \83"subcc %%g1,1,%%g1\n\t" \84"2: bne 1b\n\t" \85"subcc %1,%2,%%g0\n\t" \86"bcs 3f\n\t" \87"addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n\t" \88"b 3f\n\t" \89"sub %1,%2,%1 ! this kills msb of n\n\t" \90"4: sub %1,%2,%1\n\t" \91"5: addxcc %1,%1,%1\n\t" \92"bcc 2b\n\t" \93"subcc %%g1,1,%%g1\n\t" \94"! Got carry from n. Subtract next step to cancel this carry.\n\t" \95"bne 4b\n\t" \96"addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb\n\t" \97"sub %1,%2,%1\n\t" \98"3: xnor %0,0,%0\n\t" \99"! End of inline udiv_qrnnd\n" \100: "=&r" ((USItype)(q)), \101"=&r" ((USItype)(r)) \102: "r" ((USItype)(d)), \103"1" ((USItype)(n1)), \104"0" ((USItype)(n0)) : "%g1", "cc")105#define UDIV_NEEDS_NORMALIZATION 0106107#define abort() \108return 0109110#ifdef __BIG_ENDIAN111#define __BYTE_ORDER __BIG_ENDIAN112#else113#define __BYTE_ORDER __LITTLE_ENDIAN114#endif115116117