public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: MIPS16 -mentry pseudo instruction definitions
@ 1999-09-13  5:53 Andre McCurdy
  1999-09-13  8:52 ` Rask Ingemann Lambertsen
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Andre McCurdy @ 1999-09-13  5:53 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc

--- Jim Wilson <wilson@cygnus.com> wrote:
> The file libgloss/mips/entry.S contains an
> implementation of entry/exit
> trap handlers for mips16.  This is the best
> documentation that I am aware of.
> 
> You can find a copy of this file in the newlib-1.8.1
> release available from
> the sourceware.cygnus.com ftp site.
> 

After a quick look at this code, i believe there may
be a bug in the handling of entry instructions - the
handler returns to EPC (ie the address of the entry
instruction) rather than EPC+2, which will result in
an infinite loop.
Has anyone ever used this code ??

Aside from this possible bug, there are no comments
which give a clue as to why the stack frame size is
fixed at 32bytes, which is the question which really
bothers me.

Is there any way of tracking down when the -mentry
option became part of gcc (and where the code come
from) ?

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: MIPS16 -mentry pseudo instruction definitions
@ 1999-09-14  7:07 Andre McCurdy
  1999-09-30 18:02 ` Andre McCurdy
  0 siblings, 1 reply; 20+ messages in thread
From: Andre McCurdy @ 1999-09-14  7:07 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc

--- Jim Wilson <wilson@cygnus.com> wrote:
> > Aside from this possible bug, there are no
comments
> > which give a clue as to why the stack frame size
is
> > fixed at 32bytes, which is the question which
really
> > bothers me.
> 
> Probably it was just chosen as a convenient number.
entry has to
> allocate some amount of stack space, and there is no
opcode space to
> encode the amount, so someone picked a number that
seemed right.  Big
> enough to satisfy most frames, but not too big that
it would waste too > much stack space.

I don't think this is true.
If you assume compatability with the o32 abi, then 4
words of stack are needed for any callee to save its
parameters, but any other requirement (ie for ra, s0
and s1) is encoded within BOTH the entry/exit
instructions and therefore could be allocated (and
de-allocated again on the way back out) as required
within the trap handler.

For most embedded systems (certainly in my case), the
advantage of an (order of) 5 percent gain in code
density when using the -mentry option over standard
mips16 code is more than outweighed by the
disadvantage of increased RAM requirements. (Maybe
this problem explains why no obvious interest seems to
have been taken in this option thoughout the
development of egcs).

Anyway, thats enough complaining.
Is there anyone out there with enough knowledge of the
workings of mips.c who could take a look at this (or
even just give some pointers so a gcc newbie like me
could have a go) ?
I'm willing to do some testing and to write and test a
new entry.S trap handler.


> The gcc code supporting -mentry was originally
written by Ian
> Taylor, but he isn't at Cygnus anymore either,
though he is reachable
> by mail.

Could you forward this post to him please ? Maybe he
can shed some light on why the original choice was
made.



____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: MIPS16 -mentry pseudo instruction definitions
@ 1999-09-10  8:21 Andre McCurdy
  1999-09-10 11:57 ` Jim Wilson
  1999-09-30 18:02 ` Andre McCurdy
  0 siblings, 2 replies; 20+ messages in thread
From: Andre McCurdy @ 1999-09-10  8:21 UTC (permalink / raw)
  To: gcc; +Cc: law, rth

The mips16 ISA makes no mention of the entry/exit
pseudo instructions. (Thanks to Richard Henderson for
the reference).

I guess I'll have to jump straight in with my real
question...

As I understand from the comments in the 'mips.c'
source, it seems that the compiler expects the
implementation of the entry instruction (ie a trap
handler), to grow the stack by the fixed amount of
32bytes (exit does the same in reverse on the way back
out). ie:

+-----------------------+
| ra if required        |
| s0 if required        |
| s1 if required        |
| (always wasted)       |
+-----------------------+
|  4 words to save      |
|  arguments passed     |
|  in registers, even   |
|  if not passed.       | <- sp after 'entry'
+-----------------------+

