cilk.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* This file is part of the Intel(R) Cilk(TM) Plus support
  2. This file contains Cilk Support files.
  3. Copyright (C) 2013-2015 Free Software Foundation, Inc.
  4. Contributed by Balaji V. Iyer <balaji.v.iyer@intel.com>,
  5. Intel Corporation
  6. This file is part of GCC.
  7. GCC is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 3, or (at your option)
  10. any later version.
  11. GCC is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with GCC; see the file COPYING3. If not see
  17. <http://www.gnu.org/licenses/>. */
  18. #ifndef GCC_CILK_H
  19. #define GCC_CILK_H
  20. /* Frame status bits known to compiler. */
  21. #define CILK_FRAME_UNSYNCHED 0x02
  22. #define CILK_FRAME_DETACHED 0x04
  23. #define CILK_FRAME_EXCEPTING 0x10
  24. #define CILK_FRAME_VERSION (1 << 24)
  25. enum cilk_tree_index {
  26. /* All the built-in functions for Cilk keywords. */
  27. CILK_TI_F_WORKER = 0, /* __cilkrts_get_worker (). */
  28. CILK_TI_F_SYNC, /* __cilkrts_sync (). */
  29. CILK_TI_F_DETACH, /* __cilkrts_detach (...). */
  30. CILK_TI_F_ENTER, /* __cilkrts_enter_frame (...). */
  31. CILK_TI_F_ENTER_FAST, /* __cilkrts_enter_frame_fast (.). */
  32. CILK_TI_F_LEAVE, /* __cilkrts_leave_frame (...). */
  33. CILK_TI_F_POP, /* __cilkrts_pop_frame (...). */
  34. CILK_TI_F_RETHROW, /* __cilkrts_rethrow (...). */
  35. CILK_TI_F_SAVE_FP, /* __cilkrts_save_fp_ctrl_state (...). */
  36. CILK_TI_F_LOOP_32, /* __cilkrts_cilk_for_32 (...). */
  37. CILK_TI_F_LOOP_64, /* __cilkrts_cilk_for_64 (...). */
  38. /* __cilkrts_stack_frame struct fields. */
  39. CILK_TI_FRAME_FLAGS, /* stack_frame->flags. */
  40. CILK_TI_FRAME_PARENT, /* stack_frame->parent. */
  41. CILK_TI_FRAME_WORKER, /* stack_frame->worker. */
  42. CILK_TI_FRAME_EXCEPTION, /* stack_frame->except_data. */
  43. CILK_TI_FRAME_CONTEXT, /* stack_frame->context[4]. */
  44. CILK_TI_FRAME_PEDIGREE, /* stack_frame->pedigree. */
  45. /* __cilkrts_worker struct fields. */
  46. CILK_TI_WORKER_CUR, /* worker->current_stack_frame. */
  47. CILK_TI_WORKER_TAIL, /* worker->tail. */
  48. CILK_TI_WORKER_PEDIGREE, /* worker->pedigree. */
  49. /* __cilkrts_pedigree struct fields. */
  50. CILK_TI_PEDIGREE_RANK, /* pedigree->rank. */
  51. CILK_TI_PEDIGREE_PARENT, /* pedigree->parent. */
  52. /* Types. */
  53. CILK_TI_FRAME_TYPE, /* struct __cilkrts_stack_frame. */
  54. CILK_TI_FRAME_PTR, /* __cilkrts_stack_frame *. */
  55. CILK_TI_WORKER_TYPE, /* struct __cilkrts_worker. */
  56. CILK_TI_PEDIGREE_TYPE, /* struct __cilkrts_pedigree. */
  57. CILK_TI_MAX
  58. };
  59. extern GTY (()) tree cilk_trees[CILK_TI_MAX];
  60. #define cilk_worker_fndecl cilk_trees[CILK_TI_F_WORKER]
  61. #define cilk_sync_fndecl cilk_trees[CILK_TI_F_SYNC]
  62. #define cilk_synched_fndecl cilk_trees[CILK_TI_F_SYNCED]
  63. #define cilk_detach_fndecl cilk_trees[CILK_TI_F_DETACH]
  64. #define cilk_enter_fndecl cilk_trees[CILK_TI_F_ENTER]
  65. #define cilk_enter_fast_fndecl cilk_trees[CILK_TI_F_ENTER_FAST]
  66. #define cilk_leave_fndecl cilk_trees[CILK_TI_F_LEAVE]
  67. #define cilk_rethrow_fndecl cilk_trees[CILK_TI_F_RETHROW]
  68. #define cilk_pop_fndecl cilk_trees[CILK_TI_F_POP]
  69. #define cilk_save_fp_fndecl cilk_trees[CILK_TI_F_SAVE_FP]
  70. #define cilk_for_32_fndecl cilk_trees[CILK_TI_F_LOOP_32]
  71. #define cilk_for_64_fndecl cilk_trees[CILK_TI_F_LOOP_64]
  72. #define cilk_worker_type_fndecl cilk_trees[CILK_TI_WORKER_TYPE]
  73. #define cilk_frame_type_decl cilk_trees[CILK_TI_FRAME_TYPE]
  74. #define cilk_frame_ptr_type_decl cilk_trees[CILK_TI_FRAME_PTR]
  75. #define cilk_pedigree_type_decl cilk_trees[CILK_TI_PEDIGREE_TYPE]
  76. extern void expand_builtin_cilk_detach (tree);
  77. extern void expand_builtin_cilk_pop_frame (tree);
  78. extern tree cilk_arrow (tree, int, bool);
  79. extern tree cilk_dot (tree, int, bool);
  80. extern void cilk_init_builtins (void);
  81. extern void gimplify_cilk_sync (tree *, gimple_seq *);
  82. extern tree cilk_call_setjmp (tree);
  83. /* Returns true if Cilk Plus is enabled and if F->cilk_frame_decl is not
  84. NULL_TREE. */
  85. inline bool
  86. fn_contains_cilk_spawn_p (function *f)
  87. {
  88. return (flag_cilkplus
  89. && (f->calls_cilk_spawn || f->cilk_frame_decl != NULL_TREE));
  90. }
  91. #endif