ARM Technical Support Knowledge Articles

How do I generate ARM v6T2 or v7 DSP multiply instructions using the ARM Compiler toolchain?

Applies to: DS-5, RealView Development Suite (RVDS)

Answer

In order to utilize some of the DSP multiplication instructions in the ARM v6 and v7 ISA such as SMULWB, SMULWT, SMULBB, SMULTT, SMULBT, SMULTB, SMMUL and SMMULR,  the ARM Compiler toolchain provides the header file armdsp.h in the "Includedirectory which uses inline assembly to define functions that implement these instructions. These functions are declared with the keyword __inline which allows the ARM Compiler (armcc) to efficiently inline the desired instructions in the calling C source code.

However, prior to ARM Compiler 5.01, the inline assembler does not support Thumb code, armcc does not inline the desired DSP instructions when building for Thumb (using compiler option --thumb), but instead produces branches to these subroutines. This does not occur when compiling for ARM (using the default compiler option --arm).

Alternatively, armcc can also generate these DSP instructions by recognizing specific C idioms in the source code. The attached header file signed_mul.h defines inline functions using these C idioms that allow armcc to effectively produce the aforementioned DSP instructions for both ARM and Thumb modes.

The attached file main.c shows how to use the functions defined in the header file signed_mul.h.  This C code is built using the following commands:

armcc --thumb -c --debug --cpu=7E-M -O3 --forceinline --asm --interleave -o main.o main.c
armlink --cpu=7E-M --map --list=map.txt -o image.axf main.o

Attachments: signed_mul.h , main.c

Article last edited on: 2011-10-07 10:08:27

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential