public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Rask Ingemann Lambertsen <rask@sygehus.dk>
Cc: Uros Bizjak <ubizjak@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	        Jan Hubicka <jh@suse.cz>,
	Richard Kenner <kenner@vlsi1.ultra.nyu.edu>,
	        rridge@csclub.uwaterloo.ca
Subject: Re: New back end ia16: 16-bit Intel x86
Date: Tue, 21 Aug 2007 17:46:00 -0000	[thread overview]
Message-ID: <46CB248E.4010000@zytor.com> (raw)
In-Reply-To: <20070821142152.GO25795@sygehus.dk>

Rask Ingemann Lambertsen wrote:
> On Tue, Aug 21, 2007 at 01:45:35AM -0700, H. Peter Anvin wrote:
>> As an interesting mental exercise, I tried to see if I could get the
>> i386 backend to emit 16-bit code.  It now produces code for some very
>> simple functions, but I find myself getting stuck pretty hard on the
>> fact that the i386 backend seems to assume pretty hard that
>> word == Pmode == the width of a hard register, which is not true when
>> one wants to use 32-bit registers but have 16-bit addressing.
>>
>> Another problematic issue is that I haven't, at least, figured out any
>> way by which one can tell that only part of a register has been
>> clobbered by a function.  This means spilling 32-bit registers to the
>> stack every time, with extra 66 bytes.
> 
>    Ah yes, there was that little detail. And if you split up the registers,
> you would really have to audit the rest of the back end for assumptions that
> register size == word size. That's probably not worth it for your project.

More importantly, it violates the constraint of not destabilizing the
backend for non-16-bit code.  It probably also makes it slower, which is
another no-no.

At this point it is pretty clear that the 16-on-32 situation is pretty
different both from 16-on-16 and 32-on-32 as far as gcc is concerned.
Constructing a 16-on-32 backend from the ground up (with yours and DrV's
work as starting points) seems to be the probably the same amount of
work as modifying the i386 backend, but should result in a higher
confidence level, and doesn't have the risk of destabilize the singly
most intensively used backend in all of gcc.

>> This, in fact, was the
>> motivation for using HImode registers in DrV's port (there seems to be
>> some issues with that which we haven't figured out, but that's probably
>> just naïveté on our part.)
> 
>    If it's simply saving too many registers, I think that's not quite unusual.
> It sometimes happens with other back ends too.

It does that, but that's not the concern (that seems to be a result of
register renaming after pro- and epilogue generation.)

The issue, rather, is the following error, which I haven't figured out
the best way to address yet (mostly due to only running into it late
last week):

/home/hpa/kernel/test-gcc16/arch/i386/boot/video.c:461: internal
compiler error: in find_valid_class, at reload.c:699
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

It happens mostly when compiling code which has previously been built
with .code16gcc, so I'm using -mint32.

It looks like it calls find_valid_class with (outer=HImode,
inner=SImode, n=1), however:

/* Find the largest class which has at least one register valid in
   mode INNER, and which for every such register, that register number
   plus N is also valid in OUTER (if in range) and is cheap to move
   into REGNO.  Such a class must exist.  */

This does, however, cause trouble since we only allow SImode and HImode
values in even registers; the odd registers being the upper half of a
register.  Other than that, we're down to generating valid code for a
fair number of the things I throw at it.

There seems to be two possible ways of dealing with it: either figuring
out why it's asking (and correct the cause), or allowing gcc to put a
HImode value into the high half of a register during reload.

Oh, and switching to a proper flags register is high on the list.

	-hpa

  reply	other threads:[~2007-08-21 17:45 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-06 14:23 Uros Bizjak
2007-08-07  1:29 ` Rask Ingemann Lambertsen
2007-08-07 17:37   ` Daniel Jacobowitz
2007-08-07 20:03   ` Uros Bizjak
2007-08-08 12:21     ` Jan Hubicka
2007-08-08 17:30       ` Mark Mitchell
2007-08-08 23:22         ` Richard Kenner
2007-08-08 18:52       ` Rask Ingemann Lambertsen
2007-08-08 20:24         ` Michael Matz
2007-08-08 20:59         ` H.J. Lu
2007-08-08 22:46           ` DJ Delorie
2007-08-09  9:33         ` Jan Hubicka
2007-08-09 14:01           ` Rask Ingemann Lambertsen
2007-08-09 15:43           ` DJ Delorie
2007-08-08 15:28     ` Rask Ingemann Lambertsen
2007-08-17 22:38       ` H. Peter Anvin
2007-08-18  2:34         ` Rask Ingemann Lambertsen
2007-08-18  5:33           ` H. Peter Anvin
2007-08-18 17:36             ` Rask Ingemann Lambertsen
2007-08-18 17:50               ` H. Peter Anvin
2007-08-18 20:39                 ` Rask Ingemann Lambertsen
2007-08-19  2:11                   ` H. Peter Anvin
2007-08-19 12:25                     ` Rask Ingemann Lambertsen
2007-08-19 20:07                       ` H. Peter Anvin
2007-08-21  8:48                       ` H. Peter Anvin
2007-08-21 14:35                         ` Rask Ingemann Lambertsen
2007-08-21 17:46                           ` H. Peter Anvin [this message]
2007-08-21 18:56                             ` Real-mode i386 back end (Was: New back end ia16: 16-bit Intel x86) Rask Ingemann Lambertsen
2007-08-19  7:29                   ` New back end ia16: 16-bit Intel x86 H. Peter Anvin
2007-08-19 10:56                     ` Rask Ingemann Lambertsen
2007-08-19 21:40                       ` H. Peter Anvin
  -- strict thread matches above, loose matches on Subject: below --
2007-08-19 19:58 Ross Ridge
2007-08-19 16:11 Ross Ridge
2007-08-19 17:36 ` Rask Ingemann Lambertsen
2007-08-18 20:46 Ross Ridge
2007-08-19 16:20 ` Rask Ingemann Lambertsen
2007-08-02 20:15 Ross Ridge
2007-08-01 19:25 Ross Ridge
2007-08-01 22:57 ` Rask Ingemann Lambertsen
     [not found] <20070801153758.ACBB974253@caffeine.csclub.uwaterloo.ca.suse.lists.egcs-patches>
2007-08-01 17:44 ` Andi Kleen
2007-08-01 15:38 Ross Ridge
2007-08-01 17:59 ` Rask Ingemann Lambertsen
2007-07-31 18:06 Ross Ridge
2007-08-01  0:34 ` Rask Ingemann Lambertsen
2007-08-01  9:53   ` Richard Kenner
2007-08-01 12:33     ` Rask Ingemann Lambertsen
2007-08-01 12:44       ` Richard Kenner
2007-08-01 13:41         ` Rask Ingemann Lambertsen
2007-08-01 13:52           ` Richard Kenner
2007-08-01 10:38   ` Jan Hubicka
2007-08-01 17:30     ` Rask Ingemann Lambertsen
2007-07-31 15:24 Ross Ridge
2007-07-31 17:44 ` Michael Matz
2007-07-31  0:50 Ross Ridge
2007-07-31  8:54 ` Tristan Gingold
2007-07-31 13:46 ` Rask Ingemann Lambertsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46CB248E.4010000@zytor.com \
    --to=hpa@zytor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jh@suse.cz \
    --cc=kenner@vlsi1.ultra.nyu.edu \
    --cc=rask@sygehus.dk \
    --cc=rridge@csclub.uwaterloo.ca \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).