<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jul 18, 2013, at 12:23 PM, Tyler Hardin <<a href="mailto:tghardin1@catamount.wcu.edu">tghardin1@catamount.wcu.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><p dir="ltr">As much as I like this idea for it's use in languages with type systems like Haskell and Scheme, this proposal would limit LLVM to non-Harvard architectures. That's generally a really small minority of all processors, but it would mean there could never be a clang-avr.</p></div></blockquote><div dir="auto"><br></div><div dir="auto">LLVM already effectively assumes a unified address space. The pointer address space attributes and such come close to what would be required for good Harvard support, but it’s not enough. In particular there’s the fundamental assumption that all pointers are the same size. For embedded Harvard arches, that’s often not the case.</div><div dir="auto"><br></div><div dir="auto">-JIm</div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><p dir="ltr">An alternative you could use is, instead of using the function pointer as the variable where you are referring to a function, you could have the variable be a pointer to a static struct with the data and the actual function pointer. Basically, it's like how static class variables as handled in C++.</p><p dir="ltr">I don't know LLVM IR, so I'll use C to explain.</p><p dir="ltr">Instead of this:</p><p dir="ltr">void func(void){}</p><p dir="ltr">int main(){<br>   func();<br>   return 0;<br>}</p><p dir="ltr">You could do this:</p><p dir="ltr">void func(void){}</p><p dir="ltr">/* You have to initialize this at compile time. */<br>struct {<br>char* data;<br>int len;<br>void (*ptr)(void) = func;<br>} func_data;</p><p dir="ltr">int main(){<br>   func_data.ptr();<br>   return 0;<br>}<br></p><div class="gmail_quote">On Jul 18, 2013 12:47 PM, "Jevin Sweval" <<a href="mailto:jevinsweval@gmail.com">jevinsweval@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">On Wed, Jul 17, 2013 at 9:06 PM, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk">peter@pcc.me.uk</a>> wrote:<br>><br>> To maintain the semantics of ordinary function calls, the prefix data<br>> must have a particular format.  Specifically, it must begin with a<br>> sequence of bytes which decode to a sequence of machine instructions,<br>> valid for the module's target, which transfer control to the point<br>> immediately succeeding the prefix data, without performing any other<br>> visible action.  This allows the inliner and other passes to reason<br>> about the semantics of the function definition without needing to<br>> reason about the prefix data.  Obviously this makes the format of the<br>> prefix data highly target dependent.<br><br><br>What if the prefix data was stored before the start of the function<br>code? The function's symbol will point to the code just as before,<br>eliminating the need to have instructions that skip the prefix data.<br><br>It would look something like:<br>| Prefix Data ... (variable length) | Prefix Data Length (fixed length<br>[32 bits?]) | Function code .... |<br><br>           <span class="Apple-converted-space"> </span>^ function symbol points here (function code)<br><br>I hope the simple ASCII art makes it through my mail client.<br><br>To access the data, you do<br><br>prefix_data = function_ptr - sizeof(prefix_length) - prefix_length<br><br>Cheers,<br>Jevin<br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>       <span class="Apple-converted-space"> </span><a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>        <a href="http://llvm.cs.uiuc.edu/">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></blockquote></div><br></body></html>