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