function.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. /* Structure for saving state for a nested function.
  2. Copyright (C) 1989-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. #ifndef GCC_FUNCTION_H
  16. #define GCC_FUNCTION_H
  17. /* Stack of pending (incomplete) sequences saved by `start_sequence'.
  18. Each element describes one pending sequence.
  19. The main insn-chain is saved in the last element of the chain,
  20. unless the chain is empty. */
  21. struct GTY(()) sequence_stack {
  22. /* First and last insns in the chain of the saved sequence. */
  23. rtx_insn *first;
  24. rtx_insn *last;
  25. struct sequence_stack *next;
  26. };
  27. struct GTY(()) emit_status {
  28. /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
  29. After rtl generation, it is 1 plus the largest register number used. */
  30. int x_reg_rtx_no;
  31. /* Lowest label number in current function. */
  32. int x_first_label_num;
  33. /* The ends of the doubly-linked chain of rtl for the current function.
  34. Both are reset to null at the start of rtl generation for the function.
  35. start_sequence saves both of these on `sequence_stack' and then starts
  36. a new, nested sequence of insns. */
  37. rtx_insn *x_first_insn;
  38. rtx_insn *x_last_insn;
  39. /* Stack of pending (incomplete) sequences saved by `start_sequence'.
  40. Each element describes one pending sequence.
  41. The main insn-chain is saved in the last element of the chain,
  42. unless the chain is empty. */
  43. struct sequence_stack *sequence_stack;
  44. /* INSN_UID for next insn emitted.
  45. Reset to 1 for each function compiled. */
  46. int x_cur_insn_uid;
  47. /* INSN_UID for next debug insn emitted. Only used if
  48. --param min-nondebug-insn-uid=<value> is given with nonzero value. */
  49. int x_cur_debug_insn_uid;
  50. /* The length of the regno_pointer_align, regno_decl, and x_regno_reg_rtx
  51. vectors. Since these vectors are needed during the expansion phase when
  52. the total number of registers in the function is not yet known, the
  53. vectors are copied and made bigger when necessary. */
  54. int regno_pointer_align_length;
  55. /* Indexed by pseudo register number, if nonzero gives the known alignment
  56. for that pseudo (if REG_POINTER is set in x_regno_reg_rtx).
  57. Allocated in parallel with x_regno_reg_rtx. */
  58. unsigned char * GTY((skip)) regno_pointer_align;
  59. };
  60. /* Indexed by register number, gives an rtx for that register (and only
  61. that register). For pseudo registers, it is the unique rtx for
  62. that pseudo. For hard registers, it is an rtx of the mode specified
  63. by reg_raw_mode.
  64. FIXME: We could put it into emit_status struct, but gengtype is not
  65. able to deal with length attribute nested in top level structures. */
  66. extern GTY ((length ("crtl->emit.x_reg_rtx_no"))) rtx * regno_reg_rtx;
  67. /* For backward compatibility... eventually these should all go away. */
  68. #define reg_rtx_no (crtl->emit.x_reg_rtx_no)
  69. #define seq_stack (crtl->emit.sequence_stack)
  70. #define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO])
  71. struct GTY(()) expr_status {
  72. /* Number of units that we should eventually pop off the stack.
  73. These are the arguments to function calls that have already returned. */
  74. int x_pending_stack_adjust;
  75. /* Under some ABIs, it is the caller's responsibility to pop arguments
  76. pushed for function calls. A naive implementation would simply pop
  77. the arguments immediately after each call. However, if several
  78. function calls are made in a row, it is typically cheaper to pop
  79. all the arguments after all of the calls are complete since a
  80. single pop instruction can be used. Therefore, GCC attempts to
  81. defer popping the arguments until absolutely necessary. (For
  82. example, at the end of a conditional, the arguments must be popped,
  83. since code outside the conditional won't know whether or not the
  84. arguments need to be popped.)
  85. When INHIBIT_DEFER_POP is nonzero, however, the compiler does not
  86. attempt to defer pops. Instead, the stack is popped immediately
  87. after each call. Rather then setting this variable directly, use
  88. NO_DEFER_POP and OK_DEFER_POP. */
  89. int x_inhibit_defer_pop;
  90. /* If PREFERRED_STACK_BOUNDARY and PUSH_ROUNDING are defined, the stack
  91. boundary can be momentarily unaligned while pushing the arguments.
  92. Record the delta since last aligned boundary here in order to get
  93. stack alignment in the nested function calls working right. */
  94. int x_stack_pointer_delta;
  95. /* Nonzero means __builtin_saveregs has already been done in this function.
  96. The value is the pseudoreg containing the value __builtin_saveregs
  97. returned. */
  98. rtx x_saveregs_value;
  99. /* Similarly for __builtin_apply_args. */
  100. rtx x_apply_args_value;
  101. /* List of labels that must never be deleted. */
  102. rtx_insn_list *x_forced_labels;
  103. };
  104. typedef struct call_site_record_d *call_site_record;
  105. /* RTL representation of exception handling. */
  106. struct GTY(()) rtl_eh {
  107. rtx ehr_stackadj;
  108. rtx ehr_handler;
  109. rtx_code_label *ehr_label;
  110. rtx sjlj_fc;
  111. rtx_insn *sjlj_exit_after;
  112. vec<uchar, va_gc> *action_record_data;
  113. vec<call_site_record, va_gc> *call_site_record_v[2];
  114. };
  115. #define pending_stack_adjust (crtl->expr.x_pending_stack_adjust)
  116. #define inhibit_defer_pop (crtl->expr.x_inhibit_defer_pop)
  117. #define saveregs_value (crtl->expr.x_saveregs_value)
  118. #define apply_args_value (crtl->expr.x_apply_args_value)
  119. #define forced_labels (crtl->expr.x_forced_labels)
  120. #define stack_pointer_delta (crtl->expr.x_stack_pointer_delta)
  121. struct gimple_df;
  122. struct temp_slot;
  123. typedef struct temp_slot *temp_slot_p;
  124. struct call_site_record_d;
  125. struct dw_fde_node;
  126. class ipa_opt_pass_d;
  127. typedef ipa_opt_pass_d *ipa_opt_pass;
  128. struct GTY(()) varasm_status {
  129. /* If we're using a per-function constant pool, this is it. */
  130. struct rtx_constant_pool *pool;
  131. /* Number of tree-constants deferred during the expansion of this
  132. function. */
  133. unsigned int deferred_constants;
  134. };
  135. /* Information mainlined about RTL representation of incoming arguments. */
  136. struct GTY(()) incoming_args {
  137. /* Number of bytes of args popped by function being compiled on its return.
  138. Zero if no bytes are to be popped.
  139. May affect compilation of return insn or of function epilogue. */
  140. int pops_args;
  141. /* If function's args have a fixed size, this is that size, in bytes.
  142. Otherwise, it is -1.
  143. May affect compilation of return insn or of function epilogue. */
  144. int size;
  145. /* # bytes the prologue should push and pretend that the caller pushed them.
  146. The prologue must do this, but only if parms can be passed in
  147. registers. */
  148. int pretend_args_size;
  149. /* This is the offset from the arg pointer to the place where the first
  150. anonymous arg can be found, if there is one. */
  151. rtx arg_offset_rtx;
  152. /* Quantities of various kinds of registers
  153. used for the current function's args. */
  154. CUMULATIVE_ARGS info;
  155. /* The arg pointer hard register, or the pseudo into which it was copied. */
  156. rtx internal_arg_pointer;
  157. };
  158. /* Data for function partitioning. */
  159. struct GTY(()) function_subsections {
  160. /* Assembly labels for the hot and cold text sections, to
  161. be used by debugger functions for determining the size of text
  162. sections. */
  163. const char *hot_section_label;
  164. const char *cold_section_label;
  165. const char *hot_section_end_label;
  166. const char *cold_section_end_label;
  167. };
  168. /* Describe an empty area of space in the stack frame. These can be chained
  169. into a list; this is used to keep track of space wasted for alignment
  170. reasons. */
  171. struct GTY(()) frame_space
  172. {
  173. struct frame_space *next;
  174. HOST_WIDE_INT start;
  175. HOST_WIDE_INT length;
  176. };
  177. /* Datastructures maintained for currently processed function in RTL form. */
  178. struct GTY(()) rtl_data {
  179. struct expr_status expr;
  180. struct emit_status emit;
  181. struct varasm_status varasm;
  182. struct incoming_args args;
  183. struct function_subsections subsections;
  184. struct rtl_eh eh;
  185. /* For function.c */
  186. /* # of bytes of outgoing arguments. If ACCUMULATE_OUTGOING_ARGS is
  187. defined, the needed space is pushed by the prologue. */
  188. int outgoing_args_size;
  189. /* If nonzero, an RTL expression for the location at which the current
  190. function returns its result. If the current function returns its
  191. result in a register, current_function_return_rtx will always be
  192. the hard register containing the result. */
  193. rtx return_rtx;
  194. /* If nonxero, an RTL expression for the lcoation at which the current
  195. function returns bounds for its result. */
  196. rtx return_bnd;
  197. /* Vector of initial-value pairs. Each pair consists of a pseudo
  198. register of approprite mode that stores the initial value a hard
  199. register REGNO, and that hard register itself. */
  200. /* ??? This could be a VEC but there is currently no way to define an
  201. opaque VEC type. */
  202. struct initial_value_struct *hard_reg_initial_vals;
  203. /* A variable living at the top of the frame that holds a known value.
  204. Used for detecting stack clobbers. */
  205. tree stack_protect_guard;
  206. /* List (chain of INSN_LIST) of labels heading the current handlers for
  207. nonlocal gotos. */
  208. rtx_insn_list *x_nonlocal_goto_handler_labels;
  209. /* Label that will go on function epilogue.
  210. Jumping to this label serves as a "return" instruction
  211. on machines which require execution of the epilogue on all returns. */
  212. rtx_code_label *x_return_label;
  213. /* Label that will go on the end of function epilogue.
  214. Jumping to this label serves as a "naked return" instruction
  215. on machines which require execution of the epilogue on all returns. */
  216. rtx_code_label *x_naked_return_label;
  217. /* List (chain of EXPR_LISTs) of all stack slots in this function.
  218. Made for the sake of unshare_all_rtl. */
  219. rtx_expr_list *x_stack_slot_list;
  220. /* List of empty areas in the stack frame. */
  221. struct frame_space *frame_space_list;
  222. /* Place after which to insert the tail_recursion_label if we need one. */
  223. rtx_note *x_stack_check_probe_note;
  224. /* Location at which to save the argument pointer if it will need to be
  225. referenced. There are two cases where this is done: if nonlocal gotos
  226. exist, or if vars stored at an offset from the argument pointer will be
  227. needed by inner routines. */
  228. rtx x_arg_pointer_save_area;
  229. /* Dynamic Realign Argument Pointer used for realigning stack. */
  230. rtx drap_reg;
  231. /* Offset to end of allocated area of stack frame.
  232. If stack grows down, this is the address of the last stack slot allocated.
  233. If stack grows up, this is the address for the next slot. */
  234. HOST_WIDE_INT x_frame_offset;
  235. /* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */
  236. rtx_insn *x_parm_birth_insn;
  237. /* List of all used temporaries allocated, by level. */
  238. vec<temp_slot_p, va_gc> *x_used_temp_slots;
  239. /* List of available temp slots. */
  240. struct temp_slot *x_avail_temp_slots;
  241. /* Current nesting level for temporaries. */
  242. int x_temp_slot_level;
  243. /* The largest alignment needed on the stack, including requirement
  244. for outgoing stack alignment. */
  245. unsigned int stack_alignment_needed;
  246. /* Preferred alignment of the end of stack frame, which is preferred
  247. to call other functions. */
  248. unsigned int preferred_stack_boundary;
  249. /* The minimum alignment of parameter stack. */
  250. unsigned int parm_stack_boundary;
  251. /* The largest alignment of slot allocated on the stack. */
  252. unsigned int max_used_stack_slot_alignment;
  253. /* The stack alignment estimated before reload, with consideration of
  254. following factors:
  255. 1. Alignment of local stack variables (max_used_stack_slot_alignment)
  256. 2. Alignment requirement to call other functions
  257. (preferred_stack_boundary)
  258. 3. Alignment of non-local stack variables but might be spilled in
  259. local stack. */
  260. unsigned int stack_alignment_estimated;
  261. /* For reorg. */
  262. /* Nonzero if function being compiled called builtin_return_addr or
  263. builtin_frame_address with nonzero count. */
  264. bool accesses_prior_frames;
  265. /* Nonzero if the function calls __builtin_eh_return. */
  266. bool calls_eh_return;
  267. /* Nonzero if function saves all registers, e.g. if it has a nonlocal
  268. label that can reach the exit block via non-exceptional paths. */
  269. bool saves_all_registers;
  270. /* Nonzero if function being compiled has nonlocal gotos to parent
  271. function. */
  272. bool has_nonlocal_goto;
  273. /* Nonzero if function being compiled has an asm statement. */
  274. bool has_asm_statement;
  275. /* This bit is used by the exception handling logic. It is set if all
  276. calls (if any) are sibling calls. Such functions do not have to
  277. have EH tables generated, as they cannot throw. A call to such a
  278. function, however, should be treated as throwing if any of its callees
  279. can throw. */
  280. bool all_throwers_are_sibcalls;
  281. /* Nonzero if stack limit checking should be enabled in the current
  282. function. */
  283. bool limit_stack;
  284. /* Nonzero if profiling code should be generated. */
  285. bool profile;
  286. /* Nonzero if the current function uses the constant pool. */
  287. bool uses_const_pool;
  288. /* Nonzero if the current function uses pic_offset_table_rtx. */
  289. bool uses_pic_offset_table;
  290. /* Nonzero if the current function needs an lsda for exception handling. */
  291. bool uses_eh_lsda;
  292. /* Set when the tail call has been produced. */
  293. bool tail_call_emit;
  294. /* Nonzero if code to initialize arg_pointer_save_area has been emitted. */
  295. bool arg_pointer_save_area_init;
  296. /* Nonzero if current function must be given a frame pointer.
  297. Set in reload1.c or lra-eliminations.c if anything is allocated
  298. on the stack there. */
  299. bool frame_pointer_needed;
  300. /* When set, expand should optimize for speed. */
  301. bool maybe_hot_insn_p;
  302. /* Nonzero if function stack realignment is needed. This flag may be
  303. set twice: before and after reload. It is set before reload wrt
  304. stack alignment estimation before reload. It will be changed after
  305. reload if by then criteria of stack realignment is different.
  306. The value set after reload is the accurate one and is finalized. */
  307. bool stack_realign_needed;
  308. /* Nonzero if function stack realignment is tried. This flag is set
  309. only once before reload. It affects register elimination. This
  310. is used to generate DWARF debug info for stack variables. */
  311. bool stack_realign_tried;
  312. /* Nonzero if function being compiled needs dynamic realigned
  313. argument pointer (drap) if stack needs realigning. */
  314. bool need_drap;
  315. /* Nonzero if function stack realignment estimation is done, namely
  316. stack_realign_needed flag has been set before reload wrt estimated
  317. stack alignment info. */
  318. bool stack_realign_processed;
  319. /* Nonzero if function stack realignment has been finalized, namely
  320. stack_realign_needed flag has been set and finalized after reload. */
  321. bool stack_realign_finalized;
  322. /* True if dbr_schedule has already been called for this function. */
  323. bool dbr_scheduled_p;
  324. /* True if current function can not throw. Unlike
  325. TREE_NOTHROW (current_function_decl) it is set even for overwritable
  326. function where currently compiled version of it is nothrow. */
  327. bool nothrow;
  328. /* True if we performed shrink-wrapping for the current function. */
  329. bool shrink_wrapped;
  330. /* Nonzero if function being compiled doesn't modify the stack pointer
  331. (ignoring the prologue and epilogue). This is only valid after
  332. pass_stack_ptr_mod has run. */
  333. bool sp_is_unchanging;
  334. /* Nonzero if function being compiled doesn't contain any calls
  335. (ignoring the prologue and epilogue). This is set prior to
  336. local register allocation and is valid for the remaining
  337. compiler passes. */
  338. bool is_leaf;
  339. /* Nonzero if the function being compiled is a leaf function which only
  340. uses leaf registers. This is valid after reload (specifically after
  341. sched2) and is useful only if the port defines LEAF_REGISTERS. */
  342. bool uses_only_leaf_regs;
  343. /* Nonzero if the function being compiled has undergone hot/cold partitioning
  344. (under flag_reorder_blocks_and_partition) and has at least one cold
  345. block. */
  346. bool has_bb_partition;
  347. /* Nonzero if the function being compiled has completed the bb reordering
  348. pass. */
  349. bool bb_reorder_complete;
  350. /* Like regs_ever_live, but 1 if a reg is set or clobbered from an
  351. asm. Unlike regs_ever_live, elements of this array corresponding
  352. to eliminable regs (like the frame pointer) are set if an asm
  353. sets them. */
  354. HARD_REG_SET asm_clobbers;
  355. };
  356. #define return_label (crtl->x_return_label)
  357. #define naked_return_label (crtl->x_naked_return_label)
  358. #define stack_slot_list (crtl->x_stack_slot_list)
  359. #define parm_birth_insn (crtl->x_parm_birth_insn)
  360. #define frame_offset (crtl->x_frame_offset)
  361. #define stack_check_probe_note (crtl->x_stack_check_probe_note)
  362. #define arg_pointer_save_area (crtl->x_arg_pointer_save_area)
  363. #define used_temp_slots (crtl->x_used_temp_slots)
  364. #define avail_temp_slots (crtl->x_avail_temp_slots)
  365. #define temp_slot_level (crtl->x_temp_slot_level)
  366. #define nonlocal_goto_handler_labels (crtl->x_nonlocal_goto_handler_labels)
  367. #define frame_pointer_needed (crtl->frame_pointer_needed)
  368. #define stack_realign_fp (crtl->stack_realign_needed && !crtl->need_drap)
  369. #define stack_realign_drap (crtl->stack_realign_needed && crtl->need_drap)
  370. extern GTY(()) struct rtl_data x_rtl;
  371. /* Accessor to RTL datastructures. We keep them statically allocated now since
  372. we never keep multiple functions. For threaded compiler we might however
  373. want to do differently. */
  374. #define crtl (&x_rtl)
  375. struct GTY(()) stack_usage
  376. {
  377. /* # of bytes of static stack space allocated by the function. */
  378. HOST_WIDE_INT static_stack_size;
  379. /* # of bytes of dynamic stack space allocated by the function. This is
  380. meaningful only if has_unbounded_dynamic_stack_size is zero. */
  381. HOST_WIDE_INT dynamic_stack_size;
  382. /* # of bytes of space pushed onto the stack after the prologue. If
  383. !ACCUMULATE_OUTGOING_ARGS, it contains the outgoing arguments. */
  384. int pushed_stack_size;
  385. /* Nonzero if the amount of stack space allocated dynamically cannot
  386. be bounded at compile-time. */
  387. unsigned int has_unbounded_dynamic_stack_size : 1;
  388. };
  389. #define current_function_static_stack_size (cfun->su->static_stack_size)
  390. #define current_function_dynamic_stack_size (cfun->su->dynamic_stack_size)
  391. #define current_function_pushed_stack_size (cfun->su->pushed_stack_size)
  392. #define current_function_has_unbounded_dynamic_stack_size \
  393. (cfun->su->has_unbounded_dynamic_stack_size)
  394. #define current_function_allocates_dynamic_stack_space \
  395. (current_function_dynamic_stack_size != 0 \
  396. || current_function_has_unbounded_dynamic_stack_size)
  397. /* This structure can save all the important global and static variables
  398. describing the status of the current function. */
  399. struct GTY(()) function {
  400. struct eh_status *eh;
  401. /* The control flow graph for this function. */
  402. struct control_flow_graph *cfg;
  403. /* GIMPLE body for this function. */
  404. gimple_seq gimple_body;
  405. /* SSA and dataflow information. */
  406. struct gimple_df *gimple_df;
  407. /* The loops in this function. */
  408. struct loops *x_current_loops;
  409. /* The stack usage of this function. */
  410. struct stack_usage *su;
  411. /* Value histograms attached to particular statements. */
  412. htab_t GTY((skip)) value_histograms;
  413. /* For function.c. */
  414. /* Points to the FUNCTION_DECL of this function. */
  415. tree decl;
  416. /* A PARM_DECL that should contain the static chain for this function.
  417. It will be initialized at the beginning of the function. */
  418. tree static_chain_decl;
  419. /* An expression that contains the non-local goto save area. The first
  420. word is the saved frame pointer and the second is the saved stack
  421. pointer. */
  422. tree nonlocal_goto_save_area;
  423. /* Vector of function local variables, functions, types and constants. */
  424. vec<tree, va_gc> *local_decls;
  425. /* In a Cilk function, the VAR_DECL for the frame descriptor. */
  426. tree cilk_frame_decl;
  427. /* For md files. */
  428. /* tm.h can use this to store whatever it likes. */
  429. struct machine_function * GTY ((maybe_undef)) machine;
  430. /* Language-specific code can use this to store whatever it likes. */
  431. struct language_function * language;
  432. /* Used types hash table. */
  433. hash_set<tree> *GTY (()) used_types_hash;
  434. /* Dwarf2 Frame Description Entry, containing the Call Frame Instructions
  435. used for unwinding. Only set when either dwarf2 unwinding or dwarf2
  436. debugging is enabled. */
  437. struct dw_fde_node *fde;
  438. /* Last statement uid. */
  439. int last_stmt_uid;
  440. /* Function sequence number for profiling, debugging, etc. */
  441. int funcdef_no;
  442. /* Line number of the start of the function for debugging purposes. */
  443. location_t function_start_locus;
  444. /* Line number of the end of the function. */
  445. location_t function_end_locus;
  446. /* Properties used by the pass manager. */
  447. unsigned int curr_properties;
  448. unsigned int last_verified;
  449. /* Non-null if the function does something that would prevent it from
  450. being copied; this applies to both versioning and inlining. Set to
  451. a string describing the reason for failure. */
  452. const char * GTY((skip)) cannot_be_copied_reason;
  453. /* Last assigned dependence info clique. */
  454. unsigned short last_clique;
  455. /* Collected bit flags. */
  456. /* Number of units of general registers that need saving in stdarg
  457. function. What unit is depends on the backend, either it is number
  458. of bytes, or it can be number of registers. */
  459. unsigned int va_list_gpr_size : 8;
  460. /* Number of units of floating point registers that need saving in stdarg
  461. function. */
  462. unsigned int va_list_fpr_size : 8;
  463. /* Nonzero if function being compiled can call setjmp. */
  464. unsigned int calls_setjmp : 1;
  465. /* Nonzero if function being compiled can call alloca,
  466. either as a subroutine or builtin. */
  467. unsigned int calls_alloca : 1;
  468. /* This will indicate whether a function is a cilk function */
  469. unsigned int is_cilk_function : 1;
  470. /* Nonzero if this is a Cilk function that spawns. */
  471. unsigned int calls_cilk_spawn : 1;
  472. /* Nonzero if function being compiled receives nonlocal gotos
  473. from nested functions. */
  474. unsigned int has_nonlocal_label : 1;
  475. /* Nonzero if we've set cannot_be_copied_reason. I.e. if
  476. (cannot_be_copied_set && !cannot_be_copied_reason), the function
  477. can in fact be copied. */
  478. unsigned int cannot_be_copied_set : 1;
  479. /* Nonzero if current function uses stdarg.h or equivalent. */
  480. unsigned int stdarg : 1;
  481. unsigned int after_inlining : 1;
  482. unsigned int always_inline_functions_inlined : 1;
  483. /* Nonzero if function being compiled can throw synchronous non-call
  484. exceptions. */
  485. unsigned int can_throw_non_call_exceptions : 1;
  486. /* Nonzero if instructions that may throw exceptions but don't otherwise
  487. contribute to the execution of the program can be deleted. */
  488. unsigned int can_delete_dead_exceptions : 1;
  489. /* Fields below this point are not set for abstract functions; see
  490. allocate_struct_function. */
  491. /* Nonzero if function being compiled needs to be given an address
  492. where the value should be stored. */
  493. unsigned int returns_struct : 1;
  494. /* Nonzero if function being compiled needs to
  495. return the address of where it has put a structure value. */
  496. unsigned int returns_pcc_struct : 1;
  497. /* Nonzero if this function has local DECL_HARD_REGISTER variables.
  498. In this case code motion has to be done more carefully. */
  499. unsigned int has_local_explicit_reg_vars : 1;
  500. /* Nonzero if the current function is a thunk, i.e., a lightweight
  501. function implemented by the output_mi_thunk hook) that just
  502. adjusts one of its arguments and forwards to another
  503. function. */
  504. unsigned int is_thunk : 1;
  505. /* Nonzero if the current function contains any loops with
  506. loop->force_vectorize set. */
  507. unsigned int has_force_vectorize_loops : 1;
  508. /* Nonzero if the current function contains any loops with
  509. nonzero value in loop->simduid. */
  510. unsigned int has_simduid_loops : 1;
  511. /* Set when the tail call has been identified. */
  512. unsigned int tail_call_marked : 1;
  513. };
  514. /* Add the decl D to the local_decls list of FUN. */
  515. void add_local_decl (struct function *fun, tree d);
  516. #define FOR_EACH_LOCAL_DECL(FUN, I, D) \
  517. FOR_EACH_VEC_SAFE_ELT_REVERSE ((FUN)->local_decls, I, D)
  518. /* If va_list_[gf]pr_size is set to this, it means we don't know how
  519. many units need to be saved. */
  520. #define VA_LIST_MAX_GPR_SIZE 255
  521. #define VA_LIST_MAX_FPR_SIZE 255
  522. /* The function currently being compiled. */
  523. extern GTY(()) struct function *cfun;
  524. /* In order to ensure that cfun is not set directly, we redefine it so
  525. that it is not an lvalue. Rather than assign to cfun, use
  526. push_cfun or set_cfun. */
  527. #define cfun (cfun + 0)
  528. /* Nonzero if we've already converted virtual regs to hard regs. */
  529. extern int virtuals_instantiated;
  530. /* Nonzero if at least one trampoline has been created. */
  531. extern int trampolines_created;
  532. struct GTY((for_user)) types_used_by_vars_entry {
  533. tree type;
  534. tree var_decl;
  535. };
  536. struct used_type_hasher : ggc_hasher<types_used_by_vars_entry *>
  537. {
  538. static hashval_t hash (types_used_by_vars_entry *);
  539. static bool equal (types_used_by_vars_entry *, types_used_by_vars_entry *);
  540. };
  541. /* Hash table making the relationship between a global variable
  542. and the types it references in its initializer. The key of the
  543. entry is a referenced type, and the value is the DECL of the global
  544. variable. types_use_by_vars_do_hash and types_used_by_vars_eq below are
  545. the hash and equality functions to use for this hash table. */
  546. extern GTY(()) hash_table<used_type_hasher> *types_used_by_vars_hash;
  547. void types_used_by_var_decl_insert (tree type, tree var_decl);
  548. /* During parsing of a global variable, this vector contains the types
  549. referenced by the global variable. */
  550. extern GTY(()) vec<tree, va_gc> *types_used_by_cur_var_decl;
  551. /* Return the loop tree of FN. */
  552. inline struct loops *
  553. loops_for_fn (struct function *fn)
  554. {
  555. return fn->x_current_loops;
  556. }
  557. /* Set the loop tree of FN to LOOPS. */
  558. inline void
  559. set_loops_for_fn (struct function *fn, struct loops *loops)
  560. {
  561. gcc_checking_assert (fn->x_current_loops == NULL || loops == NULL);
  562. fn->x_current_loops = loops;
  563. }
  564. /* For backward compatibility... eventually these should all go away. */
  565. #define current_function_funcdef_no (cfun->funcdef_no)
  566. #define current_loops (cfun->x_current_loops)
  567. #define dom_computed (cfun->cfg->x_dom_computed)
  568. #define n_bbs_in_dom_tree (cfun->cfg->x_n_bbs_in_dom_tree)
  569. #define VALUE_HISTOGRAMS(fun) (fun)->value_histograms
  570. /* A pointer to a function to create target specific, per-function
  571. data structures. */
  572. extern struct machine_function * (*init_machine_status) (void);
  573. enum direction {none, upward, downward};
  574. /* Structure to record the size of a sequence of arguments
  575. as the sum of a tree-expression and a constant. This structure is
  576. also used to store offsets from the stack, which might be negative,
  577. so the variable part must be ssizetype, not sizetype. */
  578. struct args_size
  579. {
  580. HOST_WIDE_INT constant;
  581. tree var;
  582. };
  583. /* Package up various arg related fields of struct args for
  584. locate_and_pad_parm. */
  585. struct locate_and_pad_arg_data
  586. {
  587. /* Size of this argument on the stack, rounded up for any padding it
  588. gets. If REG_PARM_STACK_SPACE is defined, then register parms are
  589. counted here, otherwise they aren't. */
  590. struct args_size size;
  591. /* Offset of this argument from beginning of stack-args. */
  592. struct args_size offset;
  593. /* Offset to the start of the stack slot. Different from OFFSET
  594. if this arg pads downward. */
  595. struct args_size slot_offset;
  596. /* The amount that the stack pointer needs to be adjusted to
  597. force alignment for the next argument. */
  598. struct args_size alignment_pad;
  599. /* Which way we should pad this arg. */
  600. enum direction where_pad;
  601. /* slot_offset is at least this aligned. */
  602. unsigned int boundary;
  603. };
  604. /* Add the value of the tree INC to the `struct args_size' TO. */
  605. #define ADD_PARM_SIZE(TO, INC) \
  606. do { \
  607. tree inc = (INC); \
  608. if (tree_fits_shwi_p (inc)) \
  609. (TO).constant += tree_to_shwi (inc); \
  610. else if ((TO).var == 0) \
  611. (TO).var = fold_convert (ssizetype, inc); \
  612. else \
  613. (TO).var = size_binop (PLUS_EXPR, (TO).var, \
  614. fold_convert (ssizetype, inc)); \
  615. } while (0)
  616. #define SUB_PARM_SIZE(TO, DEC) \
  617. do { \
  618. tree dec = (DEC); \
  619. if (tree_fits_shwi_p (dec)) \
  620. (TO).constant -= tree_to_shwi (dec); \
  621. else if ((TO).var == 0) \
  622. (TO).var = size_binop (MINUS_EXPR, ssize_int (0), \
  623. fold_convert (ssizetype, dec)); \
  624. else \
  625. (TO).var = size_binop (MINUS_EXPR, (TO).var, \
  626. fold_convert (ssizetype, dec)); \
  627. } while (0)
  628. /* Convert the implicit sum in a `struct args_size' into a tree
  629. of type ssizetype. */
  630. #define ARGS_SIZE_TREE(SIZE) \
  631. ((SIZE).var == 0 ? ssize_int ((SIZE).constant) \
  632. : size_binop (PLUS_EXPR, fold_convert (ssizetype, (SIZE).var), \
  633. ssize_int ((SIZE).constant)))
  634. /* Convert the implicit sum in a `struct args_size' into an rtx. */
  635. #define ARGS_SIZE_RTX(SIZE) \
  636. ((SIZE).var == 0 ? GEN_INT ((SIZE).constant) \
  637. : expand_normal (ARGS_SIZE_TREE (SIZE)))
  638. #define ASLK_REDUCE_ALIGN 1
  639. #define ASLK_RECORD_PAD 2
  640. extern void push_function_context (void);
  641. extern void pop_function_context (void);
  642. /* Save and restore status information for a nested function. */
  643. extern void free_after_parsing (struct function *);
  644. extern void free_after_compilation (struct function *);
  645. /* Return size needed for stack frame based on slots so far allocated.
  646. This size counts from zero. It is not rounded to STACK_BOUNDARY;
  647. the caller may have to do that. */
  648. extern HOST_WIDE_INT get_frame_size (void);
  649. /* Issue an error message and return TRUE if frame OFFSET overflows in
  650. the signed target pointer arithmetics for function FUNC. Otherwise
  651. return FALSE. */
  652. extern bool frame_offset_overflow (HOST_WIDE_INT, tree);
  653. extern rtx assign_stack_local_1 (machine_mode, HOST_WIDE_INT, int, int);
  654. extern rtx assign_stack_local (machine_mode, HOST_WIDE_INT, int);
  655. extern rtx assign_stack_temp_for_type (machine_mode, HOST_WIDE_INT, tree);
  656. extern rtx assign_stack_temp (machine_mode, HOST_WIDE_INT);
  657. extern rtx assign_temp (tree, int, int);
  658. extern void update_temp_slot_address (rtx, rtx);
  659. extern void preserve_temp_slots (rtx);
  660. extern void free_temp_slots (void);
  661. extern void push_temp_slots (void);
  662. extern void pop_temp_slots (void);
  663. extern void init_temp_slots (void);
  664. extern rtx get_hard_reg_initial_reg (rtx);
  665. extern rtx get_hard_reg_initial_val (machine_mode, unsigned int);
  666. extern rtx has_hard_reg_initial_val (machine_mode, unsigned int);
  667. /* Called from gimple_expand_cfg. */
  668. extern unsigned int emit_initial_value_sets (void);
  669. extern bool initial_value_entry (int i, rtx *, rtx *);
  670. extern void instantiate_decl_rtl (rtx x);
  671. extern int aggregate_value_p (const_tree, const_tree);
  672. extern bool use_register_for_decl (const_tree);
  673. extern bool pass_by_reference (CUMULATIVE_ARGS *, machine_mode,
  674. tree, bool);
  675. extern bool reference_callee_copied (CUMULATIVE_ARGS *, machine_mode,
  676. tree, bool);
  677. extern gimple_seq gimplify_parameters (void);
  678. extern void locate_and_pad_parm (machine_mode, tree, int, int, int,
  679. tree, struct args_size *,
  680. struct locate_and_pad_arg_data *);
  681. extern void generate_setjmp_warnings (void);
  682. /* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END},
  683. and create duplicate blocks. */
  684. extern void reorder_blocks (void);
  685. extern void clear_block_marks (tree);
  686. extern tree blocks_nreverse (tree);
  687. extern tree block_chainon (tree, tree);
  688. /* Set BLOCK_NUMBER for all the blocks in FN. */
  689. extern void number_blocks (tree);
  690. /* cfun shouldn't be set directly; use one of these functions instead. */
  691. extern void set_cfun (struct function *new_cfun);
  692. extern void push_cfun (struct function *new_cfun);
  693. extern void pop_cfun (void);
  694. extern int get_next_funcdef_no (void);
  695. extern int get_last_funcdef_no (void);
  696. extern void allocate_struct_function (tree, bool);
  697. extern void push_struct_function (tree fndecl);
  698. extern void init_dummy_function_start (void);
  699. extern void init_function_start (tree);
  700. extern void stack_protect_epilogue (void);
  701. extern void expand_function_start (tree);
  702. extern void expand_dummy_function_end (void);
  703. extern void thread_prologue_and_epilogue_insns (void);
  704. #ifdef RTX_CODE
  705. extern void diddle_return_value (void (*)(rtx, void*), void*);
  706. extern void clobber_return_register (void);
  707. #endif
  708. extern void do_warn_unused_parameter (tree);
  709. extern void expand_function_end (void);
  710. extern rtx get_arg_pointer_save_area (void);
  711. extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
  712. extern int prologue_epilogue_contains (const_rtx);
  713. extern void emit_return_into_block (bool simple_p, basic_block bb);
  714. extern void set_return_jump_label (rtx);
  715. extern bool active_insn_between (rtx_insn *head, rtx_insn *tail);
  716. extern vec<edge> convert_jumps_to_returns (basic_block last_bb, bool simple_p,
  717. vec<edge> unconverted);
  718. extern basic_block emit_return_for_exit (edge exit_fallthru_edge,
  719. bool simple_p);
  720. extern void reposition_prologue_and_epilogue_notes (void);
  721. /* Returns the name of the current function. */
  722. extern const char *fndecl_name (tree);
  723. extern const char *function_name (struct function *);
  724. extern const char *current_function_name (void);
  725. extern void used_types_insert (tree);
  726. #endif /* GCC_FUNCTION_H */