From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA37C3858002; Sat, 6 Mar 2021 20:15:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA37C3858002 From: "gcc at nothien dot uber.space" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99435] New: avr: incorrect I/O address ranges for some cores Date: Sat, 06 Mar 2021 20:15:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc at nothien dot uber.space X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Mar 2021 20:15:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99435 Bug ID: 99435 Summary: avr: incorrect I/O address ranges for some cores Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: gcc at nothien dot uber.space Target Milestone: --- The `io' and `io_low' attributes incorrectly report out-of-range addresses = when compiling for the ATmega32u4 (-mmcu=3Datmega32u4), on all GCC versions. In particular, on this core, the 'low' I/O address space (within which the instructions sbi, cbi, sbis, sbic, etc. can be used, in addition to memory reads/writes) is from 0x20 to 0x5F (inclusive; 64 bytes), and the 'high' I/O address space (which can only be accessed only using memory reads/writes) is from 0x60 to 0xFF (inclusive; 160 bytes). The datasheet for the ATmega32u4 (and the ATmega16u4), which discusses these ranges (see section 5), can be found at . Compiling, for example, the following (with `avr-gcc -Wall -Wextra -Wpedant= ic -Werror -mmcu=3Datmega32u4`): volatile uint8_t io_pllcsr __attribute__((io_low (0x49))); will fail with the error: "=E2=80=98io_low=E2=80=99 attribute address out o= f range", although this is a perfectly valid low I/O address on this platform. This error occurs because currently GCC assumes that the low I/O address sp= ace is from 0x20 to 0x3F and that the high I/O address space is from 0x40 to 0x= 5F.=20 These limits are hardcoded into the `low_io_address_operand', `high_io_address_operand', and `io_address_operand' predicates, defined at `gcc/config/avr/predicates.md'. This should be corrected by moving these values into the avr_arch structure, where they can be varied by platform. I will send in a patch for this shor= tly.=