GCC Wikia
Advertisement

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

概要[]

引数[]

実装[]

4792 /* Constructors for pointer, array and function types.
4793    (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
4794    constructed by language-dependent code, not here.)  */
4795 
4796 /* Construct, lay out and return the type of pointers to TO_TYPE with
4797    mode MODE.  If CAN_ALIAS_ALL is TRUE, indicate this type can
4798    reference all of memory. If such a type has already been
4799    constructed, reuse it.  */
4800 
4801 tree
4802 build_pointer_type_for_mode (tree to_type, enum machine_mode mode,
4803                              bool can_alias_all)
4804 {
4805   tree t;
4806 
4807   if (to_type == error_mark_node)
4808     return error_mark_node;
4809 

  • TYPE_POINTER_TOがポインタ型でない場合がある
  • その場合はTYPE_POINTER_TOをそのまま返せばよい

4810   /* In some cases, languages will have things that aren't a POINTER_TYPE
4811      (such as a RECORD_TYPE for fat pointers in Ada) as TYPE_POINTER_TO.
4812      In that case, return that type without regard to the rest of our
4813      operands.
4814 
4815      ??? This is a kludge, but consistent with the way this function has
4816      always operated and there doesn't seem to be a good way to avoid this
4817      at the moment.  */
4818   if (TYPE_POINTER_TO (to_type) != 0
4819       && TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
4820     return TYPE_POINTER_TO (to_type);
4821 

  • すでにポインタ型があればそれを使う

4822   /* First, if we already have a type for pointers to TO_TYPE and it's
4823      the proper mode, use it.  */
4824   for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
4825     if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
4826       return t;
4827 

  • ポインタ型のノードを作成し、値をセットする

4828   t = make_node (POINTER_TYPE);
4829 
4830   TREE_TYPE (t) = to_type;
4831   TYPE_MODE (t) = mode;
4832   TYPE_REF_CAN_ALIAS_ALL (t) = can_alias_all;
4833   TYPE_NEXT_PTR_TO (t) = TYPE_POINTER_TO (to_type);
4834   TYPE_POINTER_TO (to_type) = t;
4835 

  • ノードを単純化する

4836   /* Lay out the type.  This function has many callers that are concerned
4837      with expression-construction, and this simplifies them all.  */
4838   layout_type (t);
4839 
4840   return t;
4841 }



リンク元

Advertisement