Hi,
I am trying to add a new parameter to functions which have a specific attribute in Clang, however I am unsure of the best way to do this.
For context, I am trying to add support for SME functions to Clang. The SME ABI requires passing in some state in X0 (modelled in LLVM with an intrinsic call) for certain functions. To achieve this, I am trying to add an implicit parameter before any other arguments (including ‘this’, if present).
I found that there is an ImplicitParamDecl class which is used in various places in lib/CodeGen to add new arguments. I’ve had some success in pushing the new parameter in various places in CGCall (arrangeCXXMethodType, arrangeFreeFunctionType, etc), though I am not sure if this is the best place to add it.
I believe my two options are to either:
- Add the new ImplicitParamDecl to the AST.
- Add the ImplicitParamDecl during CodeGen as described above, similar to what seems to be done in CGCXXABI for the C++ ‘this’ parameter.
Does anyone have suggestions on the best approach?
Thanks,
Kerry
(Pull request for alpha-level ABI support for SME: https://github.com/ARM-software/abi-aa/pull/123)