public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC] Gcc and harvard architectures (towards AVR)
@ 2002-12-17  9:57 Svein E. Seldal
  2002-12-17 12:23 ` Denis Chertykov
  2002-12-24  2:21 ` [RFC] Gcc and multiple memory spaces (former Gcc and harvard architectures (towards AVR)) Svein E. Seldal
  0 siblings, 2 replies; 6+ messages in thread
From: Svein E. Seldal @ 2002-12-17  9:57 UTC (permalink / raw)
  To: gcc

Hello,

How are Harvard architectures handled in gcc? Let me take you in on a 
little discussion:

Lets imagine a processor which have more than one address-spaces (thus 
the architecture type Harvard). In most processors we are talking about 
code-space and data-space, but there might as well be more. These CPU's 
have a set of operators to access the data-space and another set of 
operators to access the code-space. CPU's like microcontrollers and 
high-performance DSP's are typical users of this architecture because it 
yields high data throughput. Because the application data and the 
program code is transferred simetaneously on separate internal buses.

One example of this is the AVR processors. This architecture has two 
memory spaces; .text and .data. A typical AVR har plenty of flash 
(.text) but virtually no memory (.data + .bss). An application must use 
separate addressing/opcodes for accessing data from the memory than from 
flash.

The problem arises when using the avr-gcc compiler. It places (const) 
string tables, const structs etc, into the .data segment (even those 
defined as const). As you probably can understand, this memory is 
starved pretty quick.

I guess the main reason behind this method is because gcc has no way of 
knowing when to use the flash-accessing addressing from the 
data-accessing addressing, thus all data is placed into the data segment.

There are attributes for placing data into the .text section, but you 
have to manually write inline assembly for accessing the flash memory. 
This limit imposes several effects which makes the code far less 
efficient. (And error-prone.)

I've disussed this with the avr-maintainer, but he rejects this 
suggestion as this would require global gcc changes. (He also mentioned 
that Linus has asked for something similar.). So now I'm asking these 
questions in a global forum

- _does_ gcc support Harvard arch's at all?

- I will be surprised if there aren't other targets using Harvard 
architectures? How have they solved this problem?

My suggestion would be to place all initialized const variables into a 
.const section which in turn would be placed into flash. But for this to 
work properly, gcc must be able to identify pointers and accesses to the 
flash and use the correct addressing methods for that information. As 
stated earlier, data accesses and flash accesses are fundamentally 
different as seen from the targets opcodes.

I have a technical suggestion for how to implement this, but I would 
like to discuss the issue in a general basis before entering the 
detailed discussion.



Regards,
Svein Seldal

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

end of thread, other threads:[~2002-12-27 21:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-17  9:57 [RFC] Gcc and harvard architectures (towards AVR) Svein E. Seldal
2002-12-17 12:23 ` Denis Chertykov
2002-12-19  6:07   ` Svein E. Seldal
2002-12-19 22:47     ` Richard Henderson
2002-12-24  2:21 ` [RFC] Gcc and multiple memory spaces (former Gcc and harvard architectures (towards AVR)) Svein E. Seldal
2002-12-28  2:33   ` devik

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