This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Refine when bitfield operations are used
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Apr 03 17:35:34 EDT
- Subject: Refine when bitfield operations are used
This fixes the following Ada testcase and was tested on i686-pc-linux-gnu.
with Tcis_Comms_Definitions;
with Standard_Types;
with Text_Io;
procedure Testit is
use Standard_Types;
Rcvd_Sn : Standard_Types.Std_Integer := 0;
Received_Msg : Tcis_Comms_Definitions.Tcis_Record_Type
(Tcis_Comms_Definitions.Ifs_Data_Message_Indication);
function To_Try_Serial_Number (Number : in Standard_Types.Byte)
return Standard_Types.Std_Integer is
use Standard_Types; --Import operators
Base_Num : constant := Character'Pos ('0');
--Binary value of Ascii ZERO
begin
--> Convert the serial number from Ascii to Binary
return Standard_Types.Std_Integer (Number - Base_Num);
end To_Try_Serial_Number;
pragma Inline (To_Try_Serial_Number);
subtype Plain_Std_String is Standard_Types.Std_String;
Xyz : Plain_Std_String := "01";
begin
Received_Msg.Data_Message_Rxsn := "01";
Text_Io.Put_Line ("The following 2 lines is what is supposed to be printed");
Text_Io.Put_Line (Integer'Image (Character'Pos (Xyz (1))));
Text_Io.Put_Line (Integer'Image (Character'Pos (Xyz (2))));
Text_Io.New_Line;
Text_Io.Put_Line
("The following is what is actually printed out when extracted");
Text_Io.Put_Line (" from the variant record:");
Text_Io.Put_Line (Integer'Image (Character'Pos
(Received_Msg.Data_Message_Rxsn (1))));
Text_Io.Put_Line (Integer'Image (Character'Pos
(Received_Msg.Data_Message_Rxsn (2))));
Rcvd_Sn := (To_Try_Serial_Number
(Number => Character'Pos
(Received_Msg.Data_Message_Rxsn (1))) * 10) +
To_Try_Serial_Number
(Number => Character'Pos (Received_Msg.Data_Message_Rxsn (2)));
end Testit;
2003-04-16 Olivier Hainque <hainque at act-europe dot fr>
* expr.c (store_field): Force usage of bitfield instructions when
the field position requires it, whatever SLOW_UNALIGNED_ACCESS.
(expand_expr, case BIT_FIELD_REF): likewise.
*** gcc/expr.c 14 Apr 2003 21:06:06 -0000 1.523
--- gcc/expr.c 15 Apr 2003 17:15:59 -0000
*************** store_field (target, bitsize, bitpos, mo
*** 5565,5570 ****
/* If the field isn't aligned enough to store as an ordinary memref,
store it as a bit field. */
! || (mode != BLKmode && SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (target))
! && (MEM_ALIGN (target) < GET_MODE_ALIGNMENT (mode)
|| bitpos % GET_MODE_ALIGNMENT (mode)))
/* If the RHS and field are a constant size and the size of the
--- 5565,5571 ----
/* If the field isn't aligned enough to store as an ordinary memref,
store it as a bit field. */
! || (mode != BLKmode
! && ((SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (target))
! && (MEM_ALIGN (target) < GET_MODE_ALIGNMENT (mode)))
|| bitpos % GET_MODE_ALIGNMENT (mode)))
/* If the RHS and field are a constant size and the size of the
*************** expand_expr (exp, target, tmode, modifie
*** 7505,7511 ****
fetch it as a bit field. */
|| (mode1 != BLKmode
! && SLOW_UNALIGNED_ACCESS (mode1, MEM_ALIGN (op0))
! && ((TYPE_ALIGN (TREE_TYPE (tem))
! < GET_MODE_ALIGNMENT (mode))
|| (bitpos % GET_MODE_ALIGNMENT (mode) != 0)))
/* If the type and the field are a constant size and the
--- 7506,7511 ----
fetch it as a bit field. */
|| (mode1 != BLKmode
! && ((TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode)
! && SLOW_UNALIGNED_ACCESS (mode1, MEM_ALIGN (op0)))
|| (bitpos % GET_MODE_ALIGNMENT (mode) != 0)))
/* If the type and the field are a constant size and the