/*1* linux/arch/alpha/lib/memset.S2*3* This is an efficient (and small) implementation of the C library "memset()"4* function for the alpha.5*6* (C) Copyright 1996 Linus Torvalds7*8* This routine is "moral-ware": you are free to use it any way you wish, and9* the only obligation I put on you is a moral one: if you make any improvements10* to the routine, please send me your improvements for me to use similarly.11*12* The scheduling comments are according to the EV5 documentation (and done by13* hand, so they might well be incorrect, please do tell me about it..)14*/1516.set noat17.set noreorder18.text19.globl memset20.globl __memset21.globl __memsetw22.globl __constant_c_memset23.ent __memset24.align 525__memset:26.frame $30,0,$26,027.prologue 02829and $17,255,$1 /* E1 */30insbl $17,1,$17 /* .. E0 */31bis $17,$1,$17 /* E0 (p-c latency, next cycle) */32sll $17,16,$1 /* E1 (p-c latency, next cycle) */3334bis $17,$1,$17 /* E0 (p-c latency, next cycle) */35sll $17,32,$1 /* E1 (p-c latency, next cycle) */36bis $17,$1,$17 /* E0 (p-c latency, next cycle) */37ldq_u $31,0($30) /* .. E1 */3839.align 540__constant_c_memset:41addq $18,$16,$6 /* E0 */42bis $16,$16,$0 /* .. E1 */43xor $16,$6,$1 /* E0 */44ble $18,end /* .. E1 */4546bic $1,7,$1 /* E0 */47beq $1,within_one_quad /* .. E1 (note EV5 zero-latency forwarding) */48and $16,7,$3 /* E0 */49beq $3,aligned /* .. E1 (note EV5 zero-latency forwarding) */5051ldq_u $4,0($16) /* E0 */52bis $16,$16,$5 /* .. E1 */53insql $17,$16,$2 /* E0 */54subq $3,8,$3 /* .. E1 */5556addq $18,$3,$18 /* E0 $18 is new count ($3 is negative) */57mskql $4,$16,$4 /* .. E1 (and possible load stall) */58subq $16,$3,$16 /* E0 $16 is new aligned destination */59bis $2,$4,$1 /* .. E1 */6061bis $31,$31,$31 /* E0 */62ldq_u $31,0($30) /* .. E1 */63stq_u $1,0($5) /* E0 */64bis $31,$31,$31 /* .. E1 */6566.align 467aligned:68sra $18,3,$3 /* E0 */69and $18,7,$18 /* .. E1 */70bis $16,$16,$5 /* E0 */71beq $3,no_quad /* .. E1 */7273.align 374loop:75stq $17,0($5) /* E0 */76subq $3,1,$3 /* .. E1 */77addq $5,8,$5 /* E0 */78bne $3,loop /* .. E1 */7980no_quad:81bis $31,$31,$31 /* E0 */82beq $18,end /* .. E1 */83ldq $7,0($5) /* E0 */84mskqh $7,$6,$2 /* .. E1 (and load stall) */8586insqh $17,$6,$4 /* E0 */87bis $2,$4,$1 /* .. E1 */88stq $1,0($5) /* E0 */89ret $31,($26),1 /* .. E1 */9091.align 392within_one_quad:93ldq_u $1,0($16) /* E0 */94insql $17,$16,$2 /* E1 */95mskql $1,$16,$4 /* E0 (after load stall) */96bis $2,$4,$2 /* E0 */9798mskql $2,$6,$4 /* E0 */99mskqh $1,$6,$2 /* .. E1 */100bis $2,$4,$1 /* E0 */101stq_u $1,0($16) /* E0 */102103end:104ret $31,($26),1 /* E1 */105.end __memset106107.align 5108.ent __memsetw109__memsetw:110.prologue 0111112inswl $17,0,$1 /* E0 */113inswl $17,2,$2 /* E0 */114inswl $17,4,$3 /* E0 */115or $1,$2,$1 /* .. E1 */116inswl $17,6,$4 /* E0 */117or $1,$3,$1 /* .. E1 */118or $1,$4,$17 /* E0 */119br __constant_c_memset /* .. E1 */120121.end __memsetw122123memset = __memset124125126