Commit da19297d by Olivier Hainque Committed by Olivier Hainque

expr.c (expand_expr_real_1): Force op0 to memory if the component is to be…

expr.c (expand_expr_real_1): Force op0 to memory if the component is to be referenced in BLKmode according...

        * expr.c (expand_expr_real_1) <normal_inner_ref>: Force op0 to
        memory if the component is to be referenced in BLKmode according
        to get_inner_reference.

        testsuite/
        * gnat.dg/blkextract_from_reg.adb: New test.

From-SVN: r135296
parent 1fd03c70
2008-05-14 Olivier Hainque <hainque@adacore.com>
* expr.c (expand_expr_real_1) <normal_inner_ref>: Force op0 to
memory if the component is to be referenced in BLKmode according
to get_inner_reference.
2008-05-14 Adam Nemet <anemet@caviumnetworks.com> 2008-05-14 Adam Nemet <anemet@caviumnetworks.com>
* calls.c (emit_library_call_value_1): Restore code clearing * calls.c (emit_library_call_value_1): Restore code clearing
......
...@@ -7739,13 +7739,15 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, ...@@ -7739,13 +7739,15 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
/* If this is a constant, put it into a register if it is a legitimate /* If this is a constant, put it into a register if it is a legitimate
constant, OFFSET is 0, and we won't try to extract outside the constant, OFFSET is 0, and we won't try to extract outside the
register (in case we were passed a partially uninitialized object register (in case we were passed a partially uninitialized object
or a view_conversion to a larger size). Force the constant to or a view_conversion to a larger size) or a BLKmode piece of it
memory otherwise. */ (e.g. if it is unchecked-converted to a record type in Ada). Force
the constant to memory otherwise. */
if (CONSTANT_P (op0)) if (CONSTANT_P (op0))
{ {
enum machine_mode mode = TYPE_MODE (TREE_TYPE (tem)); enum machine_mode mode = TYPE_MODE (TREE_TYPE (tem));
if (mode != BLKmode && LEGITIMATE_CONSTANT_P (op0) if (mode != BLKmode && LEGITIMATE_CONSTANT_P (op0)
&& offset == 0 && offset == 0
&& mode1 != BLKmode
&& bitpos + bitsize <= GET_MODE_BITSIZE (mode)) && bitpos + bitsize <= GET_MODE_BITSIZE (mode))
op0 = force_reg (mode, op0); op0 = force_reg (mode, op0);
else else
...@@ -7759,8 +7761,9 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, ...@@ -7759,8 +7761,9 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
for an ARRAY_RANGE_REF whose type is BLKmode. */ for an ARRAY_RANGE_REF whose type is BLKmode. */
else if (!MEM_P (op0) else if (!MEM_P (op0)
&& (offset != 0 && (offset != 0
|| (bitpos + bitsize > GET_MODE_BITSIZE (GET_MODE (op0))) || mode1 == BLKmode
|| (code == ARRAY_RANGE_REF && mode == BLKmode))) || (bitpos + bitsize
> GET_MODE_BITSIZE (GET_MODE (op0)))))
{ {
tree nt = build_qualified_type (TREE_TYPE (tem), tree nt = build_qualified_type (TREE_TYPE (tem),
(TYPE_QUALS (TREE_TYPE (tem)) (TYPE_QUALS (TREE_TYPE (tem))
......
2008-05-14 Olivier Hainque <hainque@adacore.com>
* gnat.dg/blkextract_from_reg.adb: New test.
2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/36215 PR fortran/36215
-- { dg-do run }
with System, Ada.Unchecked_Conversion; use System;
procedure BLKextract_From_Reg is
type Byte is range 0 .. +255;
for Byte'size use 8;
type RGB is array (1 .. 3) of Byte;
for RGB'Size use 24;
type RAW_Packet is range 0 .. 2 ** 32 - 1;
for RAW_Packet'Size use 32;
type Composite_Packet is record
Values : RGB;
Pad : Byte;
end record;
for Composite_Packet use record
Values at 0 range 0 .. 23;
Pad at 3 range 0 .. 7;
end record;
for Composite_Packet'Size use 32;
function To_Composite_Packet is
new Ada.Unchecked_Conversion (RAW_Packet, Composite_Packet);
function Blob return RGB is
RAW_Blob : RAW_Packet := 16#01020304#;
begin
return To_Composite_Packet (RAW_Blob).Values;
end;
Blob_Color : RGB := Blob;
Expected_Color : RGB;
begin
if System.Default_Bit_Order = High_Order_First then
Expected_Color := (1 => 1, 2 => 2, 3 => 3);
else
Expected_Color := (1 => 4, 2 => 3, 3 => 2);
end if;
for I in Blob_Color'Range loop
if Blob_Color (I) /= Expected_Color (I) then
raise Program_Error;
end if;
end loop;
end;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment