3 @// Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
5 @// Use of this source code is governed by a BSD-style license
6 @// that can be found in the LICENSE file in the root of the source
7 @// tree. An additional intellectual property rights grant can be found
8 @// in the file PATENTS. All contributing project authors may
9 @// be found in the AUTHORS file in the root of the source tree.
11 @// This file was originally licensed as follows. It has been
12 @// relicensed with permission from the copyright holders.
16 @// File Name: armCOMM_s.h
17 @// OpenMAX DL: v1.0.2
18 @// Last Modified Revision: 13871
19 @// Last Modified Date: Fri, 09 May 2008
21 @// (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
25 @// ARM optimized OpenMAX common header file
28 .set _SBytes, 0 @ Number of scratch bytes on stack
29 .set _Workspace, 0 @ Stack offset of scratch workspace
31 .set _RRegList, 0 @ R saved register list (last register number)
32 .set _DRegList, 0 @ D saved register list (last register number)
34 @// Work out a list of R saved registers, and how much stack space is needed.
35 @// gas doesn't support setting a variable to a string, so we set _RRegList to
36 @// the register number.
37 .macro _M_GETRREGLIST rreg
39 @ Nothing needs to be saved
42 @ If rreg is lr or r4, save lr and r4
53 @ If rreg = r5 or r6, save up to register r6
63 @ If rreg = r7 or r8, save up to register r8
73 @ If rreg = r9 or r10, save up to register r10
83 @ If rreg = r11 or r12, save up to register r12
93 .warning "Unrecognized saved r register limit: \rreg"
96 @ Work out list of D saved registers, like for R registers.
97 .macro _M_GETDREGLIST dreg
113 .ifeqs "\dreg", "d10"
118 .ifeqs "\dreg", "d11"
123 .ifeqs "\dreg", "d12"
128 .ifeqs "\dreg", "d13"
133 .ifeqs "\dreg", "d14"
138 .ifeqs "\dreg", "d15"
143 .warning "Unrecognized saved d register limit: \rreg"
146 @//////////////////////////////////////////////////////////
147 @// Function header and footer macros
148 @//////////////////////////////////////////////////////////
150 @ Function Header Macro
151 @ Generates the function prologue
152 @ Note that functions should all be "stack-moves-once"
153 @ The FNSTART and FNEND macros should be the only places
154 @ where the stack moves.
156 @ name = function name
157 @ rreg = "" don't stack any registers
158 @ "lr" stack "lr" only
159 @ "rN" stack registers "r4-rN,lr"
160 @ dreg = "" don't stack any D registers
161 @ "dN" stack registers "d8-dN"
163 @ Note: ARM Archicture procedure call standard AAPCS
164 @ states that r4-r11, sp, d8-d15 must be preserved by
165 @ a compliant function.
166 .macro M_START name, rreg, dreg
169 @ Define the function and make it external.
172 .section .text.\name,"ax",%progbits
176 @ Save specified R registers
180 @ Save specified D registers
184 @ Ensure size claimed on stack is 8-byte aligned
185 .if (_SBytes & 7) != 0
186 .set _SBytes, _SBytes + (8 - (_SBytes & 7))
193 @ Function Footer Macro
194 @ Generates the function epilogue
196 @ Restore the stack pointer to its original value on function entry
200 @ Restore any saved R or D registers.
203 @ Reset the global stack tracking variables back to their
208 @// Based on the value of _DRegList, push the specified set of registers
209 @// to the stack. Is there a better way?
252 @// Based on the value of _RRegList, push the specified set of registers
253 @// to the stack. Is there a better way?
261 stmfd sp!, {r4-r6, lr}
266 stmfd sp!, {r4-r8, lr}
271 stmfd sp!, {r4-r10, lr}
276 stmfd sp!, {r4-r12, lr}
281 @// The opposite of _M_PUSH_DREG
324 @// The opposite of _M_PUSH_RREG
325 .macro _M_POP_RREG cc
331 ldm\cc\()fd sp!, {r4, pc}
336 ldm\cc\()fd sp!, {r4-r6, pc}
341 ldm\cc\()fd sp!, {r4-r8, pc}
346 ldm\cc\()fd sp!, {r4-r10, pc}
351 ldm\cc\()fd sp!, {r4-r12, pc}
356 @ Produce function return instructions
362 @// Allocate 4-byte aligned area of name
363 @// |name| and size |size| bytes.
364 .macro M_ALLOC4 name, size
365 .if (_SBytes & 3) != 0
366 .set _SBytes, _SBytes + (4 - (_SBytes & 3))
368 .set \name\()_F, _SBytes
369 .set _SBytes, _SBytes + \size
373 @// Allocate 8-byte aligned area of name
374 @// |name| and size |size| bytes.
375 .macro M_ALLOC8 name, size
376 .if (_SBytes & 7) != 0
377 .set _SBytes, _SBytes + (8 - (_SBytes & 7))
379 .set \name\()_F, _SBytes
380 .set _SBytes, _SBytes + \size
384 @ Load word from stack
385 .macro M_LDR r, a0, a1, a2, a3
386 _M_DATA "ldr", 4, \r, \a0, \a1, \a2, \a3
389 @ Store word to stack
390 .macro M_STR r, a0, a1, a2, a3
391 _M_DATA "str", 4, \r, \a0, \a1, \a2, \a3
394 @ Load double word from stack
395 .macro M_LDRD r0, r1, a0, a1, a2, a3
396 _M_DATA2 "ldrd", 8, \r0, \r1, \a0, \a1, \a2, \a3
399 @ Store double word to stack
400 .macro M_STRD r0, r1, a0, a1, a2, a3
401 _M_DATA2 "strd", 8, \r0, \r1, \a0, \a1, \a2, \a3
404 @ Macro to perform a data access operation
406 @ The addressing mode is modified such that
407 @ 1. If no address is given then the name is taken
409 @ 2. If the addressing mode is not available for the
410 @ state being assembled for (eg Thumb) then a suitable
411 @ addressing mode is substituted.
414 @ $i = Instruction to perform (eg "LDRB")
415 @ $a = Required byte alignment
416 @ $r = Register(s) to transfer (eg "r1")
417 @ $a0,$a1,$a2. Addressing mode and condition. One of:
420 @ [base, offset]{!} {,,cc}
421 @ [base, offset, shift]{!} {,cc}
422 @ [base], offset {,,cc}
423 @ [base], offset, shift {,cc}
425 @ WARNING: Most of the above are not supported, except the first case.
426 .macro _M_DATA i, a, r, a0, a1, a2, a3
427 .set _Offset, _Workspace + \a0\()_F
428 \i\a1 \r, [sp, #_Offset]
431 @ Macro to perform a data access operation
433 @ The addressing mode is modified such that
434 @ 1. If no address is given then the name is taken
436 @ 2. If the addressing mode is not available for the
437 @ state being assembled for (eg Thumb) then a suitable
438 @ addressing mode is substituted.
441 @ $i = Instruction to perform (eg "LDRB")
442 @ $a = Required byte alignment
443 @ $r = Register(s) to transfer (eg "r1")
444 @ $a0,$a1,$a2. Addressing mode and condition. One of:
447 @ [base, offset]{!} {,,cc}
448 @ [base, offset, shift]{!} {,cc}
449 @ [base], offset {,,cc}
450 @ [base], offset, shift {,cc}
452 @ WARNING: Most of the above are not supported, except the first case.
453 .macro _M_DATA2 i, a, r0, r1, a0, a1, a2, a3
454 .set _Offset, _Workspace + \a0\()_F
455 \i\a1 \r0, \r1, [sp, #_Offset]