8 #include <clang/AST/ASTContext.h>
9 #include <clang/AST/Type.h>
14 #include "substituter.h"
16 /* A helper class for inlining a pet_tree of the body of a called function.
17 * It keeps track of the substitutions that need to be performed on
18 * the inlined tree, along with the assignments that need to performed
19 * before the inlined tree.
21 * In particular, for a scalar argument declared "n" in the callee
22 * and passed the expression "e" by the caller, an assignment
26 * is added before the inlined tree and n is replaced by n' in the inlined
27 * tree. n' may have the same name as n, but it may also be different if
28 * n also appears in the caller.
29 * For an array argument declared "a" in the callee and passed
30 * the expression "X[i1,...,in]" by the caller, assignments
36 * are added before the inlined tree and "a" is replaced by
37 * X[__pet_arg_1,...,__pet_arg_n] in the inlined tree.
39 * The assignments are stored in "assignments".
40 * The substitutions are stored in the superclass.
42 struct pet_inliner
: pet_substituter
{
44 std::vector
<std::pair
<pet_expr
*, pet_expr
*> > assignments
;
46 clang::ASTContext
&ast_context
;
48 pet_inliner(isl_ctx
*ctx
, int &n_arg
, clang::ASTContext
&ast_context
) :
49 ctx(ctx
), n_arg(n_arg
), ast_context(ast_context
) {}
51 __isl_give pet_expr
*assign( __isl_take isl_id
*id
, clang::QualType qt
,
52 __isl_take pet_expr
*expr
);
54 void add_scalar_arg(clang::ValueDecl
*decl
, const std::string
&name
,
55 __isl_take pet_expr
*expr
);
56 void add_array_arg(clang::ValueDecl
*decl
, __isl_take pet_expr
*expr
,
59 __isl_give pet_tree
*inline_tree(__isl_take pet_tree
*tree
);