[FFmpeg-devel] [PATCH 6/6] truehd: add hand-scheduled ARM asm version of ff_mlp_pack_output.

Ben Avison bavison at riscosopen.org
Thu Mar 20 16:30:21 CET 2014

On Thu, 20 Mar 2014 09:41:59 -0000, Clément Bœsch <u at pkh.me> wrote:
>> +.macro loadregoffsh2  group, index, base, offgroup, offindex
>> +       .altmacro
>> +       loadregoffsh2_ \group, %(\index), \base, \offgroup, %(\offindex)
>> +       .noaltmacro
>> +.endm
>> +
>> +.macro loadregoffsh2_ group, index, base, offgroup, offindex
>> +        ldr     \group\index, [\base, \offgroup\offindex, lsl #2]
>> +.endm
>> +
>> +.macro eorlslreg  check, data, group, index
>> +        .altmacro
>> +        eorlslreg_ \check, \data, \group, %(\index)
>> +        .noaltmacro
>> +.endm
>> +
>> +.macro eorlslreg_ check, data, group, index
>> +        eor     \check, \check, \data, lsl \group\index
>> +.endm
>> +
> These 2 macros look like they are just 1 instruction each. They should be
> inlined if possible, it's really unnecessary obfuscation.

I absolutely agree that it's horrible (I couldn't restrain myself from
commenting on it myself next to the equivalent macros in mlpdsp_arm.S).
However, that just seems to be the best that GAS can do - it has very
poor expression manipulation abilities compared to other macro
assemblers, and what little it can achieve is often by using deep nesting
of macros like this.

What happens is that the outer macro is called with an assembler
expression, which it evaluates to a string and passes to the inner macro.
The inner macro performs a string concatenation with another argument and
it is then able to interpret the resulting string as a symbolic register

The % operator only seems to be valid for invoking another macro - you
don't seem to be able to combine it with a concatenation within a single
level macro, using \group%(\index) or \group\()%(\index). Unless anyone
knows any different? (The documentation for GAS leaves a lot to be
desired in this area too.)


More information about the ffmpeg-devel mailing list