Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShInternals.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef SHINTERNALS_HPP 
00021 #define SHINTERNALS_HPP
00022 
00023 #include <map>
00024 #include "ShDllExport.hpp"
00025 #include "ShVariableNode.hpp"
00026 #include "ShCtrlGraph.hpp"
00027 #include "ShBackend.hpp"
00028 #include "ShProgramNode.hpp"
00029 #include "ShStructural.hpp"
00030 #include <map>
00031 
00032 namespace SH { 
00033 
00034 typedef std::map<ShVariableNodePtr, ShVariableNodePtr> ShVarMap;
00035 
00036 struct
00037 SH_DLLEXPORT ShVariableReplacer {
00038 
00039   ShVariableReplacer(ShVarMap& v);
00040 
00041   // replaces variables in node based on varMap
00042   void operator()(ShCtrlGraphNodePtr node);
00043 
00044   // replaces variables in a ShProgramNode::VarList based on varMap 
00045   void operator()(ShProgramNode::VarList &varList);
00046 
00047   // replaces variables in a ShStructuralNode and all Structural
00048   // Nodes in its region.
00049   void operator()(ShStructuralNodePtr node);
00050 
00051   // replaces node in a single variable using varMap
00052   void repVar(ShVariable& var);
00053 
00054   ShVarMap& varMap;
00055 };
00056 
00057 
00062 class
00063 SH_DLLEXPORT ShVarTransformMap {
00064 private:
00065   ShVarMap m_NewToOldMap;
00066 
00067 public:
00068   ShVarTransformMap() {}
00069   explicit ShVarTransformMap(const ShVarTransformMap &m)
00070     : m_NewToOldMap(m.m_NewToOldMap)
00071   {}
00072   ShVarTransformMap & operator=(const ShVarTransformMap &m)
00073   {
00074     m_NewToOldMap = m.m_NewToOldMap;
00075     return *this;
00076   }
00077 
00079   void clear() { m_NewToOldMap.clear(); }
00080 
00084   void add_variable_transform(ShVariableNodePtr origVar, ShVariableNodePtr newVar);
00085 
00089   ShVariableNodePtr get_original_variable(ShVariableNodePtr newVar) const
00090   {
00091     ShVarMap::const_iterator i = m_NewToOldMap.find(newVar);
00092     return (i != m_NewToOldMap.end() ? i->second : newVar);
00093   }
00094 };
00095 
00096 
00097 }
00098 
00099 #endif
00100 

Generated on Thu Jul 28 17:33:02 2005 for Sh by  doxygen 1.4.3-20050530