Nisal Menuka via llvm-dev
2017-Jun-14 19:33 UTC
[llvm-dev] Reserve ARM register for only section of the program
Hi, Thanks a lot. Is it possible to implement that functionality as a pragma? Ex. .. [code] ... #pragma A .. .. #pragma B .. .. Lets say I want to reserve registers X9 and X10 only within pragma A and B. Is it possible to achieve this in llvm? Thanks Nisal On Mon, Jun 12, 2017 at 9:54 PM, Tim Northover <t.p.northover at gmail.com> wrote:> Hi Nisal, > > (Adding llvm-dev back again; best to keep these things public in case > they help someone else in the future). > > On 12 June 2017 at 19:43, Nisal Menuka <nisalmenuka23 at gmail.com> wrote: >> I am a first year graduate student at Rice University, I'm looking to >> reserve registers X9 and X10 for one of my research projects. I have >> some questions regarding this and greatly appreciate any help you can >> provide (I am a newbee when it comes to hacking compilers). > >> 1. Is it possible to reserve X9 and X10 by the same methodology used >> to reserve X18 in LLVM? > > It should be (x9 and x10 are very similar to x18, with no other > special purposes in the ABI), but you'll have to implement it > yourself. Searching for all uses of X18 in lib/Target/AArch64 and > adding your own code for the others would be a good place to get > started. For Clang the key phrase is "fixed_x18". > > You're going to have more work to do for the interworking though. For > example if a function with -ffixed-x9-x10 calls one without, you'll > probably have to implement code to save those two registers at the > callsite and restore them afterwards because the callee will be > treating them as temporaries. > >> 2. Else can you suggest a method to achieve it? > > If you didn't need interworking I'd probably suggest just > unconditionally reserving them, which would be substantially simpler > (a 2-4 line change in LLVM). > > But from what you've said so far I think following x18's > implementation is probably your best bet. It's most of the way there, > and already piped through to Clang in a usable way. > > Cheers. > > Tim.
Tim Northover via llvm-dev
2017-Jun-14 20:37 UTC
[llvm-dev] Reserve ARM register for only section of the program
On 14 June 2017 at 12:33, Nisal Menuka <nisalmenuka23 at gmail.com> wrote:> Lets say I want to reserve registers X9 and X10 only within pragma A > and B. Is it possible to achieve this in llvm?Anything's possible. I've never implemented a pragma before though, so I have no idea where you'd start. Maybe ask in cfe-dev or look at how an existing one is handled (e.g. fp_contract to pick a random example). Cheers. Tim.