6b13f685e
김민수
BSP 최초 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* arch/alpha/lib/ev67-strrchr.S
* 21264 version by Rick Gorton <rick.gorton@alpha-processor.com>
*
* Finds length of a 0-terminated string. Optimized for the
* Alpha architecture:
*
* - memory accessed as aligned quadwords only
* - uses bcmpge to compare 8 bytes in parallel
*
* Much of the information about 21264 scheduling/coding comes from:
* Compiler Writer's Guide for the Alpha 21264
* abbreviated as 'CWG' in other comments here
* ftp.digital.com/pub/Digital/info/semiconductor/literature/dsc-library.html
* Scheduling notation:
* E - either cluster
* U - upper subcluster; U0 - subcluster U0; U1 - subcluster U1
* L - lower subcluster; L0 - subcluster L0; L1 - subcluster L1
*/
.set noreorder
.set noat
.align 4
.ent strrchr
.globl strrchr
strrchr:
.frame sp, 0, ra
.prologue 0
and a1, 0xff, t2
insbl a1, 1, t4
insbl a1, 2, t5
ldq_u t0, 0(a0)
mov zero, t6
or t2, t4, a1
sll t5, 8, t3
mov zero, t8
andnot a0, 7, v0
or t5, t3, t3
sll a1, 32, t2
sll a1, 48, t4
or t4, a1, a1
or t2, t3, t2
or a1, t2, a1
lda t5, -1
cmpbge zero, t0, t1
mskqh t5, a0, t4
xor t0, a1, t2
cmpbge zero, t4, t4
cmpbge zero, t2, t3
andnot t1, t4, t1
andnot t3, t4, t3
bne t1, $eos
/* Character search main loop */
$loop:
ldq t0, 8(v0)
cmovne t3, v0, t6
nop
nop
cmovne t3, t3, t8
nop
addq v0, 8, v0
xor t0, a1, t2
cmpbge zero, t0, t1
cmpbge zero, t2, t3
beq t1, $loop
nop
/* Mask out character matches after terminator */
$eos:
negq t1, t4
and t1, t4, t4
subq t4, 1, t5
or t4, t5, t4
and t3, t4, t3
cmovne t3, t3, t8
nop
nop
cmovne t3, v0, t6
nop
/* Locate the address of the last matched character */
ctlz t8, t2
nop
cmoveq t8, 0x3f, t2
nop
lda t5, 0x3f($31)
subq t5, t2, t5
addq t6, t5, v0
ret
nop
nop
.end strrchr
|