Beispiel #1
0
void DataFlow<Annotation, Language, Runtime>::append_access(
  SgExpression * exp,
  std::vector<data_access_t> & access_set,
  const context_t & context
) const {
  std::vector<SgVarRefExp *> var_refs = SageInterface::querySubTree<SgVarRefExp>(exp);
  std::vector<SgVarRefExp *>::const_iterator it_var_ref;
  for (it_var_ref = var_refs.begin(); it_var_ref != var_refs.end(); it_var_ref++) {
    SgVarRefExp * var_ref = *it_var_ref;
    SgVariableSymbol * var_sym = var_ref->get_symbol();
    assert(var_sym != NULL);

    Data<Annotation> * data = NULL;
    typename std::set<Data<Annotation> *>::const_iterator it_data;
    for (it_data = context.datas.begin(); it_data != context.datas.end(); it_data++)
      if ((*it_data)->getVariableSymbol() == var_sym) {
        data = *it_data;
        break;
      }
    if (data == NULL)
      continue;

    access_set.push_back(data_access_t());
    access_set.back().data = data;
    SgPntrArrRefExp * parent = isSgPntrArrRefExp(var_ref->get_parent());
    while (parent != NULL) {
      access_set.back().subscripts.push_back(parent->get_rhs_operand_i());
      parent = isSgPntrArrRefExp(parent->get_parent());
    }
    assert(access_set.back().subscripts.size() == data->getSections().size());
  }
}
Beispiel #2
0
/*
 * This method inserts verify check for all the array references
 * present below the expr node.
 */
void fetchAndVerifyArrayRefs(SgExpression *expr,
		SgExprStatement *curExprStatement, bool isWrite) {

	vector<SgPntrArrRefExp*> arrayRefList = querySubTree<SgPntrArrRefExp> (
			expr, V_SgPntrArrRefExp);
	vector<SgPntrArrRefExp*> uniqueArrayRefList;

	// Create a new list as nodes change due to new statements
	for (vector<SgPntrArrRefExp*>::iterator iter = arrayRefList.begin(); iter
			!= arrayRefList.end(); iter++) {
		SgPntrArrRefExp *arrayRef = *iter;
		SgNode *parentArrayRef = arrayRef->get_parent();

		if (isSgPntrArrRefExp(parentArrayRef) == NULL)
			uniqueArrayRefList.push_back(arrayRef);
	}

	// Visit each array reference
	for (vector<SgPntrArrRefExp*>::iterator iter = uniqueArrayRefList.begin(); iter
			!= uniqueArrayRefList.end(); iter++) {
		insertChecksum(*iter, curExprStatement, isWrite);
	}
}