1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 #include "go_asm.h"
6 #include "textflag.h"
7
8 TEXT ·Compare<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-56
9 #ifndef GOEXPERIMENT_regabiargs
10 MOVD a_base+0(FP), R2
11 MOVD a_len+8(FP), R3
12 MOVD b_base+24(FP), R4
13 MOVD b_len+32(FP), R5
14 LA ret+48(FP), R6
15 #else
16 // R2 = a_base
17 // R3 = a_len
18 // R4 = a_cap (unused)
19 // R5 = b_base (want in R4)
20 // R6 = b_len (want in R5)
21 // R7 = b_cap (unused)
22 MOVD R5, R4
23 MOVD R6, R5
24 #endif
25 BR cmpbody<>(SB)
26
27 TEXT runtime·cmpstring<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-40
28 #ifndef GOEXPERIMENT_regabiargs
29 MOVD a_base+0(FP), R2
30 MOVD a_len+8(FP), R3
31 MOVD b_base+16(FP), R4
32 MOVD b_len+24(FP), R5
33 LA ret+32(FP), R6
34 #endif
35 // R2 = a_base
36 // R3 = a_len
37 // R4 = b_base
38 // R5 = b_len
39
40 BR cmpbody<>(SB)
41
42 // input:
43 // R2 = a
44 // R3 = alen
45 // R4 = b
46 // R5 = blen
47 // For regabiargs output value( -1/0/1 ) stored in R2
48 // For !regabiargs address of output word( stores -1/0/1 ) stored in R6
49 TEXT cmpbody<>(SB),NOSPLIT|NOFRAME,$0-0
50 CMPBEQ R2, R4, cmplengths
51 MOVD R3, R7
52 CMPBLE R3, R5, amin
53 MOVD R5, R7
54 amin:
55 CMPBEQ R7, $0, cmplengths
56 CMP R7, $256
57 BLE tail
58 loop:
59 CLC $256, 0(R2), 0(R4)
60 BGT gt
61 BLT lt
62 SUB $256, R7
63 MOVD $256(R2), R2
64 MOVD $256(R4), R4
65 CMP R7, $256
66 BGT loop
67 tail:
68 SUB $1, R7
69 EXRL $cmpbodyclc<>(SB), R7
70 BGT gt
71 BLT lt
72 cmplengths:
73 CMP R3, R5
74 BEQ eq
75 BLT lt
76 gt:
77 MOVD $1, R2
78 #ifndef GOEXPERIMENT_regabiargs
79 MOVD R2, 0(R6)
80 #endif
81 RET
82 lt:
83 MOVD $-1, R2
84 #ifndef GOEXPERIMENT_regabiargs
85 MOVD R2, 0(R6)
86 #endif
87 RET
88 eq:
89 MOVD $0, R2
90 #ifndef GOEXPERIMENT_regabiargs
91 MOVD R2, 0(R6)
92 #endif
93 RET
94
95 TEXT cmpbodyclc<>(SB),NOSPLIT|NOFRAME,$0-0
96 CLC $1, 0(R2), 0(R4)
97 RET
98
View as plain text