Home | History | Annotate | Line # | Download | only in interrupts
      1  1.1  christos # frv testcase to generate fp_exception
      2  1.1  christos # mach: fr550
      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 badld. 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 	set_gr_immed	4,gr20		; PC increment
     53  1.1  christos badst:	stdfi		fr0,@(sp,0)	; misaligned reg -- slot I0
     54  1.1  christos 	test_gr_immed	1,gr15
     55  1.1  christos 
     56  1.1  christos 	set_spr_addr	ok4,lr
     57  1.1  christos 	set_gr_immed	8,gr20		; PC increment
     58  1.1  christos 	nop.p
     59  1.1  christos badld:	lddfi		@(sp,0),fr8	; misaligned reg -- slot I1
     60  1.1  christos 	test_gr_immed	2,gr15
     61  1.1  christos 
     62  1.1  christos 	set_spr_addr	ok5,lr
     63  1.1  christos 	set_gr_immed	20,gr20		; PC increment
     64  1.1  christos 	fnegs.p		fr9,fr9
     65  1.1  christos 	fnegs.p		fr9,fr10
     66  1.1  christos 	fnegs.p		fr9,fr11
     67  1.1  christos pack:	fnegs		fr10,fr12
     68  1.1  christos 	fnegs		fr10,fr13	; packing violation
     69  1.1  christos 	test_gr_immed	3,gr15
     70  1.1  christos 
     71  1.1  christos 	set_spr_addr	ok1,lr
     72  1.1  christos 	set_gr_immed	4,gr20		; PC increment
     73  1.1  christos bad:	.word		0x83e502c4	; fmadds fr16,fr4,fr1 (unimplemented)
     74  1.1  christos 	test_gr_immed	4,gr15
     75  1.1  christos 
     76  1.1  christos 	and_spr_immed	0xfbffffff,fsr0		; disable div/0 fp_exception
     77  1.1  christos 	set_fr_iimmed	0x7f7f,0xffff,fr0
     78  1.1  christos 	set_fr_iimmed	0x0000,0x0000,fr1
     79  1.1  christos 	fdivs		fr0,fr1,fr2		; div/0 -- no exception
     80  1.1  christos 	test_spr_bits	0x100000,20,0x0,fsr0	; fsr0.qne is never set
     81  1.1  christos 	test_spr_bits	0xfc00,10,0x4,fsr0	; fsr0.aexc is still set
     82  1.1  christos 	test_spr_bits	0xe0000,17,0x0,fsr0	; fsr0.ftt is clear
     83  1.1  christos 
     84  1.1  christos 	set_spr_addr	ok2,lr
     85  1.1  christos 	set_gr_immed	0,gr20			; PC increment
     86  1.1  christos 	or_spr_immed	0x04000000,fsr0		; enable div/0 fp_exception
     87  1.1  christos 	set_fr_iimmed	0xdead,0xbeef,fr2
     88  1.1  christos div0:	fdivs		fr0,fr1,fr2		; fp_exception - div/0
     89  1.1  christos 	test_fr_iimmed	0xdeadbeef,fr2		; fr2 not updated
     90  1.1  christos 	test_gr_immed	5,gr15
     91  1.1  christos 
     92  1.1  christos 	and_spr_immed	0xfdffffff,fsr0		; disable inexact fp_exception
     93  1.1  christos 	fsqrts		fr32,fr2		; inexact -- no exception
     94  1.1  christos 	test_spr_bits	0x100000,20,0x0,fsr0	; fsr0.qne is never set
     95  1.1  christos 	test_spr_bits	0xfc00,10,0x6,fsr0	; fsr0.aexc is set
     96  1.1  christos 	test_spr_bits	0xe0000,17,0x0,fsr0	; fsr0.ftt is clear
     97  1.1  christos 
     98  1.1  christos 	set_fr_fr	fr2,fr3			; sqrt 2
     99  1.1  christos 	set_fr_iimmed	0xdead,0xbeef,fr2
    100  1.1  christos 	set_spr_addr	ok6,lr
    101  1.1  christos 	or_spr_immed	0x02000000,fsr0		; enable inexact fp_exception
    102  1.1  christos inxt1:	fsqrts		fr32,fr2		; fp_exception - inexact
    103  1.1  christos 	test_gr_immed	6,gr15			; handler called
    104  1.1  christos 	test_fr_fr	fr2,fr3			; fr2 updated
    105  1.1  christos 
    106  1.1  christos 	set_fr_iimmed	0xdead,0xbeef,fr2
    107  1.1  christos 	set_spr_addr	ok7,lr
    108  1.1  christos inxt2:	fsqrts		fr32,fr2		; fp_exception - inexact again
    109  1.1  christos 	test_gr_immed	7,gr15			; handler called
    110  1.1  christos 	test_fr_fr	fr2,fr3			; fr2 updated
    111  1.1  christos 
    112  1.1  christos 	pass
    113  1.1  christos 
    114  1.1  christos ; exception handler 1 -- illegal_instruction: bad insn
    115  1.1  christos ok1:
    116  1.1  christos 	test_spr_immed	1,esfr1			; esr0 active
    117  1.1  christos 	test_spr_bits	0x3e,1,0x5,esr0		; esr0.ec is set
    118  1.1  christos 	test_spr_bits	0x1,0,0x1,esr0		; esr0.valid is set
    119  1.1  christos 	bra		ret
    120  1.1  christos 
    121  1.1  christos ; exception handler 2 - fp_exception: divide by 0
    122  1.1  christos ok2:
    123  1.1  christos 	test_spr_bits	0x100000,20,0x0,fsr0	; fsr0.qne is clear
    124  1.1  christos 	test_spr_bits	0xe0000,17,0x1,fsr0	; fsr0.ftt is set
    125  1.1  christos 	test_spr_bits	0xfc00,10,0x4,fsr0	; fsr0.aexc is still set
    126  1.1  christos 
    127  1.1  christos 	test_spr_immed	4,esfr1			; esr2 active
    128  1.1  christos 	test_spr_bits	0x3e,1,0xd,esr2		; esr2.ec is set
    129  1.1  christos 	test_spr_bits	0x1,0,0x1,esr2		; esr2.valid is set
    130  1.1  christos 	test_spr_addr	div0,epcr2		; epcr2 is set
    131  1.1  christos 	bra		ret
    132  1.1  christos 
    133  1.1  christos ; exception handler 3 - illegal_instruction: register exception
    134  1.1  christos ok3:
    135  1.1  christos 	test_spr_immed	1,esfr1			; esr0 active
    136  1.1  christos 	test_spr_bits	0x3e,1,0x5,esr0		; esr0.ec is set
    137  1.1  christos 	test_spr_bits	0x1,0,0x1,esr0		; esr0.valid is set
    138  1.1  christos 	bra		ret
    139  1.1  christos 
    140  1.1  christos ; exception handler 4 - illegal_instruction: register exception
    141  1.1  christos ok4:
    142  1.1  christos 	test_spr_immed	1,esfr1			; esr0 active
    143  1.1  christos 	test_spr_bits	0x3e,1,0x5,esr0		; esr0.ec is set
    144  1.1  christos 	test_spr_bits	0x1,0,0x1,esr0		; esr0.valid is set
    145  1.1  christos 	bra		ret
    146  1.1  christos 
    147  1.1  christos ; exception handler 5 - illegal_instruction: sequence violation
    148  1.1  christos ok5:
    149  1.1  christos 	test_spr_immed	1,esfr1			; esr0 active
    150  1.1  christos 	test_spr_bits	0x3e,1,0x5,esr0		; esr0.ec is set
    151  1.1  christos 	test_spr_bits	0x1,0,0x1,esr0		; esr0.valid is set
    152  1.1  christos 	bra		ret
    153  1.1  christos 
    154  1.1  christos ; exception handler 6 - fp_exception: inexact
    155  1.1  christos ok6:
    156  1.1  christos 	test_spr_bits	0x100000,20,0x0,fsr0	; fsr0.qne is clear
    157  1.1  christos 	test_spr_bits	0xe0000,17,0x1,fsr0	; fsr0.ftt is set
    158  1.1  christos 	test_spr_bits	0xfc00,10,0x6,fsr0	; fsr0.aexc is still set
    159  1.1  christos 
    160  1.1  christos 	test_spr_immed	4,esfr1			; esr2 active
    161  1.1  christos 	test_spr_bits	0x3e,1,0xd,esr2		; esr2.ec is set
    162  1.1  christos 	test_spr_bits	0x1,0,0x1,esr2		; esr2.valid is set
    163  1.1  christos 	test_spr_addr	inxt1,epcr2		; epcr2 is set
    164  1.1  christos 	bra		ret
    165  1.1  christos 
    166  1.1  christos ; exception handler 7 - fp_exception: inexact again
    167  1.1  christos ok7:
    168  1.1  christos 	test_spr_bits	0x100000,20,0x0,fsr0	; fsr0.qne is clear
    169  1.1  christos 	test_spr_bits	0xe0000,17,0x1,fsr0	; fsr0.ftt is set
    170  1.1  christos 	test_spr_bits	0xfc00,10,0x6,fsr0	; fsr0.aexc is still set
    171  1.1  christos 
    172  1.1  christos 	test_spr_immed	4,esfr1			; esr2 active
    173  1.1  christos 	test_spr_bits	0x3e,1,0xd,esr2		; esr2.ec is set
    174  1.1  christos 	test_spr_bits	0x1,0,0x1,esr2		; esr2.valid is set
    175  1.1  christos 	test_spr_addr	inxt2,epcr2		; epcr2 is set
    176  1.1  christos 	bra		ret
    177  1.1  christos 
    178  1.1  christos ret:
    179  1.1  christos 	inc_gr_immed	1,gr15
    180  1.1  christos 	movsg		pcsr,gr60
    181  1.1  christos 	add		gr60,gr20,gr60
    182  1.1  christos 	movgs		gr60,pcsr
    183  1.1  christos 	rett		0
    184  1.1  christos 	fail
    185  1.1  christos 
    186