GCC Wikia
Advertisement

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

概要[]

tree_code に対応する型のサイズを tree_code_size で取得し,メモリを確保し,0 で初期化し,struct tree_node の code メンバを引数の tree_code で初期化する程度の処理を行うのみ.

376 /* Return a newly allocated node of code CODE.  For decl and type
377    nodes, some other fields are initialized.  The rest of the node is
378    initialized to zero.  This function cannot be used for PHI_NODE or
379    TREE_VEC nodes, which is enforced by asserts in tree_code_size.
380 
381    Achoo!  I got a code in the node.  */

引数[]

実装[]

383 tree
384 make_node_stat (enum tree_code code MEM_STAT_DECL)
385 {
386   tree t;
387   enum tree_code_class type = TREE_CODE_CLASS (code);
388   size_t length = tree_code_size (code);
389 #ifdef GATHER_STATISTICS
390   tree_node_kind kind;
391 
392   switch (type)
393     {
394     case tcc_declaration:  /* A decl node */
395       kind = d_kind;
396       break;
397 
398     case tcc_type:  /* a type node */
399       kind = t_kind;
400       break;
401 
402     case tcc_statement:  /* an expression with side effects */
403       kind = s_kind;
404       break;
405 
406     case tcc_reference:  /* a reference */
407       kind = r_kind;
408       break;
409 
410     case tcc_expression:  /* an expression */
411     case tcc_comparison:  /* a comparison expression */
412     case tcc_unary:  /* a unary arithmetic expression */
413     case tcc_binary:  /* a binary arithmetic expression */
414       kind = e_kind;
415       break;
416 
417     case tcc_constant:  /* a constant */
418       kind = c_kind;
419       break;
420 
421     case tcc_exceptional:  /* something random, like an identifier.  */
422       switch (code)
423         {
424         case IDENTIFIER_NODE:
425           kind = id_kind;
426           break;
427 
428         case TREE_VEC:
429           kind = vec_kind;
430           break;
431 
432         case TREE_BINFO:
433           kind = binfo_kind;
434           break;
435 
436         case PHI_NODE:
437           kind = phi_kind;
438           break;
439 
440         case SSA_NAME:
441           kind = ssa_name_kind;
442           break;
443 
444         case BLOCK:
445           kind = b_kind;
446           break;
447 
448         case CONSTRUCTOR:
449           kind = constr_kind;
450           break;
451 
452         default:
453           kind = x_kind;
454           break;
455         }
456       break;
457       
458     default:
459       gcc_unreachable ();
460     }
461 
462   tree_node_counts[(int) kind]++;
463   tree_node_sizes[(int) kind] += length;
464 #endif
465 
466   if (code == IDENTIFIER_NODE)
467     t = ggc_alloc_zone_pass_stat (length, &tree_id_zone);
468   else
469     t = ggc_alloc_zone_pass_stat (length, &tree_zone);
470 
471   memset (t, 0, length);
472 
473   TREE_SET_CODE (t, code);
474 
475   switch (type)
476     {
477     case tcc_statement:
478       TREE_SIDE_EFFECTS (t) = 1;
479       break;
480 
481     case tcc_declaration:
482       if (code != FUNCTION_DECL)
483         DECL_ALIGN (t) = 1;
484       DECL_USER_ALIGN (t) = 0;
485       if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
486         DECL_IN_SYSTEM_HEADER (t) = in_system_header;
487       /* We have not yet computed the alias set for this declaration.  */
488       DECL_POINTER_ALIAS_SET (t) = -1;
489       DECL_SOURCE_LOCATION (t) = input_location;
490       DECL_UID (t) = next_decl_uid++;
491 
492       break;
493 
494     case tcc_type:
495       TYPE_UID (t) = next_type_uid++;
496       TYPE_ALIGN (t) = BITS_PER_UNIT;
497       TYPE_USER_ALIGN (t) = 0;
498       TYPE_MAIN_VARIANT (t) = t;
499 
500       /* Default to no attributes for type, but let target change that.  */
501       TYPE_ATTRIBUTES (t) = NULL_TREE;
502       targetm.set_default_type_attributes (t);
503 
504       /* We have not yet computed the alias set for this type.  */
505       TYPE_ALIAS_SET (t) = -1;
506       break;
507 
508     case tcc_constant:
509       TREE_CONSTANT (t) = 1;
510       TREE_INVARIANT (t) = 1;
511       break;
512 
513     case tcc_expression:
514       switch (code)
515         {
516         case INIT_EXPR:
517         case MODIFY_EXPR:
518         case VA_ARG_EXPR:
519         case PREDECREMENT_EXPR:
520         case PREINCREMENT_EXPR:
521         case POSTDECREMENT_EXPR:
522         case POSTINCREMENT_EXPR:
523           /* All of these have side-effects, no matter what their
524              operands are.  */
525           TREE_SIDE_EFFECTS (t) = 1;
526           break;
527 
528         default:
529           break;
530         }
531       break;
532 
533     default:
534       /* Other classes need no special treatment.  */
535       break;
536     }
537 
538   return t;
539 }



リンク元

Advertisement