Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/epiphany/mode-switch-use.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Insert USEs in instructions that require mode switching. | |
2 This should probably be merged into mode-switching.c . | |
3 Copyright (C) 2011-2017 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 "backend.h" | |
26 #include "rtl.h" | |
27 #include "df.h" | |
28 #include "memmodel.h" | |
29 #include "tm_p.h" | |
30 #include "emit-rtl.h" | |
31 #include "tree-pass.h" | |
32 #include "insn-attr.h" | |
33 | |
34 #ifndef TARGET_INSERT_MODE_SWITCH_USE | |
35 #define TARGET_INSERT_MODE_SWITCH_USE NULL | |
36 #endif | |
37 | |
38 static unsigned int | |
39 insert_uses (void) | |
40 { | |
41 static const int num_modes[] = NUM_MODES_FOR_MODE_SWITCHING; | |
42 #define N_ENTITIES ARRAY_SIZE (num_modes) | |
43 int e; | |
44 void (*target_insert_mode_switch_use) (rtx_insn *insn, int, int) | |
45 = TARGET_INSERT_MODE_SWITCH_USE; | |
46 | |
47 for (e = N_ENTITIES - 1; e >= 0; e--) | |
48 { | |
49 int no_mode = num_modes[e]; | |
50 rtx_insn *insn; | |
51 int mode; | |
52 | |
53 if (!OPTIMIZE_MODE_SWITCHING (e)) | |
54 continue; | |
55 for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) | |
56 { | |
57 if (!INSN_P (insn)) | |
58 continue; | |
59 mode = epiphany_mode_needed (e, insn); | |
60 if (mode == no_mode) | |
61 continue; | |
62 if (target_insert_mode_switch_use) | |
63 { | |
64 target_insert_mode_switch_use (insn, e, mode); | |
65 df_insn_rescan (insn); | |
66 } | |
67 } | |
68 } | |
69 return 0; | |
70 } | |
71 | |
72 namespace { | |
73 | |
74 const pass_data pass_data_mode_switch_use = | |
75 { | |
76 RTL_PASS, /* type */ | |
77 "mode_switch_use", /* name */ | |
78 OPTGROUP_NONE, /* optinfo_flags */ | |
79 TV_NONE, /* tv_id */ | |
80 0, /* properties_required */ | |
81 0, /* properties_provided */ | |
82 0, /* properties_destroyed */ | |
83 0, /* todo_flags_start */ | |
84 0, /* todo_flags_finish */ | |
85 }; | |
86 | |
87 class pass_mode_switch_use : public rtl_opt_pass | |
88 { | |
89 public: | |
90 pass_mode_switch_use(gcc::context *ctxt) | |
91 : rtl_opt_pass(pass_data_mode_switch_use, ctxt) | |
92 {} | |
93 | |
94 /* opt_pass methods: */ | |
95 virtual unsigned int execute (function *) { return insert_uses (); } | |
96 | |
97 }; // class pass_mode_switch_use | |
98 | |
99 } // anon namespace | |
100 | |
101 rtl_opt_pass * | |
102 make_pass_mode_switch_use (gcc::context *ctxt) | |
103 { | |
104 return new pass_mode_switch_use (ctxt); | |
105 } |