Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
region_alias_templates.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 //-*-c++-*-
00037 //============================================================================
00038 //
00039 //
00040 // Revision history:
00041 //  22-SEP-97 dahl - Original Version
00042 //
00043 //============================================================================
00044 
00045 #include "region_util.h"        // POINTS_TO_SET
00046 #include "opt_alias_mgr.h"      // ALIAS_MANAGER
00047 #include "opt_alias_rule.h"     // ALIAS_RULE
00048 #include "opt_points_to.h"      // BASE_IS_FIXED
00049 
00050 // =======================================================================
00051 // Boundary set search comparison functions for REGION_search_set
00052 // can call search two ways:
00053 
00054 // used to see if a PT is aliased with the boundary set
00055 struct comp_aliased {
00056  private:
00057   const POINTS_TO *_item;
00058   const ALIAS_RULE *_ar;
00059  public:
00060   comp_aliased(const POINTS_TO *item, const ALIAS_RULE *ar) :
00061         _item(item), _ar(ar) { }
00062   BOOL operator()(const POINTS_TO *x) const {
00063     // copy POINTS_TOs to local memory
00064     POINTS_TO x_copy, item_copy;
00065     x_copy.Copy_fully(x);
00066     item_copy.Copy_fully(_item);
00067     // remove const attribute from each
00068     x_copy.Reset_const();
00069     item_copy.Reset_const();
00070     // call Aliased_Memop
00071     Is_True(_ar != NULL, ("comp_aliased template, alias rule is NULL"));
00072     return _ar->Aliased_Memop(&item_copy, &x_copy);
00073   }
00074 };
00075 
00076 // used to check for duplicates in the boundary set, calls Meet to merge
00077 // overlaps with the list
00078 struct comp_same_pt {
00079  private:
00080   const POINTS_TO *_item;
00081   const ALIAS_RULE *_ar;
00082  public:
00083   comp_same_pt(const POINTS_TO *item, const ALIAS_RULE *ar) :
00084         _item(item), _ar(ar) { }
00085   // may modify parameter
00086   BOOL operator()(POINTS_TO *x) {
00087     if (_ar) {
00088       struct comp_aliased comp(_item, _ar);
00089       if (!comp(x))
00090         return FALSE;
00091     }
00092     if (x->Similar(_item)) { // checks base, offset size
00093       x->Meet(_item, NULL);
00094       return TRUE;
00095     } else
00096       return FALSE;
00097   }
00098 };
00099 
00100 template <class COMP>
00101 POINTS_TO *REGION_search_set(POINTS_TO_SET *pset, COMP comp)
00102 {
00103   // don't check pset for NULL, it can be empty
00104   for (POINTS_TO_SET *ptmp=pset; ptmp; ptmp=ptmp->Next) {
00105     if (comp(ptmp->Pt))
00106       return ptmp->Pt;
00107   }
00108   return NULL;
00109 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines