Newsgroups: comp.sys.hp
Subject: Apparent bug in gcc2.2.2 from IWorks CD-ROM (HP 720)
From: heffron@falstaff.css.beckman.com (Matt Heffron)
Date: 7 Oct 92 19:21:02 GMT
Reply-To: heffron@falstaff.css.beckman.com
Organization: Scientific Services, Beckman Instruments, Inc.

I've discovered what appears to be a bug in the gcc-2.2.2 compiler
which was distributed on the InterWorks CD-ROM.  I'm using the
executables from the gcc-2.2.2.tar file (i.e. I did NOT re-build) on
my HP720.  The first system which I tried to compile with gcc fails
with an "Unrecognized keyword - ARGW4" error from the assembler.
The C function which is being compiled at this point begins:

int ProduceXFontName (char *FontName, char *name, char *style, double points) {

The assembly source generated for the function entry is (excerpt):

LC$0060
	.word LC$0043
	.align 4
	.EXPORT ProduceXFontName
	.EXPORT ProduceXFontName,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=FR,ARGW4=FU,RTNVAL=GR
ProduceXFontName
	.PROC
	.CALLINFO FRAME=192,CALLS,SAVE_RP
	.ENTRY

The problem is the ARGW4=FU.
From looking at the pa.h file in the gcc-2.2.2/config directory,
it looks like the problem is in the ASM_DECLARE_FUNCTION_NAME macro,
below (Annotation by me below is flagged with ";[mth]")

/* Output the label for a function definition.  */
#ifdef HP_FP_ARG_DESCRIPTOR_REVERSED
#define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1)	\
  do { fprintf (FILE, ",ARGW%d=FR", (ARG0));		\
       fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
#else
#define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1)	\
  do { fprintf (FILE, ",ARGW%d=FU", (ARG0));		\
       fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
#endif
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
    do { tree fntype = DECL_RESULT (DECL);	 			\
	 tree tree_type = TREE_TYPE (DECL);				\
	 tree parm;							\
	 int i;								\
	 if (TREE_PUBLIC (DECL))					\
	   {								\
	     fputs ("\t.EXPORT ", FILE); assemble_name (FILE, NAME);	\
	     fputs (",PRIV_LEV=3", FILE);				\
	     for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4;	\
		  parm = TREE_CHAIN (parm))				\
	       {							\
		 if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode)	\
		   fprintf (FILE, ",ARGW%d=FR", i++);			\
		 else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode)	\
;[mth] The problem seems to be here, at the point where the
;[mth] "double points" parm is being processed, i==3, but
;[mth] ASM_DOUBLE_ARG_DESCRIPTORS tries to use the next 2 values of i
;[mth] (3 and 4) for the ARGW's
		   {							\
		      if (i == 1) i++;				        \
		      ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++);	\
		   }							\
		 else							\
		   {							\
		     int arg_size =					\
		       FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\
					  DECL_ARG_TYPE (parm));	\
		     if (arg_size == 2 && i <= 2)			\
		       {						\
			 if (i == 1) i++;				\
			 fprintf (FILE, ",ARGW%d=GR", i++);		\
			 fprintf (FILE, ",ARGW%d=GR", i++);		\
		       }						\
		     else if (arg_size == 1)				\
		       fprintf (FILE, ",ARGW%d=GR", i++);		\
		     else						\
		       i += arg_size;					\
		   }							\
	       }							\
	     /* anonymous args */					\
	     if (TYPE_ARG_TYPES (tree_type) != 0			\
		 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
		     != void_type_node))				\
	       {							\
		 for (; i < 4; i++)					\
		   fprintf (FILE, ",ARGW%d=GR", i);			\
	       }							\
	     if (TYPE_MODE (fntype) == DFmode)				\
	       fprintf (FILE, ",RTNVAL=FR");				\
	     else if (TYPE_MODE (fntype) == SFmode)			\
	       fprintf (FILE, ",RTNVAL=FU");				\
	     else if (fntype != void_type_node)				\
	       fprintf (FILE, ",RTNVAL=GR");				\
	     fputs ("\n", FILE);					\
	   }								\
	 ASM_OUTPUT_LABEL (FILE, NAME);} while (0)


This is just my speculation, since before yesterday I had never dealt with
gcc, and I know nothing about the assembly language for the PA-RISC (other than
the assembler doesn't like ARGW4 :-) ).

So, am I really off-base here??  Are there patches that I need to install for
gcc and rebuild??  All help is appreciated.

Thanks

--
Matt Heffron                      heffron@falstaff.css.beckman.com
Beckman Instruments, Inc.         voice: (714) 961-3128
2500 N. Harbor Blvd. MS X-11, Fullerton, CA 92634-3100
I don't speak for Beckman Instruments unless they say so.
Newsgroups: comp.sys.hp