本文整理汇总了C++中SymExpr::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ SymExpr::replace方法的具体用法?C++ SymExpr::replace怎么用?C++ SymExpr::replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymExpr
的用法示例。
在下文中一共展示了SymExpr::replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertLocalTemp
//
// The argument expr is a use of a wide reference. Insert a check to ensure
// that it is on the current locale, then drop its wideness by moving the
// addr field into a non-wide of otherwise the same type. Then, replace its
// use with the non-wide version.
//
static void insertLocalTemp(Expr* expr) {
SymExpr* se = toSymExpr(expr);
Expr* stmt = expr->getStmtExpr();
INT_ASSERT(se && stmt);
SET_LINENO(se);
VarSymbol* var = newTemp(astr("local_", se->var->name),
se->var->type->getField("addr")->type);
if (!fNoLocalChecks) {
stmt->insertBefore(new CallExpr(PRIM_LOCAL_CHECK, se->copy()));
}
stmt->insertBefore(new DefExpr(var));
stmt->insertBefore(new CallExpr(PRIM_MOVE, var, se->copy()));
se->replace(new SymExpr(var));
}
示例2: localizeCall
//
// If call has the potential to cause communication, assert that the wide
// reference that might cause communication is local and remove its wide-ness
//
// The organization of this function follows the order of CallExpr::codegen()
// leaving out primitives that don't communicate.
//
static void localizeCall(CallExpr* call) {
if (call->primitive) {
switch (call->primitive->tag) {
case PRIM_ARRAY_SET: /* Fallthru */
case PRIM_ARRAY_SET_FIRST:
if (call->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS)) {
insertLocalTemp(call->get(1));
}
break;
case PRIM_MOVE:
case PRIM_ASSIGN: // Not sure about this one.
if (CallExpr* rhs = toCallExpr(call->get(2))) {
if (rhs->isPrimitive(PRIM_DEREF)) {
if (rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_REF) ||
rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS)) {
insertLocalTemp(rhs->get(1));
if (!rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_REF)) {
INT_ASSERT(rhs->get(1)->typeInfo() == dtString);
// special handling for wide strings
rhs->replace(rhs->get(1)->remove());
}
}
break;
}
else if (rhs->isPrimitive(PRIM_GET_MEMBER) ||
rhs->isPrimitive(PRIM_GET_SVEC_MEMBER) ||
rhs->isPrimitive(PRIM_GET_MEMBER_VALUE) ||
rhs->isPrimitive(PRIM_GET_SVEC_MEMBER_VALUE)) {
if (rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_REF) ||
rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS)) {
SymExpr* sym = toSymExpr(rhs->get(2));
INT_ASSERT(sym);
if (!sym->var->hasFlag(FLAG_SUPER_CLASS)) {
insertLocalTemp(rhs->get(1));
}
}
break;
} else if (rhs->isPrimitive(PRIM_ARRAY_GET) ||
rhs->isPrimitive(PRIM_ARRAY_GET_VALUE)) {
if (rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS)) {
SymExpr* lhs = toSymExpr(call->get(1));
Expr* stmt = call->getStmtExpr();
INT_ASSERT(lhs && stmt);
SET_LINENO(stmt);
insertLocalTemp(rhs->get(1));
VarSymbol* localVar = NULL;
if (rhs->isPrimitive(PRIM_ARRAY_GET))
localVar = newTemp(astr("local_", lhs->var->name),
lhs->var->type->getField("addr")->type);
else
localVar = newTemp(astr("local_", lhs->var->name),
lhs->var->type);
stmt->insertBefore(new DefExpr(localVar));
lhs->replace(new SymExpr(localVar));
stmt->insertAfter(new CallExpr(PRIM_MOVE, lhs,
new SymExpr(localVar)));
}
break;
} else if (rhs->isPrimitive(PRIM_GET_UNION_ID)) {
if (rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_REF)) {
insertLocalTemp(rhs->get(1));
}
break;
} else if (rhs->isPrimitive(PRIM_TESTCID) ||
rhs->isPrimitive(PRIM_GETCID)) {
if (rhs->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS)) {
insertLocalTemp(rhs->get(1));
}
break;
}
;
}
if (call->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS) &&
!call->get(2)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS)) {
break;
}
if (call->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_REF) &&
!call->get(2)->typeInfo()->symbol->hasFlag(FLAG_WIDE_REF) &&
!call->get(2)->typeInfo()->symbol->hasFlag(FLAG_REF)) {
insertLocalTemp(call->get(1));
}
break;
case PRIM_DYNAMIC_CAST:
if (call->get(2)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS)) {
insertLocalTemp(call->get(2));
if (call->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS) ||
call->get(1)->typeInfo()->symbol->hasFlag(FLAG_WIDE_REF)) {
toSymExpr(call->get(1))->var->type = call->get(1)->typeInfo()->getField("addr")->type;
}
}
break;
case PRIM_SETCID:
//.........这里部分代码省略.........