[cfe-dev] [ Builtins ] Returning a custom struct
ThePhD via cfe-dev
cfe-dev at lists.llvm.org
Sat May 26 10:51:04 PDT 2018
Dear cfe-dev,
I am new at hacking on Clang and I've made a decent amount of forward
progress in defining my own Constant Expression builtin for C++. It takes
arguments which must be compile-time evaluatable. This worked out just fine
so far, and has allowed me to get started on implementing std::embed
<https://rawgit.com/ThePhD/embed/master/papers/P1040%20-%20embed.html>.
I wanted to wrap my Constant Expression builtin in a C++-defined
`constexpr` function. The problem with this is that any argument passed to
my wrapping function that used my builtin ended up becoming non-evaluatable
in *Visit calls during the Sema::ActOnFinish* phase.
This has a few consequences. My wrapper function uses 2 less arguments
than my builtin currently, passing 2 variables to the builtin to be filled
in as output parameters, and then placed into a nice struct the user can
use (unsigned char* and a size_t). I lose the interface if I use the
builtin directly and someone has to provide the output parameters.
I tried to use the "t" specifier on the Builtin in Builtin.def to let
me define my own type checking, but so far it seems like even with "t" I
can't make my builtin have a signature that returns a custom structure.
Does anyone know how I would begin to work around these problems? My
first interest is to make the builtin I wrote match the struct-returning
interface I need. That would allow me to drop the 2 output parameters and
instead return a structure. I do not know how to do this.
My second idea is to abandon defining it through Builtins.def
altogether, but I'm not sure how to go about defining a builtin that's not
part of that list.
Does anyone have any insight into this?
Sincerely and Hopefully,
ThePhD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180526/d1b0640e/attachment.html>
More information about the cfe-dev
mailing list