@@ -123,6 +123,172 @@ class ScopBuilder {
123
123
// Build the SCoP for Region @p R.
124
124
void buildScop (Region &R, AssumptionCache &AC);
125
125
126
+ // / Adjust the dimensions of @p Dom that was constructed for @p OldL
127
+ // / to be compatible to domains constructed for loop @p NewL.
128
+ // /
129
+ // / This function assumes @p NewL and @p OldL are equal or there is a CFG
130
+ // / edge from @p OldL to @p NewL.
131
+ isl::set adjustDomainDimensions (isl::set Dom, Loop *OldL, Loop *NewL);
132
+
133
+ // / Compute the domain for each basic block in @p R.
134
+ // /
135
+ // / @param R The region we currently traverse.
136
+ // / @param InvalidDomainMap BB to InvalidDomain map for the BB of current
137
+ // / region.
138
+ // /
139
+ // / @returns True if there was no problem and false otherwise.
140
+ bool buildDomains (Region *R,
141
+ DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
142
+
143
+ // / Compute the branching constraints for each basic block in @p R.
144
+ // /
145
+ // / @param R The region we currently build branching conditions
146
+ // / for.
147
+ // / @param InvalidDomainMap BB to InvalidDomain map for the BB of current
148
+ // / region.
149
+ // /
150
+ // / @returns True if there was no problem and false otherwise.
151
+ bool buildDomainsWithBranchConstraints (
152
+ Region *R, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
153
+
154
+ // / Build the conditions sets for the terminator @p TI in the @p Domain.
155
+ // /
156
+ // / This will fill @p ConditionSets with the conditions under which control
157
+ // / will be moved from @p TI to its successors. Hence, @p ConditionSets will
158
+ // / have as many elements as @p TI has successors.
159
+ bool buildConditionSets (BasicBlock *BB, Instruction *TI, Loop *L,
160
+ __isl_keep isl_set *Domain,
161
+ DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
162
+ SmallVectorImpl<__isl_give isl_set *> &ConditionSets);
163
+
164
+ // / Build the conditions sets for the branch condition @p Condition in
165
+ // / the @p Domain.
166
+ // /
167
+ // / This will fill @p ConditionSets with the conditions under which control
168
+ // / will be moved from @p TI to its successors. Hence, @p ConditionSets will
169
+ // / have as many elements as @p TI has successors. If @p TI is nullptr the
170
+ // / context under which @p Condition is true/false will be returned as the
171
+ // / new elements of @p ConditionSets.
172
+ bool buildConditionSets (BasicBlock *BB, Value *Condition, Instruction *TI,
173
+ Loop *L, __isl_keep isl_set *Domain,
174
+ DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
175
+ SmallVectorImpl<__isl_give isl_set *> &ConditionSets);
176
+
177
+ // / Build the conditions sets for the switch @p SI in the @p Domain.
178
+ // /
179
+ // / This will fill @p ConditionSets with the conditions under which control
180
+ // / will be moved from @p SI to its successors. Hence, @p ConditionSets will
181
+ // / have as many elements as @p SI has successors.
182
+ bool buildConditionSets (BasicBlock *BB, SwitchInst *SI, Loop *L,
183
+ __isl_keep isl_set *Domain,
184
+ DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
185
+ SmallVectorImpl<__isl_give isl_set *> &ConditionSets);
186
+
187
+ // / Build condition sets for unsigned ICmpInst(s).
188
+ // / Special handling is required for unsigned operands to ensure that if
189
+ // / MSB (aka the Sign bit) is set for an operands in an unsigned ICmpInst
190
+ // / it should wrap around.
191
+ // /
192
+ // / @param IsStrictUpperBound holds information on the predicate relation
193
+ // / between TestVal and UpperBound, i.e,
194
+ // / TestVal < UpperBound OR TestVal <= UpperBound
195
+ __isl_give isl_set *buildUnsignedConditionSets (
196
+ BasicBlock *BB, Value *Condition, __isl_keep isl_set *Domain,
197
+ const SCEV *SCEV_TestVal, const SCEV *SCEV_UpperBound,
198
+ DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
199
+ bool IsStrictUpperBound);
200
+
201
+ // / Propagate the domain constraints through the region @p R.
202
+ // /
203
+ // / @param R The region we currently build branching
204
+ // / conditions for.
205
+ // / @param InvalidDomainMap BB to InvalidDomain map for the BB of current
206
+ // / region.
207
+ // /
208
+ // / @returns True if there was no problem and false otherwise.
209
+ bool propagateDomainConstraints (
210
+ Region *R, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
211
+
212
+ // / Propagate domains that are known due to graph properties.
213
+ // /
214
+ // / As a CFG is mostly structured we use the graph properties to propagate
215
+ // / domains without the need to compute all path conditions. In particular,
216
+ // / if a block A dominates a block B and B post-dominates A we know that the
217
+ // / domain of B is a superset of the domain of A. As we do not have
218
+ // / post-dominator information available here we use the less precise region
219
+ // / information. Given a region R, we know that the exit is always executed
220
+ // / if the entry was executed, thus the domain of the exit is a superset of
221
+ // / the domain of the entry. In case the exit can only be reached from
222
+ // / within the region the domains are in fact equal. This function will use
223
+ // / this property to avoid the generation of condition constraints that
224
+ // / determine when a branch is taken. If @p BB is a region entry block we
225
+ // / will propagate its domain to the region exit block. Additionally, we put
226
+ // / the region exit block in the @p FinishedExitBlocks set so we can later
227
+ // / skip edges from within the region to that block.
228
+ // /
229
+ // / @param BB The block for which the domain is currently
230
+ // / propagated.
231
+ // / @param BBLoop The innermost affine loop surrounding @p BB.
232
+ // / @param FinishedExitBlocks Set of region exits the domain was set for.
233
+ // / @param InvalidDomainMap BB to InvalidDomain map for the BB of current
234
+ // / region.
235
+ void propagateDomainConstraintsToRegionExit (
236
+ BasicBlock *BB, Loop *BBLoop,
237
+ SmallPtrSetImpl<BasicBlock *> &FinishedExitBlocks,
238
+ DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
239
+
240
+ // / Propagate invalid domains of statements through @p R.
241
+ // /
242
+ // / This method will propagate invalid statement domains through @p R and at
243
+ // / the same time add error block domains to them. Additionally, the domains
244
+ // / of error statements and those only reachable via error statements will
245
+ // / be replaced by an empty set. Later those will be removed completely.
246
+ // /
247
+ // / @param R The currently traversed region.
248
+ // / @param InvalidDomainMap BB to InvalidDomain map for the BB of current
249
+ // / region.
250
+ //
251
+ // / @returns True if there was no problem and false otherwise.
252
+ bool propagateInvalidStmtDomains (
253
+ Region *R, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
254
+
255
+ // / Compute the union of predecessor domains for @p BB.
256
+ // /
257
+ // / To compute the union of all domains of predecessors of @p BB this
258
+ // / function applies similar reasoning on the CFG structure as described for
259
+ // / @see propagateDomainConstraintsToRegionExit
260
+ // /
261
+ // / @param BB The block for which the predecessor domains are collected.
262
+ // / @param Domain The domain under which BB is executed.
263
+ // /
264
+ // / @returns The domain under which @p BB is executed.
265
+ isl::set getPredecessorDomainConstraints (BasicBlock *BB, isl::set Domain);
266
+
267
+ // / Add loop carried constraints to the header block of the loop @p L.
268
+ // /
269
+ // / @param L The loop to process.
270
+ // / @param InvalidDomainMap BB to InvalidDomain map for the BB of current
271
+ // / region.
272
+ // /
273
+ // / @returns True if there was no problem and false otherwise.
274
+ bool addLoopBoundsToHeaderDomain (
275
+ Loop *L, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap);
276
+
277
+ // / Compute the isl representation for the SCEV @p E in this BB.
278
+ // /
279
+ // / @param BB The BB for which isl representation is to be
280
+ // / computed.
281
+ // / @param InvalidDomainMap A map of BB to their invalid domains.
282
+ // / @param E The SCEV that should be translated.
283
+ // / @param NonNegative Flag to indicate the @p E has to be
284
+ // / non-negative.
285
+ // /
286
+ // / Note that this function will also adjust the invalid context
287
+ // / accordingly.
288
+ __isl_give isl_pw_aff *
289
+ getPwAff (BasicBlock *BB, DenseMap<BasicBlock *, isl::set> &InvalidDomainMap,
290
+ const SCEV *E, bool NonNegative = false );
291
+
126
292
// / Create equivalence classes for required invariant accesses.
127
293
// /
128
294
// / These classes will consolidate multiple required invariant loads from the
0 commit comments