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 .macro FUNCTION_BEGIN name
10 .text
11 .p2align 5
12 .globl \name
13 .type \name, @function
14\name:
15 .endm
16
17 .macro FUNCTION_END name
18 .size \name, . - \name
19 .endm
20
21#define RIN r0
22#define S r0
23#define H r1
24#define D r2
25#define E r3
26#define HALF r4
27#define R r5
28
29#define Q6_ALIAS(TAG) .global __qdsp_##TAG ; .set __qdsp_##TAG, __hexagon_##TAG
30#define FAST_ALIAS(TAG) .global __hexagon_fast_##TAG ; .set __hexagon_fast_##TAG, __hexagon_##TAG
31#define FAST2_ALIAS(TAG) .global __hexagon_fast2_##TAG ; .set __hexagon_fast2_##TAG, __hexagon_##TAG
32
33FUNCTION_BEGIN __hexagon_sqrtf
34 {
35 E,p0 = sfinvsqrta(RIN)
36 R = sffixupr(RIN)
37 HALF = ##0x3f000000 // 0.5
38 r1:0 = combine(#0,#0) // clear S/H
39 }
40 {
41 S += sfmpy(E,R):lib // S0
42 H += sfmpy(E,HALF):lib // H0
43 D = HALF
44 E = R
45 }
46 {
47 D -= sfmpy(S,H):lib // d0
48 p1 = sfclass(R,#1) // is zero?
49 //E -= sfmpy(S,S):lib // e0
50 }
51 {
52 S += sfmpy(S,D):lib // S1
53 H += sfmpy(H,D):lib // H1
54 D = HALF
55 E = R
56 }
57 {
58 D -= sfmpy(S,H):lib // d0
59 E -= sfmpy(S,S):lib // e0
60 }
61 {
62 S += sfmpy(H,E):lib // S2
63 H += sfmpy(H,D):lib // H2
64 D = HALF
65 E = R
66 }
67 {
68 //D -= sfmpy(S,H):lib // d2
69 E -= sfmpy(S,S):lib // e2
70 if (p1) r0 = or(r0,R) // sqrt(-0.0) = -0.0
71 }
72 {
73 S += sfmpy(H,E,p0):scale // S3
74 jumpr r31
75 }
76
77FUNCTION_END __hexagon_sqrtf
78
79Q6_ALIAS(sqrtf)
80FAST_ALIAS(sqrtf)
81FAST2_ALIAS(sqrtf)
82

source code of compiler-rt/lib/builtins/hexagon/sfsqrt_opt.S