This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Converting mpz_t to different integer representations


Brooks,


However, I still don't understand why you're trying to convert the mpz_t constants into _host_ integer values and asking about what types are available on the host, given that the host representation and the target representation are likely to be different. It looks like to me that the native_encode_expr() function from gcc/fold-const.c is more like what you want, since it takes a value and produces the corresponding bytewise representation on the target.
You are absolutely right! I was so concentrated on doing the right thing with the lining up the initializer elements and putting them into the union that I was not thinking clearly about whose representations of numbers should be used. I was aware of being ignorant - hence the call for help.

That said, which representation does mpz_export produce? ie. is it not outputting in the target endian-ness and bitiness?

Meanwhile, weren't you making some comments about going to not have all that much time to be working on gfortran bug-fixing after the first of the year? :) If you'd like (and aren't in too much of a hurry with this), I can poke some at translating the native_encode_expr stuff into a gfortran equivalent.
Please do - I have been raking through my bits box to make sure all the partially made patches see the light of day. I would sleep a lot better (and a lot more :-) ) if you would take both patches on.

- Brooks (with thanks to Andrew Pinski for pointing me at fold-const.c)
Indeed, thanks, Andrew. native_encode_expr is very helpful for both PRs. The version of the patch posted to the PR can be used with WORDS_BIG_ENDIAN to put the HOST_WIDE_INTs hi and lo into the right order. Since the mpz_export function is used elswhere, if it is not right, we have all sorts of troubles that we do not know about.

Paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]