This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
mmx.h
- From: Maximillian Murphy <m at de-minimis dot co dot uk>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 7 Mar 2008 10:32:24 +0000
- Subject: mmx.h
Dear All,
On the web there are a number of .h files that provide wrappers for mmx assembler commands. They are usually but not always called mmx.h. An example is here:
http://webcvs.freedesktop.org/gstreamer/gstreamer/include/mmx.h?revision=1.2&content-type=text%2Fplain&pathrev=1.2
and:
http://aggregate.org/SWAR/ars-swar.h
In there, for instance, pmullw_r2r(mm1,mm3) is defined as a macro so that it can be called as if it were a C function. Actually it performs the assembler command pmullw on mmx registers 1 & 3.
These header files seem to be entirely generic but as far as I can see they are not shipped in any of the debian developer packages. Does any of you use such header files? They seem a good idea. Is there a reason why they are not shipped as standard with gcc/debian? Are there similar wrappers for SSE2 commands? My processor doesn't support SSE3 or later, but information about future trends would be good to know too.
I may of course be wrong in saying that such a set of macros is not normally shipped. I've grepped /usr/include and found nothing similar. There is an <asm/mmx.h> header file but it is quite different and including it doesn't seem to allow assembler functions to be used:
>From the website above:
Usage: let's say you want to add the 64-bit vector of
two 32-bit floats at x into register 7. Unless you have
declared x as "mmx_t x;" you need to cast x to the
correct type. Register 7 is called "mm7". Thus:
pfadd_m2r(*((mmx_t *) &x), mm7);
Looking at some of the few clean examples of this being used that I can find it seems that register names such as mm7 don't need to be declared - presumably they are defined somewhere in the tree of header files.
In my code:
#include <asm/mmx.h>
....
pmullw_r2r(mm0,mm1);
Compiling, or rather failing to compile:
2008.02_try001$ gcc dot_002.c
dot_002.c: In function âmainâ:
dot_002.c:48: error: âmm0â undeclared (first use in this function)
dot_002.c:48: error: (Each undeclared identifier is reported only once
dot_002.c:48: error: for each function it appears in.)
dot_002.c:48: error: âmm1â undeclared (first use in this function)
2008.02_try001$
Any information on this would be welcome.
Regards, Max.