3 #include <clang/Basic/SourceManager.h>
4 #include <clang/AST/Decl.h>
5 #include <clang/AST/Stmt.h>
6 #include <clang/Lex/Preprocessor.h>
13 /* The location of the scop, as delimited by scop and endscop
14 * pragmas by the user.
24 clang::Preprocessor
&PP
;
25 /* If autodetect is false, then loc contains the location
26 * of the scop to be extracted.
30 /* The sequence number of the next statement. */
32 /* If autodetect is false, a scop delimited by pragmas is extracted,
33 * otherwise we take any scop that we can find.
36 /* Set if the pet_scop returned by an extract method only
37 * represents part of the input tree.
40 /* Set is nested accesses are allowed in general.
41 * This currently defaults to true.
44 /* Set if nested accesses are allowed in that part of the tree
45 * that is currently under investigation.
48 /* Maps identifiers to the last expression that was assigned to them.
49 * If an identifier is mapped to NULL, then something may have
50 * been assigned, but we don't know what.
52 std::map
<clang::ValueDecl
*, clang::Expr
*> assigned_value
;
54 PetScan(isl_ctx
*ctx
, clang::Preprocessor
&PP
, ScopLoc
&loc
,
56 ctx(ctx
), PP(PP
), loc(loc
), autodetect(autodetect
),
57 n_stmt(0), partial(0), allow_nested(true),
58 nesting_enabled(false) { }
60 struct pet_scop
*scan(clang::FunctionDecl
*fd
);
62 struct pet_scop
*scan(clang::Stmt
*stmt
);
64 struct pet_scop
*scan_arrays(struct pet_scop
*scop
);
65 struct pet_array
*extract_array(isl_ctx
*ctx
, clang::ValueDecl
*decl
);
66 struct pet_array
*set_upper_bounds(struct pet_array
*array
,
67 const clang::Type
*type
, int pos
);
69 struct pet_scop
*extract_conditional_assignment(clang::IfStmt
*stmt
);
71 struct pet_scop
*extract(clang::Stmt
*stmt
);
72 struct pet_scop
*extract(clang::StmtRange stmt_range
);
73 struct pet_scop
*extract(clang::IfStmt
*stmt
);
74 struct pet_scop
*extract(clang::CompoundStmt
*stmt
);
76 struct pet_scop
*extract(clang::Stmt
*stmt
, struct pet_expr
*expr
);
78 clang::BinaryOperator
*extract_initialization(clang::ForStmt
*stmt
);
79 clang::ValueDecl
*extract_induction_variable(clang::BinaryOperator
*stmt
);
80 bool check_increment(clang::ForStmt
*stmt
, clang::ValueDecl
*iv
,
82 struct pet_scop
*extract_for(clang::ForStmt
*stmt
);
83 struct pet_scop
*extract_infinite_for(clang::ForStmt
*stmt
);
85 struct pet_expr
*extract_expr(clang::Expr
*expr
);
86 struct pet_expr
*extract_expr(clang::UnaryOperator
*expr
);
87 struct pet_expr
*extract_expr(clang::BinaryOperator
*expr
);
88 struct pet_expr
*extract_expr(clang::ImplicitCastExpr
*expr
);
89 struct pet_expr
*extract_expr(clang::FloatingLiteral
*expr
);
90 struct pet_expr
*extract_expr(clang::ParenExpr
*expr
);
91 struct pet_expr
*extract_expr(clang::ConditionalOperator
*expr
);
92 struct pet_expr
*extract_expr(clang::CallExpr
*expr
);
94 struct pet_expr
*resolve_nested(struct pet_expr
*expr
);
95 struct pet_expr
*extract_access_expr(clang::Expr
*expr
);
97 __isl_give isl_map
*extract_access(clang::ArraySubscriptExpr
*expr
);
98 __isl_give isl_map
*extract_access(clang::Expr
*expr
);
99 __isl_give isl_map
*extract_access(clang::ImplicitCastExpr
*expr
);
100 __isl_give isl_map
*extract_access(clang::DeclRefExpr
*expr
);
101 __isl_give isl_map
*extract_access(clang::IntegerLiteral
*expr
);
103 __isl_give isl_pw_aff
*extract_affine_div(clang::BinaryOperator
*expr
);
104 __isl_give isl_pw_aff
*extract_affine_mod(clang::BinaryOperator
*expr
);
105 __isl_give isl_pw_aff
*extract_affine_mul(clang::BinaryOperator
*expr
);
107 int extract_int(clang::IntegerLiteral
*expr
, isl_int
*v
);
109 isl_pw_aff
*non_affine(clang::Expr
*expr
);
111 bool is_affine(clang::Expr
*expr
);
112 bool is_affine_condition(clang::Expr
*expr
);
114 __isl_give isl_pw_aff
*extract_affine(const llvm::APInt
&val
);
115 __isl_give isl_pw_aff
*extract_affine(clang::Expr
*expr
);
116 __isl_give isl_pw_aff
*extract_affine(clang::IntegerLiteral
*expr
);
117 __isl_give isl_pw_aff
*extract_affine(clang::ImplicitCastExpr
*expr
);
118 __isl_give isl_pw_aff
*extract_affine(clang::DeclRefExpr
*expr
);
119 __isl_give isl_pw_aff
*extract_affine(clang::BinaryOperator
*expr
);
120 __isl_give isl_pw_aff
*extract_affine(clang::UnaryOperator
*expr
);
121 __isl_give isl_pw_aff
*extract_affine(clang::ParenExpr
*expr
);
122 __isl_give isl_pw_aff
*extract_affine(clang::CallExpr
*expr
);
123 __isl_give isl_pw_aff
*extract_affine(clang::ArraySubscriptExpr
*expr
);
124 __isl_give isl_pw_aff
*extract_affine(clang::ConditionalOperator
*expr
);
126 __isl_give isl_set
*extract_implicit_condition(clang::Expr
*expr
);
128 __isl_give isl_set
*extract_condition(clang::UnaryOperator
*expr
);
129 __isl_give isl_set
*extract_condition(clang::Expr
*expr
);
130 __isl_give isl_set
*extract_comparison(clang::BinaryOperator
*expr
);
131 __isl_give isl_set
*extract_comparison(clang::BinaryOperatorKind op
,
132 clang::Expr
*LHS
, clang::Expr
*RHS
, clang::Expr
*comp
);
133 __isl_give isl_set
*extract_boolean(clang::BinaryOperator
*expr
);
134 __isl_give isl_set
*extract_boolean(clang::UnaryOperator
*expr
);
136 void unsupported(clang::Stmt
*stmt
);