If Cilk Plus generation (flag -fcilkplus) is enabled, all the Cilk Plus code is transformed into equivalent C and C++ functions. Majority of this transformation occurs toward the end of the parsing and right before the gimplification pass.
These are the major components to the Cilk Plus language extension:
ARRAY_NOTATION_REFtree using the function
c_parser_array_notation. During the end of parsing, we check the entire function to see if there are any array notation specific code (using the function
contains_array_notation_expr). If this function returns true, then we expand them using either
build_array_notation_expr. For the cases where array notations are inside conditions, they are transformed using the function
fix_conditional_array_notations. The C language-specific routines are located in c/c-array-notation.c and the equivalent C++ routines are in the file cp/cp-array-notation.c. Common routines such as functions to initialize built-in functions are stored in array-notation-common.c.
_Cilk_spawnkeyword is parsed and the function it contains is marked as a spawning function. The spawning function is called the spawner. At the end of the parsing phase, appropriate built-in functions are added to the spawner that are defined in the Cilk runtime. The appropriate locations of these functions, and the internal structures are detailed in
cilk_init_builtinsin the file cilk-common.c. The pointers to Cilk functions and fields of internal structures are described in cilk.h. The built-in functions are described in cilk-builtins.def.
During gimplification, a new "spawn-helper" function is created.
The spawned function is replaced with a spawn helper function in the spawner.
The spawned function-call is moved into the spawn helper. The main function
that does these transformations is
c-family/cilk.c. In the spawn-helper, the gimplification function
gimplify_call_expr, inserts a function call
This function is expanded by
builtin_expand_cilk_detach located in
_Cilk_syncis parsed like a keyword. During gimplification, the function
gimplify_cilk_syncin c-family/cilk.c, will replace this keyword with a set of functions that are stored in the Cilk runtime. One of the internal functions inserted during gimplification,
__cilkrts_pop_framemust be expanded by the compiler and is done by
Documentation about Cilk Plus and language specification is provided under the "Learn" section in https://www.cilkplus.org. It is worth mentioning that the current implementation follows ABI 1.1.