1/* Tests some basic unordered fpu compare instructions.
2
3   Copyright (C) 2019-2023 Free Software Foundation, Inc.
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 3 of the License, or
8   (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18# mach: or1k
19# output: report(0x400921f9);\n
20# output: report(0xf01b866e);\n
21# output: report(0x4005bf09);\n
22# output: report(0x95aaf790);\n
23# output: report(0x7ff80000);\n
24# output: report(0x00000000);\n
25# output: \n
26# output: report(0x00000001);\n
27# output: \n
28# output: report(0x00000000);\n
29# output: \n
30# output: report(0x00000001);\n
31# output: \n
32# output: exit(0)\n
33
34#include "or1k-asm-test-helpers.h"
35
36	STANDARD_TEST_ENVIRONMENT
37
38	.section .data
39	.align 4
40	.type   pi, @object
41	.size   pi, 8
42anchor:
43pi:
44	.double  3.14159
45
46	.type   e, @object
47	.size   e, 8
48e:
49	.double  2.71828
50
51	.section .text
52start_tests:
53	PUSH LINK_REGISTER_R9
54
55	/* Test unordered double comparisons.  Setting up:
56	 *  r11      pointer to data
57	 *  r12,r13  pi  as double
58	 *  r14,r15  e   as double
59	 *  r16,r17  nan as double
60	 */
61	l.ori	r11, r0, ha(anchor)
62	l.addi	r11, r11, lo(anchor)
63	l.lwz	r12, 0(r11)
64	l.lwz	r13, 4(r11)
65
66	l.lwz	r14, 8(r11)
67	l.lwz	r15, 12(r11)
68
69	/* Make a NaN.  */
70	lf.sub.d r16,r18, r12,r13, r12,r13
71	lf.div.d r16,r18, r16,r18, r16,r18
72
73	/* Output to ensure we loaded it correctly.  */
74	REPORT_REG_TO_CONSOLE r12
75	REPORT_REG_TO_CONSOLE r13
76
77	REPORT_REG_TO_CONSOLE r14
78	REPORT_REG_TO_CONSOLE r15
79
80	REPORT_REG_TO_CONSOLE r16
81	REPORT_REG_TO_CONSOLE r18
82	PRINT_NEWLINE_TO_CONSOLE
83
84	lf.sfuge.d r12,r13, r14,r15
85	MOVE_FROM_SPR r2, SPR_SR
86	REPORT_BIT_TO_CONSOLE r2, SPR_SR_F
87	PRINT_NEWLINE_TO_CONSOLE
88
89	lf.sfun.d r12,r13, r14,r15
90	MOVE_FROM_SPR r2, SPR_SR
91	REPORT_BIT_TO_CONSOLE r2, SPR_SR_F
92	PRINT_NEWLINE_TO_CONSOLE
93
94	lf.sfun.d r12,r13, r16,r18
95	MOVE_FROM_SPR r2, SPR_SR
96	REPORT_BIT_TO_CONSOLE r2, SPR_SR_F
97	PRINT_NEWLINE_TO_CONSOLE
98
99	POP LINK_REGISTER_R9
100	RETURN_TO_LINK_REGISTER_R9
101