Is it necessary to implement the whole backend in order to add a new "pass" to the backend ?

Hello all,

I am new to llvm. I need to make some changes to the LR. The backend should modify the LR, but only after all the normal work and all the optimizations are done.
Just before outputting the native code, LR is modified. I was wondering if I should implement the whole backend in order to achieve this or is it possible to implement a new pass and use that. Thanks !

Regards,
Sachin

Dear Sachin,

First, it's not clear to me what you mean by "LR." Do you mean that you want to modify the LLVM Intermediate Representation (the LLVM IR)?

Assuming you're wanting to transform code with LLVM, then answer is no. You can implement a pass that performs the transformation/optimization you want and add it to the compiler. If you need to modify the code generation portions of LLVM, you can write a MachineFunctionPass that modifies the native code generated by LLVM after LLVM has done instruction selection, instruction scheduling, and register allocation but before emitting the final assembly/object file.

Regards,

John Criswell

Respected Sir,

Thank you for your response. By LR I mean LLVM IR with all the optimizations done. For instance I call Register Transfer Language of GCC an LR because it is produced after some optimizations are performed on the IR. For my project I need to make some changes to this LR so that the outputted native code has certain additional features. In your reply you say that I need to implement only a MachineFunctionPass to achieve this; that’s all I needed to know. Thanks again.

Regards,
Sachin