<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64232>64232</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Implement usercall calling convention
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          KOLANICH
      </td>
    </tr>
</table>

<pre>
    https://github.com/widberg/llvm-project-widberg-extensions and https://hex-rays.com/blog/igors-tip-of-the-week-51-custom-calling-conventions/ are related.

`usercall` calling convention can be helpful not only for reverse engineering, but also for JITing.

My use case is a function hot loop, which body is partially JITed. Also some code out of the loop and after it is JITed, initializing some CPU registers with constants and preserving calee-preserved registers. I expect these constants to stay in the regs since they are initialized there. The JITed code is currently called via just jumps to it (`jmpq *%[funcJitCode];`) and in the end of it to the addresses of the labels put into another CPU register (`ljmp %rax15;`) without any use of the stack. So I need the compiler to take into account which registers should not be clobbered (and should be preserved, if they have to be clobbered) by any compiler-generated code. I also would like to eliminate all the inline assembly from my code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VNtu6zYQ_Br6ZSFDF0vn-EEPTgKjPr0CPf0AilxL61CkSq7sqF9fkFbipij6YsCUZnZ2hhoZAvUWsRX1k6hfNnLmwfn2x19_Ovxyev5h0zm9tAPzFER1EOVRlMeeeJi7rXKjKI830h36XpRHY65jNnl3QcXZepzhG6MN5GwAaTV8JhrwLfNyCStVZ1zkod75kDFNmTtnPGB2Q3zN6iJTc2A3ZkoaQ7bPlLNXtBy5RXkE6RE8GsmotyJ_Eflh_W3yOaCPKNHksKLhgQYlLXQIA5rpPBuwjsFZs8DZefB4RR8Q0PZkET3ZXpTP0M0M0gSX3vl2-k62_zT05wXmgKBkQKAAEs6zVWnY4BiMc1NkuQ2kBogOx5cm6ZmkMUskRL2FQxwQ3IignEZwM4M7Aw-YCJKf8szogT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