aboutsummaryrefslogtreecommitdiff
path: root/vendor/gmp-6.3.0/mpn/powerpc64/mode64/p7/aormul_2.asm
blob: 8731e01a8949230fb92c270e70db90fb09a89e1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
dnl  PowerPC-64 mpn_mul_2 and mpn_addmul_2.

dnl  Copyright 2013 Free Software Foundation, Inc.

dnl  This file is part of the GNU MP Library.
dnl
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
dnl  it under the terms of either:
dnl
dnl    * the GNU Lesser General Public License as published by the Free
dnl      Software Foundation; either version 3 of the License, or (at your
dnl      option) any later version.
dnl
dnl  or
dnl
dnl    * the GNU General Public License as published by the Free Software
dnl      Foundation; either version 2 of the License, or (at your option) any
dnl      later version.
dnl
dnl  or both in parallel, as here.
dnl
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dnl  for more details.
dnl
dnl  You should have received copies of the GNU General Public License and the
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
dnl  see https://www.gnu.org/licenses/.

include(`../config.m4')

C                    cycles/limb    cycles/limb
C			mul_2         addmul_2
C POWER3/PPC630		 ?		 ?
C POWER4/PPC970		 ?		 ?
C POWER5		 ?		 ?
C POWER6		 ?		 ?
C POWER7-SMT4		 3		 3
C POWER7-SMT2		 ?		 ?
C POWER7-SMT1		 ?		 ?

C INPUT PARAMETERS
define(`rp', `r3')
define(`up', `r4')
define(`n',  `r5')
define(`vp', `r6')

define(`cy0', `r10')
ifdef(`EXTRA_REGISTER',
` define(`cy1', EXTRA_REGISTER)',
` define(`cy1', `r31')')

ifdef(`OPERATION_mul_2',`
  define(`AM',		`')
  define(`ADDX',	`addc')
  define(`func',	`mpn_mul_2')
')
ifdef(`OPERATION_addmul_2',`
  define(`AM',		`$1')
  define(`ADDX',	`adde')
  define(`func',	`mpn_addmul_2')
')

MULFUNC_PROLOGUE(mpn_mul_2 mpn_addmul_2)

ASM_START()
PROLOGUE(func)

ifdef(`EXTRA_REGISTER',,`
	std	r31, -8(r1)
')
	andi.	r12, n, 1
	addi	r0, n, 1
	srdi	r0, r0, 1
	mtctr	r0
	ld	r11, 0(vp)		C v0
	li	cy0, 0
	ld	r12, 8(vp)		C v1
	li	cy1, 0
	ld	r5, 0(up)
	beq	L(lo0)
	addi	up, up, -8
	addi	rp, rp, -8
	b	L(lo1)

	ALIGN(32)
L(top):
AM(`	ld	r0, -8(rp)')
	ld	r5, 0(up)
AM(`	addc	r6, r6, r0')
	ADDX	r7, r7, r8
	addze	r9, r9
	addc	r6, r6, cy0
	adde	cy0, r7, cy1
	std	r6, -8(rp)
	addze	cy1, r9
L(lo0):	mulld	r6, r11, r5		C v0 * u[i]  weight 0
	mulhdu	r7, r11, r5		C v0 * u[i]  weight 1
	mulld	r8, r12, r5		C v1 * u[i]  weight 1
	mulhdu	r9, r12, r5		C v1 * u[i]  weight 2
AM(`	ld	r0, 0(rp)')
	ld	r5, 8(up)
AM(`	addc	r6, r6, r0')
	ADDX	r7, r7, r8
	addze	r9, r9
	addc	r6, r6, cy0
	adde	cy0, r7, cy1
	std	r6, 0(rp)
	addze	cy1, r9
L(lo1):	mulld	r6, r11, r5		C v0 * u[i]  weight 0
	mulhdu	r7, r11, r5		C v0 * u[i]  weight 1
	addi	up, up, 16
	addi	rp, rp, 16
	mulld	r8, r12, r5		C v1 * u[i]  weight 1
	mulhdu	r9, r12, r5		C v1 * u[i]  weight 2
	bdnz	L(top)

L(end):
AM(`	ld	r0, -8(rp)')
AM(`	addc	r6, r6, r0')
	ADDX	r7, r7, r8
	addze	r9, r9
	addc	r6, r6, cy0
	std	r6, -8(rp)
	adde	cy0, r7, cy1
	addze	cy1, r9
	std	cy0, 0(rp)
	mr	r3, cy1

ifdef(`EXTRA_REGISTER',,`
	ld	r31, -8(r1)
')
	blr
EPILOGUE()