brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 44f031b Raw
76 lines · plain
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-exception6//7//===----------------------------------------------------------------------===//8 9#define A r1:010#define B r3:211#define ATMP r5:412 13 14#define Q6_ALIAS(TAG) .global __qdsp_##TAG ; .set __qdsp_##TAG, __hexagon_##TAG15#define END(TAG) .size TAG,.-TAG16 17// Min and Max return A if B is NaN, or B if A is NaN18// Otherwise, they return the smaller or bigger value19//20// If values are equal, we want to favor -0.0 for min and +0.0 for max.21 22// Compares always return false for NaN23// if (isnan(A)) A = B; if (A > B) A = B will only trigger at most one of those options.24 25	.text26	.global __hexagon_mindf327	.global __hexagon_maxdf328	.global fmin29	.type fmin,@function30	.global fmax31	.type fmax,@function32	.type __hexagon_mindf3,@function33	.type __hexagon_maxdf3,@function34	Q6_ALIAS(mindf3)35	Q6_ALIAS(maxdf3)36	.p2align 537__hexagon_mindf3:38fmin:39	{40		p0 = dfclass(A,#0x10)		// If A is a number41		p1 = dfcmp.gt(A,B)		// AND B > A, don't swap42		ATMP = A43	}44	{45		if (p0) A = B			// if A is NaN use B46		if (p1) A = B			// gt is always false if either is NaN47		p2 = dfcmp.eq(A,B)		// if A == B48		if (!p2.new) jumpr:t r3149	}50	// A == B, return A|B to select -0.0 over 0.051	{52		A = or(ATMP,B)53		jumpr r3154	}55END(__hexagon_mindf3)56	.falign57__hexagon_maxdf3:58fmax:59	{60		p0 = dfclass(A,#0x10)61		p1 = dfcmp.gt(B,A)62		ATMP = A63	}64	{65		if (p0) A = B66		if (p1) A = B67		p2 = dfcmp.eq(A,B)68		if (!p2.new) jumpr:t r3169	}70	// A == B, return A&B to select 0.0 over -0.071	{72		A = and(ATMP,B)73		jumpr r3174	}75END(__hexagon_maxdf3)76