1 #------------------------------------------------------------------------------
3 # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
5 # This program and the accompanying materials are licensed and made available
6 # under the terms and conditions of the BSD License which accompanies this
7 # distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #------------------------------------------------------------------------------
19 .type ASM_PFX(InternalMemSetMem16), %function
20 ASM_GLOBAL ASM_PFX(InternalMemSetMem16)
21 ASM_PFX(InternalMemSetMem16):
24 orr r2, r2, r2, lsl #16
27 .type ASM_PFX(InternalMemSetMem32), %function
28 ASM_GLOBAL ASM_PFX(InternalMemSetMem32)
29 ASM_PFX(InternalMemSetMem32):
33 .type ASM_PFX(InternalMemSetMem64), %function
34 ASM_GLOBAL ASM_PFX(InternalMemSetMem64)
35 ASM_PFX(InternalMemSetMem64):
40 .type ASM_PFX(InternalMemSetMem), %function
41 ASM_GLOBAL ASM_PFX(InternalMemSetMem)
42 ASM_PFX(InternalMemSetMem):
44 orr r2, r2, r2, lsl #8
45 orr r2, r2, r2, lsl #16
48 .type ASM_PFX(InternalMemZeroMem), %function
49 ASM_GLOBAL ASM_PFX(InternalMemZeroMem)
50 ASM_PFX(InternalMemZeroMem):
55 cmp r1, #16 // fewer than 16 bytes of input?
56 add r1, r1, r0 // r1 := dst + length
59 bic lr, lr, #15 // align output pointer
61 str r2, [r0] // potentially unaligned store of 4 bytes
62 str r3, [r0, #4] // potentially unaligned store of 4 bytes
63 str r2, [r0, #8] // potentially unaligned store of 4 bytes
64 str r3, [r0, #12] // potentially unaligned store of 4 bytes
67 0: add lr, lr, #16 // advance the output pointer by 16 bytes
68 subs r4, r1, lr // past the output?
69 blt 3f // break out of the loop
70 strd r2, r3, [lr, #-16] // aligned store of 16 bytes
71 strd r2, r3, [lr, #-8]
72 bne 0b // goto beginning of loop
78 cmp r4, #4 // between 4 and 15 bytes?
80 cmp r4, #8 // between 8 and 15 bytes?
82 str r2, [r4] // overlapping store of 4 + (4 + 4) + 4 bytes
90 4: cmp r4, #2 // 2 or 3 bytes?
91 strb r2, [lr, #-16] // store 1 byte
93 strhge.n r2, [r1, #6] // store 2 bytes