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 * Module: be_util.c 00040 * $Revision: 1.2 $ 00041 * $Date: 02/11/07 23:41:34-00:00 $ 00042 * $Author: fchow@keyresearch.com $ 00043 * $Source: /scratch/mee/2.4-65/kpro64-pending/be/com/SCCS/s.be_util.cxx $ 00044 * 00045 * Revision history: 00046 * 06-Dec -95 - Original Version 00047 * 00048 * Description: 00049 * Utilities for all backend components. 00050 * 00051 * ==================================================================== 00052 * ==================================================================== 00053 */ 00054 00055 #include "defs.h" 00056 #include "wn.h" 00057 #include "be_util.h" 00058 00059 static INT32 current_pu_count; 00060 00061 void 00062 Reset_Current_PU_Count(void) 00063 { 00064 current_pu_count = 0; 00065 } 00066 00067 void 00068 Advance_Current_PU_Count(void) 00069 { 00070 current_pu_count++; 00071 } 00072 00073 INT32 00074 Current_PU_Count(void) 00075 { 00076 return current_pu_count; 00077 } 00078 00079 //----------------------------------------------------------------------- 00080 // NAME: St_Idx_Is_Intconst 00081 // FUNCTION: Returns TRUE if 'st_idx' is an integer constant and, when this 00082 // is the case, sets the value in 'val'. Otherwise, returns FALSE. 00083 //----------------------------------------------------------------------- 00084 00085 extern BOOL St_Idx_Is_Intconst(ST_IDX st_idx, INT64 *val) 00086 { 00087 ST* st = &St_Table[st_idx]; 00088 if (ST_class(st)==CLASS_CONST) { 00089 TCON t = STC_val(st); 00090 switch(TCON_ty(t)) { 00091 case MTYPE_I1: case MTYPE_I2 : case MTYPE_I4: case MTYPE_I8 : 00092 *val = t.vals.i0; 00093 return TRUE; 00094 case MTYPE_U1: case MTYPE_U2 : case MTYPE_U4: case MTYPE_U8 : 00095 *val = t.vals.k0; 00096 return TRUE; 00097 default: 00098 return FALSE; 00099 } 00100 } else { 00101 return FALSE; 00102 } 00103 } 00104 00105 //----------------------------------------------------------------------- 00106 // NAME: Wn_Is_Intconst 00107 // FUNCTION: Returns TRUE if 'ldid' is an integer constant and, when this 00108 // is the case, sets the value in 'val'. Otherwise, returns FALSE. 00109 //----------------------------------------------------------------------- 00110 00111 extern BOOL Wn_Is_Intconst(WN *ldid, INT64 *val) 00112 { 00113 return St_Idx_Is_Intconst(ST_st_idx(WN_st(ldid)), val); 00114 } 00115 00116 // ---------------------------------------------------------------------- 00117 // symbols defined in be.so but used in cg.so 00118 /* official builds will link with identfile that defines _Release_ID */ 00119 extern const char *__Release_ID; 00120 const char *Default_Release_ID = "none"; 00121 #if defined(SHARED_BUILD) 00122 #if defined(BUILD_OS_DARWIN) 00123 #pragma weak __Release_ID 00124 const char *__Release_ID = "none"; 00125 #else /* defined(BUILD_OS_DARWIN) */ 00126 #pragma weak __Release_ID = Default_Release_ID 00127 #endif /* defined(BUILD_OS_DARWIN) */ 00128 #endif 00129
1.5.6