00001 // 00002 // Copyright (c) 2005-2008 Kenichi Watanabe. 00003 // Copyright (c) 2005-2008 Yasuhiro Watari. 00004 // Copyright (c) 2005-2008 Hironori Ichibayashi. 00005 // Copyright (c) 2008-2009 Kazuo Horio. 00006 // Copyright (c) 2009-2013 Naruki Kurata. 00007 // Copyright (c) 2005-2013 Ryota Shioya. 00008 // Copyright (c) 2005-2013 Masahiro Goshima. 00009 // 00010 // This software is provided 'as-is', without any express or implied 00011 // warranty. In no event will the authors be held liable for any damages 00012 // arising from the use of this software. 00013 // 00014 // Permission is granted to anyone to use this software for any purpose, 00015 // including commercial applications, and to alter it and redistribute it 00016 // freely, subject to the following restrictions: 00017 // 00018 // 1. The origin of this software must not be misrepresented; you must not 00019 // claim that you wrote the original software. If you use this software 00020 // in a product, an acknowledgment in the product documentation would be 00021 // appreciated but is not required. 00022 // 00023 // 2. Altered source versions must be plainly marked as such, and must not be 00024 // misrepresented as being the original software. 00025 // 00026 // 3. This notice may not be removed or altered from any source 00027 // distribution. 00028 // 00029 // 00030 00031 00032 #include <pch.h> 00033 #include "Sim/Core/DataPredTypes.h" 00034 #include "Utility/RuntimeError.h" 00035 00036 using namespace Onikiri; 00037 00038 00039 void DataPredMissRecovery::Validate() 00040 { 00041 if( m_policy == POLICY_END || m_from == FROM_END ){ 00042 THROW_RUNTIME_ERROR( "A policy or a recovery point is not set." ); 00043 } 00044 00045 if( m_policy == POLICY_REDISPATCH_ALL ){ 00046 THROW_RUNTIME_ERROR( "A recovery policy 'Redispatch' is not implemented." ); 00047 } 00048 00049 if( m_policy == POLICY_REISSUE_SELECTIVE && m_from == FROM_NEXT_OF_PRODUCER ){ 00050 THROW_RUNTIME_ERROR( "Cannot reschedule ops based on a recovery policy 'ReissueSelective' from a 'NextOfProducer' op." ); 00051 } 00052 00053 /* if( m_policy == POLICY_REFETCH && m_from != FROM_NEXT_OF_PRODUCER ){ 00054 THROW_RUNTIME_ERROR( "A recovery policy 'Refetch' From' Consumer' or 'Producer' is not implemented." ); 00055 }*/ 00056 } 00057 00058 // 00059 // Instruction types where each speculation requires check-pointing. 00060 // Producer / Consumer 00061 // LatPredRecovery: load / any 00062 // AddrMatchPredRecovery: store / load 00063 // ValuePredRecovery: any / any 00064 // PartialLoadRecovery: store / load 00065 // 00066 bool DataPredMissRecovery::IsRequiredBeforeCheckpoint( const OpClass& opClass ) const 00067 { 00068 if( m_policy != POLICY_REFETCH ){ 00069 // An only re-fetch policy requires check-pointing. 00070 return false; 00071 } 00072 00073 switch( m_type ){ 00074 case TYPE_LATENCY: 00075 // Producer : load 00076 if( opClass.IsLoad() && m_from == FROM_PRODUCER ){ 00077 return true; 00078 } 00079 // Consumer : any 00080 if( m_from == FROM_CONSUMER ){ 00081 return true; 00082 } 00083 break; 00084 00085 case TYPE_ADDRESS_MATCH: 00086 case TYPE_PARTIAL_LOAD: 00087 // Producer : store 00088 if( opClass.IsStore() && m_from == FROM_PRODUCER ){ 00089 return true; 00090 } 00091 // Consumer : load 00092 if( opClass.IsLoad() && m_from == FROM_CONSUMER ){ 00093 return true; 00094 } 00095 break; 00096 00097 case TYPE_VALUE: 00098 // Not implemented... 00099 /* 00100 // Producer : any 00101 if( m_from == FROM_PRODUCER ){ 00102 return true; 00103 } 00104 // Consumer : any 00105 if( m_from == FROM_CONSUMER ){ 00106 return true; 00107 } 00108 */ 00109 break; 00110 00111 default: 00112 ASSERT( false, "An unknown recovery type." ); 00113 break; 00114 } 00115 00116 return false; 00117 } 00118 00119 bool DataPredMissRecovery::IsRequiredAfterCheckpoint ( const OpClass& opClass ) const 00120 { 00121 if( m_policy != POLICY_REFETCH ){ 00122 // An only re-fetch policy requires check-pointing. 00123 return false; 00124 } 00125 00126 switch( m_type ){ 00127 case TYPE_LATENCY: 00128 // Producer : load 00129 if( opClass.IsLoad() && m_from == FROM_NEXT_OF_PRODUCER ){ 00130 return true; 00131 } 00132 break; 00133 00134 case TYPE_ADDRESS_MATCH: 00135 case TYPE_PARTIAL_LOAD: 00136 // Producer : store 00137 if( opClass.IsStore() && m_from == FROM_NEXT_OF_PRODUCER ){ 00138 return true; 00139 } 00140 break; 00141 00142 case TYPE_VALUE: 00143 // Not implemented... 00144 /* 00145 // Producer : any 00146 if( m_from == FROM_NEXT_OF_PRODUCER ){ 00147 return true; 00148 } 00149 // Consumer : any 00150 if( m_from == FROM_NEXT_OF_PRODUCER ){ 00151 return true; 00152 } 00153 */ 00154 break; 00155 00156 default: 00157 ASSERT( false, "An unknown recovery type." ); 00158 break; 00159 } 00160 00161 return false; 00162 }