public void visitForLoop(AJCForLoop tree) {
super.visitForLoop(tree);
log.debug("unroll consideration for {}", tree);
EffectSet condEffects = tree.cond.effects.getEffectSet();
SymbolSet condReads = condEffects.readInternal;
SymbolSet condWrites = condEffects.writeInternal;
// Find the effects for the statements in the repeat steps...
SymbolSet repeatReads = new SymbolSet();
SymbolSet repeatWrites = new SymbolSet();
for (AJCExpressionStatement stat : tree.step) {
EffectSet stepEffects = stat.effects.getEffectSet();
repeatReads.addAll(stepEffects.readInternal);
repeatWrites.addAll(stepEffects.writeInternal);
}
// Determine if any of the symbols depended on by the condition or repeat are global.
if (containsGlobal(condReads) || containsGlobal(condWrites)
|| containsGlobal(repeatReads) || containsGlobal(repeatWrites)) {
log.debug("Aborting unrolling - global symbol deps!");
return;
}
EffectSet bodyEffects = tree.body.effects.getEffectSet();
// If the body writes anything read by the cond or repeat, abort. (That shit's complicated.).
SymbolSet bodyWrites = bodyEffects.writeInternal;
// TODO: can *sometimes* deal with this. Sort of tricky, and implies very retarded code.
if (!bodyWrites.intersect(condReads).isEmpty() || !bodyWrites.intersect(repeatReads).isEmpty()) {
log.debug("Aborting unrolling - body writes to condition/repeat deps!");
return;
}
// Attempt to evaluate the loop management code ahead of time.