This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [fortran, patch] Enable Hollerith constant and character array in format tag.


On Sat, Apr 09, 2005 at 07:40:09PM +0200, Steven Bosscher wrote:
> On Saturday 09 April 2005 19:17, Steve Kargl wrote:
> > On Fri, Apr 08, 2005 at 10:32:03PM +0800, Feng Wang wrote:
> > > --- Steven Bosscher <stevenb@suse.de> wrote:
> > > > On Friday 08 April 2005 04:11, Feng Wang wrote:
> > > > > Is anybody reviewing this? I think this is also an important
> > > > > extension.
> > > >
> > > > I agree that it is important, but there really is more to do before
> > > > the patch is OK.  At least two things come to mind (I hope I can't
> > > > think up more for the next review ;-)
> >
> > Can either of you explain why this is an important extension?
> 
> It is an important extension because there is a surprising amount
> of legacy code that uses Holleriths.  Even in the upcoming SPEC
> suite, there will still be fortran benchmarks that use holleriths.
> 
> > That is, what are the semantics of using hollerith constants?
> 
> The problem is that they are rather vague.  For ASCII Holleriths,
> they are just strings.  For numerical Holleriths, the exact bit
> pattern of the Hollerith must be converted to the numerical value
> of the target machine.
> One word: pain.

In that case, we need gfc_hollerith_to_mpfr and gfc_hollerith_to_mpz.
Both MPFR and GMP have functions to convert a string to an mpfr type
or mpz type.  Is the Hollerith (eg., your 4hdead) restricted to hex
digits?  If so, then its trivial.  If the hollerith can contain any
ascii character, then we need to convert the hollerith to the equivalent
string in binary.

int mpfr_set_str (mpfr_t X, char *S, int BASE, mp_rnd_t RND)

  mpfr_set_str (x, 'dead', 16, GFC_RND_MODE);

int mpz_set_str (mpz_t ROP, char *STR, int BASE)

  mpz_set_str (x, 'dead', 16);

-- 
Steve


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