From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17106 invoked by alias); 27 Jul 2011 12:45:36 -0000 Received: (qmail 17095 invoked by uid 22791); 27 Jul 2011 12:45:36 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_PG X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Jul 2011 12:45:19 +0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/49868] New: Implement named address space to place/access data in flash memory X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 27 Jul 2011 12:45:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg02338.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49868 Summary: Implement named address space to place/access data in flash memory Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: target AssignedTo: unassigned@gcc.gnu.org ReportedBy: gjl@gcc.gnu.org CC: eric.weddington@atmel.com Target: avr Created attachment 24841 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24841 Sample code to show usage of __pgm address space. AVR is Harvard architecture and it need special instructions to read data from flash (LPM) which are different to the instructions needed to read data from RAM. The address space is not linearized. Linearizing the address space at the compiler level is not really wanted because this would mean gread deal of overhead and incompatibility with current implementation. The current situation is this: To put data in flash storage (section .progmem.data) there is a decl attribute "progmem". To access the data, inline assembly is used, e.g. by means of pgm_read_* functions supplied by avr-libc. A Named Address Space enales to write type-safe code that is not cluttered up with inline assembly access functions all over the place. Moreover, some optimizations like PR49857 (Put constant switch-tables into flash) and PR43745 (Put VTABLES into flash) need named addresses to express the flash-access inside GCC.