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.
6 This file is part of GCC.
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)
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.
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/>. */
24 #include "coretypes.h"
29 #include "tree-pass.h"
30 #include "insn-attr.h"
31 #include "insn-config.h"
38 #include "cfgcleanup.h"
40 #ifndef TARGET_INSERT_MODE_SWITCH_USE
41 #define TARGET_INSERT_MODE_SWITCH_USE NULL
47 static const int num_modes
[] = NUM_MODES_FOR_MODE_SWITCHING
;
48 #define N_ENTITIES ARRAY_SIZE (num_modes)
50 void (*target_insert_mode_switch_use
) (rtx_insn
*insn
, int, int)
51 = TARGET_INSERT_MODE_SWITCH_USE
;
53 for (e
= N_ENTITIES
- 1; e
>= 0; e
--)
55 int no_mode
= num_modes
[e
];
59 if (!OPTIMIZE_MODE_SWITCHING (e
))
61 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
65 mode
= epiphany_mode_needed (e
, insn
);
68 if (target_insert_mode_switch_use
)
70 target_insert_mode_switch_use (insn
, e
, mode
);
71 df_insn_rescan (insn
);
80 const pass_data pass_data_mode_switch_use
=
83 "mode_switch_use", /* name */
84 OPTGROUP_NONE
, /* optinfo_flags */
86 0, /* properties_required */
87 0, /* properties_provided */
88 0, /* properties_destroyed */
89 0, /* todo_flags_start */
90 0, /* todo_flags_finish */
93 class pass_mode_switch_use
: public rtl_opt_pass
96 pass_mode_switch_use(gcc::context
*ctxt
)
97 : rtl_opt_pass(pass_data_mode_switch_use
, ctxt
)
100 /* opt_pass methods: */
101 virtual unsigned int execute (function
*) { return insert_uses (); }
103 }; // class pass_mode_switch_use
108 make_pass_mode_switch_use (gcc::context
*ctxt
)
110 return new pass_mode_switch_use (ctxt
);