virtual template methods
Norman Goldstein
normvcr@telus.net
Thu Jan 1 00:00:00 GMT 2015
Comments, below.
PS lex was needed for the gccjit build to succeed. Configure did not
tell me that lex was required. Otherwise, a completely smooth build.
Attached are logs for the configuration that led to the failed build.
-- config.log is generated by configure
-- configure.log is what I captured from the command line
../src/configure --enable-host-shared --enable-languages=jit
--disable-bootstrap --disable-multilib
On 04/16/2015 08:41 AM, David Malcolm wrote:
> 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.
The programmer could construct a std (unordered) map to translate from
the relevant
typeinfo's to the corresponding gcc_jit_types .
>
> (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?
The source code is from header files, or from whatever the compiler
encodes into
the executable. I would need gccjit to be able to do the equivalent of
the following:
1.. Generate the template instantiaion code
template void foo<T>( A* );
2. Compile and (dynamic) link in the instantiated template
where "T" is replaced by the type that is actually represented by the
specified std::type_info,
and A* is just an example of a known parameter.
> 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.
I see. The function is created directly, without writing "source code",
first. In my situation, the
source code already exists, except for the one-line template
instantiation. Perhaps, what I also
need is a programmatic interface to the compiler, something like what
clang has to offer. ??
>
> Hope this is helpful
> Dave
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: configure.log
Type: text/x-log
Size: 5656 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/jit/attachments/20150101/dad510e0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.log
Type: text/x-log
Size: 28200 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/jit/attachments/20150101/dad510e0/attachment-0001.bin>
More information about the Jit
mailing list