IA MCU psABI support: changes to libraries
[gcc.git] / gcc / gimple-streamer-in.c
index bc85ae9a353927a7ab60a65048055ff9f37d948b..6081c5b12b7d57ddff3f06c1e17838b5a2719447 100644 (file)
@@ -1,6 +1,6 @@
 /* Routines for reading GIMPLE from a file stream.
 
-   Copyright (C) 2011-2013 Free Software Foundation, Inc.
+   Copyright (C) 2011-2015 Free Software Foundation, Inc.
    Contributed by Diego Novillo <dnovillo@google.com>
 
 This file is part of GCC.
@@ -23,19 +23,29 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "diagnostic.h"
+#include "alias.h"
+#include "symtab.h"
+#include "options.h"
 #include "tree.h"
+#include "fold-const.h"
+#include "predict.h"
+#include "tm.h"
+#include "hard-reg-set.h"
+#include "function.h"
+#include "dominance.h"
+#include "cfg.h"
 #include "basic-block.h"
 #include "tree-ssa-alias.h"
 #include "internal-fn.h"
 #include "tree-eh.h"
 #include "gimple-expr.h"
-#include "is-a.h"
 #include "gimple.h"
 #include "gimple-iterator.h"
 #include "gimple-ssa.h"
 #include "tree-phinodes.h"
 #include "stringpool.h"
 #include "tree-ssanames.h"
+#include "cgraph.h"
 #include "data-streamer.h"
 #include "tree-streamer.h"
 #include "gimple-streamer.h"
@@ -44,14 +54,14 @@ along with GCC; see the file COPYING3.  If not see
 /* Read a PHI function for basic block BB in function FN.  DATA_IN is
    the file being read.  IB is the input block to use for reading.  */
 
-static gimple
+static gphi *
 input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
           struct function *fn)
 {
   unsigned HOST_WIDE_INT ix;
   tree phi_result;
   int i, len;
-  gimple result;
+  gphi *result;
 
   ix = streamer_read_uhwi (ib);
   phi_result = (*SSANAMES (fn))[ix];
@@ -66,7 +76,9 @@ input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
       tree def = stream_read_tree (ib, data_in);
       int src_index = streamer_read_uhwi (ib);
       bitpack_d bp = streamer_read_bitpack (ib);
-      location_t arg_loc = stream_input_location (&bp, data_in);
+      /* Do not cache a location - we do not have API to get pointer to the
+        location in PHI statement and we may trigger reallocation.  */
+      location_t arg_loc = stream_input_location_now (&bp, data_in);
       basic_block sbb = BASIC_BLOCK_FOR_FN (fn, src_index);
 
       edge e = NULL;
@@ -113,8 +125,9 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
   has_hist = bp_unpack_value (&bp, 1);
   stmt->subcode = bp_unpack_var_len_unsigned (&bp);
 
-  /* Read location information.  */
-  gimple_set_location (stmt, stream_input_location (&bp, data_in));
+  /* Read location information.  Caching here makes no sense until streamer
+     cache can handle the following gimple_set_block.  */
+  gimple_set_location (stmt, stream_input_location_now (&bp, data_in));
 
   /* Read lexical block reference.  */
   gimple_set_block (stmt, stream_read_tree (ib, data_in));
@@ -123,21 +136,25 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
   switch (code)
     {
     case GIMPLE_RESX:
-      gimple_resx_set_region (stmt, streamer_read_hwi (ib));
+      gimple_resx_set_region (as_a <gresx *> (stmt),
+                             streamer_read_hwi (ib));
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
-      gimple_eh_must_not_throw_set_fndecl (stmt, stream_read_tree (ib, data_in));
+      gimple_eh_must_not_throw_set_fndecl (
+       as_a <geh_mnt *> (stmt),
+       stream_read_tree (ib, data_in));
       break;
 
     case GIMPLE_EH_DISPATCH:
-      gimple_eh_dispatch_set_region (stmt, streamer_read_hwi (ib));
+      gimple_eh_dispatch_set_region (as_a <geh_dispatch *> (stmt),
+                                    streamer_read_hwi (ib));
       break;
 
     case GIMPLE_ASM:
       {
        /* FIXME lto.  Move most of this into a new gimple_asm_set_string().  */
-       gimple_statement_asm *asm_stmt = as_a <gimple_statement_asm> (stmt);
+       gasm *asm_stmt = as_a <gasm *> (stmt);
        tree str;
        asm_stmt->ni = streamer_read_uhwi (ib);
        asm_stmt->no = streamer_read_uhwi (ib);
@@ -185,13 +202,13 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
                  == TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*opp, 0), 0))))
            *opp = TREE_OPERAND (TREE_OPERAND (*opp, 0), 0);
        }
-      if (is_gimple_call (stmt))
+      if (gcall *call_stmt = dyn_cast <gcall *> (stmt))
        {
-         if (gimple_call_internal_p (stmt))
+         if (gimple_call_internal_p (call_stmt))
            gimple_call_set_internal_fn
-             (stmt, streamer_read_enum (ib, internal_fn, IFN_LAST));
+             (call_stmt, streamer_read_enum (ib, internal_fn, IFN_LAST));
          else
-           gimple_call_set_fntype (stmt, stream_read_tree (ib, data_in));
+           gimple_call_set_fntype (call_stmt, stream_read_tree (ib, data_in));
        }
       break;
 
@@ -200,7 +217,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
       break;
 
     case GIMPLE_TRANSACTION:
-      gimple_transaction_set_label (stmt, stream_read_tree (ib, data_in));
+      gimple_transaction_set_label (as_a <gtransaction *> (stmt),
+                                   stream_read_tree (ib, data_in));
       break;
 
     default:
@@ -218,11 +236,12 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
     }
   else if (code == GIMPLE_ASM)
     {
+      gasm *asm_stmt = as_a <gasm *> (stmt);
       unsigned i;
 
-      for (i = 0; i < gimple_asm_noutputs (stmt); i++)
+      for (i = 0; i < gimple_asm_noutputs (asm_stmt); i++)
        {
-         tree op = TREE_VALUE (gimple_asm_output_op (stmt, i));
+         tree op = TREE_VALUE (gimple_asm_output_op (asm_stmt, i));
          if (TREE_CODE (op) == SSA_NAME)
            SSA_NAME_DEF_STMT (op) = stmt;
        }
@@ -230,7 +249,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
 
   /* Reset alias information.  */
   if (code == GIMPLE_CALL)
-    gimple_call_reset_alias_info (stmt);
+    gimple_call_reset_alias_info (as_a <gcall *> (stmt));
 
   /* Mark the statement modified so its operand vectors can be filled in.  */
   gimple_set_modified (stmt, true);