I've been meaning to toss something like this together for a while. If we were going to do this, I wanted to get it out of the way before adding VIS2 and VIS3 support.
I considered trying to make a set of VIS headers compatible with the vis_*.h headers Sun provides in medialib and Sun Studio, but that's not possible since we use fundamentally different types in the builtins provided by GCC. Sun uses "double" and "float" in the declarations whereas we use our vector types. I even checked various users of Sun's VIS intrinsics and they all just declare their vector variables as "float" and "double" so it would be impossible to provide headers that would work out of the box. Eric, any objections? 2011-09-16 David S. Miller <da...@davemloft.net> * config/sparc/visintrin.h: New file. * config.gcc: Add it to extra_headers on sparc. diff --git a/gcc/config.gcc b/gcc/config.gcc index e442fa7..7183f26 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -422,6 +422,7 @@ score*-*-*) ;; sparc*-*-*) cpu_type=sparc + extra_headers="visintrin.h" need_64bit_hwint=yes ;; spu*-*-*) --- /dev/null 2011-09-11 10:37:28.169997151 -0700 +++ b/gcc/config/sparc/visintrin.h 2011-09-14 21:20:35.000000000 -0700 @@ -0,0 +1,160 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _VISINTRIN_H_INCLUDED +#define _VISINTRIN_H_INCLUDED + +typedef int __v2si __attribute__ ((__vector_size__ (8))); +typedef short __v4hi __attribute__ ((__vector_size__ (8))); +typedef short __v2hi __attribute__ ((__vector_size__ (4))); +typedef char __v8qi __attribute__ ((__vector_size__ (8))); +typedef char __v4qi __attribute__ ((__vector_size__ (4))); +typedef int __i64 __attribute__ ((__mode__ (DI))); + +extern __inline void * +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_alignaddr (void *__A, long __B) +{ + return __builtin_vis_alignaddr(__A, __B); +} + +extern __inline __i64 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_faligndatadi (__i64 __A) +{ + return __builtin_vis_faligndatadi (__A); +} + +extern __inline __v2si +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_faligndatav2si (__v2si __A) +{ + return __builtin_vis_faligndatav2si (__A); +} + +extern __inline __v4hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_faligndatav4hi (__v4hi __A) +{ + return __builtin_vis_faligndatav4hi (__A); +} + +extern __inline __v8qi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_faligndatav8qi (__v8qi __A) +{ + return __builtin_vis_faligndatav8qi (__A); +} + +extern __inline __v4hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fexpand (__v4qi __A) +{ + return __builtin_vis_fexpand (__A); +} + +extern __inline __v4hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fmul8x16 (__v4qi __A, __v4hi __B) +{ + return __builtin_vis_fmul8x16 (__A, __B); +} + +extern __inline __v4hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fmul8x16au (__v4qi __A, __v4hi __B) +{ + return __builtin_vis_fmul8x16au (__A, __B); +} + +extern __inline __v4hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fmul8x16al (__v4qi __A, __v4hi __B) +{ + return __builtin_vis_fmul8x16al (__A, __B); +} + +extern __inline __v4hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fmul8sux16 (__v8qi __A, __v4hi __B) +{ + return __builtin_vis_fmul8sux16 (__A, __B); +} + +extern __inline __v4hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fmul8ulx16 (__v8qi __A, __v4hi __B) +{ + return __builtin_vis_fmul8ulx16 (__A, __B); +} + +extern __inline __v2si +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fmuld8sux16 (__v4qi __A, __v2hi __B) +{ + return __builtin_vis_fmuld8sux16 (__A, __B); +} + +extern __inline __v2si +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fmuld8ulx16 (__v4qi __A, __v2hi __B) +{ + return __builtin_vis_fmuld8ulx16 (__A, __B); +} + +extern __inline __v4qi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fpack16 (__v4hi __A) +{ + return __builtin_vis_fpack16 (__A); +} + +extern __inline __v8qi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fpack32 (__v2si __A, __v2si __B) +{ + return __builtin_vis_fpack32 (__A, __B); +} + +extern __inline __v2hi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fpackfix (__v2si __A) +{ + return __builtin_vis_fpackfix (__A); +} + +extern __inline __v8qi +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_fpmerge (__v4qi __A, __v4qi __B) +{ + return __builtin_vis_fpmerge (__A, __B); +} + +extern __inline __i64 +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__vis_pdist (__v8qi __A, __v8qi __B, __i64 __C) +{ + return __builtin_vis_pdist (__A, __B, __C); +} + +#endif /* _VISINTRIN_H_INCLUDED */