00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2 of the GNU General Public License as 00011 published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with this program; if not, write the Free Software Foundation, Inc., 59 00026 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00027 00028 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00029 Mountain View, CA 94043, or: 00030 00031 http://www.sgi.com 00032 00033 For further information regarding this notice, see: 00034 00035 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00036 00037 */ 00038 00039 // LUNIT implemetation 00040 00041 // $Revision: 1.6 $ 00042 // $Date: 05/12/05 08:59:10-08:00 $ 00043 // $Author: bos@eng-24.pathscale.com $ 00044 // $Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/gra_mon/SCCS/s.gra_lunit.cxx $ 00045 00046 #ifdef USE_PCH 00047 #include "cg_pch.h" 00048 #endif // USE_PCH 00049 #pragma hdrstop 00050 00051 #ifdef _KEEP_RCS_ID 00052 static char *rcs_id = "$Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/gra_mon/SCCS/s.gra_lunit.cxx $ $Revision: 1.6 $"; 00053 #endif 00054 00055 #include "defs.h" 00056 #include "errors.h" 00057 #include "mempool.h" 00058 #include "register.h" 00059 #include "bb.h" 00060 #include "gra_bb.h" 00061 #include "gra_lunit.h" 00062 #include "gra_lrange.h" 00063 00064 #ifdef TARG_X8664 00065 #include "targ_sim.h" // For RAX, RCX and RDX 00066 #endif 00067 00068 00070 // Create and return a new LUNIT associated with <lrange> and 00071 // <gbb>. The new LUNIT is also added to the collections of 00072 // LUNITs associated with <lrange> and <gbb>. See gra_bb.h for 00073 // the definition of GRA_BB_RC_LUNIT_ITER and gra_lrange.h for 00074 // the definition of LRANGE_LUNIT_ITER. 00075 extern LUNIT* 00076 LUNIT_Create( LRANGE* lrange, GRA_BB* gbb ) 00077 { 00078 LUNIT* result = TYPE_MEM_POOL_ALLOC(LUNIT,GRA_pool); 00079 00080 result->lrange = lrange; 00081 result->gbb = gbb; 00082 result->pref_priority = 0.0; 00083 result->allowed_preferences = REGISTER_SET_EMPTY_SET; 00084 result->flags = 0; 00085 result->def_count = 0; 00086 result->last_def = -1; 00087 result->global_pref = NULL; 00088 #ifdef TARG_IA64 00089 result->has_use = FALSE; 00090 #endif 00091 gbb->Add_LUNIT(result); 00092 lrange->Add_LUNIT(result); 00093 return result; 00094 } 00095 00097 // Call once for each preferencing copy seen that copies into or 00098 // out of <lunit>'s LRANGE in its BB. <lrange> is the other side 00099 // of the copy -- where we are copying lunit to or from. 00100 void 00101 LUNIT::Preference_Copy(LRANGE *lr) 00102 { 00103 pref_priority += gbb->Freq(); 00104 if (lr->Type() == LRANGE_TYPE_LOCAL && lr->Has_Wired_Register()) { 00105 #ifdef TARG_X8664 00106 /* Relax me!!! 00107 The following condition is necessary when the curent lrange does not 00108 across an operation which uses RAX, RCX or RDX implicitly. 00109 */ 00110 if( lr->Reg() == RAX || 00111 lr->Reg() == RCX || 00112 lr->Reg() == RDX ) 00113 return; 00114 #endif 00115 allowed_preferences = REGISTER_SET_Union1(allowed_preferences,lr->Reg()); 00116 } 00117 } 00118 00120 // Is <lunit>'s LRANGE live-out of its BB? 00121 BOOL 00122 LUNIT::Live_Out(void) 00123 { 00124 return GTN_SET_MemberP(BB_live_out(gbb->Bb()), lrange->Tn()); 00125 } 00126 00128 // Is <lunit>'s LRANGE live-in to its BB? 00129 BOOL 00130 LUNIT::Live_In(void) 00131 { 00132 return GTN_SET_MemberP(BB_live_in(gbb->Bb()), lrange->Tn()); 00133 } 00134 00136 // Return the priority of the given <lunit>. 00137 float 00138 LUNIT::Priority(void) { 00139 float result; 00140 result = Live_In() ? gbb->Freq() : 0.0; 00141 if (Live_Out() && Has_Def()) 00142 result += gbb->Freq(); 00143 return result; 00144 }
1.5.6