<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 10 January 2017 at 08:41, Patrik Eklöf via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="SV">
<div class="gmail-m_862939452937474594WordSection1">
<p class="MsoNormal">We need to look at passing the argument count (i.e. number of arguments passed) to functions in some register. One way that we have considered is to use the second byte of AL to hold the argument count. Do you think that
 would work well with how LLVM works today? Or is there an alternative way that you would suggest?<br></p></div></div></blockquote><div><br class="gmail-Apple-interchange-newline">Hi Patrik,</div><div><br></div><div>Clang/LLVM already supports reserved platform registers, so this would probably be a number of small changes to both Clang and LLVM to make it work. But AFAIK, they use entire registers, so you wouldn't have those registers available to the allocator. This shouldn't be a big problem in AMD64, though.</div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="SV"><div class="gmail-m_862939452937474594WordSection1"><p class="MsoNormal"></p>
<p class="MsoNormal">We also need to look at reserving registers because existing OpenVMS code relies on being able to map variables directly to registers so that multiple functions can share variables directly inside registers. We may need
 to reserve up to as many as 6 registers. Do you think this might work? Or will this make codegen bad? We have also considered trying to put these variables into an array and reserving a global variable to index into this array, thereby emulating this feature.
 Do you think this will work better?<br></p></div></div></blockquote><div><br></div><div>I imagine you'd start by adding the triple in Clang, then walking down the Driver code to create a toolchain for it (copy what's there for GNU, Apple, etc). You'll see that different toolchains reserve registers for different purposes. Re-using the registers other toolchains use would be the easiest, but that depends if the OpenVMS ABI has any encoded registers already.</div><div><br></div><div>Obviously, the more registers you reserve, the more spills you'll have, so codegen will be affected. But that's a trade-off that you make when designing the ABI.</div><div><br></div><div>I have never designed an ABI myself, but I have been around people that did, enough to know that it's impossible to get it right, even after 10 years, let alone the first time. </div><div><br></div><div>So, if OpenVMS has an ABI, you *MUST* follow it. If it doesn't, than I strongly encourage you to contact the OpenVMS community *first* and design an ABI, and only then implement in the compiler.</div><div><br></div><div>In LLVM, we usually tend to reject ABI implementations without access to official documentation for that very reason.</div><div><br></div><div>Hope that helps,</div><div><br></div><div>cheers,</div><div>--renato</div></div></div></div>