| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <!-- Copyright (C) 1988-2015 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being "Funding Free Software", the Front-Cover |
| Texts being (a) (see below), and with the Back-Cover Texts being (b) |
| (see below). A copy of the license is included in the section entitled |
| "GNU Free Documentation License". |
| |
| (a) The FSF's Front-Cover Text is: |
| |
| A GNU Manual |
| |
| (b) The FSF's Back-Cover Text is: |
| |
| You have freedom to copy and modify this GNU Manual, like GNU |
| software. Copies published by the Free Software Foundation raise |
| funds for GNU development. --> |
| <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> |
| <head> |
| <title>GNU Compiler Collection (GCC) Internals: Cilk Plus Transformation</title> |
| |
| <meta name="description" content="GNU Compiler Collection (GCC) Internals: Cilk Plus Transformation"> |
| <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Cilk Plus Transformation"> |
| <meta name="resource-type" content="document"> |
| <meta name="distribution" content="global"> |
| <meta name="Generator" content="makeinfo"> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <link href="index.html#Top" rel="start" title="Top"> |
| <link href="Option-Index.html#Option-Index" rel="index" title="Option Index"> |
| <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| <link href="Passes.html#Passes" rel="up" title="Passes"> |
| <link href="Gimplification-pass.html#Gimplification-pass" rel="next" title="Gimplification pass"> |
| <link href="Parsing-pass.html#Parsing-pass" rel="prev" title="Parsing pass"> |
| <style type="text/css"> |
| <!-- |
| a.summary-letter {text-decoration: none} |
| blockquote.smallquotation {font-size: smaller} |
| div.display {margin-left: 3.2em} |
| div.example {margin-left: 3.2em} |
| div.indentedblock {margin-left: 3.2em} |
| div.lisp {margin-left: 3.2em} |
| div.smalldisplay {margin-left: 3.2em} |
| div.smallexample {margin-left: 3.2em} |
| div.smallindentedblock {margin-left: 3.2em; font-size: smaller} |
| div.smalllisp {margin-left: 3.2em} |
| kbd {font-style:oblique} |
| pre.display {font-family: inherit} |
| pre.format {font-family: inherit} |
| pre.menu-comment {font-family: serif} |
| pre.menu-preformatted {font-family: serif} |
| pre.smalldisplay {font-family: inherit; font-size: smaller} |
| pre.smallexample {font-size: smaller} |
| pre.smallformat {font-family: inherit; font-size: smaller} |
| pre.smalllisp {font-size: smaller} |
| span.nocodebreak {white-space:nowrap} |
| span.nolinebreak {white-space:nowrap} |
| span.roman {font-family:serif; font-weight:normal} |
| span.sansserif {font-family:sans-serif; font-weight:normal} |
| ul.no-bullet {list-style: none} |
| --> |
| </style> |
| |
| |
| </head> |
| |
| <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> |
| <a name="Cilk-Plus-Transformation"></a> |
| <div class="header"> |
| <p> |
| Next: <a href="Gimplification-pass.html#Gimplification-pass" accesskey="n" rel="next">Gimplification pass</a>, Previous: <a href="Parsing-pass.html#Parsing-pass" accesskey="p" rel="prev">Parsing pass</a>, Up: <a href="Passes.html#Passes" accesskey="u" rel="up">Passes</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p> |
| </div> |
| <hr> |
| <a name="Cilk-Plus-Transformation-1"></a> |
| <h3 class="section">9.2 Cilk Plus Transformation</h3> |
| <a name="index-CILK_005fPLUS"></a> |
| |
| <p>If Cilk Plus generation (flag <samp>-fcilkplus</samp>) 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. |
| </p> |
| <p>These are the major components to the Cilk Plus language extension: |
| </p><ul> |
| <li> Array Notations: |
| During parsing phase, all the array notation specific information is stored in |
| <code>ARRAY_NOTATION_REF</code> tree using the function |
| <code>c_parser_array_notation</code>. During the end of parsing, we check the entire |
| function to see if there are any array notation specific code (using the |
| function <code>contains_array_notation_expr</code>). If this function returns |
| true, then we expand them using either <code>expand_array_notation_exprs</code> or |
| <code>build_array_notation_expr</code>. For the cases where array notations are |
| inside conditions, they are transformed using the function |
| <code>fix_conditional_array_notations</code>. The C language-specific routines are |
| located in <samp>c/c-array-notation.c</samp> and the equivalent C++ routines are in |
| the file <samp>cp/cp-array-notation.c</samp>. Common routines such as functions to |
| initialize built-in functions are stored in <samp>array-notation-common.c</samp>. |
| |
| </li><li> Cilk keywords: |
| <ul> |
| <li> <code>_Cilk_spawn</code>: |
| The <code>_Cilk_spawn</code> keyword 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 |
| <code>cilk_init_builtins</code> in the file <samp>cilk-common.c</samp>. The pointers to |
| Cilk functions and fields of internal structures are described |
| in <samp>cilk.h</samp>. The built-in functions are described in |
| <samp>cilk-builtins.def</samp>. |
| |
| <p>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 <code>gimplify_cilk_spawn</code> in |
| <samp>c-family/cilk.c</samp>. In the spawn-helper, the gimplification function |
| <code>gimplify_call_expr</code>, inserts a function call <code>__cilkrts_detach</code>. |
| This function is expanded by <code>builtin_expand_cilk_detach</code> located in |
| <samp>c-family/cilk.c</samp>. |
| </p> |
| </li><li> <code>_Cilk_sync</code>: |
| <code>_Cilk_sync</code> is parsed like a keyword. During gimplification, |
| the function <code>gimplify_cilk_sync</code> in <samp>c-family/cilk.c</samp>, will replace |
| this keyword with a set of functions that are stored in the Cilk runtime. |
| One of the internal functions inserted during gimplification, |
| <code>__cilkrts_pop_frame</code> must be expanded by the compiler and is |
| done by <code>builtin_expand_cilk_pop_frame</code> in <samp>cilk-common.c</samp>. |
| |
| </li></ul> |
| </li></ul> |
| |
| <p>Documentation about Cilk Plus and language specification is provided under the |
| "Learn" section in <a href="http://www.cilkplus.org/">http://www.cilkplus.org/</a><!-- /@w -->. It is worth mentioning |
| that the current implementation follows ABI 1.1. |
| </p> |
| <hr> |
| <div class="header"> |
| <p> |
| Next: <a href="Gimplification-pass.html#Gimplification-pass" accesskey="n" rel="next">Gimplification pass</a>, Previous: <a href="Parsing-pass.html#Parsing-pass" accesskey="p" rel="prev">Parsing pass</a>, Up: <a href="Passes.html#Passes" accesskey="u" rel="up">Passes</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p> |
| </div> |
| |
| |
| |
| </body> |
| </html> |