/* SPDX-License-Identifier: GPL-2.0 */1/*2* linux/arch/alpha/lib/memset.S3*4* This is an efficient (and small) implementation of the C library "memset()"5* function for the alpha.6*7* (C) Copyright 1996 Linus Torvalds8*9* This routine is "moral-ware": you are free to use it any way you wish, and10* the only obligation I put on you is a moral one: if you make any improvements11* to the routine, please send me your improvements for me to use similarly.12*13* The scheduling comments are according to the EV5 documentation (and done by14* hand, so they might well be incorrect, please do tell me about it..)15*/16#include <linux/export.h>17.set noat18.set noreorder19.text20.globl memset21.globl __memset22.globl ___memset23.globl __memset1624.globl __constant_c_memset2526.ent ___memset27.align 528___memset:29.frame $30,0,$26,030.prologue 03132and $17,255,$1 /* E1 */33insbl $17,1,$17 /* .. E0 */34bis $17,$1,$17 /* E0 (p-c latency, next cycle) */35sll $17,16,$1 /* E1 (p-c latency, next cycle) */3637bis $17,$1,$17 /* E0 (p-c latency, next cycle) */38sll $17,32,$1 /* E1 (p-c latency, next cycle) */39bis $17,$1,$17 /* E0 (p-c latency, next cycle) */40ldq_u $31,0($30) /* .. E1 */4142.align 543__constant_c_memset:44addq $18,$16,$6 /* E0 */45bis $16,$16,$0 /* .. E1 */46xor $16,$6,$1 /* E0 */47ble $18,end /* .. E1 */4849bic $1,7,$1 /* E0 */50beq $1,within_one_quad /* .. E1 (note EV5 zero-latency forwarding) */51and $16,7,$3 /* E0 */52beq $3,aligned /* .. E1 (note EV5 zero-latency forwarding) */5354ldq_u $4,0($16) /* E0 */55bis $16,$16,$5 /* .. E1 */56insql $17,$16,$2 /* E0 */57subq $3,8,$3 /* .. E1 */5859addq $18,$3,$18 /* E0 $18 is new count ($3 is negative) */60mskql $4,$16,$4 /* .. E1 (and possible load stall) */61subq $16,$3,$16 /* E0 $16 is new aligned destination */62bis $2,$4,$1 /* .. E1 */6364bis $31,$31,$31 /* E0 */65ldq_u $31,0($30) /* .. E1 */66stq_u $1,0($5) /* E0 */67bis $31,$31,$31 /* .. E1 */6869.align 470aligned:71sra $18,3,$3 /* E0 */72and $18,7,$18 /* .. E1 */73bis $16,$16,$5 /* E0 */74beq $3,no_quad /* .. E1 */7576.align 377loop:78stq $17,0($5) /* E0 */79subq $3,1,$3 /* .. E1 */80addq $5,8,$5 /* E0 */81bne $3,loop /* .. E1 */8283no_quad:84bis $31,$31,$31 /* E0 */85beq $18,end /* .. E1 */86ldq $7,0($5) /* E0 */87mskqh $7,$6,$2 /* .. E1 (and load stall) */8889insqh $17,$6,$4 /* E0 */90bis $2,$4,$1 /* .. E1 */91stq $1,0($5) /* E0 */92ret $31,($26),1 /* .. E1 */9394.align 395within_one_quad:96ldq_u $1,0($16) /* E0 */97insql $17,$16,$2 /* E1 */98mskql $1,$16,$4 /* E0 (after load stall) */99bis $2,$4,$2 /* E0 */100101mskql $2,$6,$4 /* E0 */102mskqh $1,$6,$2 /* .. E1 */103bis $2,$4,$1 /* E0 */104stq_u $1,0($16) /* E0 */105106end:107ret $31,($26),1 /* E1 */108.end ___memset109EXPORT_SYMBOL(___memset)110EXPORT_SYMBOL(__constant_c_memset)111112.align 5113.ent __memset16114__memset16:115.prologue 0116117inswl $17,0,$1 /* E0 */118inswl $17,2,$2 /* E0 */119inswl $17,4,$3 /* E0 */120or $1,$2,$1 /* .. E1 */121inswl $17,6,$4 /* E0 */122or $1,$3,$1 /* .. E1 */123or $1,$4,$17 /* E0 */124br __constant_c_memset /* .. E1 */125126.end __memset16127EXPORT_SYMBOL(__memset16)128129memset = ___memset130__memset = ___memset131EXPORT_SYMBOL(memset)132EXPORT_SYMBOL(__memset)133134135