xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/hexagon/udivmodsi4.S (revision 3078531de10dcae44b253a35125c949ff4235284)
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	.macro FUNCTION_BEGIN name
11	.text
12	.p2align 5
13	.globl \name
14	.type  \name, @function
15\name:
16	.endm
17
18	.macro FUNCTION_END name
19	.size  \name, . - \name
20	.endm
21
22
23FUNCTION_BEGIN __hexagon_udivmodsi4
24	{
25		r2 = cl0(r0)
26		r3 = cl0(r1)
27		r5:4 = combine(#1,#0)
28		p0 = cmp.gtu(r1,r0)
29	}
30	{
31		r6 = sub(r3,r2)
32		r4 = r1
33		r1:0 = combine(r0,r4)
34		if (p0) jumpr r31
35	}
36	{
37		r3:2 = vlslw(r5:4,r6)
38		loop0(1f,r6)
39		p0 = cmp.eq(r6,#0)
40		if (p0.new) r4 = #0
41	}
42	.falign
431:
44	{
45		p0 = cmp.gtu(r2,r1)
46		if (!p0.new) r1 = sub(r1,r2)
47		if (!p0.new) r0 = add(r0,r3)
48		r3:2 = vlsrw(r3:2,#1)
49	}:endloop0
50	{
51		p0 = cmp.gtu(r2,r1)
52		if (!p0.new) r1 = sub(r1,r4)
53		if (!p0.new) r0 = add(r0,r3)
54		jumpr r31
55	}
56FUNCTION_END __hexagon_udivmodsi4
57
58  .globl __qdsp_udivmodsi4
59  .set   __qdsp_udivmodsi4, __hexagon_udivmodsi4
60