Hi Sun,

Could you please review the code for WHIRL SSA updater?
WHIRL SSA updater is designed to update the SSA info incrementally. The
updater works with the WHIRL CFG. Currently, the updater supports creating
new ssa information for WNs operating on PREGs and renaming the existing SSA
version for both VAR(STID/LDID) and indirect memory
operations(ILOAD/ISTORE).

Thank you very much.

-- 
Regards,
Lai Jian-Xin
/*

  Copyright (C) 2010, Hewlett-Packard Development Company, L.P. All Rights Reserved.

  Open64 is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  Open64 is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  MA  02110-1301, USA.

*/

//====================================================================
//
// Module: wssa_update.h
//
// Revision history:
//  Dec-6 - Original Version
//
// Description:
//  Interface for WHIRL SSA UPDATER
//
// Exported classes:
//  WSSA::WSSA_UPDATER
//
// SEE ALSO:
//  be/com/wssa_mgr.h  (WHIRL_SSA_MANAGER)
//  be/com/wn_cfg.h    (WHIRL CFG)
//
//====================================================================

#ifndef wssa_update_INCLUDED
#define wssa_update_INCLUDED

#include "defs.h"
#include "wssa_defs.h"
#include "wn_cfg.h"
#include "wssa_mgr.h"
#include "wssa_du.h"
#include <ext/hash_map>
using __gnu_cxx::hash_map;

namespace WSSA {

typedef hash_map<INT32 /* WST_IDX */, 
                 pair<WN* /* def WN */, VER_IDX /* def VER */> > WST_DEF_MAP;

//===================================================================
// WSSA_UPDATER
//   interface to update WHIRL SSA
//===================================================================
class WSSA_UPDATER {
public:
  typedef CFG_UTIL::WN_CFG::BB_NODE BB_NODE;

private:
  BOOL _trace;
  WN* _root;
  CFG_UTIL::WN_CFG* _cfg;
  WHIRL_SSA_MANAGER* _ssa;
  WSSA_DU_MANAGER*   _du;

public:
  WSSA_UPDATER(WN* root, CFG_UTIL::WN_CFG* cfg, 
               WHIRL_SSA_MANAGER* ssa, BOOL trace = FALSE)
    : _root(root), _ssa(ssa), _cfg(cfg), _trace(trace) {
    _du = NULL;  // TODO: update DU
  } 

public:
  // adjust phi operands order according to CFG
  // only needed for WOPT emitter since the CFG and SSA are built separately
  void Adjust_phi_opnds();

private:
  // internal methods to update SSA
  // rename the WHIRL by the def info
  void ssa_rename_rhs(WN* rhs, WST_DEF_MAP& def);
  void ssa_rename_stmt(WN* stmt, WST_DEF_MAP& def);
  void ssa_rename_last_def(BB_NODE* bb, WST_DEF_MAP& def);
  // rename the WHIRL by the old and new version info
  BOOL ssa_rename_tree(WN* wn, VER_IDX old_ver, VER_IDX new_ver);
  void ssa_rename_bb(BB_NODE* bb, VER_IDX old_ver, VER_IDX new_ver);
  void ssa_rename_wst(BB_NODE* bb, VER_IDX old_ver, VER_IDX new_ver);
  void ssa_add_stmt(WN* stmt);
  void ssa_remove_stmt(WN* stmt);

  // internal methods to update DU
  void du_add_stmt(WN* stmt);
  void du_remove_stmt(WN* stmt);

  // internal methods to update CFG
  BOOL op_change_cfg(OPERATOR opr);
  BB_NODE* cfg_find_succ(WN* stmt);
  void cfg_insert_before(WN* before, WN* stmt);
  void cfg_insert_after(WN* after, WN* stmt);
  void cfg_remove_stmt(WN* stmt);

public:
  // copy tree and ssa information
  WN* Copy_tree(WN* tree);
  WN* Copy_tree_with_map(WN* tree);

  // insert statement and update whirl, cfg and ssa
  void Insert_before(WN* block, WN* before, WN* stmt);
  void Insert_after(WN* block, WN* after, WN* stmt);

  // extract statement(s) from block, update whirl, cfg and ssa
  WN*  Extract_stmt(WN* block, WN* stmt);
  WN*  Extract_list(WN* block, WN* first, WN* last);

  // delete statement(s) from block, update whirl, cfg and ssa
  void Delete_stmt(WN* block, WN* stmt);
  void Delete_list(WN* block, WN* first, WN* last);

public:
  // rename inside bb and keep the versions of live out the same
  void Rename_BB(BB_NODE* bb);
};

}; /* namespace WSSA */

#endif /* wssa_update_INCLUDED */

Attachment: wssa_update.cxx
Description: Binary data

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to