Georgia Water/Best Practices/Conservation - Wikibooks, open books for an open world

ROSE Compiler Framework/transformation tracking – Wikibooks, open books for an open world

An experimental function to maintain monitor of transformation

The transformation monitoring or IR mapping info

  • every AST node is assigned a singular integer ID, based mostly on a preorder traversal of the AST.
  • a change generated node (affected node) is related with a number of enter nodes.
  • saved in std::map > , map from an affected node to its enter node units

It is a hardly ever used function. To keep away from reminiscence/computation overhead, we retailer info in separated reminiscence , circuitously extending AST node’s members.

The monitoring is predicated on distinctive IDs of AST nodes. To disable reminiscence reuse of deleted AST nodes, it is suggested to configure ROSE with

  • –enable-memory-pool-no-reuse Allow particular reminiscence pool mannequin: no reuse of deleted reminiscence (default is to reuse reminiscence)

The supply code and API features are outlined in https://github.com/rose-compiler/rose-develop/tree/grasp/src/midend/programTransformation/transformationTracking

From


 //! Assign Ids and save present File Data.
  void registerAstSubtreeIds (SgNode* root);

 // get distinctive ID  
  AST_NODE_ID getId (SgNode* ); 
  
  // test if a node has been assigned a singular ID
  bool hasId (SgNode* n);

  //Get hold of the SgNode from an ID
  SgNode* getNode (AST_NODE_ID id);

// the enter AST node IDs for a change generated node.
  extern std::map > inputIDs;

// This must be known as after the transformation is accomplished and all IDs are assigned. 
  void addInputNode(SgNode* affected_node, SgNode* inputnode);

from transformationTracking.cpp: inner two maps/tables retailer IDs and reminiscence addresses

  
  // the next knowledge buildings are for inner use solely
  std::map  AstToIdTable;
  // reverse lookup , oops, if they're one-to-one mapping, how a single node obtains a number of IDs?
  std::map  IdToAstTable; 

instance use[edit]


// Assign transportable and distinctive IDs for all positioned nodes in AST
  TransformationTracking::registerAstSubtreeIds (mission);

// Dump AST dotgraph with distinctive IDs , for debugging goal

 // Take a look at distinctive ID project and dot graph technology
    TransformationTracking::registerAstSubtreeIds (sageProject);
    generateWholeGraphOfAST("wholeAST-v1");

    AstDOTGeneration astdotgen;
    astdotgen.generate(sageProject,AstDOTGeneration::TOPDOWNBOTTOMUP, "v1");

// file the enter node of an affected node after some transformation

     // patch up IDs for the modified subtree 
      TransformationTracking::registerAstSubtreeIds (orig_scope);
      std::vector ::iterator iter;

      for (iter = newly_inserted_copied_decls.start(); iter!= newly_inserted_copied_decls.finish(); iter++)
      { //TransformationTracking::addInputNode (affected_node, input_node)
        TransformationTracking::addInputNode (*iter, decl);
      }

// retrieve saved mapping info

   std::map >::iterator iter;
    for (iter = TransformationTracking::inputIDs.start(); iter != TransformationTracking::inputIDs.finish(); iter++)
    {
      std::set ids = (*iter).second;
      if (ids.measurement()>0)
      {
        string src_comment = "Transformation generated based mostly on ";
        cout<<"Discovered a node with IR mapping data"<unparseToString()<::iterator iditer;
        for(iditer = ids.start(); iditer != ids.finish(); iditer ++)
        {
           SgNode* input_node = TransformationTracking::getNode((*iditer));
           SgLocatedNode* lnode = isSgLocatedNode(input_node);
           cout<unparseToString()<get_file_info()->get_line() <get_file_info()->get_line());
        }
        src_comment +="n";
        SgStatement* enclosing_stmt = getEnclosingStatement(affected_node);
        attachComment (enclosing_stmt, src_comment);
      } // finish if ids.measurement() >0
    }  // finish for inputIDs


Leave a Reply

Your email address will not be published. Required fields are marked *