public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@wasabisystems.com>
To: Peter Barada <peter@the-baradas.com>
Cc: nathan@codesourcery.com, richard.guenther@gmail.com,
	stevenb@suse.de, joseph@codesourcery.com, mark@codesourcery.com,
	gcc@gcc.gnu.org
Subject: Re: Compiler uses a lot of memory for large initialized arrays
Date: Thu, 02 Dec 2004 17:42:00 -0000	[thread overview]
Message-ID: <m3hdn4tx5f.fsf@gossamer.airs.com> (raw)
In-Reply-To: <20041202172949.9C1119842C@baradas.org>

Peter Barada <peter@the-baradas.com> writes:

> I was going to suggest using .org to go back and overwrite the
> previous value in the assembler code(since you can compute the offset
> quite easily, at least for arrays), but I see the GAS .org info page
> has the following:
> 
>   `.org' may only increase the location counter, or leave it
>   unchanged; you cannot use `.org' to move the location counter
>   backwards.
> 
>   Because `as' tries to assemble programs in one pass, NEW-LC may not
>   be undefined.  If you really detest this restriction we eagerly await
>   a chance to share your improved assembler.
> 
> So I have to ask how many GCC targets *don't* use GAS?  If that is
> very few(to none),  then perhaps the best solution is to look into
> modifying GAS to allow backward setting of .org, or is that an even
> bigger problem?

Having gas support going backward with .org would be doable, though
hardly simple.  gas is not really a one-pass assembler, not since 1990
or so; it stores all the assembled data in memory, and then writes it
out at the end of the assembly.  (On the other hand, gas is also not
really a two-pass assembler; it doesn't actually make another pass
over the input, except to write out the data.)

Backward .org could be supported with a new type of frag which
specified the exact offset to use.  When writing out that frag we
would then use that offset, instead of just keeping track of the
current offset as we do now.  Several places in the assembler would
need to be updated with information about the new frag type.  Probably
not much target dependent code would be involved.

We would have to permit general expressions in the .org, or else it
would be too hard for gcc to generate the correct expression.  That
is, gcc will want to generate ".org array + 10".  Since the data
following the .org can itself affect the placement of future symbols,
some expressions will not be resolvable.  Some attention would have to
be paid to defining what would be permitted, and handling failing
cases.  This becomes particularly complex when using a backward .org
in a code section for a target for which the assembler can relax
branches, such as the i386 (or, for that matter, the Coldfire).

There are certainly gcc targets which don't use gas, so any such
optimization would have to be made conditional on support within the
assembler.

Ian

  parent reply	other threads:[~2004-12-02 17:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-02 16:08 Ian Lance Taylor
2004-12-02 16:34 ` Joseph S. Myers
2004-12-02 17:03   ` Ian Lance Taylor
2004-12-02 17:05   ` Steven Bosscher
2004-12-02 17:12     ` Richard Guenther
2004-12-02 17:17       ` Nathan Sidwell
2004-12-02 17:29         ` Peter Barada
2004-12-02 17:39           ` Mark Mitchell
2004-12-02 17:42           ` Ian Lance Taylor [this message]
2004-12-02 17:49           ` Dave Korn
2004-12-02 17:36       ` Andreas Schwab
2004-12-02 18:18   ` Joe Buck
2004-12-02 18:23     ` Mark Mitchell
2004-12-02 17:31 ` Mark Mitchell
2004-12-02 17:33 ` Giovanni Bajo

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=m3hdn4tx5f.fsf@gossamer.airs.com \
    --to=ian@wasabisystems.com \
    --cc=gcc@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=mark@codesourcery.com \
    --cc=nathan@codesourcery.com \
    --cc=peter@the-baradas.com \
    --cc=richard.guenther@gmail.com \
    --cc=stevenb@suse.de \
    /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).