Distinguish between 'regular' foreach and foreach_unique in FunctionEmitContext

We need to do this since it's illegal to have nested foreach statements, but
nested foreach_unique, or foreach_unique inside foreach, etc., are all fine.
This commit is contained in:
Matt Pharr
2012-06-22 06:04:00 -07:00
parent 2b4a3b22bf
commit ed13dd066b
3 changed files with 41 additions and 24 deletions

View File

@@ -1458,7 +1458,7 @@ ForeachStmt::EmitCode(FunctionEmitContext *ctx) const {
ctx->StoreInst(LLVMMaskAllOn, extrasMaskPtrs[i]);
}
ctx->StartForeach();
ctx->StartForeach(FunctionEmitContext::FOREACH_REGULAR);
// On to the outermost loop's test
ctx->BranchInst(bbTest[0]);
@@ -1970,10 +1970,8 @@ ForeachUniqueStmt::EmitCode(FunctionEmitContext *ctx) const {
llvm::Value *movmsk = ctx->LaneMask(oldFullMask);
ctx->StoreInst(movmsk, maskBitsPtr);
// Officially start the loop; as far as the FunctionEmitContext is
// concerned, this can be handled the same way as a regular foreach
// loop (continue allowed but not break and return, etc.)
ctx->StartForeach();
// Officially start the loop.
ctx->StartForeach(FunctionEmitContext::FOREACH_UNIQUE);
ctx->SetContinueTarget(bbCheckForMore);
// Evaluate the varying expression we're iterating over just once.