本文整理汇总了C++中SgVarRefExp::set_endOfConstruct方法的典型用法代码示例。如果您正苦于以下问题:C++ SgVarRefExp::set_endOfConstruct方法的具体用法?C++ SgVarRefExp::set_endOfConstruct怎么用?C++ SgVarRefExp::set_endOfConstruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgVarRefExp
的用法示例。
在下文中一共展示了SgVarRefExp::set_endOfConstruct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: anyOfListPotentiallyModifiedIn
// Are any variables in syms modified anywhere within n, or is n a declaration
// of one of them?
// FIXME: move to inliner
bool anyOfListPotentiallyModifiedIn(const vector<SgVariableSymbol*>& syms,
SgNode* n) {
bool modified = false;
for (vector<SgVariableSymbol*>::const_iterator j = syms.begin();
j != syms.end(); ++j) {
SgVarRefExp* vr = new SgVarRefExp(SgNULL_FILE, *j);
vr->set_endOfConstruct(SgNULL_FILE);
if (isPotentiallyModified(vr, n)) {
modified = true;
}
delete vr;
if (modified) break;
if (isSgVariableDeclaration(n)) {
SgVariableDeclaration* decl = isSgVariableDeclaration(n);
for (SgInitializedNamePtrList::const_iterator i =
decl->get_variables().begin();
i != decl->get_variables().end(); ++i) {
if (*i == (*j)->get_declaration()) {
modified = true;
break;
}
}
}
if (modified) break;
}
return modified;
}
示例2: visit
virtual void visit(SgNode* n) {
if (isSgThisExp(n)) {
SgVarRefExp* vr = new SgVarRefExp(SgNULL_FILE, sym);
vr->set_endOfConstruct(SgNULL_FILE);
isSgExpression(n->get_parent())->
replace_expression(isSgExpression(n), vr);
}
}
示例3: partialRedundancyEliminationOne
//.........这里部分代码省略.........
{
SgName cachevarname = "cachevar__";
cachevarname << ++SageInterface::gensym_counter;
// printf ("Building variable name = %s \n",cachevarname.str());
SgType* type = expr->get_type();
if (isSgArrayType(type))
type = new SgPointerType(isSgArrayType(type)->get_base_type());
assert (SageInterface::isDefaultConstructible(type));
// FIXME: assert (isAssignable(type));
SgVariableDeclaration* decl = new SgVariableDeclaration(SgNULL_FILE, cachevarname, type, NULL);
decl->set_definingDeclaration(decl);
SgInitializedName* initname = decl->get_variables().back();
// DQ (10/5/2007): Added an assertion.
ROSE_ASSERT(initname != NULL);
decl->addToAttachedPreprocessingInfo(
new PreprocessingInfo(PreprocessingInfo::CplusplusStyleComment,
(string("// Partial redundancy elimination: ") + cachevarname.str() +
" is a cache of " + expr->unparseToString()).c_str(),
"Compiler-Generated in PRE", 0, 0, 0, PreprocessingInfo::before));
SgVariableSymbol* cachevarsym = new SgVariableSymbol(initname);
decl->set_parent(root);
// DQ (10/5/2007): Added scope (suggested by Jeremiah).
initname->set_scope(root);
root->get_statements().insert(root->get_statements().begin(),decl);
root->insert_symbol(cachevarname, cachevarsym);
cachevar = new SgVarRefExp(SgNULL_FILE, cachevarsym);
cachevar->set_endOfConstruct(SgNULL_FILE);
}
// Do expression computation replacements
for (set<SgNode*>::iterator i = replacements.begin(); i != replacements.end(); ++i)
{
ReplaceExpressionWithVarrefVisitor(expr, cachevar).traverse(*i, postorder);
}
// Do edge insertions
// int count = 0;
bool failAtEndOfFunction = false;
for (j = cfg.graph.edges().begin(); j != jend; ++j)
{
// printf ("Build the insertion list! count = %d \n",count++);
if (edge_insert[*j])
{
#if 0
// DQ (3/13/2006): Compiler warns that "src" is unused, so I have commented it out!
Vertex src = cfg.graph.source(*j), tgt = cfg.graph.target(*j);
cerr << "Doing insertion between " << src << " and " << tgt << endl;
#endif
pair<SgNode*, bool> insert_point = cfg.edge_insertion_point[*j];
if (insert_point.first)
{
insertions.push_back(insert_point);
}
else
{
// DQ (3/16/2006): This is a visited when we fixup the NULL pointer to the initializer in a SgForStatment.
cerr << "Warning: no insertion point found" << endl; //FIXME was assert
printf ("Need to figure out what to do here! cfg.edge_insertion_point[*j] = %p \n",&(cfg.edge_insertion_point[*j]));
示例4: moveForDeclaredVariables
// Move variables declared in a for statement to just outside that statement.
void moveForDeclaredVariables(SgNode* root)
{
vector<SgForStatement*> for_statements;
FindForStatementsVisitor(for_statements).traverse(root, preorder);
for (unsigned int i = 0; i < for_statements.size(); ++i)
{
SgForStatement* stmt = for_statements[i];
#ifdef FD_DEBUG
cout << "moveForDeclaredVariables: " << stmt->unparseToString() << endl;
#endif
SgForInitStatement* init = stmt->get_for_init_stmt();
if (!init) continue;
SgStatementPtrList& inits = init->get_init_stmt();
vector<SgVariableDeclaration*> decls;
for (SgStatementPtrList::iterator j = inits.begin(); j != inits.end(); ++j) {
SgStatement* one_init = *j;
if (isSgVariableDeclaration(one_init))
{
decls.push_back(isSgVariableDeclaration(one_init));
}
}
if (decls.empty()) continue;
SgStatement* parent = isSgStatement(stmt->get_parent());
assert (parent);
SgBasicBlock* bb = new SgBasicBlock(SgNULL_FILE);
stmt->set_parent(bb);
bb->set_parent(parent);
SgStatementPtrList ls;
for (unsigned int j = 0; j < decls.size(); ++j)
{
for (SgInitializedNamePtrList::iterator k = decls[j]->get_variables().begin(); k != decls[j]->get_variables().end(); ++k)
{
#ifdef FD_DEBUG
cout << "Working on variable " << (*k)->get_name().getString() << endl;
#endif
SgVariableSymbol* sym = new SgVariableSymbol(*k);
bb->insert_symbol((*k)->get_name(), sym);
(*k)->set_scope(bb);
SgAssignInitializer* kinit = 0;
if (isSgAssignInitializer((*k)->get_initializer()))
{
kinit = isSgAssignInitializer((*k)->get_initializer());
(*k)->set_initializer(0);
}
if (kinit)
{
SgVarRefExp* vr = new SgVarRefExp(SgNULL_FILE, sym);
vr->set_endOfConstruct(SgNULL_FILE);
vr->set_lvalue(true);
SgAssignOp* assignment = new SgAssignOp(SgNULL_FILE,vr,kinit->get_operand());
vr->set_parent(assignment);
kinit->get_operand()->set_parent(assignment);
SgExprStatement* expr = new SgExprStatement(SgNULL_FILE, assignment);
assignment->set_parent(expr);
ls.push_back(expr);
expr->set_parent(init);
}
}
#if 0
SgStatementPtrList::iterator fiiter = std::find(inits.begin(), inits.end(), decls[j]);
assert (fiiter != inits.end());
size_t idx = fiiter - inits.begin();
inits.erase(inits.begin() + idx);
inits.insert(inits.begin() + idx, ls.begin(), ls.end());
#endif
bb->get_statements().push_back(decls[j]);
decls[j]->set_parent(bb);
}
inits = ls;
bb->get_statements().push_back(stmt);
// printf ("In moveForDeclaredVariables(): parent = %p = %s bb = %p stmt = %p = %s \n",parent,parent->class_name().c_str(),bb,stmt,stmt->class_name().c_str());
ROSE_ASSERT(stmt->get_parent() == bb);
parent->replace_statement(stmt, bb);
}
}
示例5: doFiniteDifferencingOne
// Do finite differencing on one expression within one context. The expression
// must be defined and valid within the entire body of root. The rewrite rules
// are used to simplify expressions. When a variable var is updated from
// old_value to new_value, an expression of the form (var, (old_value,
// new_value)) is created and rewritten. The rewrite rules may either produce
// an arbitrary expression (which will be used as-is) or one of the form (var,
// (something, value)) (which will be changed to (var = value)).
void doFiniteDifferencingOne(SgExpression* e,
SgBasicBlock* root,
RewriteRule* rules)
{
SgStatementPtrList& root_stmts = root->get_statements();
SgStatementPtrList::iterator i;
for (i = root_stmts.begin(); i != root_stmts.end(); ++i)
{
if (expressionComputedIn(e, *i))
break;
}
if (i == root_stmts.end())
return; // Expression is not used within root, so quit
vector<SgVariableSymbol*> used_symbols = SageInterface::getSymbolsUsedInExpression(e);
SgName cachename = "cache_fd__"; cachename << ++SageInterface::gensym_counter;
SgVariableDeclaration* cachedecl = new SgVariableDeclaration(SgNULL_FILE, cachename, e->get_type(),0 /* new SgAssignInitializer(SgNULL_FILE, e) */);
SgInitializedName* cachevar = cachedecl->get_variables().back();
ROSE_ASSERT (cachevar);
root->get_statements().insert(i, cachedecl);
cachedecl->set_parent(root);
cachedecl->set_definingDeclaration(cachedecl);
cachevar->set_scope(root);
SgVariableSymbol* sym = new SgVariableSymbol(cachevar);
root->insert_symbol(cachename, sym);
SgVarRefExp* vr = new SgVarRefExp(SgNULL_FILE, sym);
vr->set_endOfConstruct(SgNULL_FILE);
replaceCopiesOfExpression(e, vr, root);
vector<SgExpression*> modifications_to_used_symbols;
FdFindModifyingStatementsVisitor(used_symbols, modifications_to_used_symbols).go(root);
cachedecl->addToAttachedPreprocessingInfo(
new PreprocessingInfo(PreprocessingInfo::CplusplusStyleComment,(string("// Finite differencing: ") +
cachename.str() + " is a cache of " +
e->unparseToString()).c_str(),"Compiler-Generated in Finite Differencing",0, 0, 0, PreprocessingInfo::before));
if (modifications_to_used_symbols.size() == 0)
{
SgInitializer* cacheinit = new SgAssignInitializer(SgNULL_FILE, e);
e->set_parent(cacheinit);
cachevar->set_initializer(cacheinit);
cacheinit->set_parent(cachevar);
}
else
{
for (unsigned int i = 0; i < modifications_to_used_symbols.size(); ++i)
{
SgExpression* modstmt = modifications_to_used_symbols[i];
#ifdef FD_DEBUG
cout << "Updating cache after " << modstmt->unparseToString() << endl;
#endif
SgExpression* updateCache = 0;
SgVarRefExp* varref = new SgVarRefExp(SgNULL_FILE, sym);
varref->set_endOfConstruct(SgNULL_FILE);
SgTreeCopy tc;
SgExpression* eCopy = isSgExpression(e->copy(tc));
switch (modstmt->variantT())
{
case V_SgAssignOp:
{
SgAssignOp* assignment = isSgAssignOp(modstmt);
assert (assignment);
SgExpression* lhs = assignment->get_lhs_operand();
SgExpression* rhs = assignment->get_rhs_operand();
replaceCopiesOfExpression(lhs, rhs, eCopy);
}
break;
case V_SgPlusAssignOp:
case V_SgMinusAssignOp:
case V_SgAndAssignOp:
case V_SgIorAssignOp:
case V_SgMultAssignOp:
case V_SgDivAssignOp:
case V_SgModAssignOp:
case V_SgXorAssignOp:
case V_SgLshiftAssignOp:
case V_SgRshiftAssignOp:
{
SgBinaryOp* assignment = isSgBinaryOp(modstmt);
assert (assignment);
SgExpression* lhs = assignment->get_lhs_operand();
SgExpression* rhs = assignment->get_rhs_operand();
SgTreeCopy tc;
SgExpression* rhsCopy = isSgExpression(rhs->copy(tc));
SgExpression* newval = 0;
switch (modstmt->variantT())
{
#define DO_OP(op, nonassignment) \
case V_##op: { \
newval = new nonassignment(SgNULL_FILE, lhs, rhsCopy); \
newval->set_endOfConstruct(SgNULL_FILE); \
} \
//.........这里部分代码省略.........