Home | History | Annotate | Line # | Download | only in interrupts
      1  1.1  christos # frv testcase to generate fp_exception
      2  1.1  christos # mach: fr500
      3  1.1  christos 	.include "testutils.inc"
      4  1.1  christos 
      5  1.1  christos 	float_constants
      6  1.1  christos 	start
      7  1.1  christos 	load_float_constants
      8  1.1  christos 
      9  1.1  christos 	.global align
     10  1.1  christos align:
     11  1.1  christos 	; clear the packing bit if the insn at 'pack:'. We can't simply use
     12  1.1  christos 	; '.p' because the assembler will catch the error.
     13  1.1  christos 	set_gr_mem	pack,gr10
     14  1.1  christos 	and_gr_immed	0x7fffffff,gr10
     15  1.1  christos 	set_mem_gr	gr10,pack
     16  1.1  christos 	set_gr_addr	pack,gr10
     17  1.1  christos 	flush_data_cache gr10
     18  1.1  christos 
     19  1.1  christos 	; Make the the source register number odd at badst. We can't simply
     20  1.1  christos 	; code an odd register number because the assembler will catch the
     21  1.1  christos 	; error.
     22  1.1  christos 	set_gr_mem	badst,gr10
     23  1.1  christos 	or_gr_immed	0x02000000,gr10
     24  1.1  christos 	set_mem_gr	gr10,badst
     25  1.1  christos 	set_gr_addr	badst,gr10
     26  1.1  christos 	flush_data_cache gr10
     27  1.1  christos 
     28  1.1  christos 	; Make the the dest register number odd at ld. We can't simply
     29  1.1  christos 	; code an odd register number because the assembler will catch the
     30  1.1  christos 	; error.
     31  1.1  christos 	set_gr_mem	badld,gr10
     32  1.1  christos 	or_gr_immed	0x02000000,gr10
     33  1.1  christos 	set_mem_gr	gr10,badld
     34  1.1  christos 	set_gr_addr	badld,gr10
     35  1.1  christos 	flush_data_cache gr10
     36  1.1  christos 
     37  1.1  christos 	and_spr_immed	-4081,tbr		; clear tbr.tt
     38  1.1  christos 	set_gr_spr	tbr,gr17
     39  1.1  christos 	inc_gr_immed	0x070,gr17		; address of exception handler
     40  1.1  christos 	set_bctrlr_0_0  gr17
     41  1.1  christos 	inc_gr_immed	0x060,gr17		; address of exception handler
     42  1.1  christos 	set_bctrlr_0_0  gr17
     43  1.1  christos 	set_spr_immed	128,lcr
     44  1.1  christos 	set_spr_addr	ok1,lr
     45  1.1  christos 	set_psr_et	1
     46  1.1  christos 	inc_gr_immed	-4,sp		; for alignment
     47  1.1  christos 
     48  1.1  christos 	set_gr_immed	0,gr20		; PC increment
     49  1.1  christos 	set_gr_immed	0,gr15
     50  1.1  christos 
     51  1.1  christos 	set_spr_addr	ok3,lr
     52  1.1  christos badst:	stdfi		fr0,@(sp,0)	; misaligned reg -- slot I0
     53  1.1  christos 	test_gr_immed	1,gr15
     54  1.1  christos 
     55  1.1  christos 	set_spr_addr	ok4,lr
     56  1.1  christos 	nop.p
     57  1.1  christos badld:	lddfi		@(sp,0),fr8	; misaligned reg -- slot I1
     58  1.1  christos 	test_gr_immed	2,gr15
     59  1.1  christos 
     60  1.1  christos 	set_spr_addr	ok5,lr
     61  1.1  christos 	fnegs.p		fr9,fr9
     62  1.1  christos pack:	fnegs		fr10,fr10
     63  1.1  christos 	fnegs		fr10,fr11	; packing violation
     64  1.1  christos 	test_gr_immed	3,gr15
     65  1.1  christos 
     66  1.1  christos 	set_spr_addr	ok1,lr
     67  1.1  christos 	set_gr_immed	4,gr20		; PC increment
     68  1.1  christos bad:	.word		0x83e502c4	; fmadds fr16,fr4,fr1 (unimplemented)
     69  1.1  christos 	test_gr_immed	4,gr15
     70  1.1  christos 
     71  1.1  christos 	and_spr_immed	0xfbffffff,fsr0		; disable div/0 fp_exception
     72  1.1  christos 	set_fr_iimmed	0x7f7f,0xffff,fr0
     73  1.1  christos 	set_fr_iimmed	0x0000,0x0000,fr1
     74  1.1  christos 	fdivs		fr0,fr1,fr2		; div/0 -- no exception
     75  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is still set
     76  1.1  christos 	test_spr_bits	0xfc00,10,0x4,fsr0	; fsr0.aexc is still set
     77  1.1  christos 	test_spr_bits	0xe0000,17,0x0,fsr0	; fsr0.ftt is clear
     78  1.1  christos 	and_spr_immed	0xffefffff,fsr0		; Clear fsr0.qne
     79  1.1  christos 
     80  1.1  christos 	set_spr_addr	ok2,lr
     81  1.1  christos 	set_gr_immed	0,gr20			; PC increment
     82  1.1  christos 	or_spr_immed	0x04000000,fsr0		; enable div/0 fp_exception
     83  1.1  christos 	set_fr_iimmed	0xdead,0xbeef,fr2
     84  1.1  christos 	fdivs		fr0,fr1,fr2		; fp_exception - div/0
     85  1.1  christos 	test_fr_iimmed	0xdeadbeef,fr2		; fr2 not updated
     86  1.1  christos 	test_gr_immed	5,gr15
     87  1.1  christos 
     88  1.1  christos 	and_spr_immed	0xfdffffff,fsr0		; disable inexact fp_exception
     89  1.1  christos 	fsqrts		fr32,fr2		; inexact -- no exception
     90  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is still set
     91  1.1  christos 	test_spr_bits	0xfc00,10,0x6,fsr0	; fsr0.aexc is set
     92  1.1  christos 	test_spr_bits	0xe0000,17,0x0,fsr0	; fsr0.ftt is clear
     93  1.1  christos 
     94  1.1  christos 	set_fr_fr	fr2,fr3			; sqrt 2
     95  1.1  christos 	set_fr_iimmed	0xdead,0xbeef,fr2
     96  1.1  christos 	set_spr_addr	ok6,lr
     97  1.1  christos 	or_spr_immed	0x02000000,fsr0		; enable inexact fp_exception
     98  1.1  christos 	fsqrts		fr32,fr2		; fp_exception - inexact
     99  1.1  christos 	test_gr_immed	6,gr15			; handler called
    100  1.1  christos 	test_fr_fr	fr2,fr3			; fr2 updated
    101  1.1  christos 
    102  1.1  christos 	set_fr_iimmed	0xdead,0xbeef,fr2
    103  1.1  christos 	set_spr_addr	ok7,lr
    104  1.1  christos 	fsqrts		fr32,fr2		; fp_exception - inexact again
    105  1.1  christos 	test_gr_immed	7,gr15			; handler called
    106  1.1  christos 	test_fr_fr	fr2,fr3			; fr2 updated
    107  1.1  christos 
    108  1.1  christos 	pass
    109  1.1  christos 
    110  1.1  christos ; exception handler 1 -- bad insn
    111  1.1  christos ok1:
    112  1.1  christos 	test_spr_immed	1,esfr1			; esr0 active
    113  1.1  christos 	test_spr_bits	0x3e,1,0x5,esr0		; esr0.ec is set
    114  1.1  christos 	test_spr_bits	0x1,0,0x1,esr0		; esr0.valid is set
    115  1.1  christos 	test_spr_addr	bad,epcr0
    116  1.1  christos 	bra		ret
    117  1.1  christos 
    118  1.1  christos ; exception handler 2 - fp_exception: divide by 0
    119  1.1  christos ok2:
    120  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is set
    121  1.1  christos 	test_spr_bits	0xe0000,17,0x1,fsr0	; fsr0.ftt is set
    122  1.1  christos 	test_spr_bits	0xfc00,10,0x4,fsr0	; fsr0.aexc is still set
    123  1.1  christos 
    124  1.1  christos 	test_spr_bits	0x80000000,31,0x0,fqst2	; fq2.miv is set
    125  1.1  christos 	test_spr_bits	0x18000,15,0x0,fqst2	; fq2.sie is set
    126  1.1  christos 	test_spr_bits	0x380,7,0x1,fqst2	; fq2.ftt is set
    127  1.1  christos 	test_spr_bits	0x7e,1,0x4,fqst2	; fq2.cexc is set
    128  1.1  christos 	test_spr_bits	0x1,0,0x1,fqst2		; fq2.valid is set
    129  1.1  christos 	test_spr_immed	0x85e40241,fqop2	; fq2.opc
    130  1.1  christos 	bra		ret
    131  1.1  christos 
    132  1.1  christos ; exception handler 3 - fp_exception: register exception
    133  1.1  christos ok3:
    134  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is set
    135  1.1  christos 	test_spr_bits	0xe0000,17,0x6,fsr0	; fsr0.ftt is set
    136  1.1  christos 	test_spr_bits	0xfc00,10,0x0,fsr0	; fsr0.aexc is clear
    137  1.1  christos 
    138  1.1  christos 	test_spr_bits	0x80000000,31,0x0,fqst2	; fq2.miv is set
    139  1.1  christos 	test_spr_bits	0x18000,15,0x0,fqst2	; fq2.sie is set
    140  1.1  christos 	test_spr_bits	0x380,7,0x6,fqst2	; fq2.ftt is set
    141  1.1  christos 	test_spr_bits	0x7e,1,0x0,fqst2	; fq2.cexc is set
    142  1.1  christos 	test_spr_bits	0x1,0,0x1,fqst2		; fq2.valid is set
    143  1.1  christos 	test_spr_immed	0x83581000,fqop2	; fq2.opc
    144  1.1  christos 	bra		ret
    145  1.1  christos 
    146  1.1  christos ; exception handler 4 - fp_exception: another register exception
    147  1.1  christos ok4:
    148  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is set
    149  1.1  christos 	test_spr_bits	0xe0000,17,0x6,fsr0	; fsr0.ftt is set
    150  1.1  christos 	test_spr_bits	0xfc00,10,0x0,fsr0	; fsr0.aexc is still clear
    151  1.1  christos 
    152  1.1  christos 	test_spr_bits	0x80000000,31,0x0,fqst3	; fq3.miv is set
    153  1.1  christos 	test_spr_bits	0x18000,15,0x0,fqst3	; fq3.sie is set
    154  1.1  christos 	test_spr_bits	0x380,7,0x6,fqst3	; fq3.ftt is set
    155  1.1  christos 	test_spr_bits	0x7e,1,0x0,fqst3	; fq3.cexc is set
    156  1.1  christos 	test_spr_bits	0x1,0,0x1,fqst3		; fq3.valid is set
    157  1.1  christos 	test_spr_immed	0x92ec1000,fqop3	; fq3.opc
    158  1.1  christos 	bra		ret
    159  1.1  christos 
    160  1.1  christos ; exception handler 5 - fp_exception: sequence violation
    161  1.1  christos ok5:
    162  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is set
    163  1.1  christos 	test_spr_bits	0xe0000,17,0x4,fsr0	; fsr0.ftt is set
    164  1.1  christos 	test_spr_bits	0xfc00,10,0x0,fsr0	; fsr0.aexc is still clear
    165  1.1  christos 
    166  1.1  christos 	test_spr_bits	0x80000000,31,0x0,fqst3	; fq3.miv is set
    167  1.1  christos 	test_spr_bits	0x18000,15,0x0,fqst3	; fq3.sie is set
    168  1.1  christos 	test_spr_bits	0x380,7,0x4,fqst3	; fq3.ftt is set
    169  1.1  christos 	test_spr_bits	0x7e,1,0x0,fqst3	; fq3.cexc is set
    170  1.1  christos 	test_spr_bits	0x1,0,0x1,fqst3		; fq3.valid is set
    171  1.1  christos 	test_spr_immed	0x97e400ca,fqop3	; fq3.opc
    172  1.1  christos 	bra		ret
    173  1.1  christos 
    174  1.1  christos ; exception handler 6 - fp_exception: inexact
    175  1.1  christos ok6:
    176  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is set
    177  1.1  christos 	test_spr_bits	0xe0000,17,0x1,fsr0	; fsr0.ftt is set
    178  1.1  christos 	test_spr_bits	0xfc00,10,0x6,fsr0	; fsr0.aexc is still set
    179  1.1  christos 
    180  1.1  christos 	test_spr_bits	0x80000000,31,0x0,fqst0	; fq0.miv is set
    181  1.1  christos 	test_spr_bits	0x18000,15,0x0,fqst0	; fq0.sie is set
    182  1.1  christos 	test_spr_bits	0x380,7,0x1,fqst0	; fq0.ftt is set
    183  1.1  christos 	test_spr_bits	0x7e,1,0x2,fqst0	; fq0.cexc is set
    184  1.1  christos 	test_spr_bits	0x1,0,0x1,fqst0		; fq0.valid is set
    185  1.1  christos 	test_spr_immed	0x85e40160,fqop0	; fq0.opc
    186  1.1  christos 	bra		ret
    187  1.1  christos 
    188  1.1  christos ; exception handler 7 - fp_exception: inexact again
    189  1.1  christos ok7:
    190  1.1  christos 	test_spr_bits	0x100000,20,0x1,fsr0	; fsr0.qne is set
    191  1.1  christos 	test_spr_bits	0xe0000,17,0x1,fsr0	; fsr0.ftt is set
    192  1.1  christos 	test_spr_bits	0xfc00,10,0x6,fsr0	; fsr0.aexc is still set
    193  1.1  christos 
    194  1.1  christos 	test_spr_bits	0x80000000,31,0x0,fqst1	; fq1.miv is set
    195  1.1  christos 	test_spr_bits	0x18000,15,0x0,fqst1	; fq1.sie is set
    196  1.1  christos 	test_spr_bits	0x380,7,0x1,fqst1	; fq1.ftt is set
    197  1.1  christos 	test_spr_bits	0x7e,1,0x2,fqst1	; fq1.cexc is set
    198  1.1  christos 	test_spr_bits	0x1,0,0x1,fqst1		; fq1.valid is set
    199  1.1  christos 	test_spr_immed	0x85e40160,fqop1	; fq1.opc
    200  1.1  christos 	bra		ret
    201  1.1  christos 
    202  1.1  christos ret:
    203  1.1  christos 	inc_gr_immed	1,gr15
    204  1.1  christos 	movsg		pcsr,gr60
    205  1.1  christos 	add		gr60,gr20,gr60
    206  1.1  christos 	movgs		gr60,pcsr
    207  1.1  christos 	rett		0
    208  1.1  christos 	fail
    209  1.1  christos 
    210