This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc-specific array operator in C
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: "Nicolas Boulay" <nicolas dot boulay at ifrance dot com>
- Cc: <gcc at gnu dot org>
- Date: Wed, 2 Oct 2002 09:36:44 -0400
- Subject: Re: gcc-specific array operator in C
On Wednesday, October 2, 2002, at 08:30 AM, Nicolas Boulay wrote:
Hello,
I'm working in the f-cpu team. This project is to design a "free" cpu.
It will be mainly SIMD (like SSE, MMX, altivec,...) for performance and
hardware simplicity raison.
As you know compiler aren't really nice with such feature. Vector
compiler aren't common at all.
I have seen that GCC introduice new data format and MACRO to access
such
feature. That's nice for avoiding using ASM code but that's not
portable
at all.
Actually, macros aren't necessary at all to use SIMD in gcc.
And binary operators on vector data types already works.
So you can portably do vector programming, like so:
int main(void)
{
float a __attribute__ ((mode (V4SF))) = { 1.0, 2.0, 3.0, 4.0};
float b __attribute__ ((mode (V4SF))) = { 1.0, 2.0, 3.0, 4.0};
a = a * b;
}
(V4SF = Vector of 4 Single Floats)
This will compile and work on all platforms (IE with or without vector
hardware).
On those with vector hardware, it'll use the vector operations
(assuming GCC has been informed they exist).
Otherwise, it'll synthesize the necessary operations.
You'll need GCC CVS to use this code, I don't think the code to allow
binary and unary ops on vector datatypes was added until after 3.2.
--Dan