xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/hexagon/divsi3.S (revision a90b9d0159070121c221b966469c3e36d912bf82)
1//===----------------------Hexagon builtin routine ------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9
10
11	.macro FUNCTION_BEGIN name
12	.text
13        .p2align 5
14	.globl \name
15	.type  \name, @function
16\name:
17	.endm
18
19	.macro FUNCTION_END name
20	.size  \name, . - \name
21	.endm
22
23
24FUNCTION_BEGIN __hexagon_divsi3
25	{
26		p0 = cmp.ge(r0,#0)
27		p1 = cmp.ge(r1,#0)
28		r1 = abs(r0)
29		r2 = abs(r1)
30	}
31	{
32		r3 = cl0(r1)
33		r4 = cl0(r2)
34		r5 = sub(r1,r2)
35		p2 = cmp.gtu(r2,r1)
36	}
37#if (__HEXAGON_ARCH__ == 60)
38	{
39		r0 = #0
40		p1 = xor(p0,p1)
41		p0 = cmp.gtu(r2,r5)
42	}
43		if (p2) jumpr r31
44#else
45	{
46		r0 = #0
47		p1 = xor(p0,p1)
48		p0 = cmp.gtu(r2,r5)
49		if (p2) jumpr r31
50	}
51#endif
52	{
53		r0 = mux(p1,#-1,#1)
54		if (p0) jumpr r31
55		r4 = sub(r4,r3)
56		r3 = #1
57	}
58	{
59		r0 = #0
60		r3:2 = vlslw(r3:2,r4)
61		loop0(1f,r4)
62	}
63	.falign
641:
65	{
66		p0 = cmp.gtu(r2,r1)
67		if (!p0.new) r1 = sub(r1,r2)
68		if (!p0.new) r0 = add(r0,r3)
69		r3:2 = vlsrw(r3:2,#1)
70	}:endloop0
71	{
72		p0 = cmp.gtu(r2,r1)
73		if (!p0.new) r0 = add(r0,r3)
74		if (!p1) jumpr r31
75	}
76	{
77		r0 = neg(r0)
78		jumpr r31
79	}
80FUNCTION_END __hexagon_divsi3
81
82  .globl __qdsp_divsi3
83  .set   __qdsp_divsi3, __hexagon_divsi3
84