compiler/passes/normalize.cpp
//
// We want the initialization code for a task-private variable to be
// in that variable's initBlock(). This is not where its DefExpr is,
// however. So, in order to use existing normalization code as-is, we
// move the DefExpr into a temporary BlockStmt. This BlockStmt also
// preserves the DefExpr's position in the ForallStmt::shadowVariables()
// list, which is where it lives. Once normalization completes, we
// move the resulting ASTs into the initBlock(), and the DefExpr back
// to its home list.
We want the initialization code for a task-private variable to be
in that variable's initBlock(). This is not where its DefExpr is,
however. So, in order to use existing normalization code as-is, we
move the DefExpr into a temporary BlockStmt. This BlockStmt also
preserves the DefExpr's position in the ForallStmt::shadowVariables()
list, which is where it lives. Once normalization completes, we
move the resulting ASTs into the initBlock(), and the DefExpr back
to its home list.
We want the initialization code for a task - private variable to be in that variable ' s initBlock () . This is not where its DefExpr is however . So in order to use existing normalization code as - is we move the DefExpr into a temporary BlockStmt . This BlockStmt also preserves the DefExpr ' s position in the ForallStmt :: shadowVariables () list which is where it lives . Once normalization completes we move the resulting ASTs into the initBlock () and the DefExpr back to its home list .
static Expr* prepareShadowVarForNormalize(DefExpr* def, VarSymbol* var) {
  ShadowVarSymbol* svar = toShadowVarSymbol(var);
  if (svar == NULL || !svar->isTaskPrivate())
    return NULL;
  BlockStmt* normBlock = new BlockStmt();
  def->replace(normBlock);
  normBlock->insertAtTail(def);
  return normBlock;
}
static Expr * prepareShadowVarForNormalize ( DefExpr * def , VarSymbol * var ) { ShadowVarSymbol * svar = toShadowVarSymbol ( var ) ; if ( svar == NULL || ! svar -> isTaskPrivate ( ) ) return NULL ; BlockStmt * normBlock = new BlockStmt ( ) ; def -> replace ( normBlock ) ; normBlock -> insertAtTail ( def ) ; return normBlock ; }
We want the initialization code for a task-private variable to be
in that variable's initBlock().
We want the initialization code for a task - private variable to be in that variable ' s initBlock () .
// Not a task-private variable, nothing to do.