<commit_before>		align	8
start_prg_testblit:
		jalr	x0, 0(x1)
		word	0
		jal	x0, testBlit

;== REGISTERS ==
;
; The blitter logic is optimized to use a lot of registers,
; to ensure best balance of performance versus convenient
; interface.  These equations will help readability.

bsrcdat	= x16	; data dword from source bitmap
bdstdat	= x17	; data dword from destination bitmap
bsrcprv	= x18	; previous dword from source bitmap
bropfn	= x19	; pointer to raster op function
bshiftl	= x20	; distance to shift left (0 <= bshiftl <= 64)
bshiftr	= x21	; distance to shift right (0 <= bshiftl <= 64)
bcache	= x22	; work register
bsrcadr	= x23	; pointer to next source dword
bdstadr	= x24	; pointer to next destination dword


;== DATA ==

		align	8
tbimm_FF00FF00FF00FF00: dword	$FF00FF00FF00FF00
tbimm_00005555AAAAFFFF: dword	$00005555AAAAFFFF

tbfailmsg:	byte	"0: value mismatch"
tbfailmsglen = *-tbfailmsg

;== CODE ==

		align	8

testBlit:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		jal	ra, tbdata
		ld	x16, 0(dsp)	; preserve STS jump table
		sd	x16, tb_stsBase(x15)

tb0:		auipc	gp, 0
		addi	x16, gp, tbtann-tb0
		addi	x17, x0, tbtannlen
		jal	ra, tbtype
		jal	ra, tbcr

		jal	ra, tbf0
		jal	ra, tbf1
		jal	ra, tbf2
		jal	ra, tbf3
		jal	ra, tbf4
		jal	ra, tbf5
		jal	ra, tbf6
		jal	ra, tbf7
		jal	ra, tbf8
		jal	ra, tbf9
		jal	ra, tbfA
		jal	ra, tbfB
		jal	ra, tbfC
		jal	ra, tbfD
		jal	ra, tbfE
		jal	ra, tbfF

		jal	ra, tbShiftLeft

tb1:		auipc	gp, 0
		addi	x16, gp, tbtok-tb1
		addi	x17, x0, tbtoklen
		jal	ra, tbtype
		jal	ra, tbcr

		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

; Test shifting logic.

tbShiftLeft:	jal	x31, tb_i_shltest
		align	8
tbsldata:	dword	$AA000000000000FC	; source data
		dword	$0000000000AAAAAA	; computed destination data
		dword	$5000000000AAAFEA	; expected destination data
		dword	$0000000000000005	; expected previous source value
		dword	tbFn7-tbsldata		; D=D OR S		

tb_i_shltest:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		addi	x31, x31, 7		; Ensure X31 points to our control block
		andi	x31, x31, -8

		addi	bsrcadr, x31, 0		; BSRCADR -> source "bitmap" dword
		addi	bdstadr, x31, 8		; BDSTADR -> destination "bitmap" dword
		addi	bsrcprv, x0, 0		; Always initialize to 0.
		addi	bshiftr, x0, 61		; shift 3 bits left; 64-3=61
		addi	bshiftl, x0, 3		; shift 3 bits left
		ld	bropfn, 32(x31)		; compute address of ROP procedure
		add	bropfn, bropfn, x31
		jal	ra, tbDWord		; blit a single dword.

		addi	dsp, dsp, -8
		sd	x31, 0(dsp)

		add	bcache, x31, 0
		beq	bdstadr, bcache, tbdstok
		jal	ra, tb_i_print
		byte	"   shltest: BDSTADR has unexpected value", 13, 10, 0

		align	4
tbdstok:	ld	x31, 0(dsp)
		addi	bcache, x31, -8
		beq	bsrcadr, bcache, tbsrcok
		jal	ra, tb_i_print
		byte	"   shltest: BSRCADR has unexpected value", 13, 10, 0

		align	4
tbsrcok:	ld	x31, 0(dsp)
		ld	bcache, 24(x31)
		beq	bsrcprv, bcache, tbprvok
		jal	ra, tb_i_print
		byte	"   shltest: BSRCPRV has unexpected value", 13, 10, 0

		align	4
tbprvok:	ld	x31, 0(dsp)
		ld	bcache, 8(x31)
		ld	bsrcprv, 16(x31)
		beq	bcache, bsrcprv, tbdatok
		jal	ra, tb_i_print
		byte	"   shltest: Blitted word has unexpected value", 13, 10, 0

		align	4
tbdatok:	addi	dsp, dsp, 8
		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

tbDWord:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		ld	bcache, 0(bsrcadr)
		addi	bsrcadr, bsrcadr, -8
		sll	bsrcdat, bcache, bshiftl
		or	bsrcdat, bsrcdat, bsrcprv
		srl	bsrcprv, bcache, bshiftr
		ld	bdstdat, 0(bdstadr)
		jalr	ra, 0(bropfn)
		sd	bsrcdat, 0(bdstadr)
		addi	bdstadr, bdstadr, -8

		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

