🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #53330

Help: GCC with register arguments - need advice

#53330
From: wd
Date: Mon, 03 Feb 1992 09:31
107 lines
4647 bytes
[I already posted this but it seems my message was lost. So sorry 
if you receive it twice.] 

My experiments with GCC-1.40 using register arguments on a  68000
showed some more problems: 

(1) Sometimes (structure assign) GCC generates calls to functions 
    bcopy, bcmp and bzero (resp. memcpy, memcmp amd memset). This 
    is done with emit_library_call which handles these  calls  as
    LIBCALL  and pushes the arguments on the stack. Unfortunately
    these routines are ordinary  library  functions  that  expect
    their  args to be passed in registers. Result: Memory fault -
    core dumped. 

    As a quick workaround I changed  GCC  to  generate  calls  to
    special  functions which pop the arguments from the stack and
    branch to the ordinary library functions. This works ok,  but
    I  think  it is a little bit ugly. I see two other possibili-
    ties: 

    (a) Change GCC to pass LIBCALL arguments in  registers,  too.
        But there is a comment in tm-m68k.h where FUNCTION_ARG is 
        defined:  "TYPE  is  the  data type of the argument (as a
        tree). This is null for libcalls where  that  information
        may not be available." What has to be changed to do this? 

    (b) Change GCC to handle bcopy, bcmp and bzero (resp. memcpy, 
        memcmp amd memset) not as LIBCALL but as what  they  are:
        ordinary  functions  (with arguments in registers). (This
        is what I would like to do.) How could I do it? 

(2) For some reason GCC with register args uses ___mulsi3 to com- 
    pute  pointer  expressions  where  the  unmodified  GCC  uses
    machine instructions. This is shown in the following example: 

	-> cat foo.c
	struct foo {
		int i[100];
	};

	extern struct foo foo[];

	struct foo *bar (int i)
	{
		return (&foo[i]);
	}
	-> /usr/gnu/lib/cc1.STACK foo.c -quiet -dumpbase foo.c -mshort \
		-fomit-frame-pointer -fcombine-regs -fstrength-reduce \
		-O -Wall -Wpointer-arith -pedantic -version -o foo.s.old
	GNU C version 1.40 (68k, MIT syntax) compiled by GNU C version 1.40.
	default target switches:
	-> cat foo.s.old
	#NO_APP
	gcc_compiled.:
	.text
		.even
	.globl _bar
	_bar:
		movew sp@(4),d0
		muls #200,d0		*** This is what I want
		addl #_foo,d0
		rts
	-> /usr/gnu/lib/gcc-cc1 foo.c -quiet -dumpbase foo.c -mshort -mnoregparm \
		-fomit-frame-pointer -fcombine-regs -fstrength-reduce \
		-O -Wall -Wpointer-arith -pedantic -version -o foo.s.new
	GNU C version 1.40 (68k, MIT syntax) compiled by GNU C version 1.40.
	default target switches: -mregparm
	-> cat foo.s.new
	#NO_APP
	gcc_compiled.:
	.text
		.even
	.globl _bar
	_bar:
		movew sp@(4),a0
		pea 200:w		*** But
		movel a0,sp@-		*** this is
		jbsr ___mulsi3		*** what I get.
		addqw #8,sp		*** Why ???
		addl #_foo,d0
		rts

    Anybody an idea why this happens and how it could be changed?

(3) I noticed that GCC  even  with  -mnoregparm  cannot  use  the
    registers  reserved  for  register arguments (I used D0...D2,
    A0...A1; for this setup D2 could be used  if  -mnoregparm  is
    specified). Is there a good way to modify initial_call_used_regs[]
    or call_used_regs[] depending on the current GCC options? Are 
    there any risks in doing this? 


Any help appreciated - tnx in advance.

Wolfgang

==================================================================
Name    : Wolfgang Denk                         (+49)-89-68004-288
Company : PCS GmbH, Pfaelzer-Wald-Str. 36,  8000 Munich,  Germany.
UUCP    : ..[pyramid ;uunet!unido]!pcsbst!wd  (PYRAMID PREFERRED!!)
DOMAIN  : wd@pcsbst.pcs.[ COM From rest of world; DE From Europe ]
###################################################################
#  "UNIX was not designed to stop you from doing stupid things,   #
#   because that would  also stop you from doing clever things."  #
#   -- Doug Gwyn                                                  #
###################################################################
Technical Details
Message-ID: <wd.697109471@tukan>
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!heifetz!math.fu-berlin.de!unido!pcsbst!wd

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,ad36cb7725d24707,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-02-02 14:28:58 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!heifetz!math.fu-berlin.de!unido!pcsbst!wd
From: wd@pcsbst.pcs.com (wd)
Newsgroups: gnu.gcc.help
Subject: Help: GCC with register arguments - need advice
Summary: GCC with register arguments causes several problems
Keywords: GCC-1.40, register arguments, 68000
Message-ID: <wd.697109471@tukan>
Date: 3 Feb 92 09:31:11 GMT
Sender: @pcsbst.pcs.com
Organization: PCS Computer Systeme GmbH
Lines: 107