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