Home | History | Annotate | Download | only in big
      1 // Copyright 2016 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 // +build !math_big_pure_go,ppc64le
      6 
      7 #include "textflag.h"
      8 
      9 // This file provides fast assembly versions for the elementary
     10 // arithmetic operations on vectors implemented in arith.go.
     11 
     12 // func divWW(x1, x0, y Word) (q, r Word)
     13 TEXT divWW(SB), NOSPLIT, $0
     14 	MOVD x1+0(FP), R4
     15 	MOVD x0+8(FP), R5
     16 	MOVD y+16(FP), R6
     17 
     18 	CMPU R4, R6
     19 	BGE  divbigger
     20 
     21 	// from the programmer's note in ch. 3 of the ISA manual, p.74
     22 	DIVDEU R6, R4, R3
     23 	DIVDU  R6, R5, R7
     24 	MULLD  R6, R3, R8
     25 	MULLD  R6, R7, R20
     26 	SUB    R20, R5, R10
     27 	ADD    R7, R3, R3
     28 	SUB    R8, R10, R4
     29 	CMPU   R4, R10
     30 	BLT    adjust
     31 	CMPU   R4, R6
     32 	BLT    end
     33 
     34 adjust:
     35 	MOVD $1, R21
     36 	ADD  R21, R3, R3
     37 	SUB  R6, R4, R4
     38 
     39 end:
     40 	MOVD R3, q+24(FP)
     41 	MOVD R4, r+32(FP)
     42 
     43 	RET
     44 
     45 divbigger:
     46 	MOVD $-1, R7
     47 	MOVD R7, q+24(FP)
     48 	MOVD R7, r+32(FP)
     49 	RET
     50 
     51