summaryrefslogtreecommitdiff
path: root/arch/metag/lib/muldi3.S
blob: ee66ca8644d08884d149a9e0f76d697f9c794639 (plain)
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
! Copyright (C) 2012 by Imagination Technologies Ltd.
!
! 64-bit multiply routine.
!

!
! 64-bit signed/unsigned multiply
!
! A = D1Ar1:D0Ar2 = a 2^48 + b 2^32 +  c 2^16 + d 2^0
!
! B = D1Ar3:D0Ar4 = w 2^48 + x 2^32 +  y 2^16 + z 2^0
!
	.text
	.global ___muldi3
	.type   ___muldi3,function

___muldi3:
	MULD    D1Re0,D1Ar1,D0Ar4       ! (a 2^48 + b 2^32)(y 2^16 + z 2^0)
	MULD    D0Re0,D0Ar2,D1Ar3       ! (w 2^48 + x 2^32)(c 2^16 + d 2^0)
	ADD     D1Re0,D1Re0,D0Re0

	MULW    D0Re0,D0Ar2,D0Ar4       ! (d 2^0)  * (z 2^0)

	RTDW    D0Ar2,D0Ar2
	MULW    D0Ar6,D0Ar2,D0Ar4       ! (c 2^16)(z 2^0)
	LSR     D1Ar5,D0Ar6,#16
	LSL     D0Ar6,D0Ar6,#16
	ADDS    D0Re0,D0Re0,D0Ar6
	ADDCS   D1Re0,D1Re0,#1
	RTDW    D0Ar4,D0Ar4
	ADD     D1Re0,D1Re0,D1Ar5

	MULW    D0Ar6,D0Ar2,D0Ar4       ! (c 2^16)(y 2^16)
	ADD     D1Re0,D1Re0,D0Ar6

	RTDW    D0Ar2,D0Ar2
	MULW    D0Ar6,D0Ar2,D0Ar4       ! (d 2^0)(y 2^16)
	LSR     D1Ar5,D0Ar6,#16
	LSL     D0Ar6,D0Ar6,#16
	ADDS    D0Re0,D0Re0,D0Ar6
	ADD     D1Re0,D1Re0,D1Ar5
	ADDCS   D1Re0,D1Re0,#1
	MOV     PC, D1RtP
	.size ___muldi3,.-___muldi3