does libgccjit support vector types?

David Malcolm dmalcolm@redhat.com
Sun Jan 1 00:00:00 GMT 2017


On Mon, 2017-08-07 at 20:12 +1200, Michael Cree wrote:

Hi Michael

> I am wondering if libgccjit supports vector types, i.e., can one
> attach attribute __vector_size__ to the base types?  There does not
> seem to be any indication of this in the manual.

Currently this isn't supported.

[notes to self e.g.:

   typedef int v4si __attribute__ ((vector_size (16)));

is normally handled by C/C++ here:

c-family/c-attribs.c:260:
  { "vector_size",	      1, 1, false, true, false,
			      handle_vector_size_attribute, true },

which ultimately calls:

    new_type = build_vector_type (type, nunits);

    /* Build back pointers if needed.  */
    *node = lang_hooks.types.reconstruct_complex_type (*node, new_type);

(the latter does some support stuff for C++ templates).

Hence the "vector_size" attribute itself isn't supported by libgccjit,
and the underlying build_vector_type call within gcc's internal API
isn't exposed yet via libgccjit.

end of notes to self]

Is this a blocker for you using libgccjit?  What would the ideal API
look like? 

Maybe something like:

  extern gcc_jit_type *
  gcc_jit_type_get_vector (gcc_jit_type *type, unsigned nunits);
 
with various requirements (type must be integral/floating point; nunits
must be a power of two).

> I presume using gcc_jit_context_add_command_line_option() one can
> turn
> on code generation for sse/avx/neon/altivec, etc.

That ought to work, though currently the only usage examples in the
testsuite for this entrypoint are platform-independent (e.g. "-ffast-
math").

> And is there a way to access built-in functions such as the machine
> specific simd intrinsics?

gcc_jit_context_get_builtin_function ought to work, though I don't
think I've tested this particular use-case (as above, the usage
examples in the testsuite are currently all platform-independent).


Hope this is helpful
Dave



More information about the Jit mailing list