Manipulating-GIMPLE-statements.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Manipulating GIMPLE statements</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Manipulating GIMPLE statements">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Manipulating GIMPLE statements">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="GIMPLE.html#GIMPLE" rel="up" title="GIMPLE">
  30. <link href="Tuple-specific-accessors.html#Tuple-specific-accessors" rel="next" title="Tuple specific accessors">
  31. <link href="Logical-Operators.html#Logical-Operators" rel="prev" title="Logical Operators">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Manipulating-GIMPLE-statements"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Tuple-specific-accessors.html#Tuple-specific-accessors" accesskey="n" rel="next">Tuple specific accessors</a>, Previous: <a href="Operands.html#Operands" accesskey="p" rel="prev">Operands</a>, Up: <a href="GIMPLE.html#GIMPLE" accesskey="u" rel="up">GIMPLE</a> &nbsp; [<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>
  66. </div>
  67. <hr>
  68. <a name="Manipulating-GIMPLE-statements-1"></a>
  69. <h3 class="section">11.7 Manipulating GIMPLE statements</h3>
  70. <a name="index-Manipulating-GIMPLE-statements"></a>
  71. <p>This section documents all the functions available to handle each
  72. of the GIMPLE instructions.
  73. </p>
  74. <a name="Common-accessors"></a>
  75. <h4 class="subsection">11.7.1 Common accessors</h4>
  76. <p>The following are common accessors for gimple statements.
  77. </p>
  78. <dl>
  79. <dt><a name="index-gimple_005fcode"></a>GIMPLE function: <em>enum gimple_code</em> <strong>gimple_code</strong> <em>(gimple g)</em></dt>
  80. <dd><p>Return the code for statement <code>G</code>.
  81. </p></dd></dl>
  82. <dl>
  83. <dt><a name="index-gimple_005fbb"></a>GIMPLE function: <em>basic_block</em> <strong>gimple_bb</strong> <em>(gimple g)</em></dt>
  84. <dd><p>Return the basic block to which statement <code>G</code> belongs to.
  85. </p></dd></dl>
  86. <dl>
  87. <dt><a name="index-gimple_005fblock"></a>GIMPLE function: <em>tree</em> <strong>gimple_block</strong> <em>(gimple g)</em></dt>
  88. <dd><p>Return the lexical scope block holding statement <code>G</code>.
  89. </p></dd></dl>
  90. <dl>
  91. <dt><a name="index-gimple_005fexpr_005ftype"></a>GIMPLE function: <em>tree</em> <strong>gimple_expr_type</strong> <em>(gimple stmt)</em></dt>
  92. <dd><p>Return the type of the main expression computed by <code>STMT</code>. Return
  93. <code>void_type_node</code> if <code>STMT</code> computes nothing. This will only return
  94. something meaningful for <code>GIMPLE_ASSIGN</code>, <code>GIMPLE_COND</code> and
  95. <code>GIMPLE_CALL</code>. For all other tuple codes, it will return
  96. <code>void_type_node</code>.
  97. </p></dd></dl>
  98. <dl>
  99. <dt><a name="index-gimple_005fexpr_005fcode"></a>GIMPLE function: <em>enum tree_code</em> <strong>gimple_expr_code</strong> <em>(gimple stmt)</em></dt>
  100. <dd><p>Return the tree code for the expression computed by <code>STMT</code>. This
  101. is only meaningful for <code>GIMPLE_CALL</code>, <code>GIMPLE_ASSIGN</code> and
  102. <code>GIMPLE_COND</code>. If <code>STMT</code> is <code>GIMPLE_CALL</code>, it will return <code>CALL_EXPR</code>.
  103. For <code>GIMPLE_COND</code>, it returns the code of the comparison predicate.
  104. For <code>GIMPLE_ASSIGN</code> it returns the code of the operation performed
  105. by the <code>RHS</code> of the assignment.
  106. </p></dd></dl>
  107. <dl>
  108. <dt><a name="index-gimple_005fset_005fblock"></a>GIMPLE function: <em>void</em> <strong>gimple_set_block</strong> <em>(gimple g, tree block)</em></dt>
  109. <dd><p>Set the lexical scope block of <code>G</code> to <code>BLOCK</code>.
  110. </p></dd></dl>
  111. <dl>
  112. <dt><a name="index-gimple_005flocus"></a>GIMPLE function: <em>location_t</em> <strong>gimple_locus</strong> <em>(gimple g)</em></dt>
  113. <dd><p>Return locus information for statement <code>G</code>.
  114. </p></dd></dl>
  115. <dl>
  116. <dt><a name="index-gimple_005fset_005flocus"></a>GIMPLE function: <em>void</em> <strong>gimple_set_locus</strong> <em>(gimple g, location_t locus)</em></dt>
  117. <dd><p>Set locus information for statement <code>G</code>.
  118. </p></dd></dl>
  119. <dl>
  120. <dt><a name="index-gimple_005flocus_005fempty_005fp"></a>GIMPLE function: <em>bool</em> <strong>gimple_locus_empty_p</strong> <em>(gimple g)</em></dt>
  121. <dd><p>Return true if <code>G</code> does not have locus information.
  122. </p></dd></dl>
  123. <dl>
  124. <dt><a name="index-gimple_005fno_005fwarning_005fp"></a>GIMPLE function: <em>bool</em> <strong>gimple_no_warning_p</strong> <em>(gimple stmt)</em></dt>
  125. <dd><p>Return true if no warnings should be emitted for statement <code>STMT</code>.
  126. </p></dd></dl>
  127. <dl>
  128. <dt><a name="index-gimple_005fset_005fvisited"></a>GIMPLE function: <em>void</em> <strong>gimple_set_visited</strong> <em>(gimple stmt, bool visited_p)</em></dt>
  129. <dd><p>Set the visited status on statement <code>STMT</code> to <code>VISITED_P</code>.
  130. </p></dd></dl>
  131. <dl>
  132. <dt><a name="index-gimple_005fvisited_005fp"></a>GIMPLE function: <em>bool</em> <strong>gimple_visited_p</strong> <em>(gimple stmt)</em></dt>
  133. <dd><p>Return the visited status on statement <code>STMT</code>.
  134. </p></dd></dl>
  135. <dl>
  136. <dt><a name="index-gimple_005fset_005fplf"></a>GIMPLE function: <em>void</em> <strong>gimple_set_plf</strong> <em>(gimple stmt, enum plf_mask plf, bool val_p)</em></dt>
  137. <dd><p>Set pass local flag <code>PLF</code> on statement <code>STMT</code> to <code>VAL_P</code>.
  138. </p></dd></dl>
  139. <dl>
  140. <dt><a name="index-gimple_005fplf"></a>GIMPLE function: <em>unsigned int</em> <strong>gimple_plf</strong> <em>(gimple stmt, enum plf_mask plf)</em></dt>
  141. <dd><p>Return the value of pass local flag <code>PLF</code> on statement <code>STMT</code>.
  142. </p></dd></dl>
  143. <dl>
  144. <dt><a name="index-gimple_005fhas_005fops"></a>GIMPLE function: <em>bool</em> <strong>gimple_has_ops</strong> <em>(gimple g)</em></dt>
  145. <dd><p>Return true if statement <code>G</code> has register or memory operands.
  146. </p></dd></dl>
  147. <dl>
  148. <dt><a name="index-gimple_005fhas_005fmem_005fops"></a>GIMPLE function: <em>bool</em> <strong>gimple_has_mem_ops</strong> <em>(gimple g)</em></dt>
  149. <dd><p>Return true if statement <code>G</code> has memory operands.
  150. </p></dd></dl>
  151. <dl>
  152. <dt><a name="index-gimple_005fnum_005fops-1"></a>GIMPLE function: <em>unsigned</em> <strong>gimple_num_ops</strong> <em>(gimple g)</em></dt>
  153. <dd><p>Return the number of operands for statement <code>G</code>.
  154. </p></dd></dl>
  155. <dl>
  156. <dt><a name="index-gimple_005fops-1"></a>GIMPLE function: <em>tree *</em> <strong>gimple_ops</strong> <em>(gimple g)</em></dt>
  157. <dd><p>Return the array of operands for statement <code>G</code>.
  158. </p></dd></dl>
  159. <dl>
  160. <dt><a name="index-gimple_005fop-1"></a>GIMPLE function: <em>tree</em> <strong>gimple_op</strong> <em>(gimple g, unsigned i)</em></dt>
  161. <dd><p>Return operand <code>I</code> for statement <code>G</code>.
  162. </p></dd></dl>
  163. <dl>
  164. <dt><a name="index-gimple_005fop_005fptr"></a>GIMPLE function: <em>tree *</em> <strong>gimple_op_ptr</strong> <em>(gimple g, unsigned i)</em></dt>
  165. <dd><p>Return a pointer to operand <code>I</code> for statement <code>G</code>.
  166. </p></dd></dl>
  167. <dl>
  168. <dt><a name="index-gimple_005fset_005fop"></a>GIMPLE function: <em>void</em> <strong>gimple_set_op</strong> <em>(gimple g, unsigned i, tree op)</em></dt>
  169. <dd><p>Set operand <code>I</code> of statement <code>G</code> to <code>OP</code>.
  170. </p></dd></dl>
  171. <dl>
  172. <dt><a name="index-gimple_005faddresses_005ftaken"></a>GIMPLE function: <em>bitmap</em> <strong>gimple_addresses_taken</strong> <em>(gimple stmt)</em></dt>
  173. <dd><p>Return the set of symbols that have had their address taken by
  174. <code>STMT</code>.
  175. </p></dd></dl>
  176. <dl>
  177. <dt><a name="index-gimple_005fdef_005fops"></a>GIMPLE function: <em>struct def_optype_d *</em> <strong>gimple_def_ops</strong> <em>(gimple g)</em></dt>
  178. <dd><p>Return the set of <code>DEF</code> operands for statement <code>G</code>.
  179. </p></dd></dl>
  180. <dl>
  181. <dt><a name="index-gimple_005fset_005fdef_005fops"></a>GIMPLE function: <em>void</em> <strong>gimple_set_def_ops</strong> <em>(gimple g, struct def_optype_d *def)</em></dt>
  182. <dd><p>Set <code>DEF</code> to be the set of <code>DEF</code> operands for statement <code>G</code>.
  183. </p></dd></dl>
  184. <dl>
  185. <dt><a name="index-gimple_005fuse_005fops"></a>GIMPLE function: <em>struct use_optype_d *</em> <strong>gimple_use_ops</strong> <em>(gimple g)</em></dt>
  186. <dd><p>Return the set of <code>USE</code> operands for statement <code>G</code>.
  187. </p></dd></dl>
  188. <dl>
  189. <dt><a name="index-gimple_005fset_005fuse_005fops"></a>GIMPLE function: <em>void</em> <strong>gimple_set_use_ops</strong> <em>(gimple g, struct use_optype_d *use)</em></dt>
  190. <dd><p>Set <code>USE</code> to be the set of <code>USE</code> operands for statement <code>G</code>.
  191. </p></dd></dl>
  192. <dl>
  193. <dt><a name="index-gimple_005fvuse_005fops"></a>GIMPLE function: <em>struct voptype_d *</em> <strong>gimple_vuse_ops</strong> <em>(gimple g)</em></dt>
  194. <dd><p>Return the set of <code>VUSE</code> operands for statement <code>G</code>.
  195. </p></dd></dl>
  196. <dl>
  197. <dt><a name="index-gimple_005fset_005fvuse_005fops"></a>GIMPLE function: <em>void</em> <strong>gimple_set_vuse_ops</strong> <em>(gimple g, struct voptype_d *ops)</em></dt>
  198. <dd><p>Set <code>OPS</code> to be the set of <code>VUSE</code> operands for statement <code>G</code>.
  199. </p></dd></dl>
  200. <dl>
  201. <dt><a name="index-gimple_005fvdef_005fops"></a>GIMPLE function: <em>struct voptype_d *</em> <strong>gimple_vdef_ops</strong> <em>(gimple g)</em></dt>
  202. <dd><p>Return the set of <code>VDEF</code> operands for statement <code>G</code>.
  203. </p></dd></dl>
  204. <dl>
  205. <dt><a name="index-gimple_005fset_005fvdef_005fops"></a>GIMPLE function: <em>void</em> <strong>gimple_set_vdef_ops</strong> <em>(gimple g, struct voptype_d *ops)</em></dt>
  206. <dd><p>Set <code>OPS</code> to be the set of <code>VDEF</code> operands for statement <code>G</code>.
  207. </p></dd></dl>
  208. <dl>
  209. <dt><a name="index-gimple_005floaded_005fsyms"></a>GIMPLE function: <em>bitmap</em> <strong>gimple_loaded_syms</strong> <em>(gimple g)</em></dt>
  210. <dd><p>Return the set of symbols loaded by statement <code>G</code>. Each element of
  211. the set is the <code>DECL_UID</code> of the corresponding symbol.
  212. </p></dd></dl>
  213. <dl>
  214. <dt><a name="index-gimple_005fstored_005fsyms"></a>GIMPLE function: <em>bitmap</em> <strong>gimple_stored_syms</strong> <em>(gimple g)</em></dt>
  215. <dd><p>Return the set of symbols stored by statement <code>G</code>. Each element of
  216. the set is the <code>DECL_UID</code> of the corresponding symbol.
  217. </p></dd></dl>
  218. <dl>
  219. <dt><a name="index-gimple_005fmodified_005fp"></a>GIMPLE function: <em>bool</em> <strong>gimple_modified_p</strong> <em>(gimple g)</em></dt>
  220. <dd><p>Return true if statement <code>G</code> has operands and the modified field
  221. has been set.
  222. </p></dd></dl>
  223. <dl>
  224. <dt><a name="index-gimple_005fhas_005fvolatile_005fops"></a>GIMPLE function: <em>bool</em> <strong>gimple_has_volatile_ops</strong> <em>(gimple stmt)</em></dt>
  225. <dd><p>Return true if statement <code>STMT</code> contains volatile operands.
  226. </p></dd></dl>
  227. <dl>
  228. <dt><a name="index-gimple_005fset_005fhas_005fvolatile_005fops"></a>GIMPLE function: <em>void</em> <strong>gimple_set_has_volatile_ops</strong> <em>(gimple stmt, bool volatilep)</em></dt>
  229. <dd><p>Return true if statement <code>STMT</code> contains volatile operands.
  230. </p></dd></dl>
  231. <dl>
  232. <dt><a name="index-update_005fstmt"></a>GIMPLE function: <em>void</em> <strong>update_stmt</strong> <em>(gimple s)</em></dt>
  233. <dd><p>Mark statement <code>S</code> as modified, and update it.
  234. </p></dd></dl>
  235. <dl>
  236. <dt><a name="index-update_005fstmt_005fif_005fmodified"></a>GIMPLE function: <em>void</em> <strong>update_stmt_if_modified</strong> <em>(gimple s)</em></dt>
  237. <dd><p>Update statement <code>S</code> if it has been marked modified.
  238. </p></dd></dl>
  239. <dl>
  240. <dt><a name="index-gimple_005fcopy"></a>GIMPLE function: <em>gimple</em> <strong>gimple_copy</strong> <em>(gimple stmt)</em></dt>
  241. <dd><p>Return a deep copy of statement <code>STMT</code>.
  242. </p></dd></dl>
  243. <hr>
  244. <div class="header">
  245. <p>
  246. Next: <a href="Tuple-specific-accessors.html#Tuple-specific-accessors" accesskey="n" rel="next">Tuple specific accessors</a>, Previous: <a href="Operands.html#Operands" accesskey="p" rel="prev">Operands</a>, Up: <a href="GIMPLE.html#GIMPLE" accesskey="u" rel="up">GIMPLE</a> &nbsp; [<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>
  247. </div>
  248. </body>
  249. </html>