Replacing certain operations with function calls
Ian Lance Taylor
iant@google.com
Tue Sep 1 16:35:00 GMT 2009
Jean Christophe Beyler <jean.christophe.beyler@gmail.com> writes:
> I have been also been looking into how to generate a function call for
> certain operations. I've looked at various other targets for a similar
> problem/solution but have not seen anything. On my target
> architecture, we have certain optimized versions of the multiplication
> for example.
>
> I wanted to replace certain mutliplications with a function call. The
> solution I found was to do perform a FAIL on the define_expand of the
> multiplication for these cases. This forces the compiler to generate a
> function call to __multdi3.
>
> I then go in the define_expand of the function call and check the
> symbol_ref to see what function is called. I can then modify the call
> at that point.
>
> My question is: is this a good approach or is there another solution
> that you would use?
I think that what you describe will work. I would probably generate a
call to a builtin function in the define_expand. Look for the way
targets use init_builtins and expand_builtin. Normally expand_builtin
expands to some target-specific RTL, but it can expand to a function
call too.
Ian
More information about the Gcc
mailing list