162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * arch/alpha/lib/ev6-stxncpy.S 462306a36Sopenharmony_ci * 21264 version contributed by Rick Gorton <rick.gorton@api-networks.com> 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copy no more than COUNT bytes of the null-terminated string from 762306a36Sopenharmony_ci * SRC to DST. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This is an internal routine used by strncpy, stpncpy, and strncat. 1062306a36Sopenharmony_ci * As such, it uses special linkage conventions to make implementation 1162306a36Sopenharmony_ci * of these public functions more efficient. 1262306a36Sopenharmony_ci * 1362306a36Sopenharmony_ci * On input: 1462306a36Sopenharmony_ci * t9 = return address 1562306a36Sopenharmony_ci * a0 = DST 1662306a36Sopenharmony_ci * a1 = SRC 1762306a36Sopenharmony_ci * a2 = COUNT 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * Furthermore, COUNT may not be zero. 2062306a36Sopenharmony_ci * 2162306a36Sopenharmony_ci * On output: 2262306a36Sopenharmony_ci * t0 = last word written 2362306a36Sopenharmony_ci * t10 = bitmask (with one bit set) indicating the byte position of 2462306a36Sopenharmony_ci * the end of the range specified by COUNT 2562306a36Sopenharmony_ci * t12 = bitmask (with one bit set) indicating the last byte written 2662306a36Sopenharmony_ci * a0 = unaligned address of the last *word* written 2762306a36Sopenharmony_ci * a2 = the number of full words left in COUNT 2862306a36Sopenharmony_ci * 2962306a36Sopenharmony_ci * Furthermore, v0, a3-a5, t11, and $at are untouched. 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci * Much of the information about 21264 scheduling/coding comes from: 3262306a36Sopenharmony_ci * Compiler Writer's Guide for the Alpha 21264 3362306a36Sopenharmony_ci * abbreviated as 'CWG' in other comments here 3462306a36Sopenharmony_ci * ftp.digital.com/pub/Digital/info/semiconductor/literature/dsc-library.html 3562306a36Sopenharmony_ci * Scheduling notation: 3662306a36Sopenharmony_ci * E - either cluster 3762306a36Sopenharmony_ci * U - upper subcluster; U0 - subcluster U0; U1 - subcluster U1 3862306a36Sopenharmony_ci * L - lower subcluster; L0 - subcluster L0; L1 - subcluster L1 3962306a36Sopenharmony_ci * Try not to change the actual algorithm if possible for consistency. 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#include <asm/regdef.h> 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci .set noat 4562306a36Sopenharmony_ci .set noreorder 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci .text 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* There is a problem with either gdb (as of 4.16) or gas (as of 2.7) that 5062306a36Sopenharmony_ci doesn't like putting the entry point for a procedure somewhere in the 5162306a36Sopenharmony_ci middle of the procedure descriptor. Work around this by putting the 5262306a36Sopenharmony_ci aligned copy in its own procedure descriptor */ 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci .ent stxncpy_aligned 5662306a36Sopenharmony_ci .align 4 5762306a36Sopenharmony_cistxncpy_aligned: 5862306a36Sopenharmony_ci .frame sp, 0, t9, 0 5962306a36Sopenharmony_ci .prologue 0 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci /* On entry to this basic block: 6262306a36Sopenharmony_ci t0 == the first destination word for masking back in 6362306a36Sopenharmony_ci t1 == the first source word. */ 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci /* Create the 1st output word and detect 0's in the 1st input word. */ 6662306a36Sopenharmony_ci lda t2, -1 # E : build a mask against false zero 6762306a36Sopenharmony_ci mskqh t2, a1, t2 # U : detection in the src word (stall) 6862306a36Sopenharmony_ci mskqh t1, a1, t3 # U : 6962306a36Sopenharmony_ci ornot t1, t2, t2 # E : (stall) 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci mskql t0, a1, t0 # U : assemble the first output word 7262306a36Sopenharmony_ci cmpbge zero, t2, t8 # E : bits set iff null found 7362306a36Sopenharmony_ci or t0, t3, t0 # E : (stall) 7462306a36Sopenharmony_ci beq a2, $a_eoc # U : 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci bne t8, $a_eos # U : 7762306a36Sopenharmony_ci nop 7862306a36Sopenharmony_ci nop 7962306a36Sopenharmony_ci nop 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci /* On entry to this basic block: 8262306a36Sopenharmony_ci t0 == a source word not containing a null. */ 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci /* 8562306a36Sopenharmony_ci * nops here to: 8662306a36Sopenharmony_ci * separate store quads from load quads 8762306a36Sopenharmony_ci * limit of 1 bcond/quad to permit training 8862306a36Sopenharmony_ci */ 8962306a36Sopenharmony_ci$a_loop: 9062306a36Sopenharmony_ci stq_u t0, 0(a0) # L : 9162306a36Sopenharmony_ci addq a0, 8, a0 # E : 9262306a36Sopenharmony_ci subq a2, 1, a2 # E : 9362306a36Sopenharmony_ci nop 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci ldq_u t0, 0(a1) # L : 9662306a36Sopenharmony_ci addq a1, 8, a1 # E : 9762306a36Sopenharmony_ci cmpbge zero, t0, t8 # E : 9862306a36Sopenharmony_ci beq a2, $a_eoc # U : 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci beq t8, $a_loop # U : 10162306a36Sopenharmony_ci nop 10262306a36Sopenharmony_ci nop 10362306a36Sopenharmony_ci nop 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci /* Take care of the final (partial) word store. At this point 10662306a36Sopenharmony_ci the end-of-count bit is set in t8 iff it applies. 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci On entry to this basic block we have: 10962306a36Sopenharmony_ci t0 == the source word containing the null 11062306a36Sopenharmony_ci t8 == the cmpbge mask that found it. */ 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci$a_eos: 11362306a36Sopenharmony_ci negq t8, t12 # E : find low bit set 11462306a36Sopenharmony_ci and t8, t12, t12 # E : (stall) 11562306a36Sopenharmony_ci /* For the sake of the cache, don't read a destination word 11662306a36Sopenharmony_ci if we're not going to need it. */ 11762306a36Sopenharmony_ci and t12, 0x80, t6 # E : (stall) 11862306a36Sopenharmony_ci bne t6, 1f # U : (stall) 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci /* We're doing a partial word store and so need to combine 12162306a36Sopenharmony_ci our source and original destination words. */ 12262306a36Sopenharmony_ci ldq_u t1, 0(a0) # L : 12362306a36Sopenharmony_ci subq t12, 1, t6 # E : 12462306a36Sopenharmony_ci or t12, t6, t8 # E : (stall) 12562306a36Sopenharmony_ci zapnot t0, t8, t0 # U : clear src bytes > null (stall) 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci zap t1, t8, t1 # .. e1 : clear dst bytes <= null 12862306a36Sopenharmony_ci or t0, t1, t0 # e1 : (stall) 12962306a36Sopenharmony_ci nop 13062306a36Sopenharmony_ci nop 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci1: stq_u t0, 0(a0) # L : 13362306a36Sopenharmony_ci ret (t9) # L0 : Latency=3 13462306a36Sopenharmony_ci nop 13562306a36Sopenharmony_ci nop 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci /* Add the end-of-count bit to the eos detection bitmask. */ 13862306a36Sopenharmony_ci$a_eoc: 13962306a36Sopenharmony_ci or t10, t8, t8 # E : 14062306a36Sopenharmony_ci br $a_eos # L0 : Latency=3 14162306a36Sopenharmony_ci nop 14262306a36Sopenharmony_ci nop 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci .end stxncpy_aligned 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci .align 4 14762306a36Sopenharmony_ci .ent __stxncpy 14862306a36Sopenharmony_ci .globl __stxncpy 14962306a36Sopenharmony_ci__stxncpy: 15062306a36Sopenharmony_ci .frame sp, 0, t9, 0 15162306a36Sopenharmony_ci .prologue 0 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci /* Are source and destination co-aligned? */ 15462306a36Sopenharmony_ci xor a0, a1, t1 # E : 15562306a36Sopenharmony_ci and a0, 7, t0 # E : find dest misalignment 15662306a36Sopenharmony_ci and t1, 7, t1 # E : (stall) 15762306a36Sopenharmony_ci addq a2, t0, a2 # E : bias count by dest misalignment (stall) 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci subq a2, 1, a2 # E : 16062306a36Sopenharmony_ci and a2, 7, t2 # E : (stall) 16162306a36Sopenharmony_ci srl a2, 3, a2 # U : a2 = loop counter = (count - 1)/8 (stall) 16262306a36Sopenharmony_ci addq zero, 1, t10 # E : 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci sll t10, t2, t10 # U : t10 = bitmask of last count byte 16562306a36Sopenharmony_ci bne t1, $unaligned # U : 16662306a36Sopenharmony_ci /* We are co-aligned; take care of a partial first word. */ 16762306a36Sopenharmony_ci ldq_u t1, 0(a1) # L : load first src word 16862306a36Sopenharmony_ci addq a1, 8, a1 # E : 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci beq t0, stxncpy_aligned # U : avoid loading dest word if not needed 17162306a36Sopenharmony_ci ldq_u t0, 0(a0) # L : 17262306a36Sopenharmony_ci nop 17362306a36Sopenharmony_ci nop 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci br stxncpy_aligned # .. e1 : 17662306a36Sopenharmony_ci nop 17762306a36Sopenharmony_ci nop 17862306a36Sopenharmony_ci nop 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ci/* The source and destination are not co-aligned. Align the destination 18362306a36Sopenharmony_ci and cope. We have to be very careful about not reading too much and 18462306a36Sopenharmony_ci causing a SEGV. */ 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci .align 4 18762306a36Sopenharmony_ci$u_head: 18862306a36Sopenharmony_ci /* We know just enough now to be able to assemble the first 18962306a36Sopenharmony_ci full source word. We can still find a zero at the end of it 19062306a36Sopenharmony_ci that prevents us from outputting the whole thing. 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci On entry to this basic block: 19362306a36Sopenharmony_ci t0 == the first dest word, unmasked 19462306a36Sopenharmony_ci t1 == the shifted low bits of the first source word 19562306a36Sopenharmony_ci t6 == bytemask that is -1 in dest word bytes */ 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci ldq_u t2, 8(a1) # L : Latency=3 load second src word 19862306a36Sopenharmony_ci addq a1, 8, a1 # E : 19962306a36Sopenharmony_ci mskql t0, a0, t0 # U : mask trailing garbage in dst 20062306a36Sopenharmony_ci extqh t2, a1, t4 # U : (3 cycle stall on t2) 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci or t1, t4, t1 # E : first aligned src word complete (stall) 20362306a36Sopenharmony_ci mskqh t1, a0, t1 # U : mask leading garbage in src (stall) 20462306a36Sopenharmony_ci or t0, t1, t0 # E : first output word complete (stall) 20562306a36Sopenharmony_ci or t0, t6, t6 # E : mask original data for zero test (stall) 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ci cmpbge zero, t6, t8 # E : 20862306a36Sopenharmony_ci beq a2, $u_eocfin # U : 20962306a36Sopenharmony_ci lda t6, -1 # E : 21062306a36Sopenharmony_ci nop 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ci bne t8, $u_final # U : 21362306a36Sopenharmony_ci mskql t6, a1, t6 # U : mask out bits already seen 21462306a36Sopenharmony_ci stq_u t0, 0(a0) # L : store first output word 21562306a36Sopenharmony_ci or t6, t2, t2 # E : (stall) 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci cmpbge zero, t2, t8 # E : find nulls in second partial 21862306a36Sopenharmony_ci addq a0, 8, a0 # E : 21962306a36Sopenharmony_ci subq a2, 1, a2 # E : 22062306a36Sopenharmony_ci bne t8, $u_late_head_exit # U : 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci /* Finally, we've got all the stupid leading edge cases taken care 22362306a36Sopenharmony_ci of and we can set up to enter the main loop. */ 22462306a36Sopenharmony_ci extql t2, a1, t1 # U : position hi-bits of lo word 22562306a36Sopenharmony_ci beq a2, $u_eoc # U : 22662306a36Sopenharmony_ci ldq_u t2, 8(a1) # L : read next high-order source word 22762306a36Sopenharmony_ci addq a1, 8, a1 # E : 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci extqh t2, a1, t0 # U : position lo-bits of hi word (stall) 23062306a36Sopenharmony_ci cmpbge zero, t2, t8 # E : 23162306a36Sopenharmony_ci nop 23262306a36Sopenharmony_ci bne t8, $u_eos # U : 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci /* Unaligned copy main loop. In order to avoid reading too much, 23562306a36Sopenharmony_ci the loop is structured to detect zeros in aligned source words. 23662306a36Sopenharmony_ci This has, unfortunately, effectively pulled half of a loop 23762306a36Sopenharmony_ci iteration out into the head and half into the tail, but it does 23862306a36Sopenharmony_ci prevent nastiness from accumulating in the very thing we want 23962306a36Sopenharmony_ci to run as fast as possible. 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci On entry to this basic block: 24262306a36Sopenharmony_ci t0 == the shifted low-order bits from the current source word 24362306a36Sopenharmony_ci t1 == the shifted high-order bits from the previous source word 24462306a36Sopenharmony_ci t2 == the unshifted current source word 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ci We further know that t2 does not contain a null terminator. */ 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ci .align 4 24962306a36Sopenharmony_ci$u_loop: 25062306a36Sopenharmony_ci or t0, t1, t0 # E : current dst word now complete 25162306a36Sopenharmony_ci subq a2, 1, a2 # E : decrement word count 25262306a36Sopenharmony_ci extql t2, a1, t1 # U : extract low bits for next time 25362306a36Sopenharmony_ci addq a0, 8, a0 # E : 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci stq_u t0, -8(a0) # U : save the current word 25662306a36Sopenharmony_ci beq a2, $u_eoc # U : 25762306a36Sopenharmony_ci ldq_u t2, 8(a1) # U : Latency=3 load high word for next time 25862306a36Sopenharmony_ci addq a1, 8, a1 # E : 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ci extqh t2, a1, t0 # U : extract low bits (2 cycle stall) 26162306a36Sopenharmony_ci cmpbge zero, t2, t8 # E : test new word for eos 26262306a36Sopenharmony_ci nop 26362306a36Sopenharmony_ci beq t8, $u_loop # U : 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci /* We've found a zero somewhere in the source word we just read. 26662306a36Sopenharmony_ci If it resides in the lower half, we have one (probably partial) 26762306a36Sopenharmony_ci word to write out, and if it resides in the upper half, we 26862306a36Sopenharmony_ci have one full and one partial word left to write out. 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci On entry to this basic block: 27162306a36Sopenharmony_ci t0 == the shifted low-order bits from the current source word 27262306a36Sopenharmony_ci t1 == the shifted high-order bits from the previous source word 27362306a36Sopenharmony_ci t2 == the unshifted current source word. */ 27462306a36Sopenharmony_ci$u_eos: 27562306a36Sopenharmony_ci or t0, t1, t0 # E : first (partial) source word complete 27662306a36Sopenharmony_ci nop 27762306a36Sopenharmony_ci cmpbge zero, t0, t8 # E : is the null in this first bit? (stall) 27862306a36Sopenharmony_ci bne t8, $u_final # U : (stall) 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci stq_u t0, 0(a0) # L : the null was in the high-order bits 28162306a36Sopenharmony_ci addq a0, 8, a0 # E : 28262306a36Sopenharmony_ci subq a2, 1, a2 # E : 28362306a36Sopenharmony_ci nop 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci$u_late_head_exit: 28662306a36Sopenharmony_ci extql t2, a1, t0 # U : 28762306a36Sopenharmony_ci cmpbge zero, t0, t8 # E : 28862306a36Sopenharmony_ci or t8, t10, t6 # E : (stall) 28962306a36Sopenharmony_ci cmoveq a2, t6, t8 # E : Latency=2, extra map slot (stall) 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci /* Take care of a final (probably partial) result word. 29262306a36Sopenharmony_ci On entry to this basic block: 29362306a36Sopenharmony_ci t0 == assembled source word 29462306a36Sopenharmony_ci t8 == cmpbge mask that found the null. */ 29562306a36Sopenharmony_ci$u_final: 29662306a36Sopenharmony_ci negq t8, t6 # E : isolate low bit set 29762306a36Sopenharmony_ci and t6, t8, t12 # E : (stall) 29862306a36Sopenharmony_ci and t12, 0x80, t6 # E : avoid dest word load if we can (stall) 29962306a36Sopenharmony_ci bne t6, 1f # U : (stall) 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_ci ldq_u t1, 0(a0) # L : 30262306a36Sopenharmony_ci subq t12, 1, t6 # E : 30362306a36Sopenharmony_ci or t6, t12, t8 # E : (stall) 30462306a36Sopenharmony_ci zapnot t0, t8, t0 # U : kill source bytes > null 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci zap t1, t8, t1 # U : kill dest bytes <= null 30762306a36Sopenharmony_ci or t0, t1, t0 # E : (stall) 30862306a36Sopenharmony_ci nop 30962306a36Sopenharmony_ci nop 31062306a36Sopenharmony_ci 31162306a36Sopenharmony_ci1: stq_u t0, 0(a0) # L : 31262306a36Sopenharmony_ci ret (t9) # L0 : Latency=3 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_ci /* Got to end-of-count before end of string. 31562306a36Sopenharmony_ci On entry to this basic block: 31662306a36Sopenharmony_ci t1 == the shifted high-order bits from the previous source word */ 31762306a36Sopenharmony_ci$u_eoc: 31862306a36Sopenharmony_ci and a1, 7, t6 # E : avoid final load if possible 31962306a36Sopenharmony_ci sll t10, t6, t6 # U : (stall) 32062306a36Sopenharmony_ci and t6, 0xff, t6 # E : (stall) 32162306a36Sopenharmony_ci bne t6, 1f # U : (stall) 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci ldq_u t2, 8(a1) # L : load final src word 32462306a36Sopenharmony_ci nop 32562306a36Sopenharmony_ci extqh t2, a1, t0 # U : extract low bits for last word (stall) 32662306a36Sopenharmony_ci or t1, t0, t1 # E : (stall) 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci1: cmpbge zero, t1, t8 # E : 32962306a36Sopenharmony_ci mov t1, t0 # E : 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci$u_eocfin: # end-of-count, final word 33262306a36Sopenharmony_ci or t10, t8, t8 # E : 33362306a36Sopenharmony_ci br $u_final # L0 : Latency=3 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci /* Unaligned copy entry point. */ 33662306a36Sopenharmony_ci .align 4 33762306a36Sopenharmony_ci$unaligned: 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ci ldq_u t1, 0(a1) # L : load first source word 34062306a36Sopenharmony_ci and a0, 7, t4 # E : find dest misalignment 34162306a36Sopenharmony_ci and a1, 7, t5 # E : find src misalignment 34262306a36Sopenharmony_ci /* Conditionally load the first destination word and a bytemask 34362306a36Sopenharmony_ci with 0xff indicating that the destination byte is sacrosanct. */ 34462306a36Sopenharmony_ci mov zero, t0 # E : 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci mov zero, t6 # E : 34762306a36Sopenharmony_ci beq t4, 1f # U : 34862306a36Sopenharmony_ci ldq_u t0, 0(a0) # L : 34962306a36Sopenharmony_ci lda t6, -1 # E : 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci mskql t6, a0, t6 # U : 35262306a36Sopenharmony_ci nop 35362306a36Sopenharmony_ci nop 35462306a36Sopenharmony_ci subq a1, t4, a1 # E : sub dest misalignment from src addr 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci /* If source misalignment is larger than dest misalignment, we need 35762306a36Sopenharmony_ci extra startup checks to avoid SEGV. */ 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci1: cmplt t4, t5, t12 # E : 36062306a36Sopenharmony_ci extql t1, a1, t1 # U : shift src into place 36162306a36Sopenharmony_ci lda t2, -1 # E : for creating masks later 36262306a36Sopenharmony_ci beq t12, $u_head # U : (stall) 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci extql t2, a1, t2 # U : 36562306a36Sopenharmony_ci cmpbge zero, t1, t8 # E : is there a zero? 36662306a36Sopenharmony_ci andnot t2, t6, t2 # E : dest mask for a single word copy 36762306a36Sopenharmony_ci or t8, t10, t5 # E : test for end-of-count too 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci cmpbge zero, t2, t3 # E : 37062306a36Sopenharmony_ci cmoveq a2, t5, t8 # E : Latency=2, extra map slot 37162306a36Sopenharmony_ci nop # E : keep with cmoveq 37262306a36Sopenharmony_ci andnot t8, t3, t8 # E : (stall) 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci beq t8, $u_head # U : 37562306a36Sopenharmony_ci /* At this point we've found a zero in the first partial word of 37662306a36Sopenharmony_ci the source. We need to isolate the valid source data and mask 37762306a36Sopenharmony_ci it into the original destination data. (Incidentally, we know 37862306a36Sopenharmony_ci that we'll need at least one byte of that original dest word.) */ 37962306a36Sopenharmony_ci ldq_u t0, 0(a0) # L : 38062306a36Sopenharmony_ci negq t8, t6 # E : build bitmask of bytes <= zero 38162306a36Sopenharmony_ci mskqh t1, t4, t1 # U : 38262306a36Sopenharmony_ci 38362306a36Sopenharmony_ci and t6, t8, t12 # E : 38462306a36Sopenharmony_ci subq t12, 1, t6 # E : (stall) 38562306a36Sopenharmony_ci or t6, t12, t8 # E : (stall) 38662306a36Sopenharmony_ci zapnot t2, t8, t2 # U : prepare source word; mirror changes (stall) 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci zapnot t1, t8, t1 # U : to source validity mask 38962306a36Sopenharmony_ci andnot t0, t2, t0 # E : zero place for source to reside 39062306a36Sopenharmony_ci or t0, t1, t0 # E : and put it there (stall both t0, t1) 39162306a36Sopenharmony_ci stq_u t0, 0(a0) # L : (stall) 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_ci ret (t9) # L0 : Latency=3 39462306a36Sopenharmony_ci nop 39562306a36Sopenharmony_ci nop 39662306a36Sopenharmony_ci nop 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci .end __stxncpy 399