1 /* Optimised simple memory fill
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #include <asm/cache.h>
14 .balign L1_CACHE_BYTES
16 ###############################################################################
18 # void *memset(void *dst, int c, size_t n)
20 ###############################################################################
22 .type memset,@function
27 mov (20,sp),d2 # count
29 mov d0,e3 # the return value
32 beq memset_done # return if zero-length fill
34 # see if the region parameters are four-byte aligned
37 bne memset_1 # jump if not
45 # we want to transfer as much as we can in chunks of 32 bytes
47 bls memset_4_remainder # 4-byte aligned remainder
66 beq memset_4_no_remainder
69 # cut 4-7 words down to 0-3
71 bcs memset_4_three_or_fewer_words
77 beq memset_4_no_remainder
79 # copy the remaining 1, 2 or 3 words
80 memset_4_three_or_fewer_words:
83 beq memset_4_two_words
90 memset_4_no_remainder:
91 # check we set the correct amount
105 # handle misaligned copying
109 setlb # setlb requires the next insns
110 # to occupy exactly 4 bytes
121 .size memset, memset_end-memset