<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">I’m still kinda lost, some example would help.<div>Anyway I’ll try my best here. If the core code(functions) are predefined and is written in C++,I’d say re-use libClang to compile them into Bitcode/LLVM IR, then perform your own linking/inlining procedures, add function calls etc to sort of “pipe” everything together. Basically:</div><div>- Setting up a libClang’s CompilerInstance with headers and stuff.</div><div>- Emit a new C++ source code from the user’s input and use your CompilerInstance to run EmitLLVMOnlyAction. (See this article <a href="http://fdiv.net/2012/08/15/compiling-code-clang-api">http://fdiv.net/2012/08/15/compiling-code-clang-api</a> for a hands-on walkthrough. See the Compile a .c file into a Module part)</div><div>- Some IR level transformation if you need to.</div><div><br></div><div>In this way you should be able to tackle the problem without hacking with libClang or anything, if my understanding is correct. Also for any libClang related question, cfe-dev is a more suitable place.</div><div><br></div><div><div id="AppleMailSignature" dir="ltr">Zhang</div><div dir="ltr"><br>在 2019年6月20日,20:32,Steven Truppe <<a href="mailto:workbench@gmx.at">workbench@gmx.at</a>> 写道:<br><br></div><blockquote type="cite"><div dir="ltr"><span>I explain it in more detail:</span><br><span></span><br><span>I'm writing an application that works completely with nodes (think about</span><br><span>a node like a function with parameters and in and output slots. there</span><br><span>will be type-nodes like vec3f, int, float, etc. and operation nodes (the</span><br><span>functions that are predefined). So as far as i know i need clang to</span><br><span>parse and create an AST from the nodes (which have access to the</span><br><span>predefined functions and variables). The nodes that are create with a</span><br><span>GUI and the user can connect those nodes to create higher order</span><br><span>functions. (if you know houdini you might know the system i'm trying to</span><br><span>create).</span><br><span></span><br><span>And the code should be C++ (for the predefined functions and the</span><br><span>operator nodes). So no own language just parse and execute in realtime a</span><br><span>self created AST (with predefined functions that must be available for</span><br><span>the code that every operator node has included. More like a graphical</span><br><span>interface to let the use create it's own AST and then run it in realtime</span><br><span>(so the user don' t need programming skills and can create smaller</span><br><span>applications only with the graphical interface.</span><br><span></span><br><span></span><br><span>I was not able to find a clang book, only for llvm and they don't go</span><br><span>into much detail when it comes to clang.</span><br><span></span><br><span></span><br><span>I hope someone here can point me in the right direction (name of a clang</span><br><span>book or links to the documentation that i need to get things done.</span><br><span></span><br><span></span><br><span>best regards.</span><br><span></span><br><span>Steven Truppe</span><br><span></span><br><span></span><br><span></span><br><span></span><br><span>On 20.06.19 20:52, <a href="http://mayuyu.io">mayuyu.io</a> wrote:</span><br><blockquote type="cite"><span>As far as I understand it you are basically trying to create your own domain specific language for scientific computation?</span><br></blockquote><blockquote type="cite"><span>Clang seems to kinda match what you need but I don’t think it’s able to support function definition in another function which sounds like something you’d need. Your best approach would be using some lexer/parser generate tool to code your own compiler frontend (GREAT DEAL OF WORK) or hack up libClang a bit. Alternatively there are a bunch of readily usable LLVM based languages like Halide that are designed for generating efficient tensor computation code so changing your workflow a bit to re-use those libraries/frameworks is probably a better idea, in my humble opinion. Unless I’m missing something obvious here.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Zhang</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>在 2019年6月20日,19:01,Steven Truppe via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> 写道:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Hi everyone,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>i'm currently trying to write an application that let you "code" with</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>nodes. (think of a node like a function that has input and output slots</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>that can get connected).</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>I need a few functions that are predefined and can be used in the code</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>(so i want to parse and create an AST for those functions/variables and</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>then i need to parse C++ code (one node has c++ code that should be</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>executed. So in the end i've nodes that are for types, then one for</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>operations (the functions).</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>The code from the nodes must be able to run the code from it's node with</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>the parameters i pass to the node's slots or in the node itself and i</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>need it to be able to create own functions that must be available in the</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>code of the nodes.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>so for example i've a typenode that declares and defines variables, for</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>example vec3f for 3d vector types.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Now my question would be: Where should i start reading or is there a</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>special article how to achive what i want ?? As far as i know i need</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>clang to parse my own functions so he knows about my types and my</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>functions (one for each operation nodes and the structure declarations).</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>this creates one AST for each type/function). then i need to build an</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>AST for my own nodes that must be interpreted and compiled with llvm and</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>then run the code at runtime.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>I hope one of you guys can point me in the right direction because i'm</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>completely new to clang and llvm (but i found a book about "learning</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>llvm basic libaries that helps a bit but they do not talk much about</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>clang (so i only know the basics about llvm and have not much of a clue</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>about clang.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>best regards,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Steven Truppe</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>_______________________________________________</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>LLVM Developers mailing list</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span><a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><span></span><br></div></blockquote></div></body></html>