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