[Polly][Refactor] IslAst [4/7]

Tobias Grosser tobias at grosser.es
Wed Jul 23 22:33:15 PDT 2014


On 23/07/2014 22:46, Johannes Doerfert wrote:
> Here is yet another patch of the IslAst refactoring series.

LGTM.


> +
> +  /// @brief The dependence information used for the parallelism check.
>     Dependences *Deps;
>
> -  // We are inside a parallel for node.
> -  int InParallelFor;
> +  /// @brief Flag to indicate that we are inside a parallel for node.
> +  bool InParallelFor;
> +
> +  /// @brief The last iterator id created for the current SCoP.
> +  isl_id *LastForNodeId;
>   };
>
>   // Print a loop annotated with OpenMP or vector pragmas.
> @@ -237,52 +244,13 @@ static __isl_give isl_id *astBuildBeforeFor(__isl_keep isl_ast_build *Build,
>     IslAstUserPayload *NodeInfo = new IslAstUserPayload();
>     isl_id *Id = isl_id_alloc(isl_ast_build_get_ctx(Build), "", NodeInfo);
>     Id = isl_id_set_free_user(Id, freeIslAstUserPayload);
> +  BuildInfo->LastForNodeId = Id;
>
>     markOpenmpParallel(Build, BuildInfo, NodeInfo);
>
>     return Id;
>   }
>
> -// Returns 0 when Node contains loops, otherwise returns -1. This search
> -// function uses ISL's way to iterate over lists of isl_ast_nodes with
> -// isl_ast_node_list_foreach. Please use the single argument wrapper function
> -// that returns a bool instead of using this function directly.
> -static int containsLoops(__isl_take isl_ast_node *Node, void *User) {
> -  if (!Node)
> -    return -1;
> -
> -  switch (isl_ast_node_get_type(Node)) {
> -  case isl_ast_node_for:
> -    isl_ast_node_free(Node);
> -    return 0;
> -  case isl_ast_node_block: {
> -    isl_ast_node_list *List = isl_ast_node_block_get_children(Node);
> -    int Res = isl_ast_node_list_foreach(List, &containsLoops, nullptr);
> -    isl_ast_node_list_free(List);
> -    isl_ast_node_free(Node);
> -    return Res;
> -  }
> -  case isl_ast_node_if: {
> -    int Res = -1;
> -    if (0 == containsLoops(isl_ast_node_if_get_then(Node), nullptr) ||
> -        (isl_ast_node_if_has_else(Node) &&
> -         0 == containsLoops(isl_ast_node_if_get_else(Node), nullptr)))
> -      Res = 0;
> -    isl_ast_node_free(Node);
> -    return Res;
> -  }
> -  case isl_ast_node_user:
> -  default:
> -    isl_ast_node_free(Node);
> -    return -1;
> -  }
> -}
> -
> -// Returns true when Node contains loops.
> -static bool containsLoops(__isl_take isl_ast_node *Node) {
> -  return 0 == containsLoops(Node, nullptr);
> -}
> -

Nice!

Tobias




More information about the llvm-commits mailing list