This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/15152] New: Gigi error on inlined asm code
- From: "rolf dot ebert dot gcc at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Apr 2004 15:35:41 -0000
- Subject: [Bug ada/15152] New: Gigi error on inlined asm code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code causes a bug box in gcc-3.4.0
with System.Machine_Code; use System.Machine_Code;
with Interfaces; use Interfaces;
procedure Bug_nest is
procedure Wait_4_Cycles(Count : Unsigned_16);
pragma Inline_Always (Wait_4_Cycles);
procedure Wait_4_Cycles(Count : Unsigned_16) is
Cnt : Unsigned_16 := Count;
begin
if Count > 0 then
Asm("1: sbiw %0,1" & ASCII.LF &
"brne 1b",
Outputs => Unsigned_16'Asm_Output("=w", Cnt),
Inputs => Unsigned_16'Asm_Input("0", Cnt),
Volatile => True);
-- This statements work correctly in gcc-3.4
-- Asm("1: sbiw %0,1" & ASCII.LF &
-- "brne 1b",
-- Inputs => Unsigned_16'Asm_Input("w", Cnt),
-- Volatile => True);
end if;
end Wait_4_Cycles;
-- at 4MHz 4 cycles are 1 micro second
procedure Wait_10ms is
T : constant Unsigned_16 := 10000;
begin
Wait_4_Cycles(T);
end Wait_10ms;
begin
null;
end Bug_Nest;
-- re@pd3:~/devel/examples/bug_nest$ avr-gcc -Os -gnatG -S --RTS=rts
-mmcu=at90s8515 bug_nest.adb
-- Source recreated from tree for Bug_Nest (body)
-- ----------------------------------------------
-- with system;
-- with system.system__machine_code;
-- use system.system__machine_code;
-- with interfaces;
-- use interfaces;
-- with system.system__machine_code;
-- with system.system__storage_elements;
-- procedure bug_nest is
-- procedure bug_nest__wait_4_cycles (count : interfaces__unsigned_16);
-- pragma inline_always (bug_nest__wait_4_cycles);
-- procedure bug_nest__wait_4_cycles (count : interfaces__unsigned_16) is
-- cnt : interfaces__unsigned_16 := count;
-- begin
-- if count > 0 then
-- system__machine_code__asm_insn'(
-- asm ("1: sbiw %0,1["0a"]brne 1b", outputs =>
-- interfaces__unsigned_16'asm_output("=w", cnt), inputs =>
-- interfaces__unsigned_16'asm_input("0", cnt), volatile =>
-- true, clobber => ""););
-- end if;
-- return;
-- end bug_nest__wait_4_cycles;
-- procedure bug_nest__wait_10ms is
-- begin
-- B8b : declare
-- cnt : interfaces__unsigned_16 := 10000;
-- begin
-- system__machine_code__asm_insn'(
-- asm ("1: sbiw %0,1["0a"]brne 1b", outputs =>
-- interfaces__unsigned_16'asm_output("=w", 10000), inputs =>
-- interfaces__unsigned_16'asm_input("0", 10000), volatile =>
-- true, clobber => ""););
-- end B8b;
-- return;
-- end bug_nest__wait_10ms;
-- begin
-- null;
-- return;
-- end bug_nest;
-- +===========================GNAT BUG DETECTED==============================+
-- | 3.4.0 (avr-unknown-none) Gigi abort, Code=516 |
-- | No source file position information available |
-- | Please submit a bug report; see http://gcc.gnu.org/bugs.html. |
-- | Include the entire contents of this bug box in the report. |
-- | Include the exact gcc or gnatmake command that you entered. |
-- | Also include sources listed below in gnatchop format |
-- | (concatenated together with no headers between files). |
-- +==========================================================================+
-- Please include these source files with error report
-- Note that list may not be accurate in some cases,
-- so please double check that the problem can still
-- be reproduced with the set of files listed.
-- bug_nest.adb
--------------------------------------------------------------------
As one can see, the constant 10000 is directly sent to the input and the output
parameter of the assembler statement despite the intermediate variable Cnt.
The constraint "w" is AVR specific (I think) and refers to register pairs r24,
r26, r28 (for 16Bit values)
This is a gegression against gcc-3.3.x
I can provide the necessary RTS files (system.ads, interfac.ads, etc.) if there
is any need.
--
Summary: Gigi error on inlined asm code
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rolf dot ebert dot gcc at gmx dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: linux-x86
GCC target triplet: avr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15152