xref: /netbsd-src/external/gpl3/gcc.old/dist/libgcc/config/pru/mpyll.S (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
1/*  Copyright (C) 2014-2020 Free Software Foundation, Inc.
2    Contributed by Dimitar Dimitrov <dimitar@dinux.eu>
3
4  This file is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License as published by the
6  Free Software Foundation; either version 3, or (at your option) any
7  later version.
8
9  This file is distributed in the hope that it will be useful, but
10  WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  General Public License for more details.
13
14  Under Section 7 of GPL version 3, you are granted additional
15  permissions described in the GCC Runtime Library Exception, version
16  3.1, as published by the Free Software Foundation.
17
18  You should have received a copy of the GNU General Public License and
19  a copy of the GCC Runtime Library Exception along with this program;
20  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
21  <http://www.gnu.org/licenses/>.
22
23      (al + C * ah) * (bl + C * bh) =    al * bl
24				       + C * ah * bl
25				       + C * al * bh
26				       + C * C * ah * bh  -> discard, overflow
27	Where C=(1 << 32)
28  */
29
30#include "pru-asm.h"
31
32	.global	SYM(__pruabi_mpyll)
33	FUNC(__pruabi_mpyll)
34SYM(__pruabi_mpyll):
35	/* + C * ah * bl */
36	mov	r28, r15
37	mov	r29, r16
38	nop
39	xin	0, r26, 8
40
41	/* + C * al * bh */
42	mov	r28, r14
43	mov	r29, r17
44	mov	r15, r26		/* "Loose" ah, record only reslo.  */
45	xin	0, r26, 8
46
47	/* + al * bl */
48	/* mov	r28, r14		-> No need, already loaded.  */
49	mov	r29, r16
50	add	r15, r15, r26
51	xin	0, r26, 8
52	mov	r14, r26
53	add	r15, r15, r27
54
55	ret
56
57	ENDFUNC(__pruabi_mpyll)
58