1 /* Tests some basic fpu instructions.
3 Copyright (C) 2017-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
19 # output: report(0x00007ab7);\n
20 # output: report(0xffffd8f0);\n
21 # output: report(0x46f56e00);\n
22 # output: report(0xc61c4000);\n
23 # output: report(0x00007ab7);\n
24 # output: report(0xffffd8f0);\n
26 # output: report(0xc0490e56);\n
27 # output: report(0xfffffffd);\n
29 # output: report(0x4e6b4bbb);\n
31 # output: report(0xbdc0be40);\n
33 # output: report(0x00000001);\n
35 # output: WARNING: ignoring fpu error caught in fast mode.\n
36 # output: report(0x00000000);\n
40 #include "or1k-asm-test-helpers.h"
42 STANDARD_TEST_ENVIRONMENT
44 .section .exception_vectors
46 /* Floating point exception. */
49 /* The handling is a bit dubious at present. We just patch the
50 instruction with l.nop and restart. This will go wrong in branch
51 delay slots. But we don't have those in this test. */
52 l.addi r1, r1, -EXCEPTION_STACK_SKIP_SIZE
55 /* Save the address of the instruction that caused the problem. */
56 MOVE_FROM_SPR r2, SPR_EPCR_BASE
57 LOAD_IMMEDIATE r3, 0x15000000 /* Opcode for l.nop */
61 l.addi r1, r1, EXCEPTION_STACK_SKIP_SIZE
68 /* Test lf.itof.s int to float conversion. Setting up:
77 REPORT_REG_TO_CONSOLE r11
78 REPORT_REG_TO_CONSOLE r13
81 REPORT_REG_TO_CONSOLE r10
82 REPORT_REG_TO_CONSOLE r12
84 /* Test lf.ftoi.s float to int conversion. */
87 REPORT_REG_TO_CONSOLE r11
88 REPORT_REG_TO_CONSOLE r13
89 PRINT_NEWLINE_TO_CONSOLE
91 /* Test lf.div.s divide 31415 by -1000 to get -pi. Setting up:
95 REPORT_REG_TO_CONSOLE r8
98 REPORT_REG_TO_CONSOLE r11
99 PRINT_NEWLINE_TO_CONSOLE
101 /* Test lf.mul.s multiply -pi x -10000 x 31415. Setting up:
106 REPORT_REG_TO_CONSOLE r6
107 PRINT_NEWLINE_TO_CONSOLE
109 /* Test lf.rem.s remainder of 986902225 / -pi. */
111 REPORT_REG_TO_CONSOLE r2
112 PRINT_NEWLINE_TO_CONSOLE
114 /* Test lf.sfge.s set flag if r6 >= r10. */
116 MOVE_FROM_SPR r2, SPR_SR
117 REPORT_BIT_TO_CONSOLE r2, SPR_SR_F
118 PRINT_NEWLINE_TO_CONSOLE
120 /* Test raising an exception by dividing by 0. */
121 MOVE_FROM_SPR r2, SPR_FPCSR
123 MOVE_TO_SPR SPR_FPCSR, r2
124 div0: lf.div.s r2, r8, r0
125 REPORT_EXCEPTION div0
126 PRINT_NEWLINE_TO_CONSOLE
129 RETURN_TO_LINK_REGISTER_R9