pro64-support
[Top] [All Lists]

Re: C to Whirl

To: hardnett@xxxxxxxxxxxxx
Subject: Re: C to Whirl
From: Chandrasekhar Murthy <murthy@xxxxxxx>
Date: Mon, 25 Jun 2001 11:43:16 -0700
Cc: pro64-support@xxxxxxxxxxx
References: <15159.16643.507376.91718@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: owner-pro64-support@xxxxxxxxxxx
"Charles R. Hardnett" wrote:

> Hello,
>
> I have a question that involves the C to Whirl generation. I am using
> the whirl2C module, and noticed a bug with code such as the following:
>
>         struct stat sbuf;
>
>         if (sbuf.st_mode) {
>           printf("hello");
>         }
>
> The above code comes out of pro64 after whirl2c translation to look
> something like:
>
> if((_UINT32)(*(struct stat0 {
>     _UINT64 st_dev;
>     _UINT32 st_ino;
>     _INT32 __pad1;
>     _UINT32 st_mode;
>     _UINT32 st_nlink;
>     _UINT32 st_uid;
>     _UINT32 st_gid;
>     _UINT64 st_rdev;
>     _INT64 st_size;
>     _INT64 st_atime;
>     _INT64 st_mtime;
>     _INT64 st_ctime;
>     _INT32 st_blocks;
>     _INT32 __pad2;
>     _UINT32 st_blksize;
>     _INT32 __pad3;
>     _INT64 __unused[6LL];
>   } *)(((_INT8 *) & sbuf) + 16LL)) != 0U)
>   {
>     printf((const _INT8 *)(_INT8(*)[6LL]) "hello");
>   }
>
> The problem of course is cast contains a declaration of the struct,
> and not just the name of the struct. I have tracked down the problem
> to where this only occurs when a struct field is accessed within a
> cond exp i.e. within while, if, for, etc.
>
> I have also convinced myself that the problem is not in the whirl2c
> conversion because it appears that whirl2C is only outputing the token
> information that is stored in the WN for this object's
> type. Therefore, it appears that the problem is the translation from C
> to whirl by GFEC is most likely the culprit.
>

The problem is with whirl2c.
It has not been modified to reflect field_id usage.

>
> My questions are:
>
>    1. Is there anyone else looking at the whirl2c module that may have
> run into this problem?

>
>    2. If not, does anyone have any good information on GFEC and how
> its exprs are stored? operated on to create the whirl? I was looking
> at the code this weekend, and could use any documentation anyone may
> have on it.
>

The WHIRL generation in gfec is done on the fly.
Unlike gfecc,(which works on a tree representation for the
entire compilation unit), gfec intercepts calls during the gnu
IR generation (these are under #ifdef SGI_MONGOSE in the
gccfe/gnu directory).  This interception is done at a
statement level (handled in wfe_stmt.cxx), which will in
turn handle expressions  (handled in wfe_expr.cxx).

>
> Thanks,
>
> Charles
>
> --
> --------------------------------------------------------------------
> Charles R. Hardnett www.spelman.edu/~hardnett

Murthy



<Prev in Thread] Current Thread [Next in Thread>