1/* 2 * Copyright 2018, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6#include <asm_defs.h> 7 8 9.align 4 10FUNCTION(memcpy): 11FUNCTION(__aeabi_memcpy): 12 push {r4, r5, r6, r7, r8, r10, r11, lr} 13 add r11, sp, #24 14 cmp r0, r1 15 cmpne r2, #0 16 bne .LBB0_2 17.LBB0_1: 18 pop {r4, r5, r6, r7, r8, r10, r11, pc} 19.LBB0_2: 20 orr r3, r1, r0 21 tst r3, #3 22 beq .LBB0_9 23 eor r3, r1, r0 24 and r7, r0, #3 25 tst r3, #3 26 mov r12, r2 27 rsbeq r12, r7, #4 28 cmp r2, #4 29 movlo r12, r2 30 sub r2, r2, r12 31 cmp r12, #1 32 blt .LBB0_9 33 mvn r7, r12 34 cmn r7, #2 35 mvn r3, #1 36 mvn r6, #1 37 movgt r3, r7 38 add r3, r12, r3 39 add r3, r3, #2 40 cmp r3, #16 41 blo .LBB0_22 42 cmn r7, #2 43 movgt r6, r7 44 add r7, r12, r6 45 add r7, r7, #2 46 add r6, r1, r7 47 cmp r6, r0 48 addhi r7, r0, r7 49 cmphi r7, r1 50 bhi .LBB0_22 51 bic r4, r3, #15 52 mov r7, r0 53 add r5, r0, r4 54 add lr, r1, r4 55 sub r12, r12, r4 56 mov r6, r4 57.LBB0_7: 58 vld1.8 {d16, d17}, [r1]! 59 subs r6, r6, #16 60 vst1.8 {d16, d17}, [r7]! 61 bne .LBB0_7 62 cmp r3, r4 63 bne .LBB0_23 64 b .LBB0_25 65.LBB0_9: 66 mov r5, r0 67 mov r3, #0 68 cmp r3, r2, lsr #2 69 beq .LBB0_19 70.LBB0_10: 71 bic r12, r2, #3 72 lsr r3, r2, #2 73 cmp r2, #16 74 blo .LBB0_15 75 add r7, r1, r12 76 cmp r5, r7 77 addlo r7, r5, r12 78 cmplo r1, r7 79 blo .LBB0_15 80 and lr, r3, #3 81 mov r7, r1 82 sub r8, r3, lr 83 mov r6, r5 84 sub r3, r12, lr, lsl #2 85 add r4, r5, r3 86 add r3, r1, r3 87.LBB0_13: 88 vld1.32 {d16, d17}, [r7]! 89 subs r8, r8, #4 90 vst1.32 {d16, d17}, [r6]! 91 bne .LBB0_13 92 cmp lr, #0 93 bne .LBB0_16 94 b .LBB0_18 95.LBB0_15: 96 mov lr, r3 97 mov r3, r1 98 mov r4, r5 99.LBB0_16: 100 add r6, lr, #1 101.LBB0_17: 102 ldr r7, [r3], #4 103 sub r6, r6, #1 104 str r7, [r4], #4 105 cmp r6, #1 106 bgt .LBB0_17 107.LBB0_18: 108 add r5, r5, r12 109 add r1, r1, r12 110.LBB0_19: 111 ands r2, r2, #3 112 beq .LBB0_1 113 add r2, r2, #1 114.LBB0_21: 115 ldrb r3, [r1], #1 116 sub r2, r2, #1 117 strb r3, [r5], #1 118 cmp r2, #1 119 bgt .LBB0_21 120 b .LBB0_1 121.LBB0_22: 122 mov lr, r1 123 mov r5, r0 124.LBB0_23: 125 add r1, r12, #1 126.LBB0_24: 127 ldrb r3, [lr], #1 128 sub r1, r1, #1 129 strb r3, [r5], #1 130 cmp r1, #1 131 bgt .LBB0_24 132.LBB0_25: 133 mov r1, lr 134 mov r3, #0 135 cmp r3, r2, lsr #2 136 bne .LBB0_10 137 b .LBB0_19 138FUNCTION_END(memcpy) 139FUNCTION_END(__aeabi_memcpy) 140