public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Torbjörn Lindh <toobii@gopta.se>
To: gcc@gcc.gnu.org
Subject: H8300H Tiny
Date: Sat, 10 Aug 2002 12:09:00 -0000	[thread overview]
Message-ID: <Pine.LNX.3.91.1020810210836.7852B-100000@samuraj.c3l.tyreso.se> (raw)

Hitachi have generated a number of so called Tiny H8:s, for instance the 
H8/3664F. These have an h8300h cpu but are limited to a 64k address 
space.

The problem with gcc-3.1 (and as far as I can see, the current cvs version
too) is that if I use h8300 mode, I don't take advantage of the added
instructions, adressing modes etc of the h8300h cpu. But if I use the
h8300h mode the addressing gets far to long: 

	subs	#0x4,er7
	mov.l	er7,@-er7

should really be

	subs	#0x4,er7
	mov.w	r7,@er7

and a piece of code such as:

unsigned char a[5];

void f(void)
{
  unsigned char i;

  i = 0;
  while (i < 5) {
    if (a[i])
      whatever();
    i++;
  }
}

generates

	sub.b  r3l,r3l
l0	mov.b  r3l,r2l
	extu.w r2
	mov.w  r2,r0
	extu.l er0
	mov.l  er0,er1
	add.l  #0xfffbd8,er1
	mov.b  @er1,r2l
	beq    l1
	jsr    @whatever
l1	add.b  #0x1,r3l
	cmp.b  #0x5,r3l
	bls	l0

whereas I would prefer

        sub.b  r3l,r3l
l0      mov.b  r3l,r2l
        extu.w r2   
        mov.w  r2,r0
        mov.w  r0,r1
        add.w  #0xfbd8,r1	* Changed
        mov.b  @er1,r2l
        beq    l1   
        ...
l1      add.b  #0x1,r3l
        cmp.b  #0x5,r3l
        bls     l0

(or maybe even save a few register moves, but that is beyond this scope).

This might not seem like a big difference, but when you only have 32k for
your code, every wasted word is bad.

I have looked at the code, and one possible way seems to be to define a 
new target that differs slightly from the h8300h target.

Does anyone have alternative suggestions how I should go about this? 


             reply	other threads:[~2002-08-10 12:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-10 12:09 Torbjörn Lindh [this message]
2002-08-12 15:12 ` Jeff Law
2002-08-13 12:29   ` Torbjörn Lindh
2002-08-14  8:05     ` Jeff Law

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=Pine.LNX.3.91.1020810210836.7852B-100000@samuraj.c3l.tyreso.se \
    --to=toobii@gopta.se \
    --cc=gcc@gcc.gnu.org \
    /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).