11f7e3dc0SClaudiu Zissulescu/* 21f7e3dc0SClaudiu Zissulescu * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) 31f7e3dc0SClaudiu Zissulescu * 41f7e3dc0SClaudiu Zissulescu * This program is free software; you can redistribute it and/or modify 51f7e3dc0SClaudiu Zissulescu * it under the terms of the GNU General Public License version 2 as 61f7e3dc0SClaudiu Zissulescu * published by the Free Software Foundation. 71f7e3dc0SClaudiu Zissulescu */ 81f7e3dc0SClaudiu Zissulescu 91f7e3dc0SClaudiu Zissulescu#include <linux/linkage.h> 101f7e3dc0SClaudiu Zissulescu 111f7e3dc0SClaudiu Zissulescu#undef PREALLOC_NOT_AVAIL 121f7e3dc0SClaudiu Zissulescu 131f7e3dc0SClaudiu ZissulescuENTRY(memset) 141f7e3dc0SClaudiu Zissulescu prefetchw [r0] ; Prefetch the write location 151f7e3dc0SClaudiu Zissulescu mov.f 0, r2 161f7e3dc0SClaudiu Zissulescu;;; if size is zero 171f7e3dc0SClaudiu Zissulescu jz.d [blink] 181f7e3dc0SClaudiu Zissulescu mov r3, r0 ; don't clobber ret val 191f7e3dc0SClaudiu Zissulescu 201f7e3dc0SClaudiu Zissulescu;;; if length < 8 211f7e3dc0SClaudiu Zissulescu brls.d.nt r2, 8, .Lsmallchunk 221f7e3dc0SClaudiu Zissulescu mov.f lp_count,r2 231f7e3dc0SClaudiu Zissulescu 241f7e3dc0SClaudiu Zissulescu and.f r4, r0, 0x03 251f7e3dc0SClaudiu Zissulescu rsub lp_count, r4, 4 261f7e3dc0SClaudiu Zissulescu lpnz @.Laligndestination 271f7e3dc0SClaudiu Zissulescu ;; LOOP BEGIN 281f7e3dc0SClaudiu Zissulescu stb.ab r1, [r3,1] 291f7e3dc0SClaudiu Zissulescu sub r2, r2, 1 301f7e3dc0SClaudiu Zissulescu.Laligndestination: 311f7e3dc0SClaudiu Zissulescu 321f7e3dc0SClaudiu Zissulescu;;; Destination is aligned 331f7e3dc0SClaudiu Zissulescu and r1, r1, 0xFF 341f7e3dc0SClaudiu Zissulescu asl r4, r1, 8 351f7e3dc0SClaudiu Zissulescu or r4, r4, r1 361f7e3dc0SClaudiu Zissulescu asl r5, r4, 16 371f7e3dc0SClaudiu Zissulescu or r5, r5, r4 381f7e3dc0SClaudiu Zissulescu mov r4, r5 391f7e3dc0SClaudiu Zissulescu 401f7e3dc0SClaudiu Zissulescu sub3 lp_count, r2, 8 411f7e3dc0SClaudiu Zissulescu cmp r2, 64 421f7e3dc0SClaudiu Zissulescu bmsk.hi r2, r2, 5 431f7e3dc0SClaudiu Zissulescu mov.ls lp_count, 0 441f7e3dc0SClaudiu Zissulescu add3.hi r2, r2, 8 451f7e3dc0SClaudiu Zissulescu 461f7e3dc0SClaudiu Zissulescu;;; Convert len to Dwords, unfold x8 471f7e3dc0SClaudiu Zissulescu lsr.f lp_count, lp_count, 6 48262137bcSVineet Gupta 491f7e3dc0SClaudiu Zissulescu lpnz @.Lset64bytes 501f7e3dc0SClaudiu Zissulescu ;; LOOP START 51262137bcSVineet Gupta#ifdef PREALLOC_NOT_AVAIL 52262137bcSVineet Gupta prefetchw [r3, 64] ;Prefetch the next write location 53262137bcSVineet Gupta#else 54262137bcSVineet Gupta prealloc [r3, 64] 55262137bcSVineet Gupta#endif 56262137bcSVineet Gupta#ifdef CONFIG_ARC_HAS_LL64 571f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 581f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 591f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 601f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 611f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 621f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 631f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 641f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 65262137bcSVineet Gupta#else 66262137bcSVineet Gupta st.ab r4, [r3, 4] 67262137bcSVineet Gupta st.ab r4, [r3, 4] 68262137bcSVineet Gupta st.ab r4, [r3, 4] 69262137bcSVineet Gupta st.ab r4, [r3, 4] 70262137bcSVineet Gupta st.ab r4, [r3, 4] 71262137bcSVineet Gupta st.ab r4, [r3, 4] 72262137bcSVineet Gupta st.ab r4, [r3, 4] 73262137bcSVineet Gupta st.ab r4, [r3, 4] 74262137bcSVineet Gupta st.ab r4, [r3, 4] 75262137bcSVineet Gupta st.ab r4, [r3, 4] 76262137bcSVineet Gupta st.ab r4, [r3, 4] 77262137bcSVineet Gupta st.ab r4, [r3, 4] 78262137bcSVineet Gupta st.ab r4, [r3, 4] 79262137bcSVineet Gupta st.ab r4, [r3, 4] 80262137bcSVineet Gupta st.ab r4, [r3, 4] 81262137bcSVineet Gupta st.ab r4, [r3, 4] 82262137bcSVineet Gupta#endif 831f7e3dc0SClaudiu Zissulescu.Lset64bytes: 841f7e3dc0SClaudiu Zissulescu 851f7e3dc0SClaudiu Zissulescu lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes 861f7e3dc0SClaudiu Zissulescu lpnz .Lset32bytes 871f7e3dc0SClaudiu Zissulescu ;; LOOP START 881f7e3dc0SClaudiu Zissulescu prefetchw [r3, 32] ;Prefetch the next write location 89262137bcSVineet Gupta#ifdef CONFIG_ARC_HAS_LL64 901f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 911f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 921f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 931f7e3dc0SClaudiu Zissulescu std.ab r4, [r3, 8] 94262137bcSVineet Gupta#else 95262137bcSVineet Gupta st.ab r4, [r3, 4] 96262137bcSVineet Gupta st.ab r4, [r3, 4] 97262137bcSVineet Gupta st.ab r4, [r3, 4] 98262137bcSVineet Gupta st.ab r4, [r3, 4] 99262137bcSVineet Gupta st.ab r4, [r3, 4] 100262137bcSVineet Gupta st.ab r4, [r3, 4] 101262137bcSVineet Gupta st.ab r4, [r3, 4] 102262137bcSVineet Gupta st.ab r4, [r3, 4] 103262137bcSVineet Gupta#endif 1041f7e3dc0SClaudiu Zissulescu.Lset32bytes: 1051f7e3dc0SClaudiu Zissulescu 1061f7e3dc0SClaudiu Zissulescu and.f lp_count, r2, 0x1F ;Last remaining 31 bytes 1071f7e3dc0SClaudiu Zissulescu.Lsmallchunk: 1081f7e3dc0SClaudiu Zissulescu lpnz .Lcopy3bytes 1091f7e3dc0SClaudiu Zissulescu ;; LOOP START 1101f7e3dc0SClaudiu Zissulescu stb.ab r1, [r3, 1] 1111f7e3dc0SClaudiu Zissulescu.Lcopy3bytes: 1121f7e3dc0SClaudiu Zissulescu 1131f7e3dc0SClaudiu Zissulescu j [blink] 1141f7e3dc0SClaudiu Zissulescu 1151f7e3dc0SClaudiu ZissulescuEND(memset) 1161f7e3dc0SClaudiu Zissulescu 1171f7e3dc0SClaudiu ZissulescuENTRY(memzero) 1181f7e3dc0SClaudiu Zissulescu ; adjust bzero args to memset args 1191f7e3dc0SClaudiu Zissulescu mov r2, r1 1201f7e3dc0SClaudiu Zissulescu b.d memset ;tail call so need to tinker with blink 1211f7e3dc0SClaudiu Zissulescu mov r1, 0 1221f7e3dc0SClaudiu ZissulescuEND(memzero) 123