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 // Module: region_alias_templates.h 00040 // $Revision: 1.2 $ 00041 // $Date: 02/11/07 23:41:58-00:00 $ 00042 // $Author: fchow@keyresearch.com $ 00043 // $Source: /scratch/mee/2.4-65/kpro64-pending/be/region/SCCS/s.region_alias_templates.h $ 00044 // 00045 // Revision history: 00046 // 22-SEP-97 dahl - Original Version 00047 // 00048 //============================================================================ 00049 00050 #include "region_util.h" // POINTS_TO_SET 00051 #include "opt_alias_mgr.h" // ALIAS_MANAGER 00052 #include "opt_alias_rule.h" // ALIAS_RULE 00053 #include "opt_points_to.h" // BASE_IS_FIXED 00054 00055 // ======================================================================= 00056 // Boundary set search comparison functions for REGION_search_set 00057 // can call search two ways: 00058 00059 // used to see if a PT is aliased with the boundary set 00060 struct comp_aliased { 00061 private: 00062 const POINTS_TO *_item; 00063 const ALIAS_RULE *_ar; 00064 public: 00065 comp_aliased(const POINTS_TO *item, const ALIAS_RULE *ar) : 00066 _item(item), _ar(ar) { } 00067 BOOL operator()(const POINTS_TO *x) const { 00068 // copy POINTS_TOs to local memory 00069 POINTS_TO x_copy, item_copy; 00070 x_copy.Copy_fully(x); 00071 item_copy.Copy_fully(_item); 00072 // remove const attribute from each 00073 x_copy.Reset_const(); 00074 item_copy.Reset_const(); 00075 // call Aliased_Memop 00076 Is_True(_ar != NULL, ("comp_aliased template, alias rule is NULL")); 00077 return _ar->Aliased_Memop(&item_copy, &x_copy); 00078 } 00079 }; 00080 00081 // used to check for duplicates in the boundary set, calls Meet to merge 00082 // overlaps with the list 00083 struct comp_same_pt { 00084 private: 00085 const POINTS_TO *_item; 00086 const ALIAS_RULE *_ar; 00087 public: 00088 comp_same_pt(const POINTS_TO *item, const ALIAS_RULE *ar) : 00089 _item(item), _ar(ar) { } 00090 // may modify parameter 00091 BOOL operator()(POINTS_TO *x) { 00092 if (_ar) { 00093 struct comp_aliased comp(_item, _ar); 00094 if (!comp(x)) 00095 return FALSE; 00096 } 00097 if (x->Similar(_item)) { // checks base, offset size 00098 x->Meet(_item, NULL); 00099 return TRUE; 00100 } else 00101 return FALSE; 00102 } 00103 }; 00104 00105 template <class COMP> 00106 POINTS_TO *REGION_search_set(POINTS_TO_SET *pset, COMP comp) 00107 { 00108 // don't check pset for NULL, it can be empty 00109 for (POINTS_TO_SET *ptmp=pset; ptmp; ptmp=ptmp->Next) { 00110 if (comp(ptmp->Pt)) 00111 return ptmp->Pt; 00112 } 00113 return NULL; 00114 }
1.5.6