This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
About implementing new intrinsic
- From: "Ferad Zyulkyarov" <feradz at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 14 Feb 2007 18:34:48 +0100
- Subject: About implementing new intrinsic
Hi,
I try to introduce a new intrinsic in gcc's back-end, for the alpha
machines. In doing that, I referenced to the implementaions of altivec
intrinsics for the PowerPC. In the mean time I noticed that the
gcc-4.0 and gcc-4.1 implements these in different way which confused
me. The difference is that in 4.0 for each intrinsic is defined a in
inline template function and/or macro. gcc-4.1 and later miss these
definition.
So finally what I did is:
1. Created a file myintrinsics.h where I have the folowing definition:
#define myintrinsic __builtin_alpha_myintrinsic
2. Created myintrinsics.md file where I I have my intrinsic's definition:
(define_insn "myintrinsic"
[(unspec_volatile [(const_int 0)] 101)]
""
"xor $31, $0, $31")
;;This intrinsic does not have any parameters ("void intrinsic()")
3. In file alpha.c I added the following
3.1. In enum alpha_builtin
enum alpha_builtin
{
...
ALPHA_BUILTIN_MYINTRINSIC,
...
}
3.2. In array code_for_builtin I added the following members:
static unsigned int const code_for_builtin[ALPHA_BUILTIN_max] = {
...
CODE_FOR_builtin_myintrinsic,
...
}
3.3. In array zero_arg_builtins I added the following members
static struct alpha_builtin_def const zero_arg_builtins[] = {
...
{ "__builtin_alpha_myintrinsic", ALPHA_BUILTIN_MYINTRINSIC, 0, true },
...
}
I supposed that this is enough but I when I tried this in a simple
test case like the one bellow:
#include <stdio.h>
#include "myintrinsics.h"
int main(void)
{
myintrinsic();
printf("Hello world!\n");
}
I got an error that __builtin_alspa_myintrinsic is not defined in this
scope. I think that my implementaion does not work. I don't know where
the problem is, but I am sure that I miss something. I hope for your
comments that would be very helpful.
Thanks,
Ferad Zyulkyarov
--
Ferad Zyulkyarov
Barcelona Supercomputing Center