On Wed, Oct 16, 2013 at 12:58:01PM +0330, Mehrdad Abdi wrote: > I want to change all my binary operations to functions. for example > transform expression `b + c * d` to `my_add(b,my_multp(c,d))`.
You cannot have nested function calls in CIL. > The problem is function call is a instruction and binop is a expression. > How can I do this transform by a visitor? You'll need to descend recursively into your expressions, splitting them and introducing temporary variables for intermediate results. Then, when you reach code of the form: tmp1 = c * d; tmp2 = tmp1 + b; return tmp2; it is straightforward to substitute Set by Call. What you need, essentially, is called "three-address code": http://en.wikipedia.org/wiki/Three_address_code You should probably implement this in two passes: one producing three-address code, and one introducing your functions. > and a suggestion: create a `C-IL` Tag in stackoverflow.com and move > your support there. If anybody is interested, feel free to initiate community support there. I don't use stackoverflow.com, mostly because I'm much more efficient with email than web-based interfaces, so I'm afraid you'll need to use this list if you value my answers ;-) Best regards, -- Gabriel ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk _______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users