<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Charles,<div class=""><br class=""></div><div class="">It sounds like you already have some of this implemented? How different is it from <font face="Courier New" class="">-mx32</font> ? It sounds kinda different, but with some overlap?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">JF<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 6, 2018, at 2:49 PM, Charles Davis via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Resending to the new mailing list address...</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br class=""></div><div class="gmail_quote">---------- Forwarded message ----------<br class="">From: <b class="gmail_sendername">Charles Davis</b> <span dir="ltr" class=""><<a href="mailto:cdavis5x@gmail.com" target="_blank" class="">cdavis5x@gmail.com</a>></span><br class="">Date: Thu, Aug 2, 2018 at 5:59 PM<br class="">Subject: 32-bit pointers and calls from 64-bit code<br class="">To: Clang Developers List <<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank" class="">cfe-dev@cs.uiuc.edu</a>><br class=""><br class=""><br class=""><div dir="ltr" class=""><div class=""><div style="font-family:arial,helvetica,sans-serif;font-size:small;text-decoration-style:initial;text-decoration-color:initial" class="">Hello,</div><div style="font-family:arial,helvetica,sans-serif;font-size:small;text-decoration-style:initial;text-decoration-color:initial" class=""><br class=""></div><div style="font-family:arial,helvetica,sans-serif;font-size:small;text-decoration-style:initial;text-decoration-color:initial" class="">With Apple's impending 32-bit deprecation, my new employer is having a bit of an existential crisis. We think we've found a way forward, but we need a little help from the compiler to accomplish this.</div><div style="font-family:arial,helvetica,sans-serif;font-size:small;text-decoration-style:initial;text-decoration-color:initial" class=""><br class=""></div><div style="font-family:arial,helvetica,sans-serif;font-size:small;text-decoration-style:initial;text-decoration-color:initial" class="">Basically, what we want to do is have code that is technically x86-64 but that can use 32-bit pointers and that can make calls to 32-bit code. In a separate thread on llvmdev, I asked about LLVM changes we need for this. Here are the corresponding C language extensions we need:</div><div style="text-decoration-style:initial;text-decoration-color:initial" class=""><ul class=""><li class=""><font face="arial, helvetica, sans-serif" class="">(Possibly) a preprocessor macro to be defined when we're building 64-bit code to be called by 32-bit code. This code, while still technically being 64-bit, needs to look and act like 32-bit code to our clients--so we'd like to define </font><font face="monospace, monospace" class="">__i386__</font><font face="arial, helvetica, sans-serif" class=""> et al. as though we were building real 32-bit code.</font></li><li class=""><font face="arial, helvetica, sans-serif" class="">Microsoft's </font><font face="monospace, monospace" class="">__ptr32</font><font face="arial, helvetica, sans-serif" class=""> and </font><font face="monospace, monospace" class="">__ptr64</font><font face="arial, helvetica, sans-serif" class=""> keywords--to distinguish 32-bit and 64-bit pointers.</font></li><li class=""><font face="arial, helvetica, sans-serif" class="">A pragma to choose the default pointer size--with this, we can avoid littering our code with lots of </font><font face="monospace, monospace" class="">__ptr32</font><font face="arial, helvetica, sans-serif" class=""> keywords.</font></li><li class=""><font face="arial, helvetica, sans-serif" class="">Attributes for various 32-bit calling conventions. We can't use the existing ones, because they are defined not to do anything in 64-bit code. I'll probably define new ones that are just the old ones suffixed with '32' (e.g. </font><font face="monospace, monospace" class="">__attribute__((cdecl32))</font><font face="arial, helvetica, sans-serif" class="">).</font></li><li class=""><font face="arial, helvetica, sans-serif" class="">An attribute to declare that a function pointer must be called far, and to declare the segment selector to use when calling it. We need this to be able to transition to a 32-bit code segment. I'm currently leaning towards (ab)using Microsoft's </font><font face="monospace, monospace" class="">__based</font><font face="arial, helvetica, sans-serif" class=""> extension (which originally supported something like this, I believe) for this purpose.</font></li></ul><div class=""><font face="arial, helvetica, sans-serif" class=""><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial" class="">Questions? Comments? Insinuations that I'm off my rocker? We understand if you don't want any of this, but note that a large chunk of my employer's revenue depends on this, so if need be, we'll maintain our own fork. We would prefer, however, that this be upstreamed.</div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial" class=""><br class=""></div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial" class="">Chip<br class=""></div></font></div></div><br class=""></div></div>
</div><br class=""></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></div></body></html>