Hi Andrew, On Thu, Dec 8, 2011 at 11:48 PM, Andrew Pinski <pins...@gmail.com> wrote: > On Thu, Dec 8, 2011 at 1:47 PM, Feng LI <nemoking...@gmail.com> wrote: >> Hi, >> >> I'm extending the i386 instructions by using the builtins in the backend. >> And generate the builtin functions in the middle end. And would like >> the generated builtin functions will be transformed to ASM code. >> >> I tested the backend with a hand writing builtin functions, it *works* >> well, but *not with* the middle end automatically generated functions. > > have you looked into ix86_builtin_reciprocal and where it gets used in > tree-ssa-math-opts.c ?
Thanks for this hint. I get something when I look into the code in this file. I think the reason is that the DECL_FUNCTION_CODE which is used in the back end is not properly constructed. If I add a line when build the builtin in the middle end: DECL_FUNCTION_CODE (decl) = code; It'll work. But I'm still a little confused. When the user use the builtin functions (write the c code), the DECL_FUNCTION_CODE is set automatically somewhere by the compiler (not sure where this happens...), but why when generating gimple from the middle end, it's not properly set? An not clean thing of set the DECL_FUNCTION_CODE in the middle end is that the CODE is actually defined in i386.c file, which is target specified. Where I still have to use the code in the middle end. I'm not so sure if this a good solution, let me know if there are some better ways. Thank you! Feng > > I think you need a target hook which returns the decl and that decl is > the same decl you created in the target. > > Thanks, > Andrew Pinski