<html><head><style type="text/css">.style1 {font-family: "Times New Roman";}</style></head><body>Hi Jesper,<BR>
<BR>
My company (CML Microsystems) would definitely be interested in having this feature upstream too. <BR>
<BR>
We currently maintain an out of tree backend that has a minimum addressable size of 16 bits and this is implemented using the method outlined by Jones and Cook of Embecosm that you refer to in the RFC. <BR>
<BR>
Our implementation is slightly different than the one you’ve proposed in that we used the concept of bitPerChar and only support multiples of 8 bits for that char width.<BR>
<BR>
I would be happy to help out with the work in any way I can.<BR>
<BR>
Regards<BR>
Sean Kilmurray<BR>
<BR>
-----Original Message-----<BR>
From: llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org] On Behalf Of Jesper Antonsson via llvm-dev<BR>
Sent: 02 May 2019 13:21<BR>
To: <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><BR>
Subject: [llvm-dev] RFC: On removing magic numbers assuming 8-bit bytes<BR>
<BR>
A. This RFC outlines a proposal regarding non-8-bit-byte support that<BR>
got positive reception at a Round Table at EuroLLVM19. The general<BR>
topic has been brought up several times before and one good overview<BR>
can be found in a FOSDEM 2017 presentation by Jones and Cook:<BR>
<a href="https://archive.fosdem.org/2017/schedule/event/llvm_16_bit/" target="_blank">https://archive.fosdem.org/2017/schedule/event/llvm_16_bit/</a><BR>
<BR>
In a nutshell, the proposal is for the llvm community to<BR>
allow/encourage interested parties to gradually remove "magic numbers",<BR>
e.g. assumptions on the size of bytes from the codebase. Overview,<BR>
rationale and some example refactorings follows.<BR>
<BR>
Overview:<BR>
<BR>
LLVM currently assumes 8-bit bytes, while there exist a few out-of-tree <BR>
llvm targets that utilize bytes of other sizes, including our<BR>
(Ericsson's) proprietary target. The main issues are the magic number 8<BR>
and "/8" and "*8" all over the place and the use of i8 pointers.<BR>
<BR>
There's considerable agreement that the use of magic numbers is not<BR>
good coding style, and removing these ones would be of particular<BR>
benefit, even though the effort would not be complete and no in-tree<BR>
target with tests exist to guarantee that all gains are maintained.<BR>
<BR>
Ericsson is willing to drive this effort. During EuroLLVM19, there<BR>
seemed to be sufficient positive interest from other companies for us<BR>
to expect help with reviewing patch sets. Ericsson has been performing<BR>
nightly integration towards top-of-tree with this backend for years,<BR>
catching and fixing new 8-bit-byte continuously. Thus we're able to<BR>
commit to doing similar upstream fixes for the long haul in a no-drama<BR>
way.<BR>
<BR>
Rationale:<BR>
<BR>
Benefits of moving toward a byte-size agnostic llvm include:<BR>
* Less magic numbers in the codebase.<BR>
* A reduced effort to maintain out-of-tree targets with non-8-bit bytes<BR>
as contributors follow the established patterns. (One company has told<BR>
us that they created but eventually gave up on a 16-bit byte target due<BR>
to too-high integration burden.)<BR>
* A reduction in duplicate efforts as some of the adaptation work would<BR>
happen in-tree rather than in several out-of-tree targets.<BR>
* For up-and-coming targets that have non-8-bit-byte sizes, time to<BR>
market using llvm would be far quicker.<BR>
* A higher probability of LLVM being the compiler of choice for such<BR>
targets.<BR>
* Eventually, as the patch set required to make llvm fully byte size<BR>
agnostic becomes small enough, the effort to provide a mock in-tree<BR>
target with some other byte size should be surmountable.<BR>
<BR>
As cons, one could see a burden for the in-tree community to maintain<BR>
whatever gains that have been had. However the onus should be on<BR>
interested parties to mend any bit-rot. The impact of not having as<BR>
much magic numbers and such should if anything make the code more easy<BR>
to understand. The permission to go ahead would be under the condition<BR>
that significant added complexities are avoided. Another con would be<BR>
added compilation time e.g. in cases where the byte size is a run-time<BR>
variable rather than a constant. However, this cost seems negligible in<BR>
practice.<BR>
<BR>
Refactoring examples:<BR>
<a href="https://reviews.llvm.org/D61432" target="_blank">https://reviews.llvm.org/D61432</a><BR>
<BR>
Best Regards,<BR>
Jesper<BR>
_______________________________________________<BR>
LLVM Developers mailing list<BR>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><BR>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><BR>
<br /><br /><p style="font-family: Verdana; font-size:10pt; color:#666666;"><b>Disclaimer</b></p><p style="font-family: Verdana; font-size:8pt; color:#666666;">The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.<br /><br />This email has been scanned for viruses and malware, and may have been automatically archived by <b>Mimecast Ltd</b>, an innovator in Software as a Service (SaaS) for business. Providing a <b>safer</b> and <b>more useful</b> place for your human generated data. Specializing in; Security, archiving and compliance. To find out more <a href="http://www.mimecast.com/products/" target="_blank">Click Here</a>.</p></body></html>