(any of the a0..a3 registers that require stacking are
put in space reserved in the caller's stack frame as
normal).

Assuming a 32bit target where the stack pointer can be
aligned on any 4byte boundary, it seems that between 4
and 24 bytes of stack space are wasted (or upto 32 if
used on a leaf function where ra doesn't need saving)
by having this simple 'always grow by 32bytes'
algorithm.

Does anyone know why this is the case ? Is there any
reason why 'compute_frame_size()' can't calculate the
exact value depending on which of ra, s0 and s1 need
stacking on a function by function basis ?

(I'd like to be able to try and fix this myself but as
I've never tried hacking gcc before, I'd like to get
as much background as possible on why its been done
the way it is :-).


Andre
--

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: MIPS16 -mentry pseudo instruction definitions
@ 1999-09-09  7:06 Andre McCurdy
  1999-09-09 14:42 ` Richard Henderson
  1999-09-30 18:02 ` Andre McCurdy
  0 siblings, 2 replies; 20+ messages in thread
From: Andre McCurdy @ 1999-09-09  7:06 UTC (permalink / raw)
  To: law; +Cc: gcc

--- Jeffrey A Law <law@cygnus.com> wrote:
> 
>   In message
>
< 19990908183055.2659.rocketmail@web601.yahoomail.com >you
> write:
>   > Does anyone have a description of exactly what
> the
>   > 'entry' and 'exit' pseudo instructions
> (generated with
>   > the -mips16 -mentry options for MIPS targets)
> require
>   > of a trap exception handler in order for them to
> be
>   > used ?
>   > 
>   > Is there are formal definition somewhere
> describing
>   > what they do ?
> I would check the mips16 ISA.  
> 
> jeff
> 

Do you have a URL for such a document ?

Actually, although I haven't seen an official mip16
ISA spec, I thought the entry/exit pseudo instructions
were a Cygnus and/or gcc addition rather than being
part of the spec ??

Andre
--
____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

^ permalink raw reply	[flat|nested] 20+ messages in thread
* MIPS16 -mentry pseudo instruction definitions
@ 1999-09-08 11:33 Andre McCurdy
  1999-09-08 14:05 ` Jeffrey A Law
  1999-09-30 18:02 ` Andre McCurdy
  0 siblings, 2 replies; 20+ messages in thread
From: Andre McCurdy @ 1999-09-08 11:33 UTC (permalink / raw)
  To: gcc

Does anyone have a description of exactly what the
'entry' and 'exit' pseudo instructions (generated with
the -mips16 -mentry options for MIPS targets) require
of a trap exception handler in order for them to be
used ?

Is there are formal definition somewhere describing
what they do ?

Thanks

Andre
--

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~1999-09-30 18:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-13  5:53 MIPS16 -mentry pseudo instruction definitions Andre McCurdy
1999-09-13  8:52 ` Rask Ingemann Lambertsen
1999-09-30 18:02   ` Rask Ingemann Lambertsen
1999-09-13 12:32 ` Jim Wilson
1999-09-30 18:02   ` Jim Wilson
1999-09-30 18:02 ` Andre McCurdy
  -- strict thread matches above, loose matches on Subject: below --
1999-09-14  7:07 Andre McCurdy
1999-09-30 18:02 ` Andre McCurdy
1999-09-10  8:21 Andre McCurdy
1999-09-10 11:57 ` Jim Wilson
1999-09-30 18:02   ` Jim Wilson
1999-09-30 18:02 ` Andre McCurdy
1999-09-09  7:06 Andre McCurdy
1999-09-09 14:42 ` Richard Henderson
1999-09-30 18:02   ` Richard Henderson
1999-09-30 18:02 ` Andre McCurdy
1999-09-08 11:33 Andre McCurdy
1999-09-08 14:05 ` Jeffrey A Law
1999-09-30 18:02   ` Jeffrey A Law
1999-09-30 18:02 ` Andre McCurdy

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).