🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49954

GCC for a MIPS with 64 general purpose registers

#49954
From: Marc Shapiro
Date: Tue, 30 Nov 1993 16:37
99 lines
4599 bytes
Hi.

I'm trying to minimally modify gcc to generate assembler code for a MIPS-like
machine.  I want it to differ from a MIPS only in the number of registers
it has (namely 64 general purpose, and 64 floating point, versus 32).

I changed config/mips/mips.h to have constants like
#define FIRST_PSEUDO_REGISTER 131
#define FP_REG_FIRST 64
and so on, and made the obvious things bigger, like
#define REG_CLASS_CONTENTS                                        \
{                                                                 \
  { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },/* no reg */\
  { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000 }, /* int */  \
  { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000 }, /* float */ \
...
and
#define DEBUG_REGISTER_NAMES						\
{									\
  "$0",   "at",   "v0",   "v1",   "a0",   "a1",   "a2",   "a3",		\
  "t0",   "t1",   "t2",   "t3",   "t4",   "t5",   "t6",   "t7",		\
  "s0",   "s1",   "s2",   "s3",   "s4",   "s5",   "s6",   "s7",		\
  "t8",   "t9",   "k0",   "k1",   "gp",   "sp",   "$fp",   "ra",	\
  "$32",  "$33",  "$34",  "$35",  "$36",  "$37",  "$38",  "$39",        \
  "$40",  "$41",  "$42",  "$43",  "$44",  "$45",  "$46",  "$47",        \
  "$48",  "$49",  "$50",  "$51",  "$52",  "$53",  "$54",  "$55",        \
  "$56",  "$57",  "$58",  "$59",  "$60",  "$61",  "$62",  "$63",        \
  "$f0",  "$f1",  "$f2",  "$f3",  "$f4",  "$f5",  "$f6",  "$f7",	\
  "$f8",  "$f9",  "$f10", "$f11", "$f12", "$f13", "$f14", "$f15",	\
  "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23",	\
  "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31",	\
  "$f32", "$f33", "$f34", "$f35", "$f36", "$f37", "$f38", "$f39",       \
  "$f40", "f$41", "$f42", "$f43", "$f44", "$f45", "$f46", "$f47",       \
  "$f48", "f$49", "$f50", "$f51", "$f52", "$f53", "$f54", "$f55",       \
  "$f56", "f$57", "$f58", "$f59", "$f60", "$f61", "$f62", "$f63",       \
  "hi",   "lo",   "$fcr31"						\
}


I similarly modified the obvious parts of config/mips/mips.c.

I was hoping that this would be sufficient to generate assembler code,
but there seem to be some problems.

When I compile with -O, I get an internal error:

monty[27]% bin/gcc6 -O -g -S t2.c
t2.c: In function `main':
t2.c:64: internal error--insn does not satisfy its constraints:
(insn 500 499 121 (set (reg/v:SI 23 s7)
        (reg:SI 65 $f1)) 89 {movsi_internal2} (nil)
    (nil))
gcc6: Internal compiler error: program cc1 got fatal signal 4
2.0u 0.8s 0:15 18% 2017+1268k 18+16io 160pf+0w
monty[28]% 


When I compile without -O (eg, with just -g -S), I get a .s file,
but even a trivial program isn't the same as on the unmodified MIPS.
In particular, extra registers are saved in functions:

monty[42]% bin/gcc5 -g -S t3.c; mv t3.s t3.5.s
monty[43]% bin/gcc6 -g -S t3.c; mv t3.s t3.6.s
monty[44]% diff t3.5.s t3.6.s
24,25c24,27
<       sw      $31,36($sp)
<       sw      $fp,32($sp)
---
>       sw      $63,36($sp)
>       sw      $62,32($sp)
>       sw      $31,28($sp)
>       sw      $fp,24($sp)
55,56c57,60
<       lw      $31,36($sp)
<       lw      $fp,32($sp)
---
>       lw      $63,36($sp)
>       lw      $62,32($sp)
>       lw      $31,28($sp)
>       lw      $fp,24($sp)
monty[45]% 

Can anyone suggest less obvious (to me, anyway) changes that I need to
make to get this to work?  Do I have to make any major changes to anything
besides mips.c and mips.h?

Many thanks.

			Marc Shapiro

By the way, I compiled these like a cross-compiler, although I'm 
using a DECstation.
monty[49]% m config.status
#!/bin/sh
# GCC was configured as follows:
./configure --host=mips-dec-ultrix --target=mips-local6 --prefix=/var/home/mds/7
52p/local --local-prefix=/var/home/mds/752p/local/local
echo host=mips-dec-ultrix target=mips-local6 build=mips-dec-ultrix
monty[50]% 
Technical Details
Message-ID: <mds.754677430@cs.wisc.edu>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!daffy!uwvax!cs.wisc.edu!mds

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,f81bda1791d334df,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-11-30 17:36:45 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!daffy!uwvax!cs.wisc.edu!mds
From: mds@monty.cs.wisc.edu (Marc Shapiro)
Subject: GCC for a MIPS with 64 general purpose registers
Message-ID: <mds.754677430@cs.wisc.edu>
Summary: I'm having problems modifying GCC slightly
Keywords: GCC, MIPS
Sender: news@cs.wisc.edu (The News)
Organization: U of Wisconsin Madison - Computer Sciences
Date: Tue, 30 Nov 1993 16:37:10 GMT
Lines: 100