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