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 /* ==================================================================== 00037 * ==================================================================== 00038 * 00039 * 00040 * Revision history: 00041 * 3-MAR-96 dahl - Original Version 00042 * 00043 * Description: 00044 * PU iterator for BE driver. 00045 * 00046 * ==================================================================== 00047 * ==================================================================== 00048 */ 00049 00050 #define rbi_CXX "iter.c" 00051 #ifdef _KEEP_RCS_ID 00052 #endif /* _KEEP_RCS_ID */ 00053 00054 #include <elf.h> /* for Elf64_Word */ 00055 #include "defs.h" 00056 #include "stab.h" 00057 #include "pu_info.h" /* PU_Info */ 00058 #include "iter.h" /* PU_INFO_ITER */ 00059 #include "wn.h" 00060 #include "be_util.h" /* Reset_Current_PU_Count, Advance_Current_PU_Count */ 00061 #include "errors.h" /* FmtAssert */ 00062 00063 /* ==================================================================== */ 00064 /* iterator functions for PU loop in back-end */ 00065 /* ==================================================================== */ 00066 00067 static void Pu_Push(PU_INFO_ITER *iter, PU_Info *pu_tree) 00068 { 00069 PU_INFO_ITER_stack(iter) = pu_tree; 00070 PU_INFO_ITER_sp(iter)++; 00071 FmtAssert(PU_INFO_ITER_sp(iter) <= PU_INFO_ITER_stack_size, 00072 ("Pu_Push, stack overflow - too many nested procedures")); 00073 } 00074 00075 static PU_Info *Pu_Pop(PU_INFO_ITER *iter) 00076 { 00077 if (PU_INFO_ITER_sp(iter) == 0) { 00078 Is_True(0,("Pu_Pop, stack underflow, problem with nested procedure")); 00079 return NULL; 00080 } 00081 PU_INFO_ITER_sp(iter)--; 00082 return PU_INFO_ITER_stack(iter); 00083 } 00084 00085 void Pu_Init(PU_INFO_ITER *iter, PU_Info *pu_tree) 00086 { 00087 PU_INFO_ITER_sp(iter) = 0; 00088 PU_INFO_ITER_current(iter) = pu_tree; 00089 Reset_Current_PU_Count(); 00090 } 00091 00092 BOOL Pu_While(PU_INFO_ITER *iter) 00093 { 00094 return PU_INFO_ITER_current(iter) != NULL; 00095 } 00096 00097 /* check for child PUs added by MP lowering */ 00098 void Pu_Next(PU_INFO_ITER *iter) 00099 { 00100 if (PU_Info_child(PU_INFO_ITER_current(iter))) { 00101 Pu_Push(iter, PU_INFO_ITER_current(iter)); 00102 PU_INFO_ITER_current(iter) = PU_Info_child(PU_INFO_ITER_current(iter)); 00103 } else { 00104 PU_INFO_ITER_current(iter) = PU_Info_next(PU_INFO_ITER_current(iter)); 00105 if (PU_INFO_ITER_current(iter) == NULL && PU_INFO_ITER_sp(iter)) { 00106 while (PU_INFO_ITER_sp(iter)) { 00107 PU_INFO_ITER_current(iter) = Pu_Pop(iter); 00108 if (PU_Info_next(PU_INFO_ITER_current(iter))) 00109 break; 00110 } 00111 PU_INFO_ITER_current(iter) = PU_Info_next(PU_INFO_ITER_current(iter)); 00112 } 00113 } 00114 Advance_Current_PU_Count(); 00115 }