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_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_whirl_templates.h $ 00044 // 00045 // Revision history: 00046 // 1-SEP-97 dahl - Original Version 00047 // 00048 //============================================================================ 00049 00050 // ======================================================================= 00051 // WHIRL search comparison functions for REGION_search_block 00052 // can search two ways: 00053 // 1) same pragma number in a pragma list 00054 // 2) same label_number in a region exit list 00055 struct comp_same_pragma { 00056 private: 00057 const WN_PRAGMA_ID _pragma; 00058 public: 00059 comp_same_pragma(const WN_PRAGMA_ID pragma) : _pragma(pragma) { } 00060 BOOL operator()(const WN *x) const { 00061 Is_True(WN_opcode(x) == OPC_PRAGMA, 00062 ("comp_same_pragma, not a pragma")); 00063 if (WN_pragma(x) == _pragma) 00064 return TRUE; 00065 return FALSE; 00066 } 00067 }; 00068 00069 struct comp_same_label_no { 00070 private: 00071 const INT32 _label_number; 00072 public: 00073 comp_same_label_no(const INT32 label_no) : _label_number(label_no) { } 00074 BOOL operator()(const WN *x) const { 00075 // in CG these can be converted to gotos or labels, rest of the time they 00076 // are always region_exits 00077 Is_True(WN_opcode(x) == OPC_REGION_EXIT || WN_opcode(x) == OPC_LABEL || 00078 WN_opcode(x) == OPC_GOTO, 00079 ("comp_same_label_no, not a region exit or label")); 00080 return (WN_label_number(x) == _label_number); 00081 } 00082 }; 00083 00084 // ======================================================================= 00085 // REGION_search_block: search statements in a WHIRL block 00086 // returns address of WHIRL node if found 00087 template <class COMP> 00088 WN *REGION_search_block(WN *block, COMP comp) 00089 { 00090 Is_True(WN_opcode(block) == OPC_BLOCK, ("REGION_search_block, not a block")); 00091 for (WN *wtmp=WN_first(block); wtmp; wtmp=WN_next(wtmp)) 00092 if (comp(wtmp)) 00093 return wtmp; 00094 return NULL; 00095 }
1.5.6