author | Mike Kinghan <mikek@symbian.org> |
Mon, 26 Jul 2010 18:22:55 +0100 | |
branch | GCC_SURGE |
changeset 235 | cbd07013118c |
parent 159 | 185ac9ba847c |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32\common\arm\carray.cia |
|
15 |
// Machine coded arrays for ARM |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include <e32cia.h> |
|
20 |
#include "../common.h" |
|
21 |
||
22 |
#ifdef __ARRAY_MACHINE_CODED__ |
|
23 |
extern "C" void PanicBadArrayFindMode(); |
|
24 |
||
25 |
EXPORT_C __NAKED__ TAny*& RPointerArrayBase::At(TInt /*anIndex*/) const |
|
26 |
{ |
|
27 |
asm("ldmia r0, {r2,r3} "); // r2=iCount, r3=iEntries |
|
28 |
asm("cmp r1, #0 "); // check anIndex>=0 |
|
29 |
asm("cmpge r2, r1 "); // if so, check iCount>anIndex |
|
30 |
asm("addgt r0, r3, r1, lsl #2 "); // address of entry = iEntries+4*anIndex |
|
31 |
#ifdef __CPU_ARMV6 |
|
32 |
asm("ble 1f "); // avoid conditional return on ARMv6 |
|
33 |
__JUMP(,lr); |
|
34 |
#else |
|
35 |
__JUMP(gt,lr); |
|
36 |
#endif |
|
37 |
asm("1: "); |
|
38 |
asm("b " CSM_Z18PanicBadArrayIndexv); |
|
39 |
} |
|
40 |
||
41 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::Append(const TAny* /*anEntry*/) |
|
42 |
{ |
|
43 |
asm("ldmia r0, {r2,r3,r12} "); // r2=iCount, r3=iEntries, r12=iAllocated |
|
44 |
asm("cmp r2, r12 "); |
|
45 |
asm("beq ptr_append_1 "); |
|
46 |
asm("ptr_append_0: "); |
|
47 |
asm("str r1, [r3, r2, lsl #2] "); |
|
48 |
asm("add r2, r2, #1 "); |
|
49 |
asm("str r2, [r0] "); |
|
50 |
asm("mov r0, #0 "); |
|
51 |
__JUMP(,lr); |
|
52 |
asm("ptr_append_1: "); |
|
53 |
asm("stmfd sp!, {r0,r1,r2,lr} "); |
|
54 |
asm("bl " CSM_ZN17RPointerArrayBase4GrowEv); |
|
55 |
asm("cmp r0, #0 "); |
|
56 |
asm("bne ptr_append_2 "); |
|
57 |
asm("ldmfd sp!, {r0,r1,r2,lr} "); |
|
58 |
asm("ldmia r0, {r2, r3} "); |
|
59 |
asm("b ptr_append_0 "); |
|
60 |
asm("ptr_append_2: "); // error enlarging array |
|
61 |
asm("add sp, sp, #12 "); |
|
62 |
__POPRET(""); |
|
63 |
} |
|
64 |
||
65 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::Find(const TAny* /*anEntry*/) const |
|
66 |
{ |
|
67 |
asm("ldmia r0, {r2,r3} "); // r2=iCount, r3=iEntries |
|
68 |
asm("mov r0, #0 "); // r0=0 (will be index+1) |
|
69 |
asm("subs r2, r2, #1 "); // r2=iCount-1 |
|
70 |
asm("blt 0f "); |
|
71 |
asm("1: "); |
|
72 |
asm("ldr r12, [r3], #4 "); // r12=iEntries[r0] |
|
73 |
asm("add r0, r0, #1 "); // r0 = index+1 |
|
74 |
asm("cmp r2, r0 "); // C=1 iff iCount-1>=index+1 iff index<=iCount-2 iff this isn't last entry |
|
75 |
asm("teq r12, r1 "); // check for equality, doesn't affect C |
|
76 |
asm("bhi 1b "); // loop if C=1 & Z=0, i.e. if no match and this isn't last entry |
|
77 |
asm("0: "); |
|
78 |
asm("movne r0, #0 "); // if no match set r0=0 |
|
79 |
asm("sub r0, r0, #1 "); // r0 was index+1, return index |
|
80 |
__JUMP(,lr); |
|
81 |
} |
|
82 |
||
83 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::Find(const TAny* /*anEntry*/, TGeneralIdentityRelation /*anIdentity*/) const |
|
84 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
85 |
__EH_FNSTART |
0 | 86 |
asm("stmfd sp!, {r4-r8,lr} "); |
87 |
__EH_FRAME_PUSH2(r4-r8,lr) |
|
88 |
asm("ldmia r0, {r4,r5} "); // r4=iCount, r5=iEntries |
|
89 |
asm("mvn r6, #0 "); |
|
90 |
asm("mov r7, r1 "); |
|
91 |
asm("mov r8, r2 "); |
|
92 |
asm("subs r4, r4, #1 "); // r4=iCount-1 |
|
93 |
asm("bmi ptr_find2_return "); // if count=0, return -1 |
|
94 |
asm("ptr_find2_loop: "); |
|
95 |
asm("ldr r1, [r5], #4 "); // r1=pointer to entry r6 |
|
96 |
asm("add r6, r6, #1 "); |
|
97 |
asm("mov r0, r7 "); // r0=anEntry |
|
98 |
__JUMPL(8); |
|
99 |
asm("cmp r0, #0 "); |
|
100 |
asm("bne ptr_find2_return "); // if equal, return r6 |
|
101 |
asm("cmp r6, r4 "); |
|
102 |
asm("blt ptr_find2_loop "); |
|
103 |
asm("mvn r6, #0 "); |
|
104 |
asm("ptr_find2_return: "); // return r6 |
|
105 |
asm("mov r0, r6 "); |
|
106 |
__POPRET("r4-r8,"); |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
107 |
__EH_FNEND |
0 | 108 |
} |
109 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
110 |
EXPORT_C TInt RPointerArrayBase::BinarySearchSigned(TInt anEntry, TInt& anIndex) const |
0 | 111 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
112 |
return RPointerArrayBase::BinarySearchSigned(anEntry, anIndex, 0); |
0 | 113 |
} |
114 |
||
115 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearchSigned(TInt /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const |
|
116 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
117 |
__EH_FNSTART |
0 | 118 |
asm("stmfd sp!, {r4-r6,lr} "); |
119 |
__EH_FRAME_PUSH2(r4-r6,lr) |
|
120 |
asm("mov r6, r2 "); // r6=&anIndex |
|
121 |
asm("ldmia r0, {r2,r4} "); // r2=count, r4=iEntries |
|
122 |
asm("bl BinarySearchSigned "); |
|
123 |
asm("str r2, [r6] "); // store index |
|
124 |
__POPRET("r4-r6,"); |
|
125 |
||
126 |
// Binary search list of signed integers |
|
127 |
// Match value in r1 |
|
128 |
// List address in r4 |
|
129 |
// Count in r2 |
|
130 |
// Match mode in r3 |
|
131 |
// Return with: r0=0 if match found, r0=-1 otherwise |
|
132 |
// Z flag set if match found, clear if not |
|
133 |
// r2=index of match or next higher |
|
134 |
// r5 modified |
|
135 |
asm("BinarySearchSigned: "); |
|
136 |
#ifdef _DEBUG |
|
137 |
asm("cmp r3, #%a0" : : "i" ((TInt)EArrayFindMode_Limit) ); |
|
138 |
asm("bhs PanicBadArrayFindMode "); |
|
139 |
#endif |
|
140 |
asm("mov r3, r3, lsl #30 "); // match mode -> bits 30,31 (00000000=any, 40000000=first, 80000000=last) |
|
141 |
asm("orr r3, r3, #1 "); // set NOT FOUND flag |
|
142 |
asm("cmp r2, #0 "); // r2 will be right index |
|
143 |
asm("beq 0f "); |
|
144 |
asm("mov r5, #0 "); // r5 = left index |
|
145 |
asm("1: "); |
|
146 |
asm("add r12, r2, r5 "); |
|
147 |
asm("mov r12, r12, lsr #1 "); // r12 = mid index |
|
148 |
asm("ldr r0, [r4, r12, lsl #2] "); // r0 = entry[mid] |
|
149 |
asm("subs r0, r0, r1 "); // r0 = entry[mid] - match |
|
150 |
asm("beq 2f "); // if match branch out |
|
151 |
asm("3: "); |
|
152 |
asm("addlt r5, r12, #1 "); // else if entry<match left=mid+1 |
|
153 |
asm("movgt r2, r12 "); // else if entry>match right=mid |
|
154 |
asm("subs r0, r2, r5 "); // right > left ? |
|
155 |
asm("bgt 1b "); // r0 = 0 when loop terminates |
|
156 |
asm("0: "); |
|
157 |
asm("tst r3, #1 "); // test not found flag |
|
158 |
asm("mvnnes r0, #0 "); // if set r0=-1 = KErrNotFound |
|
159 |
__JUMP(,lr); |
|
160 |
asm("2: "); |
|
161 |
asm("bics r3, r3, #1 "); // clear NOT FOUND flag, test for find mode ANY (Z set if so) |
|
162 |
asm("bne 3b "); // if not, V=0 (left from subs), N=1 for last, 0 for first, Z=0 => LAST->LT FIRST->GT |
|
163 |
asm("mov r2, r12 "); // if so, r2 = mid |
|
164 |
__JUMP(,lr); // and return with r0 = 0 |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
165 |
__EH_FNEND |
0 | 166 |
} |
167 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
168 |
EXPORT_C TInt RPointerArrayBase::BinarySearchUnsigned(TUint anEntry, TInt& anIndex) const |
0 | 169 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
170 |
return RPointerArrayBase::BinarySearchUnsigned(anEntry, anIndex, 0); |
0 | 171 |
} |
172 |
||
173 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearchUnsigned(TUint /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const |
|
174 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
175 |
__EH_FNSTART |
0 | 176 |
asm("stmfd sp!, {r4-r6,lr} "); |
177 |
__EH_FRAME_PUSH2(r4-r6,lr) |
|
178 |
asm("mov r6, r2 "); // r6=&anIndex |
|
179 |
asm("ldmia r0, {r2,r4} "); // r2=count, r4=iEntries |
|
180 |
asm("bl BinarySearchUnsigned "); |
|
181 |
asm("str r2, [r6] "); // store index |
|
182 |
__POPRET("r4-r6,"); |
|
183 |
||
184 |
// Binary search list of unsigned integers |
|
185 |
// Match value in r1 |
|
186 |
// List address in r4 |
|
187 |
// Count in r2 |
|
188 |
// Match mode in r3 |
|
189 |
// Return with: r0=0 if match found, r0=-1 otherwise |
|
190 |
// Z flag set if match found, clear if not |
|
191 |
// r2=index of match or next higher |
|
192 |
// r5 modified |
|
193 |
asm("BinarySearchUnsigned: "); |
|
194 |
#ifdef _DEBUG |
|
195 |
asm("cmp r3, #%a0" : : "i" ((TInt)EArrayFindMode_Limit) ); |
|
196 |
asm("bhs PanicBadArrayFindMode "); |
|
197 |
#endif |
|
198 |
asm("mov r3, r3, lsl #30 "); // match mode -> bits 30,31 (00000000=any, 40000000=first, 80000000=last) |
|
199 |
asm("orr r3, r3, #1 "); // set NOT FOUND flag |
|
200 |
asm("cmp r2, #0 "); // r2 will be right index |
|
201 |
asm("beq 0f "); |
|
202 |
asm("mov r5, #0 "); // r5 = left index |
|
203 |
asm("1: "); |
|
204 |
asm("add r12, r2, r5 "); |
|
205 |
asm("mov r12, r12, lsr #1 "); // r12 = mid index |
|
206 |
asm("ldr r0, [r4, r12, lsl #2] "); // r0 = entry[mid] |
|
207 |
asm("subs r0, r1, r0 "); // r0 = match - entry[mid] |
|
208 |
asm("beq 2f "); // if match branch out |
|
209 |
asm("3: "); |
|
210 |
asm("addhi r5, r12, #1 "); // else if entry<match left=mid+1 HI = C &~ Z |
|
211 |
asm("movlo r2, r12 "); // else if entry>match right=mid LO = ~C |
|
212 |
asm("subs r0, r2, r5 "); // right > left ? |
|
213 |
asm("bgt 1b "); // r0 = 0 when loop terminates |
|
214 |
asm("0: "); |
|
215 |
asm("tst r3, #1 "); // test not found flag |
|
216 |
asm("mvnnes r0, #0 "); // if set r0=-1 = KErrNotFound |
|
217 |
__JUMP(,lr); |
|
218 |
asm("2: "); // N=0 Z=1 C=1 V=0 r0=0 here |
|
219 |
asm("bics r3, r3, #1 "); // clear NOT FOUND flag, test for find mode ANY (Z set if so) |
|
220 |
asm("cmpne r3, #0x60000000 "); // HI if LAST, LO if FIRST |
|
221 |
asm("bne 3b "); // if not ANY, branch back |
|
222 |
asm("mov r2, r12 "); // if ANY, r2 = mid |
|
223 |
__JUMP(,lr); // and return with r0 = 0 |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
224 |
__EH_FNEND |
0 | 225 |
} |
226 |
||
227 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearch(const TAny* /*anEntry*/, TInt& /*anIndex*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const |
|
228 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
229 |
__EH_FNSTART |
0 | 230 |
asm("stmfd sp!, {r2,r4-r11,lr} "); // store &anIndex, r4-r11, lr |
231 |
__EH_FRAME_ADDRESS(sp,4) |
|
232 |
__EH_FRAME_PUSH2(r4-r11,lr) |
|
233 |
asm("ldmia r0, {r5,r6} "); // r5=count, r6=iEntries |
|
234 |
asm("ldr r11, [sp, #40] "); // r11 = aMode |
|
235 |
asm("mov r7, r3 "); // r7=anOrder |
|
236 |
asm("mov r4, r1 "); // r1=anEntry |
|
237 |
asm("bl BinarySearchPointers "); // r0=KErrNone if match, KErrNotFound if not |
|
238 |
asm("ldmfd sp!, {r2,r4} "); // r2=&anIndex, restore r4 |
|
239 |
// Dont need to FRAME RESTORE here since there's no barrier here |
|
240 |
asm("str r5, [r2] "); // store index |
|
241 |
__POPRET("r5-r11,"); // restore r5-r11 and return |
|
242 |
||
243 |
// Binary search list of pointers |
|
244 |
// Pointer to match value in r4 |
|
245 |
// List address in r6 |
|
246 |
// Count in r5 |
|
247 |
// Pointer to ordering function in r7 |
|
248 |
// r11 = find mode |
|
249 |
// Return with: r0=0 if match found, r0=-1 otherwise |
|
250 |
// Z flag set if match found, clear otherwise |
|
251 |
// r5=index of match or next higher |
|
252 |
// r9,r10,r11 modified |
|
253 |
asm("BinarySearchPointers: "); |
|
254 |
#ifdef _DEBUG |
|
255 |
asm("cmp r11, #%a0" : : "i" ((TInt)EArrayFindMode_Limit) ); |
|
256 |
asm("bhs PanicBadArrayFindMode "); |
|
257 |
#endif |
|
258 |
asm("movs r11, r11, lsl #30 "); // match mode -> bits 30,31 (00000000=any, 40000000=first, 80000000=last) |
|
259 |
asm("eorne r11, r11, #0xC0000000 "); // match mode -> bits 30,31 (00000000=any, 80000000=first, 40000000=last) |
|
260 |
asm("orr r11, r11, #1 "); // set NOT FOUND flag |
|
261 |
asm("mov r9, lr "); |
|
262 |
asm("cmp r5, #0 "); // r5 will be right index |
|
263 |
asm("beq 0f "); |
|
264 |
asm("mov r10, #0 "); // r10 = left index |
|
265 |
asm("1: "); |
|
266 |
asm("add r8, r5, r10 "); |
|
267 |
asm("mov r8, r8, lsr #1 "); // r8 = mid index |
|
268 |
||
269 |
/** the latency of the indirect call should mask the latency of the ldr |
|
270 |
arm1136 requires base register to be valid one cycle early |
|
271 |
*/ |
|
272 |
asm("mov r0, r4 "); // r0 points to match value |
|
273 |
asm("ldr r1, [r6, r8, lsl #2] "); // r1 points to entry[mid] |
|
274 |
__JUMPL(7); // call ordering function (match, entry) |
|
275 |
asm("cmp r0, #0 "); |
|
276 |
asm("biceq r11, r11, #1 "); // if match clear NOT FOUND flag |
|
277 |
asm("addeqs r0, r0, r11 "); // and add match mode to r0 (>0 if LAST, <0 if FIRST, 0 if ANY) |
|
278 |
asm("beq 2f "); // branch out if match and ANY |
|
279 |
asm("addgt r10, r8, #1 "); // else if match > entry, left = mid + 1 |
|
280 |
asm("movlt r5, r8 "); // else if match < entry, right = mid |
|
281 |
asm("subs r0, r5, r10 "); // loop if right > left |
|
282 |
asm("bgt 1b "); // finish loop with r0 = 0 |
|
283 |
asm("0: "); |
|
284 |
asm("tst r11, #1 "); // test not found flag |
|
285 |
asm("mvnnes r0, #0 "); // if set r0=-1 = KErrNotFound |
|
286 |
__JUMP(,r9); |
|
287 |
asm("2: "); |
|
288 |
asm("mov r5, r8 "); // if ANY, r8 = mid |
|
289 |
__JUMP(,r9); // and return with r0 = 0, Z=1 |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
290 |
__EH_FNEND |
0 | 291 |
} |
292 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
293 |
EXPORT_C TInt RPointerArrayBase::FindIsqSigned(TInt anEntry) const |
0 | 294 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
295 |
return RPointerArrayBase::FindIsqSigned(anEntry, 0); |
0 | 296 |
} |
297 |
||
298 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsqSigned(TInt /*anEntry*/, TInt /*aMode*/) const |
|
299 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
300 |
__EH_FNSTART |
0 | 301 |
#ifdef __EABI__ |
302 |
// sp needs correct alignment |
|
303 |
asm("stmfd sp!, {r4-r6,lr} "); |
|
304 |
__EH_FRAME_PUSH2(r4-r6,lr) |
|
305 |
#else |
|
306 |
asm("stmfd sp!, {r4,r5,lr} "); |
|
307 |
#endif |
|
308 |
asm("mov r3, r2 "); // r3 = match mode |
|
309 |
asm("ldmia r0, {r2,r4} "); // r2=count, r4=iEntries |
|
310 |
asm("bl BinarySearchSigned "); |
|
311 |
asm("moveq r0, r2 "); // if match r0=match index; if no match, r0=KErrNotFound |
|
312 |
#ifdef __EABI__ |
|
313 |
__POPRET("r4-r6,"); |
|
314 |
#else |
|
315 |
__POPRET("r4,r5,"); |
|
316 |
#endif |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
317 |
__EH_FNEND |
0 | 318 |
} |
319 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
320 |
EXPORT_C TInt RPointerArrayBase::FindIsqUnsigned(TUint anEntry) const |
0 | 321 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
322 |
return RPointerArrayBase::FindIsqUnsigned(anEntry, 0); |
0 | 323 |
} |
324 |
||
325 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsqUnsigned(TUint /*anEntry*/, TInt /*aMode*/) const |
|
326 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
327 |
__EH_FNSTART |
0 | 328 |
#ifdef __EABI__ |
329 |
// sp needs correct alignment |
|
330 |
asm("stmfd sp!, {r4-r6,lr} "); |
|
331 |
__EH_FRAME_PUSH2(r4-r6,lr) |
|
332 |
#else |
|
333 |
asm("stmfd sp!, {r4,r5,lr} "); |
|
334 |
#endif |
|
335 |
asm("mov r3, r2 "); // r3 = match mode |
|
336 |
asm("ldmia r0, {r2,r4} "); // r2=count, r4=iEntries |
|
337 |
asm("bl BinarySearchUnsigned "); |
|
338 |
asm("moveq r0, r2 "); // if match r0=match index; if no match, r0=KErrNotFound |
|
339 |
#ifdef __EABI__ |
|
340 |
__POPRET("r4-r6,"); |
|
341 |
#else |
|
342 |
__POPRET("r4,r5,"); |
|
343 |
#endif |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
344 |
__EH_FNEND |
0 | 345 |
} |
346 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
347 |
EXPORT_C TInt RPointerArrayBase::FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const |
0 | 348 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
349 |
return RPointerArrayBase::FindIsq(anEntry, anOrder, 0); |
0 | 350 |
} |
351 |
||
352 |
EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsq(const TAny* /*anEntry*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const |
|
353 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
354 |
__EH_FNSTART |
0 | 355 |
asm("stmfd sp!, {r3-r11,lr} "); |
356 |
__EH_FRAME_PUSH2(r4-r6,lr) |
|
357 |
asm("ldmia r0, {r5,r6} "); // r5=count, r6=iEntries |
|
358 |
asm("mov r11, r3 "); // r11 = aMode |
|
359 |
asm("mov r7, r2 "); // r7=anOrder |
|
360 |
asm("mov r4, r1 "); // r1=anEntry |
|
361 |
asm("bl BinarySearchPointers "); |
|
362 |
asm("moveq r0, r5 "); // if match, r0=match index |
|
363 |
__POPRET("r3-r11,"); |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
364 |
__EH_FNEND |
0 | 365 |
} |
366 |
||
367 |
#ifndef __KERNEL_MODE__ |
|
368 |
EXPORT_C __NAKED__ void RPointerArrayBase::HeapSortSigned() |
|
369 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
370 |
__EH_FNSTART |
0 | 371 |
#ifdef __EABI__ |
372 |
asm("stmfd sp!, {r4-r10,lr} "); |
|
373 |
__EH_FRAME_PUSH2(r4-r10,lr) |
|
374 |
#else |
|
375 |
asm("stmfd sp!, {r4-r9,lr} "); |
|
376 |
#endif |
|
377 |
asm("ldmia r0, {r4,r5} "); // r4=iCount, r5=iEntries |
|
378 |
asm("bl HeapSortSigned "); |
|
379 |
#ifdef __EABI__ |
|
380 |
__POPRET("r4-r10,"); |
|
381 |
#else |
|
382 |
__POPRET("r4-r9,"); |
|
383 |
#endif |
|
384 |
// Heap sort list of signed integers |
|
385 |
// List address in r5, count in r4 |
|
386 |
// r4=ss, r6=sh, r7=si |
|
387 |
// r8,r9 modified |
|
388 |
asm("HeapSortSigned: "); |
|
389 |
asm("cmp r4, #1 "); |
|
390 |
__JUMP(le,lr); |
|
391 |
asm("mov r6, r4, lsr #1 "); |
|
392 |
asm("hss_loop_start1: "); |
|
393 |
asm("sub r6, r6, #1 "); |
|
394 |
asm("ldr r7, [r5, r6, lsl #2] "); |
|
395 |
asm("mov r8, r6 "); |
|
396 |
asm("mov r9, r6 "); |
|
397 |
asm("b hss_loop_start2 "); |
|
398 |
asm("hss_loop_inner: "); |
|
399 |
asm("ldr r0, [r5, r8, lsl #2] "); |
|
400 |
asm("str r0, [r5, r9, lsl #2] "); |
|
401 |
asm("mov r9, r8 "); |
|
402 |
asm("hss_loop_start2: "); |
|
403 |
asm("add r8, r8, #1 "); |
|
404 |
asm("add r8, r8, r8 "); |
|
405 |
asm("cmp r8, r4 "); |
|
406 |
asm("bgt hss_loop_inner_end "); |
|
407 |
asm("add r0, r5, r8, lsl #2 "); |
|
408 |
asm("ldmneda r0, {r1,r2} "); |
|
409 |
asm("ldreq r1, [r0, #-4] "); |
|
410 |
asm("subeq r8, r8, #1 "); |
|
411 |
asm("beq hss_loop_inner2 "); |
|
412 |
asm("cmp r1, r2 "); |
|
413 |
asm("subgt r8, r8, #1 "); |
|
414 |
asm("movle r1, r2 "); |
|
415 |
asm("hss_loop_inner2: "); |
|
416 |
asm("cmp r1, r7 "); |
|
417 |
asm("bgt hss_loop_inner "); |
|
418 |
asm("hss_loop_inner_end: "); |
|
419 |
asm("str r7, [r5, r9, lsl #2] "); |
|
420 |
asm("cmp r6, #0 "); |
|
421 |
asm("bne hss_loop_start1 "); |
|
422 |
asm("sub r4, r4, #1 "); |
|
423 |
asm("ldr r7, [r5, r4, lsl #2] "); |
|
424 |
asm("ldr r0, [r5, #0] "); |
|
425 |
asm("str r0, [r5, r4, lsl #2] "); |
|
426 |
asm("cmp r4, #1 "); |
|
427 |
asm("mov r8, r6 "); |
|
428 |
asm("mov r9, r6 "); |
|
429 |
asm("bgt hss_loop_start2 "); |
|
430 |
asm("str r7, [r5, #0] "); |
|
431 |
__JUMP(,lr); |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
432 |
__EH_FNEND |
0 | 433 |
} |
434 |
||
435 |
EXPORT_C __NAKED__ void RPointerArrayBase::HeapSortUnsigned() |
|
436 |
{ |
|
437 |
asm("stmfd sp!, {r4-r9,lr} "); |
|
438 |
asm("ldmia r0, {r4,r5} "); // r4=iCount, r5=iEntries |
|
439 |
asm("bl HeapSortUnsigned "); |
|
440 |
__POPRET("r4-r9,"); |
|
441 |
} |
|
442 |
#endif // !__KERNEL_MODE__ |
|
443 |
||
444 |
__NAKED__ void HeapSortUnsigned(TUint* aEntries,TInt aCount) |
|
445 |
{ |
|
446 |
asm("stmfd sp!, {r4-r9,lr} "); |
|
447 |
asm("mov r4,r1"); // r4=iCount |
|
448 |
asm("mov r5,r0"); // r5=iEntries |
|
449 |
asm("bl HeapSortUnsigned "); |
|
450 |
__POPRET("r4-r9,"); |
|
451 |
||
452 |
// Heap sort list of unsigned integers |
|
453 |
// List address in r5, count in r4 |
|
454 |
// r4=ss, r6=sh, r7=si |
|
455 |
// r8,r9 modified |
|
456 |
asm("HeapSortUnsigned: "); |
|
457 |
asm("cmp r4, #1 "); |
|
458 |
__JUMP(le,lr); |
|
459 |
asm("mov r6, r4, lsr #1 "); |
|
460 |
asm("hsu_loop_start1: "); |
|
461 |
asm("sub r6, r6, #1 "); |
|
462 |
asm("ldr r7, [r5, r6, lsl #2] "); |
|
463 |
asm("mov r8, r6 "); |
|
464 |
asm("mov r9, r6 "); |
|
465 |
asm("b hsu_loop_start2 "); |
|
466 |
asm("hsu_loop_inner: "); |
|
467 |
asm("ldr r0, [r5, r8, lsl #2] "); |
|
468 |
asm("str r0, [r5, r9, lsl #2] "); |
|
469 |
asm("mov r9, r8 "); |
|
470 |
asm("hsu_loop_start2: "); |
|
471 |
asm("add r8, r8, #1 "); |
|
472 |
asm("add r8, r8, r8 "); |
|
473 |
asm("cmp r8, r4 "); |
|
474 |
asm("bgt hsu_loop_inner_end "); |
|
475 |
asm("add r0, r5, r8, lsl #2 "); |
|
476 |
asm("ldmneda r0, {r1,r2} "); |
|
477 |
asm("ldreq r1, [r0, #-4] "); |
|
478 |
asm("subeq r8, r8, #1 "); |
|
479 |
asm("beq hsu_loop_inner2 "); |
|
480 |
asm("cmp r1, r2 "); |
|
481 |
asm("subhi r8, r8, #1 "); |
|
482 |
asm("movls r1, r2 "); |
|
483 |
asm("hsu_loop_inner2: "); |
|
484 |
asm("cmp r1, r7 "); |
|
485 |
asm("bhi hsu_loop_inner "); |
|
486 |
asm("hsu_loop_inner_end: "); |
|
487 |
asm("str r7, [r5, r9, lsl #2] "); |
|
488 |
asm("cmp r6, #0 "); |
|
489 |
asm("bne hsu_loop_start1 "); |
|
490 |
asm("sub r4, r4, #1 "); |
|
491 |
asm("ldr r7, [r5, r4, lsl #2] "); |
|
492 |
asm("ldr r0, [r5, #0] "); |
|
493 |
asm("str r0, [r5, r4, lsl #2] "); |
|
494 |
asm("cmp r4, #1 "); |
|
495 |
asm("mov r8, r6 "); |
|
496 |
asm("mov r9, r6 "); |
|
497 |
asm("bgt hsu_loop_start2 "); |
|
498 |
asm("str r7, [r5, #0] "); |
|
499 |
__JUMP(,lr); |
|
500 |
} |
|
501 |
||
502 |
#ifndef __KERNEL_MODE__ |
|
503 |
EXPORT_C __NAKED__ void RPointerArrayBase::HeapSort(TGeneralLinearOrder /*anOrder*/) |
|
504 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
505 |
__EH_FNSTART |
0 | 506 |
asm("stmfd sp!, {r3-r11,lr} "); |
507 |
// r3 is caller save |
|
508 |
__EH_FRAME_ADDRESS(sp,4) |
|
509 |
// we can push the callee save regs |
|
510 |
__EH_FRAME_PUSH2(r4-r11,lr) |
|
511 |
asm("ldmia r0, {r4,r5} "); // r4=iCount, r5=iEntries |
|
512 |
asm("mov r10, r1 "); // r10=anOrder |
|
513 |
asm("bl HeapSortPointers "); |
|
514 |
__POPRET("r3-r11,"); |
|
515 |
||
516 |
// Heap sort list of pointers |
|
517 |
// List address in r5, count in r4, r10 points to ordering function |
|
518 |
// r4=ss, r6=sh, r7=si |
|
519 |
// r8,r9,r11 modified |
|
520 |
asm("HeapSortPointers: "); |
|
521 |
asm("cmp r4, #1 "); |
|
522 |
__JUMP(le,lr); |
|
523 |
asm("mov r11, lr "); |
|
524 |
asm("mov r6, r4, lsr #1 "); |
|
525 |
asm("hsp_loop_start1: "); |
|
526 |
asm("sub r6, r6, #1 "); |
|
527 |
asm("ldr r7, [r5, r6, lsl #2] "); |
|
528 |
asm("mov r8, r6 "); |
|
529 |
asm("mov r9, r6 "); |
|
530 |
asm("b hsp_loop_start2 "); |
|
531 |
asm("hsp_loop_inner: "); |
|
532 |
asm("ldr r0, [r5, r8, lsl #2] "); |
|
533 |
asm("str r0, [r5, r9, lsl #2] "); |
|
534 |
asm("mov r9, r8 "); |
|
535 |
asm("hsp_loop_start2: "); |
|
536 |
asm("add r8, r8, #1 "); |
|
537 |
asm("add r8, r8, r8 "); |
|
538 |
asm("cmp r8, r4 "); |
|
539 |
asm("bgt hsp_loop_inner_end "); |
|
540 |
asm("subeq r8, r8, #1 "); |
|
541 |
asm("beq hsp_loop_inner2 "); |
|
542 |
asm("add r0, r5, r8, lsl #2 "); |
|
543 |
asm("ldmda r0, {r0,r1} "); |
|
544 |
__JUMPL(10); |
|
545 |
asm("cmp r0, #0 "); |
|
546 |
asm("subgt r8, r8, #1 "); |
|
547 |
asm("hsp_loop_inner2: "); |
|
548 |
asm("ldr r0, [r5, r8, lsl #2] "); |
|
549 |
asm("mov r1, r7 "); |
|
550 |
__JUMPL(10); |
|
551 |
asm("cmp r0, #0 "); |
|
552 |
asm("bgt hsp_loop_inner "); |
|
553 |
asm("hsp_loop_inner_end: "); |
|
554 |
asm("str r7, [r5, r9, lsl #2] "); |
|
555 |
asm("cmp r6, #0 "); |
|
556 |
asm("bne hsp_loop_start1 "); |
|
557 |
asm("sub r4, r4, #1 "); |
|
558 |
asm("ldr r7, [r5, r4, lsl #2] "); |
|
559 |
asm("ldr r0, [r5, #0] "); |
|
560 |
asm("str r0, [r5, r4, lsl #2] "); |
|
561 |
asm("cmp r4, #1 "); |
|
562 |
asm("mov r8, r6 "); |
|
563 |
asm("mov r9, r6 "); |
|
564 |
asm("bgt hsp_loop_start2 "); |
|
565 |
asm("str r7, [r5, #0] "); |
|
566 |
__JUMP(,r11); |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
567 |
__EH_FNEND |
0 | 568 |
} |
569 |
#endif // __KERNEL_MODE__ |
|
570 |
||
571 |
EXPORT_C __NAKED__ TAny* RArrayBase::At(TInt /*anIndex*/) const |
|
572 |
{ |
|
573 |
asm("ldmia r0, {r2,r3,r12} "); // r2=iCount, r3=iEntries, r12=iEntrySize |
|
574 |
asm("cmp r1, #0 "); // check anIndex>=0 |
|
575 |
asm("cmpge r2, r1 "); // if so, check iCount>anIndex |
|
576 |
asm("mlagt r0, r1, r12, r3 "); // if ok, r0=anIndex*iEntrySize+iEntries |
|
577 |
#ifdef __CPU_ARMV6 |
|
578 |
asm("ble 1f "); |
|
579 |
__JUMP(,lr); |
|
580 |
#else |
|
581 |
__JUMP(gt,lr); |
|
582 |
#endif |
|
583 |
asm("1: "); |
|
584 |
asm("b " CSM_Z18PanicBadArrayIndexv); |
|
585 |
} |
|
586 |
||
587 |
EXPORT_C __NAKED__ TInt RArrayBase::Append(const TAny* /*anEntry*/) |
|
588 |
{ |
|
589 |
asm("stmfd sp!, {lr} "); |
|
590 |
asm("ldmia r0, {r3,r12} "); // r3=iCount, r12=iEntries |
|
591 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(RArrayBase,iAllocated)); |
|
592 |
asm("cmp r3, r2 "); |
|
593 |
asm("beq simple_append_1 "); |
|
594 |
asm("simple_append_0: "); |
|
595 |
asm("add r2, r3, #1 "); |
|
596 |
asm("str r2, [r0] "); // iCount++ |
|
597 |
asm("ldr r2, [r0, #%a0]" : : "i" _FOFF(RArrayBase,iEntrySize)); |
|
598 |
asm("mla r0, r2, r3, r12 "); // r0=iEntries+iEntrySize*iCount |
|
599 |
asm("bl wordmove "); // r1=anEntry, r2=iEntrySize, do copy |
|
600 |
asm("mov r0, #0 "); // return KErrNone; |
|
601 |
__POPRET(""); |
|
602 |
||
603 |
asm("simple_append_1: "); |
|
604 |
asm("stmfd sp!, {r0,r1,r2} "); |
|
605 |
asm("bl " CSM_ZN10RArrayBase4GrowEv); |
|
606 |
asm("cmp r0, #0 "); |
|
607 |
asm("bne simple_append_2 "); |
|
608 |
asm("ldmfd sp!, {r0,r1,r2} "); |
|
609 |
asm("ldmia r0, {r3, r12} "); |
|
610 |
asm("b simple_append_0 "); |
|
611 |
asm("simple_append_2: "); // error enlarging array |
|
612 |
asm("add sp, sp, #12 "); |
|
613 |
__POPRET(""); |
|
614 |
} |
|
615 |
||
616 |
EXPORT_C __NAKED__ TInt RArrayBase::Find(const TAny* /*anEntry*/) const |
|
617 |
{ |
|
618 |
asm("ldmia r0, {r0,r2,r3,r12} "); // r0=count, r2=iEntries, r3=iEntrySize, r12=iKeyOffset |
|
619 |
asm("stmfd sp!, {r4,lr} "); // save r4,lr |
|
620 |
asm("subs r0, r0, #1 "); // r0 = count-1 |
|
621 |
asm("blt 0f "); // skip if count was zero |
|
622 |
asm("ldr r1, [r1, r12] "); // r1=key of match entry |
|
623 |
asm("sub r4, r0, #1 "); // r4 = iCount-2 |
|
624 |
asm("1: "); |
|
625 |
asm("ldr lr, [r2, r12] "); // lr=key of current entry |
|
626 |
asm("add r2, r2, r3 "); // step r2 to next entry |
|
627 |
asm("subs r0, r0, #1 "); // C=1 iff this isn't last entry |
|
628 |
asm("teq lr, r1 "); // check for match - C unaffected |
|
629 |
asm("bhi 1b "); // loop if C=1 & Z=0, i.e. if no match and this isn't last entry |
|
630 |
asm("0: "); |
|
631 |
asm("mvnne r0, #0 "); // if no match, return -1 |
|
632 |
asm("subeq r0, r4, r0 "); // if match, index = (iCount-2)-r0 |
|
633 |
__POPRET("r4,"); |
|
634 |
} |
|
635 |
||
636 |
EXPORT_C __NAKED__ TInt RArrayBase::Find(const TAny* /*anEntry*/, TGeneralIdentityRelation /*anIdentity*/) const |
|
637 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
638 |
__EH_FNSTART |
0 | 639 |
asm("stmfd sp!, {r4-r10,lr} "); // save r4-r10,lr |
640 |
__EH_FRAME_PUSH2(r4-r10,lr) |
|
641 |
asm("ldmia r0, {r4,r5,r6} "); // r4=count, r5=iEntries, r6=iEntrySize |
|
642 |
asm("mov r8, r1 "); // r8=anEntry |
|
643 |
asm("mov r9, r2 "); // r9=anIdentity |
|
644 |
asm("sub r7, r4, #1 "); // r7=iCount-1 |
|
645 |
asm("b simple_find2_start "); |
|
646 |
asm("simple_find2_loop: "); |
|
647 |
asm("mov r1, r5 "); // r1->current entry |
|
648 |
asm("mov r0, r8 "); // r0=anEntry |
|
649 |
__JUMPL(9); |
|
650 |
asm("cmp r0, #0 "); |
|
651 |
asm("bne simple_find2_return "); |
|
652 |
asm("add r5, r5, r6 "); // else step to next entry |
|
653 |
asm("simple_find2_start: "); |
|
654 |
asm("subs r4, r4, #1 "); |
|
655 |
asm("bpl simple_find2_loop "); |
|
656 |
asm("add r4, r7, #1 "); // no match, arrange to return -1 |
|
657 |
asm("simple_find2_return: "); |
|
658 |
asm("sub r0, r7, r4 "); // index=count-r4 |
|
659 |
__POPRET("r4-r10,"); |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
660 |
__EH_FNEND |
0 | 661 |
} |
662 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
663 |
EXPORT_C TInt RArrayBase::BinarySearchSigned(const TAny* anEntry, TInt& anIndex) const |
0 | 664 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
665 |
return RArrayBase::BinarySearchSigned(anEntry, anIndex, 0); |
0 | 666 |
} |
667 |
||
668 |
EXPORT_C __NAKED__ TInt RArrayBase::BinarySearchSigned(const TAny* /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const |
|
669 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
670 |
__EH_FNSTART |
0 | 671 |
asm("stmfd sp!, {r4-r8,lr} "); |
672 |
__EH_FRAME_PUSH2(r4-r8,lr) |
|
673 |
asm("mov r8, r2 "); // r8=&anIndex |
|
674 |
asm("ldmia r0, {r2,r4,r5,r6} "); // r2=count, r3=iEntries, r5=entry size, r6=key offset |
|
675 |
asm("cmp r5, #4 "); // check for 4 byte entries |
|
676 |
asm("ldr r1, [r1, r6] "); // r1=match key |
|
677 |
asm("beq 1f "); // if 4 byte entries, call simpler routine |
|
678 |
asm("bl BinarySearchSignedKey "); // if not, call general routine |
|
679 |
asm("b 2f "); |
|
680 |
asm("1: "); |
|
681 |
asm("bl BinarySearchSigned "); // use simpler routine for 4 byte entries |
|
682 |
asm("2: "); |
|
683 |
asm("str r2, [r8] "); |
|
684 |
__POPRET("r4-r8,"); |
|
685 |
||
686 |
// Binary search list of signed integers |
|
687 |
// Match key in r1 |
|
688 |
// List address in r4 |
|
689 |
// Count in r2 |
|
690 |
// Match mode in r3 |
|
691 |
// EntrySize in r5, KeyOffset in r6 |
|
692 |
// Return with: r0=0 if match found, r0 nonzero otherwise |
|
693 |
// r2=index of match or next higher |
|
694 |
// r7 modified |
|
695 |
asm("BinarySearchSignedKey: "); |
|
696 |
#ifdef _DEBUG |
|
697 |
asm("cmp r3, #%a0" : : "i" ((TInt)EArrayFindMode_Limit) ); |
|
698 |
asm("bhs PanicBadArrayFindMode "); |
|
699 |
#endif |
|
700 |
asm("mov r3, r3, lsl #30 "); // match mode -> bits 30,31 (00000000=any, 40000000=first, 80000000=last) |
|
701 |
asm("orr r3, r3, #1 "); // set NOT FOUND flag |
|
702 |
asm("cmp r2, #0 "); // r2 will be right index |
|
703 |
asm("beq 0f "); |
|
704 |
asm("mov r7, #0 "); // r7 will be left index |
|
705 |
asm("1: "); |
|
706 |
asm("add r12, r2, r7 "); |
|
707 |
asm("mov r12, r12, lsr #1 "); // r12 = mid index |
|
708 |
asm("mla r0, r12, r5, r6 "); // r0 = key offset + entry size * mid index |
|
709 |
asm("ldr r0, [r4, r0] "); // r0 = key[mid] |
|
710 |
asm("subs r0, r0, r1 "); // r0 = entry[mid] - match |
|
711 |
asm("beq 2f "); // if match branch out |
|
712 |
asm("3: "); |
|
713 |
asm("addlt r7, r12, #1 "); // else if entry<match left=mid+1 |
|
714 |
asm("movgt r2, r12 "); // else if entry>match right=mid |
|
715 |
asm("subs r0, r2, r7 "); // right > left ? |
|
716 |
asm("bgt 1b "); // r0 = 0 when loop terminates |
|
717 |
asm("0: "); |
|
718 |
asm("tst r3, #1 "); // test not found flag |
|
719 |
asm("mvnnes r0, #0 "); // if set r0=-1 = KErrNotFound |
|
720 |
__JUMP(,lr); |
|
721 |
asm("2: "); |
|
722 |
asm("bics r3, r3, #1 "); // clear NOT FOUND flag, test for find mode ANY (Z set if so) |
|
723 |
asm("bne 3b "); // if not, V=0 (left from subs), N=1 for last, 0 for first, Z=0 => LAST->LT FIRST->GT |
|
724 |
asm("mov r2, r12 "); // if so, r2 = mid |
|
725 |
__JUMP(,lr); // and return with r0 = 0 |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
726 |
__EH_FNEND |
0 | 727 |
} |
728 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
729 |
EXPORT_C TInt RArrayBase::BinarySearchUnsigned(const TAny* anEntry, TInt& anIndex) const |
0 | 730 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
731 |
return RArrayBase::BinarySearchUnsigned(anEntry, anIndex, 0); |
0 | 732 |
} |
733 |
||
734 |
EXPORT_C __NAKED__ TInt RArrayBase::BinarySearchUnsigned(const TAny* /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const |
|
735 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
736 |
__EH_FNSTART |
0 | 737 |
asm("stmfd sp!, {r4-r8,lr} "); |
738 |
__EH_FRAME_PUSH2(r4-r8,lr) |
|
739 |
asm("mov r8, r2 "); // r8=&anIndex |
|
740 |
asm("ldmia r0, {r2,r4,r5,r6} "); // r2=count, r4=iEntries, r5=entry size, r6=key offset |
|
741 |
asm("cmp r5, #4 "); // check for 4 byte entries |
|
742 |
asm("ldr r1, [r1, r6] "); // r1=match key |
|
743 |
asm("beq 1f "); // if 4 byte entries, call simpler routine |
|
744 |
asm("bl BinarySearchUnsignedKey "); // if not, call general routine |
|
745 |
asm("b 2f "); |
|
746 |
asm("1: "); |
|
747 |
asm("bl BinarySearchUnsigned "); // use simpler routine for 4 byte entries |
|
748 |
asm("2: "); |
|
749 |
asm("str r2, [r8] "); |
|
750 |
__POPRET("r4-r8,"); |
|
751 |
||
752 |
// Binary search list of unsigned integers |
|
753 |
// Match key in r1 |
|
754 |
// List address in r4 |
|
755 |
// Count in r2 |
|
756 |
// Match mode in r3 |
|
757 |
// EntrySize in r5, KeyOffset in r6 |
|
758 |
// Return with: r0=0 if match found, r0 nonzero otherwise |
|
759 |
// r2=index of match or next higher |
|
760 |
// r7 modified |
|
761 |
asm("BinarySearchUnsignedKey: "); |
|
762 |
#ifdef _DEBUG |
|
763 |
asm("cmp r3, #%a0" : : "i" ((TInt)EArrayFindMode_Limit) ); |
|
764 |
asm("bhs PanicBadArrayFindMode "); |
|
765 |
#endif |
|
766 |
asm("mov r3, r3, lsl #30 "); // match mode -> bits 30,31 (00000000=any, 40000000=first, 80000000=last) |
|
767 |
asm("orr r3, r3, #1 "); // set NOT FOUND flag |
|
768 |
asm("cmp r2, #0 "); // r2 will be right index |
|
769 |
asm("beq 0f "); |
|
770 |
asm("mov r7, #0 "); // r7 will be left index |
|
771 |
asm("1: "); |
|
772 |
asm("add r12, r2, r7 "); |
|
773 |
asm("mov r12, r12, lsr #1 "); // r12 = mid index |
|
774 |
asm("mla r0, r12, r5, r6 "); // r0 = key offset + entry size * mid index |
|
775 |
asm("ldr r0, [r4, r0] "); // r0 = key[mid] |
|
776 |
asm("subs r0, r1, r0 "); // r0 = match - entry[mid] |
|
777 |
asm("beq 2f "); // if match branch out |
|
778 |
asm("3: "); |
|
779 |
asm("addhi r7, r12, #1 "); // else if entry<match left=mid+1 HI = C &~ Z |
|
780 |
asm("movlo r2, r12 "); // else if entry>match right=mid LO = ~C |
|
781 |
asm("subs r0, r2, r7 "); // right > left ? |
|
782 |
asm("bgt 1b "); // r0 = 0 when loop terminates |
|
783 |
asm("0: "); |
|
784 |
asm("tst r3, #1 "); // test not found flag |
|
785 |
asm("mvnnes r0, #0 "); // if set r0=-1 = KErrNotFound |
|
786 |
__JUMP(,lr); |
|
787 |
asm("2: "); // N=0 Z=1 C=1 V=0 r0=0 here |
|
788 |
asm("bics r3, r3, #1 "); // clear NOT FOUND flag, test for find mode ANY (Z set if so) |
|
789 |
asm("cmpne r3, #0x60000000 "); // HI if LAST, LO if FIRST |
|
790 |
asm("bne 3b "); // if not ANY, branch back |
|
791 |
asm("mov r2, r12 "); // if ANY, r2 = mid |
|
792 |
__JUMP(,lr); // and return with r0 = 0 |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
793 |
__EH_FNEND |
0 | 794 |
} |
795 |
||
796 |
EXPORT_C __NAKED__ TInt RArrayBase::BinarySearch(const TAny* /*anEntry*/, TInt& /*anIndex*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const |
|
797 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
798 |
__EH_FNSTART |
0 | 799 |
asm("stmfd sp!, {r3-r11,lr} "); |
800 |
// r3 is caller save |
|
801 |
__EH_FRAME_ADDRESS(sp,4) |
|
802 |
// we can push the callee save regs |
|
803 |
__EH_FRAME_PUSH2(r4-r11,lr) |
|
804 |
asm("ldmia r0, {r5,r6,r11} "); // r5=count, r6=iEntries, r11=entry size |
|
805 |
asm("ldr r9, [sp, #40] "); // r9 = aMode |
|
806 |
asm("mov r4, r1 "); // r4=anEntry |
|
807 |
asm("mov r7, r3 "); // r7=anOrder |
|
808 |
asm("bl BinarySearchEntries "); |
|
809 |
asm("str r5, [r2] "); // store index |
|
810 |
__POPRET("r3-r11,"); |
|
811 |
||
812 |
// Binary search list of general entries |
|
813 |
// Pointer to match value in r4 |
|
814 |
// List address in r6 |
|
815 |
// Count in r5 |
|
816 |
// Match mode in r9 |
|
817 |
// Pointer to ordering function in r7 |
|
818 |
// Entry size in r11 |
|
819 |
// Return with: r0=0 if match found, r0 nonzero otherwise |
|
820 |
// r5=index of match or next higher |
|
821 |
// r9,r10 modified |
|
822 |
// r2 preserved |
|
823 |
asm("BinarySearchEntries: "); |
|
824 |
#ifdef _DEBUG |
|
825 |
asm("cmp r9, #%a0" : : "i" ((TInt)EArrayFindMode_Limit) ); |
|
826 |
asm("bhs PanicBadArrayFindMode "); |
|
827 |
#endif |
|
828 |
asm("stmfd sp!, {r2,lr} "); |
|
829 |
asm("movs r9, r9, lsl #30 "); // match mode -> bits 30,31 (00000000=any, 40000000=first, 80000000=last) |
|
830 |
asm("eorne r9, r9, #0xC0000000 "); // match mode -> bits 30,31 (00000000=any, 80000000=first, 40000000=last) |
|
831 |
asm("orr r9, r9, #1 "); // set NOT FOUND flag |
|
832 |
asm("cmp r5, #0 "); // r5 will be right index |
|
833 |
asm("beq 0f "); |
|
834 |
asm("mov r10, #0 "); // r10 will be left index |
|
835 |
asm("1: "); |
|
836 |
asm("add r8, r5, r10 "); |
|
837 |
asm("mov r8, r8, lsr #1 "); // r8 = mid index |
|
838 |
asm("mla r1, r8, r11, r6 "); // r1 = r8*entry size + list address = &entry[mid] |
|
839 |
asm("mov r0, r4 "); // r0 points to match value |
|
840 |
__JUMPL(7); // call ordering function (match, entry) |
|
841 |
asm("cmp r0, #0 "); |
|
842 |
asm("biceq r9, r9, #1 "); // if match clear NOT FOUND flag |
|
843 |
asm("addeqs r0, r0, r9 "); // and add match mode to r0 (>0 if LAST, <0 if FIRST, 0 if ANY) |
|
844 |
asm("beq 2f "); // branch out if match and ANY |
|
845 |
asm("addgt r10, r8, #1 "); // else if match > entry, left = mid + 1 |
|
846 |
asm("movlt r5, r8 "); // else if match < entry, right = mid |
|
847 |
asm("subs r0, r5, r10 "); // loop if right > left |
|
848 |
asm("bgt 1b "); // finish loop with r0 = 0 |
|
849 |
asm("0: "); |
|
850 |
asm("tst r9, #1 "); // test not found flag |
|
851 |
asm("mvnnes r0, #0 "); // if set r0=-1 = KErrNotFound |
|
852 |
__POPRET("r2,"); |
|
853 |
asm("2: "); |
|
854 |
asm("mov r5, r8 "); // if ANY, r8 = mid |
|
855 |
__POPRET("r2,"); // and return with r0 = 0, Z=1 |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
856 |
__EH_FNEND |
0 | 857 |
} |
858 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
859 |
EXPORT_C TInt RArrayBase::FindIsqSigned(const TAny* anEntry) const |
0 | 860 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
861 |
return RArrayBase::FindIsqSigned(anEntry, 0); |
0 | 862 |
} |
863 |
||
864 |
EXPORT_C __NAKED__ TInt RArrayBase::FindIsqSigned(const TAny* /*anEntry*/, TInt /*aMode*/) const |
|
865 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
866 |
__EH_FNSTART |
0 | 867 |
#ifdef __EABI__ |
868 |
// sp needs to be aligned correctly |
|
869 |
asm("stmfd sp!, {r4-r8,lr} "); |
|
870 |
__EH_FRAME_PUSH2(r4-r8,lr) |
|
871 |
#else |
|
872 |
asm("stmfd sp!, {r4-r7,lr} "); |
|
873 |
#endif |
|
874 |
asm("mov r3, r2 "); // r3 = match mode |
|
875 |
asm("ldmia r0, {r2,r4,r5,r6} "); // r2=count, r4=iEntries, r5=entry size, r6=key offset |
|
876 |
asm("cmp r5, #4 "); // check for 4 byte entries |
|
877 |
asm("ldr r1, [r1, r6] "); // r1=match key |
|
878 |
asm("beq 1f "); // use simpler routine for 4 byte entries |
|
879 |
asm("bl BinarySearchSignedKey "); // else call general routine |
|
880 |
asm("b 2f "); |
|
881 |
asm("1: "); |
|
882 |
asm("bl BinarySearchSigned "); |
|
883 |
asm("2: "); |
|
884 |
asm("moveq r0, r2 "); // if match r0=index else r0=KErrNotFound |
|
885 |
#ifdef __EABI__ |
|
886 |
__POPRET("r4-r8,"); |
|
887 |
#else |
|
888 |
__POPRET("r4-r7,"); |
|
889 |
#endif |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
890 |
__EH_FNEND |
0 | 891 |
} |
892 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
893 |
EXPORT_C TInt RArrayBase::FindIsqUnsigned(const TAny* anEntry) const |
0 | 894 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
895 |
return RArrayBase::FindIsqUnsigned(anEntry, 0); |
0 | 896 |
} |
897 |
||
898 |
EXPORT_C __NAKED__ TInt RArrayBase::FindIsqUnsigned(const TAny* /*anEntry*/, TInt /*aMode*/) const |
|
899 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
900 |
__EH_FNSTART |
0 | 901 |
#ifdef __EABI__ |
902 |
// sp needs to be aligned correctly |
|
903 |
asm("stmfd sp!, {r4-r8,lr} "); |
|
904 |
__EH_FRAME_PUSH2(r4-r8,lr) |
|
905 |
#else |
|
906 |
asm("stmfd sp!, {r4-r7,lr} "); |
|
907 |
#endif |
|
908 |
asm("mov r3, r2 "); // r3 = match mode |
|
909 |
asm("ldmia r0, {r2,r4,r5,r6} "); // r2=count, r4=iEntries, r5=entry size, r6=key offset |
|
910 |
asm("cmp r5, #4 "); // check for 4 byte entries |
|
911 |
asm("ldr r1, [r1, r6] "); // r1=match key |
|
912 |
asm("beq 1f "); // use simpler routine for 4 byte entries |
|
913 |
asm("bl BinarySearchUnsignedKey "); // else call general routine |
|
914 |
asm("b 2f "); |
|
915 |
asm("1: "); |
|
916 |
asm("bl BinarySearchUnsigned "); |
|
917 |
asm("2: "); |
|
918 |
asm("moveq r0, r2 "); // if match r0=index else r0=KErrNotFound |
|
919 |
#ifdef __EABI__ |
|
920 |
__POPRET("r4-r8,"); |
|
921 |
#else |
|
922 |
__POPRET("r4-r7,"); |
|
923 |
#endif |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
924 |
__EH_FNEND |
0 | 925 |
} |
926 |
||
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
927 |
EXPORT_C TInt RArrayBase::FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const |
0 | 928 |
{ |
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
929 |
return RArrayBase::FindIsq(anEntry, anOrder, 0); |
0 | 930 |
} |
931 |
||
932 |
EXPORT_C __NAKED__ TInt RArrayBase::FindIsq(const TAny* /*anEntry*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const |
|
933 |
{ |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
934 |
__EH_FNSTART |
0 | 935 |
asm("stmfd sp!, {r3-r11,lr} "); |
936 |
// r3 is caller save |
|
937 |
__EH_FRAME_ADDRESS(sp,4) |
|
938 |
// we can push the callee save regs |
|
939 |
__EH_FRAME_PUSH2(r4-r11,lr) |
|
940 |
asm("ldmia r0, {r5,r6,r11} "); // r5=count, r6=iEntries, r11=entry size |
|
941 |
asm("mov r4, r1 "); // r4=anEntry |
|
942 |
asm("mov r7, r2 "); // r7=anOrder |
|
943 |
asm("mov r9, r3 "); // r9 = aMode |
|
944 |
asm("bl BinarySearchEntries "); |
|
945 |
asm("moveq r0, r5 "); // if match r0=index |
|
946 |
__POPRET("r3-r11,"); |
|
156
12b6722e7753
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp.
mikek
parents:
0
diff
changeset
|
947 |
__EH_FNEND |
0 | 948 |
} |
949 |
||
950 |
#ifndef __KERNEL_MODE__ |
|
951 |
EXPORT_C __NAKED__ void RArrayBase::HeapSortSigned() |
|
952 |
{ |
|
159 | 953 |
// __EH_FNSTART |
0 | 954 |
#ifdef __EABI__ |
955 |
// need sp aligned correctly |
|
956 |
asm("stmfd sp!, {r3-r11,lr} "); |
|
957 |
__EH_FRAME_ADDRESS(sp,4) |
|
958 |
__EH_FRAME_PUSH2(r4-r11,lr) |
|
959 |
#else |
|
960 |
asm("stmfd sp!, {r4-r11,lr} "); |
|
961 |
#endif |
|
962 |
asm("ldmia r0, {r4,r5,r10,r11} "); // r4=iCount, r5=iEntries, r10=entry size, r11=key offset |
|
963 |
asm("cmp r10, #4 "); |
|
964 |
asm("bleq HeapSortSigned "); |
|
965 |
asm("cmp r10, #4 "); |
|
966 |
asm("blne HeapSortSignedKey "); |
|
967 |
#ifdef __EABI__ |
|
968 |
__POPRET("r3-r11,"); |
|
969 |
#else |
|
970 |
__POPRET("r4-r11,"); |
|
971 |
#endif |
|
972 |
||
973 |
// Heap sort list of entries by signed key |
|
974 |
// List address in r5, count in r4, entry size in r10, key offset in r11 |
|
975 |
// r4=ss, r6=sh |
|
976 |
// r8,r9 modified |
|
977 |
asm("HeapSortSignedKey: "); |
|
978 |
asm("cmp r4, #1 "); |
|
979 |
__JUMP(le,lr); |
|
980 |
asm("mov r7, lr "); // save lr in r7 |
|
981 |
asm("sub sp, sp, r10 "); // get some temporary space on the stack |
|
982 |
asm("mov r6, r4, lsr #1 "); |
|
983 |
asm("hssk_loop_start1: "); |
|
984 |
asm("sub r6, r6, #1 "); |
|
985 |
asm("mla r1, r6, r10, r5 "); // [sp]=entry[r6] |
|
986 |
asm("mov r0, sp "); |
|
987 |
asm("mov r2, r10 "); |
|
988 |
asm("bl wordmove "); |
|
989 |
asm("mov r8, r6 "); |
|
990 |
asm("mov r9, r6 "); |
|
991 |
asm("b hssk_loop_start2 "); |
|
992 |
asm("hssk_loop_inner: "); |
|
993 |
asm("mla r0, r9, r10, r5 "); // r0=&entry[r9] |
|
994 |
asm("mla r1, r8, r10, r5 "); // r1=&entry[r8] |
|
995 |
asm("mov r2, r10 "); |
|
996 |
asm("bl wordmove "); // entry[r9]=entry[r8] |
|
997 |
asm("mov r9, r8 "); |
|
998 |
asm("hssk_loop_start2: "); |
|
999 |
asm("add r8, r8, #1 "); |
|
1000 |
asm("add r8, r8, r8 "); |
|
1001 |
asm("cmp r8, r4 "); |
|
1002 |
asm("bgt hssk_loop_inner_end "); |
|
1003 |
asm("mla r0, r8, r10, r5 "); |
|
1004 |
asm("ldrne r2, [r0, r11]! "); // r2=key[r8] |
|
1005 |
asm("addeq r0, r0, r11 "); |
|
1006 |
asm("ldr r1, [r0, -r10] "); // r1=key[r8-1] |
|
1007 |
asm("subeq r8, r8, #1 "); |
|
1008 |
asm("beq hssk_loop_inner2 "); |
|
1009 |
asm("cmp r1, r2 "); |
|
1010 |
asm("subgt r8, r8, #1 "); |
|
1011 |
asm("movle r1, r2 "); |
|
1012 |
asm("hssk_loop_inner2: "); |
|
1013 |
asm("ldr r2, [sp, r11] "); // r2=key[sp] |
|
1014 |
asm("cmp r1, r2 "); |
|
1015 |
asm("bgt hssk_loop_inner "); |
|
1016 |
asm("hssk_loop_inner_end: "); |
|
1017 |
asm("mla r0, r9, r10, r5 "); // r0=&entry[r9] |
|
1018 |
asm("mov r1, sp "); |
|
1019 |
asm("mov r2, r10 "); |
|
1020 |
asm("bl wordmove "); // entry[r9]=[sp] |
|
1021 |
asm("cmp r6, #0 "); |
|
1022 |
asm("bne hssk_loop_start1 "); |
|
1023 |
asm("sub r4, r4, #1 "); |
|
1024 |
asm("mla r1, r4, r10, r5 "); // r1=&entry[r4] |
|
1025 |
asm("mov r0, sp "); |
|
1026 |
asm("mov r2, r10 "); |
|
1027 |
asm("bl wordmove "); // [sp]=entry[r4] |
|
1028 |
asm("mla r0, r4, r10, r5 "); // r0=&entry[r4] |
|
1029 |
asm("mov r1, r5 "); // r1=&entry[0] |
|
1030 |
asm("mov r2, r10 "); |
|
1031 |
asm("bl wordmove "); // entry[0]=entry[r4] |
|
1032 |
asm("cmp r4, #1 "); |
|
1033 |
asm("mov r8, r6 "); |
|
1034 |
asm("mov r9, r6 "); |
|
1035 |
asm("bgt hssk_loop_start2 "); |
|
1036 |
asm("mov r0, r5 "); // r0=&entry[0] |
|
1037 |
asm("mov r1, sp "); |
|
1038 |
asm("mov r2, r10 "); |
|
1039 |
asm("bl wordmove "); // entry[0]=[sp] |
|
1040 |
asm("add sp, sp, r10 "); // free temporary stack space |
|
1041 |
__JUMP(,r7); |
|
159 | 1042 |
// __EH_FNEND |
0 | 1043 |
} |
1044 |
||
1045 |
EXPORT_C __NAKED__ void RArrayBase::HeapSortUnsigned() |
|
1046 |
{ |
|
159 | 1047 |
// __EH_FNSTART |
0 | 1048 |
#ifdef __EABI__ |
1049 |
// need sp aligned correctly |
|
1050 |
asm("stmfd sp!, {r3-r11,lr} "); |
|
1051 |
__EH_FRAME_ADDRESS(sp,4) |
|
1052 |
__EH_FRAME_PUSH2(r4-r11,lr) |
|
1053 |
#else |
|
1054 |
asm("stmfd sp!, {r4-r11,lr} "); |
|
1055 |
#endif |
|
1056 |
asm("ldmia r0, {r4,r5,r10,r11} "); // r4=iCount, r5=iEntries, r10=entry size, r11=key offset |
|
1057 |
asm("cmp r10, #4 "); |
|
1058 |
asm("bleq HeapSortUnsigned "); |
|
1059 |
asm("cmp r10, #4 "); |
|
1060 |
asm("blne HeapSortUnsignedKey "); |
|
1061 |
#ifdef __EABI__ |
|
1062 |
__POPRET("r3-r11,"); |
|
1063 |
#else |
|
1064 |
__POPRET("r4-r11,"); |
|
1065 |
#endif |
|
1066 |
||
1067 |
// Heap sort list of entries by unsigned key |
|
1068 |
// List address in r5, count in r4, entry size in r10, key offset in r11 |
|
1069 |
// r4=ss, r6=sh |
|
1070 |
// r8,r9 modified |
|
1071 |
asm("HeapSortUnsignedKey: "); |
|
1072 |
asm("cmp r4, #1 "); |
|
1073 |
__JUMP(le,lr); |
|
1074 |
asm("mov r7, lr "); // save lr in r7 |
|
1075 |
asm("sub sp, sp, r10 "); // get some temporary space on the stack |
|
1076 |
asm("mov r6, r4, lsr #1 "); |
|
1077 |
asm("hsuk_loop_start1: "); |
|
1078 |
asm("sub r6, r6, #1 "); |
|
1079 |
asm("mla r1, r6, r10, r5 "); // [sp]=entry[r6] |
|
1080 |
asm("mov r0, sp "); |
|
1081 |
asm("mov r2, r10 "); |
|
1082 |
asm("bl wordmove "); |
|
1083 |
asm("mov r8, r6 "); |
|
1084 |
asm("mov r9, r6 "); |
|
1085 |
asm("b hsuk_loop_start2 "); |
|
1086 |
asm("hsuk_loop_inner: "); |
|
1087 |
asm("mla r0, r9, r10, r5 "); // r0=&entry[r9] |
|
1088 |
asm("mla r1, r8, r10, r5 "); // r1=&entry[r8] |
|
1089 |
asm("mov r2, r10 "); |
|
1090 |
asm("bl wordmove "); // entry[r9]=entry[r8] |
|
1091 |
asm("mov r9, r8 "); |
|
1092 |
asm("hsuk_loop_start2: "); |
|
1093 |
asm("add r8, r8, #1 "); |
|
1094 |
asm("add r8, r8, r8 "); |
|
1095 |
asm("cmp r8, r4 "); |
|
1096 |
asm("bgt hsuk_loop_inner_end "); |
|
1097 |
asm("mla r0, r8, r10, r5 "); |
|
1098 |
asm("ldrne r2, [r0, r11]! "); // r2=key[r8] |
|
1099 |
asm("addeq r0, r0, r11 "); |
|
1100 |
asm("ldr r1, [r0, -r10] "); // r1=key[r8-1] |
|
1101 |
asm("subeq r8, r8, #1 "); |
|
1102 |
asm("beq hsuk_loop_inner2 "); |
|
1103 |
asm("cmp r1, r2 "); |
|
1104 |
asm("subhi r8, r8, #1 "); |
|
1105 |
asm("movls r1, r2 "); |
|
1106 |
asm("hsuk_loop_inner2: "); |
|
1107 |
asm("ldr r2, [sp, r11] "); // r2=key[sp] |
|
1108 |
asm("cmp r1, r2 "); |
|
1109 |
asm("bhi hsuk_loop_inner "); |
|
1110 |
asm("hsuk_loop_inner_end: "); |
|
1111 |
asm("mla r0, r9, r10, r5 "); // r0=&entry[r9] |
|
1112 |
asm("mov r1, sp "); |
|
1113 |
asm("mov r2, r10 "); |
|
1114 |
asm("bl wordmove "); // entry[r9]=[sp] |
|
1115 |
asm("cmp r6, #0 "); |
|
1116 |
asm("bne hsuk_loop_start1 "); |
|
1117 |
asm("sub r4, r4, #1 "); |
|
1118 |
asm("mla r1, r4, r10, r5 "); // r1=&entry[r4] |
|
1119 |
asm("mov r0, sp "); |
|
1120 |
asm("mov r2, r10 "); |
|
1121 |
asm("bl wordmove "); // [sp]=entry[r4] |
|
1122 |
asm("mla r0, r4, r10, r5 "); // r0=&entry[r4] |
|
1123 |
asm("mov r1, r5 "); // r1=&entry[0] |
|
1124 |
asm("mov r2, r10 "); |
|
1125 |
asm("bl wordmove "); // entry[0]=entry[r4] |
|
1126 |
asm("cmp r4, #1 "); |
|
1127 |
asm("mov r8, r6 "); |
|
1128 |
asm("mov r9, r6 "); |
|
1129 |
asm("bgt hsuk_loop_start2 "); |
|
1130 |
asm("mov r0, r5 "); // r0=&entry[0] |
|
1131 |
asm("mov r1, sp "); |
|
1132 |
asm("mov r2, r10 "); |
|
1133 |
asm("bl wordmove "); // entry[0]=[sp] |
|
1134 |
asm("add sp, sp, r10 "); // free temporary stack space |
|
1135 |
__JUMP(,r7); |
|
159 | 1136 |
// __EH_FNEND |
0 | 1137 |
} |
1138 |
||
1139 |
EXPORT_C __NAKED__ void RArrayBase::HeapSort(TGeneralLinearOrder anOrder) |
|
1140 |
{ |
|
159 | 1141 |
// __EH_FNSTART |
0 | 1142 |
#ifdef __EABI__ |
1143 |
// need sp aligned correctly |
|
1144 |
asm("stmfd sp!, {r3-r11,lr} "); |
|
1145 |
__EH_FRAME_ADDRESS(sp,4) |
|
1146 |
__EH_FRAME_PUSH2(r4-r11,lr) |
|
1147 |
#else |
|
1148 |
asm("stmfd sp!, {r4-r11,lr} "); |
|
1149 |
#endif |
|
1150 |
asm("ldmia r0, {r4,r5,r10,r11} "); |
|
1151 |
asm("mov r7, r1 "); |
|
1152 |
asm("bl HeapSortEntries "); |
|
1153 |
#ifdef __EABI__ |
|
1154 |
__POPRET("r3-r11,"); |
|
1155 |
#else |
|
1156 |
__POPRET("r4-r11,"); |
|
1157 |
#endif |
|
1158 |
||
1159 |
// Heap sort list of entries |
|
1160 |
// List address in r5, count in r4, entry size in r10, key offset in r11 |
|
1161 |
// Address of ordering function in r7 |
|
1162 |
// r4=ss, r6=sh |
|
1163 |
// r8,r9 modified |
|
1164 |
asm("HeapSortEntries: "); |
|
1165 |
asm("cmp r4, #1 "); |
|
1166 |
__JUMP(le,lr); |
|
1167 |
asm("str lr, [sp, #-4]! "); |
|
1168 |
asm("mov r8, sp "); // original SP |
|
1169 |
asm("sub sp, sp, r10 "); // get some temporary space on the stack |
|
1170 |
asm("sub sp, sp, #4 "); // make room for original SP |
|
1171 |
asm("bic sp, sp, #4 "); // align stack to 8 byte boundary |
|
1172 |
asm("str r8, [sp, r10] "); // save original SP |
|
1173 |
asm("mov r6, r4, lsr #1 "); |
|
1174 |
asm("hse_loop_start1: "); |
|
1175 |
asm("sub r6, r6, #1 "); |
|
1176 |
asm("mla r1, r6, r10, r5 "); // [sp]=entry[r6] |
|
1177 |
asm("mov r0, sp "); |
|
1178 |
asm("mov r2, r10 "); |
|
1179 |
asm("bl wordmove "); |
|
1180 |
asm("mov r8, r6 "); |
|
1181 |
asm("mov r9, r6 "); |
|
1182 |
asm("b hse_loop_start2 "); |
|
1183 |
asm("hse_loop_inner: "); |
|
1184 |
asm("mla r0, r9, r10, r5 "); // r0=&entry[r9] |
|
1185 |
asm("mla r1, r8, r10, r5 "); // r1=&entry[r8] |
|
1186 |
asm("mov r2, r10 "); |
|
1187 |
asm("bl wordmove "); // entry[r9]=entry[r8] |
|
1188 |
asm("mov r9, r8 "); |
|
1189 |
asm("hse_loop_start2: "); |
|
1190 |
asm("add r8, r8, #1 "); |
|
1191 |
asm("add r8, r8, r8 "); |
|
1192 |
asm("cmp r8, r4 "); |
|
1193 |
asm("bgt hse_loop_inner_end "); |
|
1194 |
asm("subeq r8, r8, #1 "); |
|
1195 |
asm("beq hse_loop_inner2 "); |
|
1196 |
asm("mla r1, r8, r10, r5 "); // r1=&entry[r8] |
|
1197 |
asm("sub r0, r1, r10 "); // r0=&entry[r8-1] |
|
1198 |
__JUMPL(7); |
|
1199 |
asm("cmp r0, #0 "); // compare entry[r8-1] with entry[r8] |
|
1200 |
asm("subgt r8, r8, #1 "); |
|
1201 |
asm("hse_loop_inner2: "); |
|
1202 |
asm("mla r0, r8, r10, r5 "); // r0=&entry[r8] |
|
1203 |
asm("mov r1, sp "); |
|
1204 |
__JUMPL(7); |
|
1205 |
asm("cmp r0, #0 "); // compare entry[r8] with [sp] |
|
1206 |
asm("bgt hse_loop_inner "); |
|
1207 |
asm("hse_loop_inner_end: "); |
|
1208 |
asm("mla r0, r9, r10, r5 "); // r0=&entry[r9] |
|
1209 |
asm("mov r1, sp "); |
|
1210 |
asm("mov r2, r10 "); |
|
1211 |
asm("bl wordmove "); // entry[r9]=[sp] |
|
1212 |
asm("cmp r6, #0 "); |
|
1213 |
asm("bne hse_loop_start1 "); |
|
1214 |
asm("sub r4, r4, #1 "); |
|
1215 |
asm("mla r1, r4, r10, r5 "); // r1=&entry[r4] |
|
1216 |
asm("mov r0, sp "); |
|
1217 |
asm("mov r2, r10 "); |
|
1218 |
asm("bl wordmove "); // [sp]=entry[r4] |
|
1219 |
asm("mla r0, r4, r10, r5 "); // r0=&entry[r4] |
|
1220 |
asm("mov r1, r5 "); // r1=&entry[0] |
|
1221 |
asm("mov r2, r10 "); |
|
1222 |
asm("bl wordmove "); // entry[0]=entry[r4] |
|
1223 |
asm("cmp r4, #1 "); |
|
1224 |
asm("mov r8, r6 "); |
|
1225 |
asm("mov r9, r6 "); |
|
1226 |
asm("bgt hse_loop_start2 "); |
|
1227 |
asm("mov r0, r5 "); // r0=&entry[0] |
|
1228 |
asm("mov r1, sp "); |
|
1229 |
asm("mov r2, r10 "); |
|
1230 |
asm("bl wordmove "); // entry[0]=[sp] |
|
1231 |
asm("ldr sp, [sp, r10] "); // restore stack pointer, freeing temporary stack space |
|
1232 |
__POPRET(""); |
|
159 | 1233 |
// __EH_FNEND |
0 | 1234 |
} |
1235 |
#endif // __KERNEL_MODE__ |
|
1236 |
#endif // __ARRAY_MACHINE_CODED__ |