; Test individual raster operations.

tbfF:		jal	x31, tb_i_fntest
		align	8
tbfFdata:	dword	$FFFFFFFFFFFFFFFF
		hword	tbFnF-tbfFdata, $46

tbfE:		jal	x31, tb_i_fntest
		align	8
tbfEdata:	dword	$FFFFAAFF55FF00FF
		hword	tbFnE-tbfEdata, $45

tbfD:		jal	x31, tb_i_fntest
		align	8
tbfDdata:	dword	$00FF55FFAAFFFFFF
		hword	tbFnD-tbfDdata, $44

tbfC:		jal	x31, tb_i_fntest
		align	8<commit_msg>Blit dword shifting right<commit_after>		align	8
start_prg_testblit:
		jalr	x0, 0(x1)
		word	0
		jal	x0, testBlit

;== REGISTERS ==
;
; The blitter logic is optimized to use a lot of registers,
; to ensure best balance of performance versus convenient
; interface.  These equations will help readability.

bsrcdat	= x16	; data dword from source bitmap
bdstdat	= x17	; data dword from destination bitmap
bsrcprv	= x18	; previous dword from source bitmap
bropfn	= x19	; pointer to raster op function
bshiftl	= x20	; distance to shift left (0 <= bshiftl <= 64)
bshiftr	= x21	; distance to shift right (0 <= bshiftl <= 64)
bcache	= x22	; work register
bsrcadr	= x23	; pointer to next source dword
bdstadr	= x24	; pointer to next destination dword


;== DATA ==

		align	8
tbimm_FF00FF00FF00FF00: dword	$FF00FF00FF00FF00
tbimm_00005555AAAAFFFF: dword	$00005555AAAAFFFF

tbfailmsg:	byte	"0: value mismatch"
tbfailmsglen = *-tbfailmsg

;== CODE ==

		align	8

testBlit:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		jal	ra, tbdata
		ld	x16, 0(dsp)	; preserve STS jump table
		sd	x16, tb_stsBase(x15)

tb0:		auipc	gp, 0
		addi	x16, gp, tbtann-tb0
		addi	x17, x0, tbtannlen
		jal	ra, tbtype
		jal	ra, tbcr

		jal	ra, tbf0
		jal	ra, tbf1
		jal	ra, tbf2
		jal	ra, tbf3
		jal	ra, tbf4
		jal	ra, tbf5
		jal	ra, tbf6
		jal	ra, tbf7
		jal	ra, tbf8
		jal	ra, tbf9
		jal	ra, tbfA
		jal	ra, tbfB
		jal	ra, tbfC
		jal	ra, tbfD
		jal	ra, tbfE
		jal	ra, tbfF

		jal	ra, tbShiftLeft
		jal	ra, tbShiftRight

tb1:		auipc	gp, 0
		addi	x16, gp, tbtok-tb1
		addi	x17, x0, tbtoklen
		jal	ra, tbtype
		jal	ra, tbcr

		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

; Test shifting logic: to the left.

tbShiftLeft:	jal	x31, tb_i_shltest
		align	8
tbsldata:	dword	$AA000000000000FC	; source data
		dword	$0000000000AAAAAA	; computed destination data
		dword	$5000000000AAAFEA	; expected destination data
		dword	$0000000000000005	; expected previous source value
		dword	tbFn7-tbsldata		; D=D OR S		

tb_i_shltest:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		addi	x31, x31, 7		; Ensure X31 points to our control block
		andi	x31, x31, -8

		addi	bsrcadr, x31, 0		; BSRCADR -> source "bitmap" dword
		addi	bdstadr, x31, 8		; BDSTADR -> destination "bitmap" dword
		addi	bsrcprv, x0, 0		; Always initialize to 0.
		addi	bshiftr, x0, 61		; shift 3 bits left; 64-3=61
		addi	bshiftl, x0, 3		; shift 3 bits left
		ld	bropfn, 32(x31)		; compute address of ROP procedure
		add	bropfn, bropfn, x31
		jal	ra, tbDWordL		; blit a single dword.

		addi	dsp, dsp, -8
		sd	x31, 0(dsp)

		addi	bcache, x31, 0
		beq	bdstadr, bcache, tbdstok
		jal	ra, tb_i_print
		byte	"   shltest: BDSTADR has unexpected value", 13, 10, 0

		align	4
tbdstok:	ld	x31, 0(dsp)
		addi	bcache, x31, -8
		beq	bsrcadr, bcache, tbsrcok
		jal	ra, tb_i_print
		byte	"   shltest: BSRCADR has unexpected value", 13, 10, 0

		align	4
tbsrcok:	ld	x31, 0(dsp)
		ld	bcache, 24(x31)
		beq	bsrcprv, bcache, tbprvok
		jal	ra, tb_i_print
		byte	"   shltest: BSRCPRV has unexpected value", 13, 10, 0

		align	4
