1 # frv testcase to generate fp_exception
3 .include "testutils.inc"
11 ; clear the packing bit if the insn at 'pack:'. We can't simply use
12 ; '.p' because the assembler will catch the error.
14 and_gr_immed 0x7fffffff,gr10
19 ; Make the the source register number odd at badst. We can't simply
20 ; code an odd register number because the assembler will catch the
23 or_gr_immed 0x02000000,gr10
25 set_gr_addr badst,gr10
28 ; Make the the dest register number odd at ld. We can't simply
29 ; code an odd register number because the assembler will catch the
32 or_gr_immed 0x02000000,gr10
34 set_gr_addr badld,gr10
37 and_spr_immed -4081,tbr ; clear tbr.tt
39 inc_gr_immed 0x070,gr17 ; address of exception handler
41 inc_gr_immed 0x060,gr17 ; address of exception handler
46 inc_gr_immed -4,sp ; for alignment
48 set_gr_immed 0,gr20 ; PC increment
52 badst: stdfi fr0,@(sp,0) ; misaligned reg -- slot I0
57 badld: lddfi @(sp,0),fr8 ; misaligned reg -- slot I1
63 fnegs fr10,fr11 ; packing violation
67 set_gr_immed 4,gr20 ; PC increment
68 bad: .word 0x83e502c4 ; fmadds fr16,fr4,fr1 (unimplemented)
71 and_spr_immed 0xfbffffff,fsr0 ; disable div/0 fp_exception
72 set_fr_iimmed 0x7f7f,0xffff,fr0
73 set_fr_iimmed 0x0000,0x0000,fr1
74 fdivs fr0,fr1,fr2 ; div/0 -- no exception
75 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is still set
76 test_spr_bits 0xfc00,10,0x4,fsr0 ; fsr0.aexc is still set
77 test_spr_bits 0xe0000,17,0x0,fsr0 ; fsr0.ftt is clear
78 and_spr_immed 0xffefffff,fsr0 ; Clear fsr0.qne
81 set_gr_immed 0,gr20 ; PC increment
82 or_spr_immed 0x04000000,fsr0 ; enable div/0 fp_exception
83 set_fr_iimmed 0xdead,0xbeef,fr2
84 fdivs fr0,fr1,fr2 ; fp_exception - div/0
85 test_fr_iimmed 0xdeadbeef,fr2 ; fr2 not updated
88 and_spr_immed 0xfdffffff,fsr0 ; disable inexact fp_exception
89 fsqrts fr32,fr2 ; inexact -- no exception
90 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is still set
91 test_spr_bits 0xfc00,10,0x6,fsr0 ; fsr0.aexc is set
92 test_spr_bits 0xe0000,17,0x0,fsr0 ; fsr0.ftt is clear
94 set_fr_fr fr2,fr3 ; sqrt 2
95 set_fr_iimmed 0xdead,0xbeef,fr2
97 or_spr_immed 0x02000000,fsr0 ; enable inexact fp_exception
98 fsqrts fr32,fr2 ; fp_exception - inexact
99 test_gr_immed 6,gr15 ; handler called
100 test_fr_fr fr2,fr3 ; fr2 updated
102 set_fr_iimmed 0xdead,0xbeef,fr2
104 fsqrts fr32,fr2 ; fp_exception - inexact again
105 test_gr_immed 7,gr15 ; handler called
106 test_fr_fr fr2,fr3 ; fr2 updated
110 ; exception handler 1 -- bad insn
112 test_spr_immed 1,esfr1 ; esr0 active
113 test_spr_bits 0x3e,1,0x5,esr0 ; esr0.ec is set
114 test_spr_bits 0x1,0,0x1,esr0 ; esr0.valid is set
115 test_spr_addr bad,epcr0
118 ; exception handler 2 - fp_exception: divide by 0
120 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is set
121 test_spr_bits 0xe0000,17,0x1,fsr0 ; fsr0.ftt is set
122 test_spr_bits 0xfc00,10,0x4,fsr0 ; fsr0.aexc is still set
124 test_spr_bits 0x80000000,31,0x0,fqst2 ; fq2.miv is set
125 test_spr_bits 0x18000,15,0x0,fqst2 ; fq2.sie is set
126 test_spr_bits 0x380,7,0x1,fqst2 ; fq2.ftt is set
127 test_spr_bits 0x7e,1,0x4,fqst2 ; fq2.cexc is set
128 test_spr_bits 0x1,0,0x1,fqst2 ; fq2.valid is set
129 test_spr_immed 0x85e40241,fqop2 ; fq2.opc
132 ; exception handler 3 - fp_exception: register exception
134 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is set
135 test_spr_bits 0xe0000,17,0x6,fsr0 ; fsr0.ftt is set
136 test_spr_bits 0xfc00,10,0x0,fsr0 ; fsr0.aexc is clear
138 test_spr_bits 0x80000000,31,0x0,fqst2 ; fq2.miv is set
139 test_spr_bits 0x18000,15,0x0,fqst2 ; fq2.sie is set
140 test_spr_bits 0x380,7,0x6,fqst2 ; fq2.ftt is set
141 test_spr_bits 0x7e,1,0x0,fqst2 ; fq2.cexc is set
142 test_spr_bits 0x1,0,0x1,fqst2 ; fq2.valid is set
143 test_spr_immed 0x83581000,fqop2 ; fq2.opc
146 ; exception handler 4 - fp_exception: another register exception
148 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is set
149 test_spr_bits 0xe0000,17,0x6,fsr0 ; fsr0.ftt is set
150 test_spr_bits 0xfc00,10,0x0,fsr0 ; fsr0.aexc is still clear
152 test_spr_bits 0x80000000,31,0x0,fqst3 ; fq3.miv is set
153 test_spr_bits 0x18000,15,0x0,fqst3 ; fq3.sie is set
154 test_spr_bits 0x380,7,0x6,fqst3 ; fq3.ftt is set
155 test_spr_bits 0x7e,1,0x0,fqst3 ; fq3.cexc is set
156 test_spr_bits 0x1,0,0x1,fqst3 ; fq3.valid is set
157 test_spr_immed 0x92ec1000,fqop3 ; fq3.opc
160 ; exception handler 5 - fp_exception: sequence violation
162 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is set
163 test_spr_bits 0xe0000,17,0x4,fsr0 ; fsr0.ftt is set
164 test_spr_bits 0xfc00,10,0x0,fsr0 ; fsr0.aexc is still clear
166 test_spr_bits 0x80000000,31,0x0,fqst3 ; fq3.miv is set
167 test_spr_bits 0x18000,15,0x0,fqst3 ; fq3.sie is set
168 test_spr_bits 0x380,7,0x4,fqst3 ; fq3.ftt is set
169 test_spr_bits 0x7e,1,0x0,fqst3 ; fq3.cexc is set
170 test_spr_bits 0x1,0,0x1,fqst3 ; fq3.valid is set
171 test_spr_immed 0x97e400ca,fqop3 ; fq3.opc
174 ; exception handler 6 - fp_exception: inexact
176 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is set
177 test_spr_bits 0xe0000,17,0x1,fsr0 ; fsr0.ftt is set
178 test_spr_bits 0xfc00,10,0x6,fsr0 ; fsr0.aexc is still set
180 test_spr_bits 0x80000000,31,0x0,fqst0 ; fq0.miv is set
181 test_spr_bits 0x18000,15,0x0,fqst0 ; fq0.sie is set
182 test_spr_bits 0x380,7,0x1,fqst0 ; fq0.ftt is set
183 test_spr_bits 0x7e,1,0x2,fqst0 ; fq0.cexc is set
184 test_spr_bits 0x1,0,0x1,fqst0 ; fq0.valid is set
185 test_spr_immed 0x85e40160,fqop0 ; fq0.opc
188 ; exception handler 7 - fp_exception: inexact again
190 test_spr_bits 0x100000,20,0x1,fsr0 ; fsr0.qne is set
191 test_spr_bits 0xe0000,17,0x1,fsr0 ; fsr0.ftt is set
192 test_spr_bits 0xfc00,10,0x6,fsr0 ; fsr0.aexc is still set
194 test_spr_bits 0x80000000,31,0x0,fqst1 ; fq1.miv is set
195 test_spr_bits 0x18000,15,0x0,fqst1 ; fq1.sie is set
196 test_spr_bits 0x380,7,0x1,fqst1 ; fq1.ftt is set
197 test_spr_bits 0x7e,1,0x2,fqst1 ; fq1.cexc is set
198 test_spr_bits 0x1,0,0x1,fqst1 ; fq1.valid is set
199 test_spr_immed 0x85e40160,fqop1 ; fq1.opc