target-globals.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* Target-dependent globals.
  2. Copyright (C) 2010-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #include "config.h"
  16. #include "system.h"
  17. #include "coretypes.h"
  18. #include "tm.h"
  19. #include "insn-config.h"
  20. #include "machmode.h"
  21. #include "hash-set.h"
  22. #include "vec.h"
  23. #include "double-int.h"
  24. #include "input.h"
  25. #include "alias.h"
  26. #include "symtab.h"
  27. #include "wide-int.h"
  28. #include "inchash.h"
  29. #include "tree.h"
  30. #include "ggc.h"
  31. #include "toplev.h"
  32. #include "target-globals.h"
  33. #include "flags.h"
  34. #include "regs.h"
  35. #include "rtl.h"
  36. #include "hard-reg-set.h"
  37. #include "reload.h"
  38. #include "expmed.h"
  39. #include "hashtab.h"
  40. #include "function.h"
  41. #include "statistics.h"
  42. #include "real.h"
  43. #include "fixed-value.h"
  44. #include "dojump.h"
  45. #include "explow.h"
  46. #include "calls.h"
  47. #include "emit-rtl.h"
  48. #include "varasm.h"
  49. #include "stmt.h"
  50. #include "expr.h"
  51. #include "insn-codes.h"
  52. #include "optabs.h"
  53. #include "libfuncs.h"
  54. #include "cfgloop.h"
  55. #include "ira-int.h"
  56. #include "builtins.h"
  57. #include "gcse.h"
  58. #include "bb-reorder.h"
  59. #include "lower-subreg.h"
  60. #include "recog.h"
  61. #if SWITCHABLE_TARGET
  62. struct target_globals default_target_globals = {
  63. &default_target_flag_state,
  64. &default_target_regs,
  65. &default_target_rtl,
  66. &default_target_recog,
  67. &default_target_hard_regs,
  68. &default_target_reload,
  69. &default_target_expmed,
  70. &default_target_optabs,
  71. &default_target_libfuncs,
  72. &default_target_cfgloop,
  73. &default_target_ira,
  74. &default_target_ira_int,
  75. &default_target_builtins,
  76. &default_target_gcse,
  77. &default_target_bb_reorder,
  78. &default_target_lower_subreg
  79. };
  80. struct target_globals *
  81. save_target_globals (void)
  82. {
  83. struct target_globals *g = ggc_cleared_alloc <target_globals> ();
  84. g->flag_state = XCNEW (struct target_flag_state);
  85. g->regs = XCNEW (struct target_regs);
  86. g->rtl = ggc_cleared_alloc<target_rtl> ();
  87. g->recog = XCNEW (struct target_recog);
  88. g->hard_regs = XCNEW (struct target_hard_regs);
  89. g->reload = XCNEW (struct target_reload);
  90. g->expmed = XCNEW (struct target_expmed);
  91. g->optabs = XCNEW (struct target_optabs);
  92. g->libfuncs = ggc_cleared_alloc<target_libfuncs> ();
  93. g->cfgloop = XCNEW (struct target_cfgloop);
  94. g->ira = XCNEW (struct target_ira);
  95. g->ira_int = XCNEW (struct target_ira_int);
  96. g->builtins = XCNEW (struct target_builtins);
  97. g->gcse = XCNEW (struct target_gcse);
  98. g->bb_reorder = XCNEW (struct target_bb_reorder);
  99. g->lower_subreg = XCNEW (struct target_lower_subreg);
  100. restore_target_globals (g);
  101. init_reg_sets ();
  102. target_reinit ();
  103. return g;
  104. }
  105. /* Like save_target_globals() above, but set *this_target_optabs
  106. correctly when a previous function has changed
  107. *this_target_optabs. */
  108. struct target_globals *
  109. save_target_globals_default_opts ()
  110. {
  111. struct target_globals *globals;
  112. if (optimization_current_node != optimization_default_node)
  113. {
  114. tree opts = optimization_current_node;
  115. /* Temporarily switch to the default optimization node, so that
  116. *this_target_optabs is set to the default, not reflecting
  117. whatever a previous function used for the optimize
  118. attribute. */
  119. optimization_current_node = optimization_default_node;
  120. cl_optimization_restore
  121. (&global_options,
  122. TREE_OPTIMIZATION (optimization_default_node));
  123. globals = save_target_globals ();
  124. optimization_current_node = opts;
  125. cl_optimization_restore (&global_options,
  126. TREE_OPTIMIZATION (opts));
  127. return globals;
  128. }
  129. return save_target_globals ();
  130. }
  131. target_globals::~target_globals ()
  132. {
  133. /* default_target_globals points to static data so shouldn't be freed. */
  134. if (this != &default_target_globals)
  135. {
  136. ira_int->~target_ira_int ();
  137. hard_regs->finalize ();
  138. XDELETE (flag_state);
  139. XDELETE (regs);
  140. XDELETE (recog);
  141. XDELETE (hard_regs);
  142. XDELETE (reload);
  143. XDELETE (expmed);
  144. XDELETE (optabs);
  145. XDELETE (cfgloop);
  146. XDELETE (ira);
  147. XDELETE (ira_int);
  148. XDELETE (builtins);
  149. XDELETE (gcse);
  150. XDELETE (bb_reorder);
  151. XDELETE (lower_subreg);
  152. }
  153. }
  154. #endif