<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64233>64233</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
An interface between the C++ compiler and JIT compiler
</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>
When one makes a JIT for a hotloop, he has to set up some calling convention between the compiler compiling non-JITed part of the program and the embedded codegen compiling the JITed one. For example for the maximum efficiency one may want to avoid unnecessary memory accesses in the hot loop. So it may be needed to know which callee-preserved registers have to be restored by jited code, without restoring all of them.
It may make sense to expose the information about the decisions made by the compiler, such as registers clobbered by the compiler-generated code living between a pair of labels `start ≤ stop` of the same branch of a function with something like `constexpr std::span<__Registers::GP> clobberedRegs = __compiler_reflection_get_clobbered<__Registers::GP>(start, stop);`, where `__Registers::GP<size>` is an `template <uint16_t size> enum class GP: uint8_t` which contents matches the encoding of general purpose registers used within architecture (i.e. `GP<8>{rax = 0, rcx = 1,}`, `GP<4>{eax=0, ecx=1}` for x86_64) and `__Registers::SIMD<size>` is for the SIMD registers (`SIMD<8>{mmx0=0, ...}`, `SIMD<16>{xmm0=0,...}`). Then only the clobbered regs can be restored, if the JITed code uses them. Also one needs to some way to get the registers chosen by compiler for passing variables to extended `asm` blocks, it'd require some extensions to its syntax to make it named, and then to allow to get a register using somethjng like `constexpr auto reg1 = __compiler_reflection_get_asm_reg("asmBlockName", "%[variableName]");`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVU1z2zYQ_TXQZcccirQo6qCDbMet0zbtJJnpUbMElyRifLAAaEv99Z0FKVuZptOLBAKLxXu7eA8Yguot0V5s7sTmYYVTHJzf__L7r4dPT_c_rxrXnvd_DmTBWQKDzxQA4ePTV-icB4TBRe3cKIp7GAgGDBAdBIowjRCcIZCotbI9SGdfyEblLDQUX4ksxI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