Dear llvm developers,
For the purpose of a research project, I want to add a function type modifier as an extension to LLVM that looks like
keyword void function(params1, 2, 3) {…}
to serve the purpose of tracking all registers that the function has touched. Is there any documentation or previous examples relate to this feature?
Thank you very much
Garnet
For the purpose of a research project, I want to add a function type
modifier as an extension to LLVM that looks like
Do you really need it to be part of the function's type? That brings
massive extra complexity, especially when C++ and its overloading
rules are involved.
Modifying a function's definition is a lot simpler. At the C/C++ level
you'd add a custom "__attribute__((whatever))", of which plenty
already exist. Since this records register usage Clang should probably
just add an LLVM function attribute saying the same thing. Then each
backend you want to support should look for that LLVM attribute, tot
up the registers just before emission and save them somewhere (a
separate section of the .o file?).
Basically you'd want some limited Clang support for forwarding a new
attribute, and a new LLVM backend pass in each target you supported to
save the correct info if needed.
Cheers.
Tim.
Thanks a lot for the reply! I looked into the function attributes description in the references and I believe it’s a great approach, which hits the point directly, but so far my mentor asks me to make it as a function type and it’s for C. So I’m looking into both ways.
If I need add the function type modifier keyword, should it be in the Qualtype class?
Thanks,
Garnet