1@ 2@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3@ 4@ Use of this source code is governed by a BSD-style license 5@ that can be found in the LICENSE file in the root of the source 6@ tree. An additional intellectual property rights grant can be found 7@ in the file PATENTS. All contributing project authors may 8@ be found in the AUTHORS file in the root of the source tree. 9@ 10 11@ This file contains the function WebRtcSpl_ComplexBitReverse(), optimized 12@ for ARMv5 platforms. 13@ Reference C code is in file complex_bit_reverse.c. Bit-exact. 14 15#include "webrtc/system_wrappers/include/asm_defines.h" 16 17GLOBAL_FUNCTION WebRtcSpl_ComplexBitReverse 18.align 2 19DEFINE_FUNCTION WebRtcSpl_ComplexBitReverse 20 push {r4-r7} 21 22 cmp r1, #7 23 adr r3, index_7 @ Table pointer. 24 mov r4, #112 @ Number of interations. 25 beq PRE_LOOP_STAGES_7_OR_8 26 27 cmp r1, #8 28 adr r3, index_8 @ Table pointer. 29 mov r4, #240 @ Number of interations. 30 beq PRE_LOOP_STAGES_7_OR_8 31 32 mov r3, #1 @ Initialize m. 33 mov r1, r3, asl r1 @ n = 1 << stages; 34 subs r6, r1, #1 @ nn = n - 1; 35 ble END 36 37 mov r5, r0 @ &complex_data 38 mov r4, #0 @ ml 39 40LOOP_GENERIC: 41 rsb r12, r4, r6 @ l > nn - mr 42 mov r2, r1 @ n 43 44LOOP_SHIFT: 45 asr r2, #1 @ l >>= 1; 46 cmp r2, r12 47 bgt LOOP_SHIFT 48 49 sub r12, r2, #1 50 and r4, r12, r4 51 add r4, r2 @ mr = (mr & (l - 1)) + l; 52 cmp r4, r3 @ mr <= m ? 53 ble UPDATE_REGISTERS 54 55 mov r12, r4, asl #2 56 ldr r7, [r5, #4] @ complex_data[2 * m, 2 * m + 1]. 57 @ Offset 4 due to m incrementing from 1. 58 ldr r2, [r0, r12] @ complex_data[2 * mr, 2 * mr + 1]. 59 str r7, [r0, r12] 60 str r2, [r5, #4] 61 62UPDATE_REGISTERS: 63 add r3, r3, #1 64 add r5, #4 65 cmp r3, r1 66 bne LOOP_GENERIC 67 68 b END 69 70PRE_LOOP_STAGES_7_OR_8: 71 add r4, r3, r4, asl #1 72 73LOOP_STAGES_7_OR_8: 74 ldrsh r2, [r3], #2 @ index[m] 75 ldrsh r5, [r3], #2 @ index[m + 1] 76 ldr r1, [r0, r2] @ complex_data[index[m], index[m] + 1] 77 ldr r12, [r0, r5] @ complex_data[index[m + 1], index[m + 1] + 1] 78 cmp r3, r4 79 str r1, [r0, r5] 80 str r12, [r0, r2] 81 bne LOOP_STAGES_7_OR_8 82 83END: 84 pop {r4-r7} 85 bx lr 86 87@ The index tables. Note the values are doubles of the actual indexes for 16-bit 88@ elements, different from the generic C code. It actually provides byte offsets 89@ for the indexes. 90 91.align 2 92index_7: @ Indexes for stages == 7. 93 .short 4, 256, 8, 128, 12, 384, 16, 64, 20, 320, 24, 192, 28, 448, 36, 288 94 .short 40, 160, 44, 416, 48, 96, 52, 352, 56, 224, 60, 480, 68, 272, 72, 144 95 .short 76, 400, 84, 336, 88, 208, 92, 464, 100, 304, 104, 176, 108, 432, 116 96 .short 368, 120, 240, 124, 496, 132, 264, 140, 392, 148, 328, 152, 200, 156 97 .short 456, 164, 296, 172, 424, 180, 360, 184, 232, 188, 488, 196, 280, 204 98 .short 408, 212, 344, 220, 472, 228, 312, 236, 440, 244, 376, 252, 504, 268 99 .short 388, 276, 324, 284, 452, 300, 420, 308, 356, 316, 484, 332, 404, 348 100 .short 468, 364, 436, 380, 500, 412, 460, 444, 492 101 102index_8: @ Indexes for stages == 8. 103 .short 4, 512, 8, 256, 12, 768, 16, 128, 20, 640, 24, 384, 28, 896, 32, 64 104 .short 36, 576, 40, 320, 44, 832, 48, 192, 52, 704, 56, 448, 60, 960, 68, 544 105 .short 72, 288, 76, 800, 80, 160, 84, 672, 88, 416, 92, 928, 100, 608, 104 106 .short 352, 108, 864, 112, 224, 116, 736, 120, 480, 124, 992, 132, 528, 136 107 .short 272, 140, 784, 148, 656, 152, 400, 156, 912, 164, 592, 168, 336, 172 108 .short 848, 176, 208, 180, 720, 184, 464, 188, 976, 196, 560, 200, 304, 204 109 .short 816, 212, 688, 216, 432, 220, 944, 228, 624, 232, 368, 236, 880, 244 110 .short 752, 248, 496, 252, 1008, 260, 520, 268, 776, 276, 648, 280, 392, 284 111 .short 904, 292, 584, 296, 328, 300, 840, 308, 712, 312, 456, 316, 968, 324 112 .short 552, 332, 808, 340, 680, 344, 424, 348, 936, 356, 616, 364, 872, 372 113 .short 744, 376, 488, 380, 1000, 388, 536, 396, 792, 404, 664, 412, 920, 420 114 .short 600, 428, 856, 436, 728, 440, 472, 444, 984, 452, 568, 460, 824, 468 115 .short 696, 476, 952, 484, 632, 492, 888, 500, 760, 508, 1016, 524, 772, 532 116 .short 644, 540, 900, 548, 580, 556, 836, 564, 708, 572, 964, 588, 804, 596 117 .short 676, 604, 932, 620, 868, 628, 740, 636, 996, 652, 788, 668, 916, 684 118 .short 852, 692, 724, 700, 980, 716, 820, 732, 948, 748, 884, 764, 1012, 796 119 .short 908, 812, 844, 828, 972, 860, 940, 892, 1004, 956, 988 120