Skip to contentSkip to conversation

How to emulate lw/sw instruction by lb/sb instruction

DISCUSSION [email protected] 3 participants 3 messages Sep 25, 2006 – Sep 27, 2006 1 message not in the archive MIPS

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Dear Kevin
Because there are some aligned instruction will load/store from/to
unaligned base address in some module,such as "lw t0,56(sp) ##sp is odd address"
that's why I want some special version GCC can avoid generating load/store 4 bytes opcode,then I can use this "GCC" to compile specified module and linked with others,it will avoid unnecessary exception processing when these instruction to be invoked and come up with best performance for me. Regards
William Lei

|---------+---------------------------->
|         |           "Kevin D.        |
|         |           Kissell"         |
|         |           <[email protected]>|
|         |                            |
|         |                            |
|         |           2006-09-25 16:42 |
|---------+---------------------------->
Quoted 1 line

------------------------------------------------------------------------------------------------------------------------------|

  |                                                                                                                              |
  |       To:       <[email protected]>, <[email protected]>                                                        |
  |       cc:                                                                                                                    |
  |       Subject:  Re: How to emulate lw/sw instruction by lb/sb instruction                                                    |
  >------------------------------------------------------------------------------------------------------------------------------|

The MIPS Linux kernel is capable of handling unalgined loads and stores in emulation. This is less efficient than synthesizing the word access out of byte or left/right load/store operations in-line, but it's only done when there really is an unaligned access, whereas forcing the compiler to synthesize *all* loads/stores adds that overhead even when the addresses are actually aligned.

Regards,

Kevin K.

----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Monday, September 25, 2006 2:41 AM
Subject: How to emulate lw/sw instruction by lb/sb instruction

Quoted 2 lines

Dear all
Could someone tell me how to modify GCC as titled?because we have

met

Quoted 11 lines

problem while porting some middleware,which will generate some lw/sw instruction to unaligned address,so I would modify GCC to not generate lw/sw instructions for this pieces code.
Regards
William Lei

************* Email Confidentiality Notice ********************

The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be

conveyed

Quoted 1 line

only to the designated recipient(s). Any use, dissemination,

distribution,

Quoted 3 lines

printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you

have

Quoted 8 lines

received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!

#2 lore raw
Quoted 3 lines · On Mon, 25 Sep 2006, [email protected] wrote:

Because there are some aligned instruction will load/store from/to
unaligned base address in some module,such as "lw t0,56(sp) ##sp is odd address"

Hmm, the stack at an odd address -- somebody must be in the hard joking
mood...

Maciej

#3 lore raw
In reply to [email protected]
Quoted 3 lines · On Mon, 2006-09-25 at 18:35 +0800, [email protected] wrote:

Because there are some aligned instruction will load/store from/to
unaligned base address in some module,such as "lw t0,56(sp) ##sp is odd address"

You are better off fixing your code. SP must always be aligned to an 8 byte boundary minimum, 16 bytes for the New ABIs.

Changing gcc would be difficult, and it isn't even clear if such a change can be made to work. If it is possible, the resulting code will likely be so bad as to be nearly useless.

Signature · 1 line
Jim Wilson, GNU Tools Support, http://www.specifix.com