<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I happen to be using LLVM for just this reason. I process large volumes of data records with schemas that are only known at runtime and/or can change dynamically as various transforms are applied to such records at various stages. </div><div><br></div><div>To this end, I auto-generate C99 syntax at run time, parse it using clang, do some AST transformations, compile using LLVM JIT, and then execute within the same (C++) process. As a point of comparison, I've done similar things with Java bytecode and while the JVM approach was [much] easier learning curve- and documentation-wise, it is hard to complain about the level of control you get with LLVM. It is like having a WISS (When I Say So) dynamic compiler producing -03-level native code. In my case, I target x86-64 and had only minor trouble supporting the same toolchain on Linux and Darwin.</div><div><br></div><div>So, the approach is definitely workable, but I must warn about the non-trivial amount of effort required to figure things out in both clang and LLVM codebases. For example, how to traverse or mutate ASTs produced by clang is pretty much a FAQ on the clang list but there is no good documentation addressing this very common use case.</div><div><br></div><div>HTH,</div><div>Vlad</div><div><br></div><div><div>On Jul 16, 2010, at 10:47 AM, David Piepgrass wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div lang="EN-US" link="blue" vlink="purple"><div class="WordSection1" style="page: WordSection1; "><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Using C++ code, I would like to generate code at run-time (the same way .NET code can use dynamic methods or compiled expressions) in order to obtain very high performance code (to read binary data records whose formats are only known at run-time.) I need to target x86 (Win32) and ARM (WinCE).<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; ">Can LLVM be used for this purpose, or would something else work better? Are there any open-source projects that have done this, that I could look to as an example?<o:p></o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; page-break-after: avoid; "><b><span style="font-size: 10pt; font-family: Verdana, sans-serif; ">David Piepgrass, E.I.T.<o:p></o:p></span></b></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; page-break-after: avoid; "><span style="font-size: 8pt; font-family: Verdana, sans-serif; ">Software Developer<br></span><span style="font-size: 10pt; font-family: CastleTUlt; ">__________________________________________<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 7px; "><span style="font-size: 4pt; line-height: 4px; font-family: 'Futura Hv BT'; "><o:p> </o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><b><span style="font-size: 8.5pt; font-family: Verdana, sans-serif; "><a href="http://www.mentoreng.com/" style="color: blue; text-decoration: underline; "><span style="color: blue; ">Mentor Engineering Inc.</span></a><span style="color: red; "><o:p></o:p></span></span></b></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 8pt; font-family: Verdana, sans-serif; ">10, 2175 - 29th Street NE<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 8pt; font-family: Verdana, sans-serif; ">Calgary, AB, Canada  T1Y 7H8<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 4pt; font-family: Verdana, sans-serif; "><o:p> </o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 8pt; font-family: Verdana, sans-serif; ">Ph: (403) 777-3760 ext. 490  Fax: (403) 777-3769<o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.25in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 18px; "><b><span style="font-size: 10pt; line-height: 15px; font-family: Verdana, sans-serif; color: rgb(49, 73, 99); ">What are the costs of speeding & idling in your fleet?</span></b><b><span style="font-size: 9pt; line-height: 14px; font-family: Verdana, sans-serif; color: rgb(49, 73, 99); "><span class="Apple-converted-space"> </span></span></b><b><span style="font-size: 9pt; line-height: 14px; font-family: Verdana, sans-serif; color: rgb(161, 173, 39); "><br></span></b><b><u><span style="font-size: 8pt; line-height: 13px; font-family: Verdana, sans-serif; color: rgb(141, 179, 226); "><a href="http://www.mentoreng.com/speed-idle/speed-idle-demo.html" style="color: blue; text-decoration: underline; "><span style="line-height: 13px; color: rgb(141, 179, 226); ">Watch this short demo to find out</span></a></span></u></b><span style="font-size: 9pt; line-height: 14px; font-family: Verdana, sans-serif; color: rgb(161, 173, 39); "><o:p></o:p></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 8pt; font-family: Verdana, sans-serif; color: blue; "><span><image001.jpg></span><u><o:p></o:p></u></span></div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" style="color: blue; text-decoration: underline; ">LLVMdev@cs.uiuc.edu</a><span class="Apple-converted-space"> </span>        <a href="http://llvm.cs.uiuc.edu/" style="color: blue; text-decoration: underline; ">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" style="color: blue; text-decoration: underline; ">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></span></blockquote></div><br></body></html>