static void create_arg_bundle_class(FnSymbol* fn, CallExpr* fcall, ModuleSymbol* mod, BundleArgsFnData &baData) { INT_ASSERT(!baData.ctype); SET_LINENO(fn); // Here, 'fcall' is the first of fn's callees and so it acts as a // representative of all the other callees, if any. // As of this writing, this should be OK because the callees are // obtained by duplicating the original call, which resulted in // outlining a block into 'fn' and so is unique. // To eliminate 'fcall' in create_arg_bundle_class(), we need // to rely on fn's formal types instead of fcall's actual types. // create a new class to capture refs to locals AggregateType* ctype = new AggregateType(AGGREGATE_CLASS); TypeSymbol* new_c = new TypeSymbol(astr("_class_locals", fn->name), ctype); new_c->addFlag(FLAG_NO_OBJECT); new_c->addFlag(FLAG_NO_WIDE_CLASS); // add the function args as fields in the class int i = 0; // Fields are numbered for uniqueness. for_actuals(arg, fcall) { SymExpr *s = toSymExpr(arg); Symbol *var = s->var; // arg or var if (var->type->symbol->hasFlag(FLAG_REF) || isClass(var->type)) // Only a variable that is passed by reference out of its current scope // is concurrently accessed -- which means that it has to be passed by // reference. var->addFlag(FLAG_CONCURRENTLY_ACCESSED); VarSymbol* field = new VarSymbol(astr("_", istr(i), "_", var->name), var->type); ctype->fields.insertAtTail(new DefExpr(field)); i++; }
void addFlag(BaseAST* ast, int flag) { Symbol* sym = symflagOK("addFlag", ast, flag); if (sym) sym->addFlag((Flag)flag); }