This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Proposal: implement API for registering custom built-in functions from dynamic plugins
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Mon, 16 Mar 2015 04:08:39 +0300
- Subject: Proposal: implement API for registering custom built-in functions from dynamic plugins
- Authentication-results: sourceware.org; auth=none
Hi, all.
Currently GCC allows dynamic plugins to register custom attributes and
pragmas. I would like to propose to add API for registering custom
built-in functions.
AFAIK, current plugin API can be used to emulate this feature, for
example by creating a function declaration in PLUGIN_START_UNIT and then
replacing calls to such function in a custom lowering pass. But this
solution seems inelegant: it would be better, if user-defined built-in
functions could use the same "machinery" as normal ones, i.e. use common
classification and flags (RTL-level vs GIMPLE-level; external library
equivalents vs compiler-generated entities), and have unified API for
creating declarations, GIMPLE (or even RTL) expansion, inlining
(callback for is_inexpensive_builtin), etc.
Possible applications of this plugin API include:
* Generating optimized pattern matching functions (e.g. precomputing
tables for Boyer-Moore matcher).
* Generating functions for parsing (compile-time regular expressions).
* Marshalling functions with compile-time type checking (something like
binary printf/scanf with custom format specifiers).
* String formatting and conversion. By the way, there is a guy, who has
written a perl wrapper for GCC, which preprocesses calls to snprintf to
make it work faster: https://github.com/h2o/qrintf... though it's
probably worth enhancing snprintf in GCC, rather than reimplementing it
in plugin - but that's a different story.
* (to some extent): lazy evaluation.
* Custom instrumentation of source code (user or framework-specific
fortification or performance profiling).
Any thoughts on this? Is such API useful for GCC?
--
Regards,
Mikhail Maltsev