This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Proposal: implement API for registering custom built-in functions from dynamic plugins

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: 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?

    Mikhail Maltsev

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]