coretypes.h: Include input.h and as-a.h.
[platform/upstream/gcc.git] / gcc / config / epiphany / mode-switch-use.c
1 /* Insert USEs in instructions that require mode switching.
2    This should probably be merged into mode-switching.c .
3    Copyright (C) 2011-2015 Free Software Foundation, Inc.
4    Contributed by Embecosm on behalf of Adapteva, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "rtl.h"
27 #include "hard-reg-set.h"
28 #include "function.h"
29 #include "emit-rtl.h"
30 #include "tree-pass.h"
31 #include "insn-attr.h"
32 #include "insn-config.h"
33 #include "recog.h"
34 #include "tm_p.h"
35 #include "dominance.h"
36 #include "cfg.h"
37 #include "cfgrtl.h"
38 #include "cfganal.h"
39 #include "lcm.h"
40 #include "cfgbuild.h"
41 #include "cfgcleanup.h"
42 #include "predict.h"
43 #include "basic-block.h"
44 #include "df.h"
45
46 #ifndef TARGET_INSERT_MODE_SWITCH_USE
47 #define TARGET_INSERT_MODE_SWITCH_USE NULL
48 #endif
49
50 static unsigned int
51 insert_uses (void)
52 {
53   static const int num_modes[] = NUM_MODES_FOR_MODE_SWITCHING;
54 #define N_ENTITIES ARRAY_SIZE (num_modes)
55   int e;
56   void (*target_insert_mode_switch_use) (rtx_insn *insn, int, int)
57     = TARGET_INSERT_MODE_SWITCH_USE;
58
59   for (e = N_ENTITIES - 1; e >= 0; e--)
60     {
61       int no_mode = num_modes[e];
62       rtx_insn *insn;
63       int mode;
64
65       if (!OPTIMIZE_MODE_SWITCHING (e))
66         continue;
67       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
68         {
69           if (!INSN_P (insn))
70             continue;
71           mode = epiphany_mode_needed (e, insn);
72           if (mode == no_mode)
73             continue;
74           if (target_insert_mode_switch_use)
75             {
76               target_insert_mode_switch_use (insn, e, mode);
77               df_insn_rescan (insn);
78             }
79         }
80     }
81   return 0;
82 }
83
84 namespace {
85
86 const pass_data pass_data_mode_switch_use =
87 {
88   RTL_PASS, /* type */
89   "mode_switch_use", /* name */
90   OPTGROUP_NONE, /* optinfo_flags */
91   TV_NONE, /* tv_id */
92   0, /* properties_required */
93   0, /* properties_provided */
94   0, /* properties_destroyed */
95   0, /* todo_flags_start */
96   0, /* todo_flags_finish */
97 };
98
99 class pass_mode_switch_use : public rtl_opt_pass
100 {
101 public:
102   pass_mode_switch_use(gcc::context *ctxt)
103     : rtl_opt_pass(pass_data_mode_switch_use, ctxt)
104   {}
105
106   /* opt_pass methods: */
107   virtual unsigned int execute (function *) { return insert_uses (); }
108
109 }; // class pass_mode_switch_use
110
111 } // anon namespace
112
113 rtl_opt_pass *
114 make_pass_mode_switch_use (gcc::context *ctxt)
115 {
116   return new pass_mode_switch_use (ctxt);
117 }