From 1c49a3ed0c29e904916d794f34364dee95791297 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Thu, 7 Sep 2017 15:53:09 +0000 Subject: [PATCH] re PR bootstrap/80897 (gnat bootstrap broken on SPARC64/Linux) PR target/80897 * config/sparc/sparc.c (sparc_emit_set_symbolic_const64): Deal with too large offsets. From-SVN: r251847 --- gcc/ChangeLog | 9 +++++++- gcc/config/sparc/sparc.c | 18 ++++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/opt67.adb | 35 +++++++++++++++++++++++++++++ gcc/testsuite/gnat.dg/opt67_pkg.adb | 29 ++++++++++++++++++++++++ gcc/testsuite/gnat.dg/opt67_pkg.ads | 28 +++++++++++++++++++++++ 6 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/opt67.adb create mode 100644 gcc/testsuite/gnat.dg/opt67_pkg.adb create mode 100644 gcc/testsuite/gnat.dg/opt67_pkg.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 138a776d39f..a58252e5c79 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,13 @@ +2017-09-07 Eric Botcazou + + PR target/80897 + * config/sparc/sparc.c (sparc_emit_set_symbolic_const64): Deal with too + large offsets. + 2017-09-07 Carl Love - * config/rs6000/vsx.md (define_insn "*stxvl"): Add missing argument to the sldi instruction. + * config/rs6000/vsx.md (define_insn "*stxvl"): Add missing argument to + the sldi instruction. 2017-09-07 David Edelsohn diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 3a532e580c6..9fe89c08d11 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -2159,9 +2159,25 @@ sparc_emit_set_const32 (rtx op0, rtx op1) void sparc_emit_set_symbolic_const64 (rtx op0, rtx op1, rtx temp) { - rtx temp1, temp2, temp3, temp4, temp5; + rtx cst, temp1, temp2, temp3, temp4, temp5; rtx ti_temp = 0; + /* Deal with too large offsets. */ + if (GET_CODE (op1) == CONST + && GET_CODE (XEXP (op1, 0)) == PLUS + && CONST_INT_P (cst = XEXP (XEXP (op1, 0), 1)) + && trunc_int_for_mode (INTVAL (cst), SImode) != INTVAL (cst)) + { + gcc_assert (!temp); + temp1 = gen_reg_rtx (DImode); + temp2 = gen_reg_rtx (DImode); + sparc_emit_set_const64 (temp2, cst); + sparc_emit_set_symbolic_const64 (temp1, XEXP (XEXP (op1, 0), 0), + NULL_RTX); + emit_insn (gen_rtx_SET (op0, gen_rtx_PLUS (DImode, temp1, temp2))); + return; + } + if (temp && GET_MODE (temp) == TImode) { ti_temp = temp; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1080030cf5f..2ef3b167216 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-07 Eric Botcazou + + * gnat.dg/opt67.adb: New test. + * gnat.dg/opt67_pkg.ad[sb]: New helper. + 2017-09-07 Jakub Jelinek PR target/81979 diff --git a/gcc/testsuite/gnat.dg/opt67.adb b/gcc/testsuite/gnat.dg/opt67.adb new file mode 100644 index 00000000000..20590d17ad0 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt67.adb @@ -0,0 +1,35 @@ +-- { dg-do run } +-- { dg-options "-O" } + +with Opt67_Pkg; use Opt67_Pkg; + +procedure Opt67 is + + function Predef_Stream_Attr_Spec + (Loc : Source_Ptr; + Tag_Typ : Entity_Id; + Name : TSS_Name_Type) return Node_Id is + begin + return Predef (Loc, Make_TSS_Name (Tag_Typ, Name), Tag_Typ); + end; + + Stream_Op_TSS_Names : + constant array (Integer range <>) of TSS_Name_Type := + (TSS_Stream_Read, + TSS_Stream_Write, + TSS_Stream_Input, + TSS_Stream_Output); + + Tag_Typ : constant Entity_Id := Entity_Id(Init); + Res : constant Natural := Init; + Loc : constant Source_Ptr := Source_Ptr(Init); + +begin + for Op in Stream_Op_TSS_Names'Range loop + if Stream_Operation_OK (Tag_Typ, Stream_Op_TSS_Names (Op)) then + Append_To (Res, + Predef_Stream_Attr_Spec (Loc, Tag_Typ, + Stream_Op_TSS_Names (Op))); + end if; + end loop; +end; diff --git a/gcc/testsuite/gnat.dg/opt67_pkg.adb b/gcc/testsuite/gnat.dg/opt67_pkg.adb new file mode 100644 index 00000000000..4222531dd83 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt67_pkg.adb @@ -0,0 +1,29 @@ +package body Opt67_Pkg is + + function Make_TSS_Name (Typ : Entity_Id; Nam : TNT) return Name_Id is + begin + return 0; + end; + + function Stream_Operation_OK (N : Entity_Id; Name : TNT) return Boolean is + begin + return True; + end; + + procedure Append_To (N1 : Natural; N2 : Node_Id) is + begin + null; + end; + + function Predef (Loc : Source_Ptr; Name : Name_Id; E : Entity_Id) + return Node_Id is + begin + return 0; + end; + + function Init return Natural is + begin + return 0; + end; + +end Opt67_Pkg; diff --git a/gcc/testsuite/gnat.dg/opt67_pkg.ads b/gcc/testsuite/gnat.dg/opt67_pkg.ads new file mode 100644 index 00000000000..c2533716736 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt67_pkg.ads @@ -0,0 +1,28 @@ +package Opt67_Pkg is + + type Source_Ptr is new Natural; + type Entity_Id is new Natural; + type Node_Id is new Natural; + type Name_Id is new Natural; + + type TSS_Name_Type is new String (1 .. 2); + subtype TNT is TSS_Name_Type; + + TSS_Stream_Input : constant TNT := "SI"; + TSS_Stream_Output : constant TNT := "SO"; + TSS_Stream_Read : constant TNT := "SR"; + TSS_Stream_Write : constant TNT := "SW"; + TSS_To_Any : constant TNT := "TA"; + + function Make_TSS_Name (Typ : Entity_Id; Nam : TSS_Name_Type) return Name_Id; + + function Stream_Operation_OK (N : Entity_Id; Name : TNT) return Boolean; + + procedure Append_To (N1 : Natural; N2 : Node_Id); + + function Predef (Loc : Source_Ptr; Name : Name_Id; E : Entity_Id) + return Node_Id; + + function Init return Natural; + +end Opt67_Pkg; -- 2.30.2