virtual template methods
David Malcolm
dmalcolm@redhat.com
Thu Jan 1 00:00:00 GMT 2015
On Wed, 2015-04-15 at 17:20 -0700, Norman Goldstein wrote:
> I have been thinking about a reasonable work-around for virtual template
> methods.
> The crux boils down to being able to do the following (in the simplest
> case of a
> single template parameter):
>
> Input:
> -- An std::type_info
> -- A template global/static function (of one template parameter)
> Output:
> -- An instantiation of the template function with the given type
>
> Is this the kind of thing that is in the ballpark for gccjit?
If I understand your idea correctly, there are a couple of issues with
using gccjit for it:
(i) gccjit doesn't have any special knowledge of std::type_info at the
moment, and AIUI the latter is implementation-specific. I guess we'd
need some way to make a gcc_jit_type * from a std::type_info.
(ii) gccjit doesn't have any knowledge of the C++ frontend; and there's
no API yet for the latter. When you talk about "a template
global/static function (of one template parameter)", where would this
come from?
Note that it's possible to use gccjit in a parameterized way to create
functions; have a function that creates a gcc_jit_function *, passing in
a gcc_jit_type * as a parameter. An example of doing this can be seen
in the testsuite in
gcc/testsuite/jit.dg/test-arith-overflow.c
where we create the equivalent of:
int
test_overflow_T_OP (T x, T y, bool *ovf);
for various types T.
Hope this is helpful
Dave
More information about the Jit
mailing list