On Fri, 2015-11-06 at 20:14 +0100, Bernd Schmidt wrote: > > > + if (SCALAR_INT_MODE_P (from_mode)) > > + { > > + /* If we need to promote the integer function argument we need to do > > Extra space at the start of the comment. > > > + it here instead of inside emit_library_call_value because here we > > + know if we should be doing a signed or unsigned promotion. */ > > + > > + machine_mode arg_mode; > > + int unsigned_p = 0; > > + > > + arg_mode = promote_function_mode (NULL_TREE, from_mode, > > + &unsigned_p, NULL_TREE, 0); > > + if (arg_mode != from_mode) > > + { > > + from = convert_to_mode (arg_mode, from, uintp); > > + from_mode = arg_mode; > > + } > > + } > > Move this into a separate function (prepare_libcall_arg)? I'll think > about it over the weekend and let others chime in if they want, but I > think I'll probably end up approving it with that change. > > > Bernd
Are you thinking of a simple function that is called on all targets or a target specific function? Maybe a target specific function would be safer. We could have: from = targetm.prepare_libcall_arg (from, uintp); from_mode = GET_MODE (from); And have the default prepare_libcall_arg simply return the original 'from' rtx value. We could also pass some other arguments, maybe the library call rtx (fun) and an integer to specify what argument this is (1, 2, 3, ...) if we wanted to try and generalize it even more. Steve Ellcey sell...@imgtec.com