OpenADFortTk (basic)
src/lib/support/WhirlParentize.h
Go to the documentation of this file.
00001 // -*-Mode: C++;-*-
00002 // $Header: /m_home/m_utkej/Argonne/cvs2svn/cvs/OpenADFortTk/src/lib/support/WhirlParentize.h,v 1.5 2007-10-08 18:28:33 utke Exp $
00003 #ifndef WhirlParentize_h_INCLUDED
00004 #define WhirlParentize_h_INCLUDED
00005 
00006 #include "Open64IRInterface/Open64BasicTypes.h"
00007 
00008 namespace fortTkSupport { 
00009 
00010   // FindParentWNBlock: Given two WHIRL nodes, a subtree 'wn_tree' and an
00011   // some descendent 'wn', return the BLOCK WN that contains 'wn', or
00012   // NULL.  
00013   // 
00014   // Warning: This routine does not require creation of a
00015   // 'WhirlParentMap'.  Use sparingly and carefully or order statistics
00016   // will bite you!
00017   extern WN* 
00018   FindParentWNBlock(const WN* wn_tree, const WN* wn);
00019 
00020 
00026   class WhirlParentMap {
00027   public:
00028   
00029     WhirlParentMap();
00030     WhirlParentMap(const WN* wn); // automatically creates the map
00031     ~WhirlParentMap();
00032   
00033     // Create: Given a WN*, creates the map.  Clears any previously existing map.
00034     void Create(const WN* wn);
00035   
00036     // Clear: Clears the map.
00037     void Clear();
00038 
00039     // Find: Given a WN*, return its parent.  N.B. Does not check that
00040     // the map exists.
00041     WN* Find(const WN* wn) { return (WN *)WN_MAP_Get(parentMap, wn); }
00042   
00043     // Find: Given a WN*, find the first enclosing block or NULL.
00044     // N.B. Does not check that the map exists.
00045     WN* FindBlock(const WN* wn);
00046   
00047     // Insert: Given a WN* and its parent, insert in the map. Overwrites
00048     // any existing value.
00049     void Insert(const WN* wn, const WN* parent) {
00050       WN_MAP_Set(parentMap, (WN*)wn, (void *)parent);
00051     }
00052   
00053     // GetMap: returns the parent map.  Intended to be only used with
00054     // Open64 routines that want a parent map.
00055     WN_MAP GetMap() const { return parentMap; }
00056 
00057   private:
00058     void Ctor();
00059     void Parentize(const WN* wn);
00060   
00061   private:
00062     // For now keep the implementation using Open64's WN_MAP
00063     MEM_POOL memPool;
00064     WN_MAP parentMap;
00065   };
00066 
00067 
00068 
00069 }
00070 
00071 #endif 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines