<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Folks,<div class=""><br class=""></div><div class="">I converted the PDF for the compact code model proposal to an MD file and put it at <a href="https://github.com/ebahapo/riscv-elf-psabi-doc" class="">https://github.com/ebahapo/riscv-elf-psabi-doc</a> for easier reading and commenting.</div><div class=""><br class=""></div><div class="">Thank you,</div><div class=""><br class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>__ </div><div>Evandro Menezes ◊ SiFive ◊ Austin, TX</div></div></div></div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Mar 23, 2020, at 13:14, Evandro Menezes <<a href="mailto:evandro.menezes@sifive.com" class="">evandro.menezes@sifive.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi, Sam.<div class=""><br class=""></div><div class="">I think that it's a fair comparison.</div><div class=""><br class=""></div><div class="">Keep in mind that the GP is only used to reach global variables of local scope and the GOT, where the address of global variables of global scope reside.  </div><div class=""><br class=""></div><div class="">This model assumes that the distance between the GP and the global data area, GOT and local scope variables is defined at link time.</div><div class=""><br class=""><div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">__ </div><div class="">Evandro Menezes ◊ SiFive ◊ Austin, TX</div></div></div></div></div>
</div>
<div class=""><br class=""><blockquote type="cite" class=""><div class="">On Mar 23, 2020, at 6:20, Sam Elliott <<a href="mailto:selliott@lowrisc.org" class="">selliott@lowrisc.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Eli,<br class=""><br class="">Yep, we’re looking at a ROPI/RWPI model for RISC-V and it is shaking out to be fairly similar to this model (though we’ve only been looking at it for 32-bit RISC-V).<br class=""><br class="">I suppose how I’m thinking about the difference between a ROPI/RWPI model and this compact model is in the former, you cannot know until load-time what the offset is between the code section and the data section is, whereas in the latter you’re using `gp` to keep the upper 32-bits of that offset to avoid materialising it in every access (if you statically linked, and we added enough relocations to materialise 64-bit immediates, you could materialise the offset everywhere. It would be inefficient, but not wrong).<br class=""><br class="">Is this a fair understanding, Evandro?<br class=""><br class="">Sam<br class=""><br class=""><blockquote type="cite" class="">On 20 Mar 2020, at 7:49 pm, Eli Friedman via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""><br class="">Oh, I wasn’t really thinking about devices without an MMU where the addresses are physically separated. Makes sense.<br class=""><br class="">This reminds me of rwpi on ARM; it has a sort of similar scheme of referring to data indirectly through a pointer, but it also changes the ABI to keep the pointer in a reserved register.<br class=""><br class="">-Eli<br class=""><br class="">From: Evandro Menezes <<a href="mailto:evandro.menezes@sifive.com" class="">evandro.menezes@sifive.com</a>> <br class="">Sent: Friday, March 20, 2020 12:28 PM<br class="">To: Eli Friedman <<a href="mailto:efriedma@quicinc.com" class="">efriedma@quicinc.com</a>><br class="">Cc: Alex Bradbury <<a href="mailto:asb@lowrisc.org" class="">asb@lowrisc.org</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>><br class="">Subject: [EXT] Re: [llvm-dev] RISC-V LLVM sync-up call 19 Mar 2020<br class=""><br class="">Hi, Eli.<br class=""><br class="">If I’m following correctly, there are two size-limited areas.  One area, limited to 2GB, is the “text” area.  This contains all the code.  Then there’s a “global” area, limited to 4GB, which is pointed to by the global pointer. This contains the GOT, plus a flexible area that the object file can stick small bits of data into.  And then outside of both of those, additional data is unlimited.<br class=""><br class="">Actually, the global data area, which includes the GOT and any global of local scope, is limited to 4GiB.  However, the latter is limited to 2GiB, in order to guarantee addressing the GOT and the small data area, assuming this section order:<br class=""><span class="Apple-tab-span" style="white-space:pre">   </span>• .got<br class=""><span class="Apple-tab-span" style="white-space:pre">       </span>• .sdata .sbss<br class=""><span class="Apple-tab-span" style="white-space:pre">       </span>• .ldata .lbss<br class=""><br class="">The .data and .bss sections, containing the globals of global scope, may follow these immediately, but can actually be placed anywhere in the memory map.<br class=""><br class=""><br class="">It took me multiple times reading through the proposal to parse that out; it might be a good idea to reorganize the proposal so that’s explained somewhere explicitly.<br class=""><br class="">Will do.<br class=""><br class=""><br class="">My big question here is, how much benefit are you really getting from having a global pointer?  If you eliminate it and combine the two size-limited areas into one, you end up with essentially the small-PIC code model. The small-PIC code model supports everything your proposed “compact” model does, with a couple minor differences:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">  </span>• The size-limited areas are limited to 2GB combined, instead of 6GB combined.<br class=""><span class="Apple-tab-span" style="white-space:pre">       </span>• The relaxations are a little different.  Small-PIC always takes two instructions to access a GOT entry; the compact model can do it in one instruction for the first 500 (?) entries in the GOT.  Not sure what would end up with smaller codesize in practice.<br class=""><br class="">This code model addresses the cases when code and data reside in different memory devices and at distant addresses.  Sometimes, RAM is faster than ROM and it's not desirable to have even read only data in ROM.  Besides the obvious case of addressing, say, a peripheral buffer in a distant memory location.  But the scheme above would not allow code and data to reside in different memory devices, if the user so prefers.<br class=""><br class="">On the other hand, just like we have the code models `medlow` and `medany`, we could have two variations of the compact code model too.  One assuming that code and small data and local data are on the same memory device (`cmplow`) and another assuming no such restriction (`cmpany`).<br class=""><br class="">Thank you,<br class=""><br class="">__ <br class="">Evandro Menezes ◊ SiFive ◊ Austin, TX<br class=""><br class=""><br class="">From: llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" class="">llvm-dev-bounces@lists.llvm.org</a>> On Behalf Of Evandro Menezes via llvm-dev<br class="">Sent: Thursday, March 19, 2020 9:19 AM<br class="">To: Alex Bradbury <<a href="mailto:asb@lowrisc.org" class="">asb@lowrisc.org</a>><br class="">Cc: llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>><br class="">Subject: [EXT] Re: [llvm-dev] RISC-V LLVM sync-up call 19 Mar 2020<br class=""><br class="">Here's the draft proposal for the compact code model on RV.  I'd appreciate your feedback before I propose it to the foundation and go about updating the psABI.<br class=""><br class="">Thank you,<br class=""><br class="">__ <br class="">Evandro Menezes ◊ SiFive ◊ Austin, TX<br class=""><br class=""><br class=""><br class="">On Mar 19, 2020, at 8:58, Alex Bradbury via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""><br class="">For background on these calls, see<br class=""><<a href="http://lists.llvm.org/pipermail/llvm-dev/2019-September/135087.html" class="">http://lists.llvm.org/pipermail/llvm-dev/2019-September/135087.html</a>>.<br class=""><br class="">Reminder: the purpose is to co-ordinate between active contributors.<br class="">If you have support questions etc then it's best to post to llvm-dev.<br class=""><br class="">We have a call each Thursday at 4pm GMT, via<br class=""><<a href="https://meet.google.com/ske-zcog-spp" class="">https://meet.google.com/ske-zcog-spp</a>>.<br class=""><br class="">I've created a shared calendar which may help in keeping track, which<br class="">is accessible at:<br class=""> * <<a href="https://calendar.google.com/calendar/b/1?cid=bG93cmlzYy5vcmdfMG41cGtlc2ZqY25wMGJoNWhwczFwMGJkODBAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ" class="">https://calendar.google.com/calendar/b/1?cid=bG93cmlzYy5vcmdfMG41cGtlc2ZqY25wMGJoNWhwczFwMGJkODBAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ</a>><br class=""> * <<a href="https://calendar.google.com/calendar/ical/lowrisc.org_0n5pkesfjcnp0bh5hps1p0bd80%40group.calendar.google.com/public/basic.ics" class="">https://calendar.google.com/calendar/ical/lowrisc.org_0n5pkesfjcnp0bh5hps1p0bd80%40group.calendar.google.com/public/basic.ics</a>><br class=""><br class="">Issues to discuss today include the following:<br class="">* Improving rust code size by not forcing frame pointers<br class=""><<a href="https://github.com/rust-lang/rust/pull/69890" class="">https://github.com/rust-lang/rust/pull/69890</a>><br class="">* Compact code model (Evandro)<br class="">* Update on embedded PIC discussions<br class="">* Small data limit <<a href="https://reviews.llvm.org/D57497" class="">https://reviews.llvm.org/D57497</a>><br class="">* Bitmanip / experimental extension status<br class="">* ELF attribute support close to merging<br class=""><<a href="https://reviews.llvm.org/D75833" class="">https://reviews.llvm.org/D75833</a>> <<a href="https://reviews.llvm.org/D74023" class="">https://reviews.llvm.org/D74023</a>><br class="">* No other topics were submitted, as always, please do submit things<br class="">you'd like to discuss<br class=""><br class="">Best,<br class=""><br class="">Alex<br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""><br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class="">llvm-dev@lists.llvm.org<br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></blockquote><br class="">--<br class="">Sam Elliott<br class="">Software Developer - LLVM and OpenTitan<br class="">lowRISC CIC<br class=""><br class=""></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>