GCC Wikia
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

  • gcc-4.1.0/gcc/tree.cにて定義
  • コードcodeで木によって占められるバイト数を計算
    • TREE_VEC、PHI_NODE、STRING_CSTに使えないのはそれらが可変長であるため

引数[]

実装[]

 263 /* Compute the number of bytes occupied by a tree with code CODE.
 264    This function cannot be used for TREE_VEC, PHI_NODE, or STRING_CST
 265    codes, which are of variable length.  */
266 size_t
267 tree_code_size (enum tree_code code)
268 {
269   switch (TREE_CODE_CLASS (code))
270     {

~

271     case [[tcc_declaration>enum tree_code_class]]:  /* A decl node */
272       {
273         switch (code)
274           {
275           case [[FIELD_DECL>enum tree_code]]:
276             return sizeof (struct tree_field_decl);
277           case [[PARM_DECL>enum tree_code_class]]:
278             return sizeof (struct tree_parm_decl);
279           case [[VAR_DECL>enum tree_code_class]]:
280             return sizeof (struct tree_var_decl);
281           case [[LABEL_DECL>enum tree_code_class]]:
282             return sizeof (struct tree_label_decl);
283           case [[RESULT_DECL>enum tree_code_class]]:
284             return sizeof (struct tree_result_decl);
285           case [[CONST_DECL>enum tree_code_class]]:
286             return sizeof (struct tree_const_decl);
287           case [[TYPE_DECL>enum tree_code_class]]:
288             return sizeof (struct tree_type_decl);
289           case [[FUNCTION_DECL>enum tree_code_class]]:
290             return sizeof (struct tree_function_decl);
291           default:
292             return sizeof (struct tree_decl_non_common);
293           }
294       }
295 

~

296     case [[tcc_type>enum tree_code_class]]:  /* a type node */
297       return sizeof (struct tree_type);
298 

~

299     case [[tcc_reference>enum tree_code_class]]:   /* a reference */
300     case [[tcc_expression>enum tree_code_class]]:  /* an expression */
301     case [[tcc_statement>enum tree_code_class]]:   /* an expression with side effects */
302     case [[tcc_comparison>enum tree_code_class]]:  /* a comparison expression */
303     case [[tcc_unary>enum tree_code_class]]:       /* a unary arithmetic expression */
304     case [[tcc_binary>enum tree_code_class]]:      /* a binary arithmetic expression */
305       return (sizeof (struct tree_exp)
306               + (TREE_CODE_LENGTH (code) - 1) * sizeof (char *));
307 

~

308     case [[tcc_constant>enum tree_code_class]]:  /* a constant */
309       switch (code)
310         {
311         case [[INTEGER_CST>enum tree_code_class]]:       return sizeof (struct tree_int_cst);
312         case [[REAL_CST>enum tree_code_class]]:          return sizeof (struct tree_real_cst);
313         case [[COMPLEX_CST>enum tree_code_class]]:       return sizeof (struct tree_complex);
314         case [[VECTOR_CST>enum tree_code_class]]:        return sizeof (struct tree_vector);
315         case [[STRING_CST>enum tree_code_class]]:        gcc_unreachable ();
316         default:
317           return lang_hooks.tree_size (code);
318         }
319 

~

320     case [[tcc_exceptional>enum tree_code_class]]:  /* something random, like an identifier.  */
321       switch (code)
322         {
323         case [[IDENTIFIER_NODE>enum tree_code_class]]:   return lang_hooks.identifier_size;
324         case [[TREE_LIST>enum tree_code_class]]:         return sizeof (struct tree_list);
325 
326         case [[ERROR_MARK>enum tree_code_class]]:
327         case [[PLACEHOLDER_EXPR>enum tree_code_class]]:  return sizeof (struct tree_common);
328 
329         case [[TREE_VEC>enum tree_code_class]]:
330         case [[PHI_NODE>enum tree_code_class]]:          gcc_unreachable ();
331 
332         case [[SSA_NAME>enum tree_code_class]]:          return sizeof (struct tree_ssa_name);
333 
334         case [[STATEMENT_LIST>enum tree_code_class]]:    return sizeof (struct tree_statement_list);
335         case [[BLOCK>enum tree_code_class]]:             return sizeof (struct tree_block);
336         case [[VALUE_HANDLE>enum tree_code_class]]:      return sizeof (struct tree_value_handle);
337         case [[CONSTRUCTOR>enum tree_code_class]]:       return sizeof (struct tree_constructor);
338 
339         default:
340           return lang_hooks.tree_size (code);
341         }
342 

~

343     default:
344       gcc_unreachable ();
345     }
346 }


リンク元

Advertisement