1dnl  SPARC v9-2011 simulation support.
2
3dnl  Contributed to the GNU project by Torbjörn Granlund.
4
5dnl  Copyright 2013 Free Software Foundation, Inc.
6
7dnl  This file is part of the GNU MP Library.
8dnl
9dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10dnl  it under the terms of either:
11dnl
12dnl    * the GNU Lesser General Public License as published by the Free
13dnl      Software Foundation; either version 3 of the License, or (at your
14dnl      option) any later version.
15dnl
16dnl  or
17dnl
18dnl    * the GNU General Public License as published by the Free Software
19dnl      Foundation; either version 2 of the License, or (at your option) any
20dnl      later version.
21dnl
22dnl  or both in parallel, as here.
23dnl
24dnl  The GNU MP Library is distributed in the hope that it will be useful, but
25dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27dnl  for more details.
28dnl
29dnl  You should have received copies of the GNU General Public License and the
30dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
31dnl  see https://www.gnu.org/licenses/.
32
33
34dnl Usage addxccc(r1,r2,r3, t1)
35dnl  64-bit add with carry-in and carry-out
36dnl  FIXME: Register g2 must not be destination
37
38define(`addxccc',`dnl
39	add	%sp, -512, %sp
40	stx	%g2, [%sp+2047+256+16]
41	mov	0, %g2
42	movcs	%xcc, -1, %g2
43	addcc	%g2, 1, %g0
44	addccc	$1, $2, $3
45	ldx	[%sp+2047+256+16], %g2
46	sub	%sp, -512, %sp
47')
48
49
50dnl Usage addxc(r1,r2,r3, t1,t2)
51dnl  64-bit add with carry-in
52
53define(`addxc',`dnl
54	bcc	%xcc, 1f
55	 add	$1, $2, $3
56	add	$3, 1, $3
571:
58')
59
60
61dnl Usage umulxhi(r1,r2,r3)
62dnl  64-bit multiply returning upper 64 bits
63dnl  Calls __gmpn_umulh using a non-standard calling convention
64
65define(`umulxhi',`dnl
66	add	%sp, -512, %sp
67	stx	$1, [%sp+2047+256]
68	stx	$2, [%sp+2047+256+8]
69	stx	%o7, [%sp+2047+256+16]
70	call	__gmpn_umulh
71	 nop
72	ldx	[%sp+2047+256+16], %o7
73	ldx	[%sp+2047+256], $3
74	sub	%sp, -512, %sp
75')
76dnl Usage lzcnt(r1,r2)
77dnl  Plain count leading zeros
78dnl  Calls __gmpn_lzcnt using a non-standard calling convention
79
80define(`lzcnt',`dnl
81	add	%sp, -512, %sp
82	stx	%o7, [%sp+2047+256+16]
83	call	__gmpn_lzcnt
84	 stx	$1, [%sp+2047+256]
85	ldx	[%sp+2047+256+16], %o7
86	ldx	[%sp+2047+256], $2
87	sub	%sp, -512, %sp
88')
89