tbprvok:	ld	x31, 0(dsp)
		ld	bcache, 8(x31)
		ld	bsrcprv, 16(x31)
		beq	bcache, bsrcprv, tbdatok
		jal	ra, tb_i_print
		byte	"   shltest: Blitted word has unexpected value", 13, 10, 0

		align	4
tbdatok:	addi	dsp, dsp, 8
		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

tbDWordL:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		ld	bcache, 0(bsrcadr)
		addi	bsrcadr, bsrcadr, -8
		sll	bsrcdat, bcache, bshiftl
		or	bsrcdat, bsrcdat, bsrcprv
		srl	bsrcprv, bcache, bshiftr
		ld	bdstdat, 0(bdstadr)
		jalr	ra, 0(bropfn)
		sd	bsrcdat, 0(bdstadr)
		addi	bdstadr, bdstadr, -8

		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

; Test shifting logic: to the right.

tbShiftRight:	jal	x31, tb_i_shrtest
		align	8
tbsldata:	dword	$AA000000000000FE	; source data
		dword	$0000000000AAAAAA	; computed destination data
		dword	$2A80000000AAAA95	; expected destination data
		dword	$8000000000000000	; expected previous source value
		dword	tbFn6-tbsldata		; D=D XOR S		

tb_i_shrtest:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		addi	x31, x31, 7		; Ensure X31 points to our control block
		andi	x31, x31, -8

		addi	bsrcadr, x31, 0		; BSRCADR -> source "bitmap" dword
		addi	bdstadr, x31, 8		; BDSTADR -> destination "bitmap" dword
		addi	bsrcprv, x0, 0		; Always initialize to 0.
		addi	bshiftr, x0, 2		; shift 2 bits left
		addi	bshiftl, x0, 62		; shift 2 bits left; 64-2 = 62
		ld	bropfn, 32(x31)		; compute address of ROP procedure
		add	bropfn, bropfn, x31
		jal	ra, tbDWordR		; blit a single dword.

		addi	dsp, dsp, -8
		sd	x31, 0(dsp)

		addi	bcache, x31, 16
		beq	bdstadr, bcache, tbdstok2
		jal	ra, tb_i_print
		byte	"   shrtest: BDSTADR has unexpected value", 13, 10, 0

		align	4
tbdstok2:	ld	x31, 0(dsp)
		addi	bcache, x31, 8
		beq	bsrcadr, bcache, tbsrcok2
		jal	ra, tb_i_print
		byte	"   shrtest: BSRCADR has unexpected value", 13, 10, 0

		align	4
tbsrcok2:	ld	x31, 0(dsp)
		ld	bcache, 24(x31)
		beq	bsrcprv, bcache, tbprvok2
		jal	ra, tb_i_print
		byte	"   shrtest: BSRCPRV has unexpected value", 13, 10, 0

		align	4
tbprvok2:	ld	x31, 0(dsp)
		ld	bcache, 8(x31)
		ld	bsrcprv, 16(x31)
		beq	bcache, bsrcprv, tbdatok2
		jal	ra, tb_i_print
		byte	"   shrtest: Blitted word has unexpected value", 13, 10, 0

		align	4
tbdatok2:	addi	dsp, dsp, 8
		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

tbDWordR:	addi	rsp, rsp, -8
		sd	ra, 0(rsp)

		ld	bcache, 0(bsrcadr)
		addi	bsrcadr, bsrcadr, 8
		srl	bsrcdat, bcache, bshiftr
		or	bsrcdat, bsrcdat, bsrcprv
		sll	bsrcprv, bcache, bshiftl
		ld	bdstdat, 0(bdstadr)
		jalr	ra, 0(bropfn)
		sd	bsrcdat, 0(bdstadr)
		addi	bdstadr, bdstadr, 8

		ld	ra, 0(rsp)
		addi	rsp, rsp, 8
		jalr	x0, 0(ra)

; Test individual raster operations.

tbfF:		jal	x31, tb_i_fntest
		align	8
tbfFdata:	dword	$FFFFFFFFFFFFFFFF
		hword	tbFnF-tbfFdata, $46

tbfE:		jal	x31, tb_i_fntest
		align	8
tbfEdata:	dword	$FFFFAAFF55FF00FF
		hword	tbFnE-tbfEdata, $45

tbfD:		jal	x31, tb_i_fntest
		align	8
tbfDdata:	dword	$00FF55FFAAFFFFFF
		hword	tbFnD-tbfDdata, $44

tbfC:		jal	x31, tb_i_fntest
		align	8
{'fraction_non_alphanumeric': 0.08583733974358974, 'fraction_numerical': 0.07632211538461539, 'mean_word_length': 3.3206404154045868, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2450157', 'n_tokens_mistral': 5573, 'n_tokens_neox': 4915, 'n_words': 1458}