00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "errors.h"
00028 #include "tn.h"
00029 #include "op.h"
00030 #include "cgtarget.h"
00031 #include "targ_isa_bundle.h"
00032 #include "targ_issue_port.h"
00033 #include "dag.h"
00034 #include "msched_util.h"
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 void MSCHED_Convert_Simulated(OP *op, ISA_EXEC_UNIT_PROPERTY prop)
00056 {
00057 TOP adjust_top = CGTARG_Simulated_Top(op, prop);
00058 OP_Change_Opcode(op, adjust_top);
00059 if (prop == ISA_EXEC_PROPERTY_M_Unit) {
00060 Set_OP_m_unit(op);
00061 } else {
00062 Reset_OP_m_unit(op);
00063 }
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 void MSCHED_Real_OP(OP *op)
00073 {
00074
00075 REGISTER reg;
00076 BOOL is_m, is_i;
00077 switch (OP_code(op)){
00078 case TOP_mov_t_ar_i:
00079 case TOP_mov_t_ar_r:
00080 if (TN_is_dedicated(OP_result(op,0))){
00081 reg = TN_register(OP_result(op,0));
00082 is_m = REGISTER_SET_MemberP(
00083 REGISTER_SUBCLASS_members(ISA_REGISTER_SUBCLASS_ar_m),
00084 reg);
00085 is_i = REGISTER_SET_MemberP(
00086 REGISTER_SUBCLASS_members(ISA_REGISTER_SUBCLASS_ar_i),
00087 reg);
00088 if (is_m && !is_i){
00089 MSCHED_Convert_Simulated(op, ISA_EXEC_PROPERTY_M_Unit);
00090 }
00091 else if (is_i && !is_m){
00092 MSCHED_Convert_Simulated(op, ISA_EXEC_PROPERTY_I_Unit);
00093 }
00094 }
00095 break;
00096 case TOP_mov_f_ar:
00097 if (TN_is_dedicated(OP_opnd(op,1))){
00098 reg = TN_register(OP_opnd(op,1));
00099 is_m = REGISTER_SET_MemberP(
00100 REGISTER_SUBCLASS_members(ISA_REGISTER_SUBCLASS_ar_m),
00101 reg);
00102 is_i = REGISTER_SET_MemberP(
00103 REGISTER_SUBCLASS_members(ISA_REGISTER_SUBCLASS_ar_i),
00104 reg);
00105 if (is_m && !is_i){
00106 MSCHED_Convert_Simulated(op, ISA_EXEC_PROPERTY_M_Unit);
00107 }
00108 else if (is_i && !is_m){
00109 MSCHED_Convert_Simulated(op, ISA_EXEC_PROPERTY_I_Unit);
00110 }
00111 }
00112 break;
00113 }
00114 }
00115
00116 BOOL Is_Violate_Issue_Rule(OP *op, INT ip)
00117 {
00118 if ( (OP_code(op) == TOP_break)
00119 && (*Issue_Port_Name(ip) == 'B')){
00120
00121
00122 TN *immd_tn=OP_opnd(op, 1);
00123 FmtAssert((TN_has_value(immd_tn) && TN_value(immd_tn) == 0),
00124 ("break opruction with none zero operand"
00125 " should specifies the slot type!") );
00126 }
00127 return false;
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 GROUP_ASSEMBLE::GROUP_ASSEMBLE(void)
00140 {
00141 OPS_Init(&_op_list);
00142 }
00143 GROUP_ASSEMBLE::~GROUP_ASSEMBLE(void)
00144 {
00145
00146 Is_True(OPS_length(&_op_list) == 0,
00147 ("There are %d ops were not issued!"
00148 , OPS_length(&_op_list)));
00149
00150
00151 }
00152
00153 void GROUP_ASSEMBLE::SetBundled(OP *op)
00154 {
00155 Set_OP_Scheduled(op);
00156 Set_OP_bundled(op);
00157 }
00158
00159 void GROUP_ASSEMBLE::SetStartBundle(OP *op)
00160 {
00161 SetBundled(op);
00162 Set_OP_start_bundle(op);
00163 }
00164
00165 void GROUP_ASSEMBLE::SetEndBundle(OP *op)
00166 {
00167 SetBundled(op);
00168
00169 }
00170
00171 void GROUP_ASSEMBLE::SetStartGroup(OP *op)
00172 {
00173
00174 }
00175
00176 void GROUP_ASSEMBLE::SetEndGroup(OP *op)
00177 {
00178
00179 if (op != NULL) {
00180 Set_OP_end_group(op);
00181 SetStopBit(op);
00182 }
00183 }
00184
00185 void GROUP_ASSEMBLE::SetStopBit(OP *op)
00186 {
00187
00188 }
00189
00190
00191 void GROUP_ASSEMBLE::ResetBundled(OP *op)
00192 {
00193 Reset_OP_bundled(op);
00194 }
00195
00196 void GROUP_ASSEMBLE::ResetStartBundle(OP *op)
00197 {
00198 Reset_OP_start_bundle(op);
00199 }
00200
00201 void GROUP_ASSEMBLE::ResetEndBundle(OP *op)
00202 {
00203
00204 }
00205
00206 void GROUP_ASSEMBLE::ResetStartGroup(OP *op)
00207 {
00208
00209 }
00210
00211 void GROUP_ASSEMBLE::ResetEndGroup(OP *op)
00212 {
00213 Reset_OP_end_group(op);
00214 ResetStopBit(op);
00215 }
00216
00217 void GROUP_ASSEMBLE::ResetStopBit(OP *op)
00218 {
00219
00220 }
00221
00222 ISA_EXEC_UNIT_PROPERTY
00223 GROUP_ASSEMBLE::ReplaceMLX(INT slot, ISA_EXEC_UNIT_PROPERTY prop) {
00224
00225
00226
00227 if (prop == ISA_EXEC_PROPERTY_L_Unit)
00228 {
00229 switch (slot){
00230 case 1:
00231 prop = ISA_EXEC_PROPERTY_F_Unit;
00232 break;
00233 case 2:
00234 prop = ISA_EXEC_PROPERTY_I2_Unit;
00235 break;
00236 default:
00237 Is_True(FALSE, ("L slot occured in slot 0!"));
00238 }
00239 }
00240 return prop;
00241 }
00242
00243
00244 OP *GROUP_ASSEMBLE::MakeNop2Slot(INT itemplate, INT slot)
00245 {
00246 ISA_EXEC_UNIT_PROPERTY slot_prop =
00247 ISA_EXEC_Slot_Prop(itemplate, slot);
00248
00249 slot_prop = ReplaceMLX(slot, slot_prop);
00250
00251 TOP top = (TOP)CGTARG_Noop_Top(slot_prop);
00252 Is_True(top!=TOP_nop, ("Failed in find proper nop!"));
00253 OP *op = Mk_OP(top, True_TN, Gen_Literal_TN(0,4));
00254 return op;
00255 }
00256
00257
00258 void GROUP_ASSEMBLE::InsertOP(OP *op)
00259 {
00260 OPS_Append_Op(&_op_list, op);
00261 }
00262
00263
00264 void GROUP_ASSEMBLE::RemoveOP(OP *op)
00265 {
00266 OPS_Remove_Op(&_op_list, op);
00267 }
00268
00269
00270 void GROUP_ASSEMBLE:: ConvertSimulatedOP(OP *op, INT itemplate, INT slot)
00271 {
00272 if (TOP_is_simulated(OP_code(op))){
00273 ISA_EXEC_UNIT_PROPERTY slot_prop =
00274 ISA_EXEC_Slot_Prop(itemplate, slot);
00275
00276 if (!Long_Instruction(op)) {
00277 slot_prop = ReplaceMLX(slot, slot_prop);
00278 }
00279
00280 MSCHED_Convert_Simulated(op, slot_prop);
00281 }
00282 }
00283
00284
00285 void GROUP_ASSEMBLE::Bundle_OP_End(OP *op, INT itemplate, INT slot)
00286 {
00287
00288 Is_True(op, ("Not anything issued in a used slot!"));
00289
00290
00291 ResetStartBundle(op);
00292 ResetEndBundle(op);
00293 ResetStartGroup(op);
00294 ResetEndGroup(op);
00295
00296 if (slot == 0) {
00297 SetStartBundle(op);
00298 } else if(slot == (ISA_MAX_SLOTS-1)) {
00299 SetEndBundle(op);
00300 } else {
00301 SetBundled(op);
00302 }
00303
00304
00305 ISA_EXEC_UNIT_PROPERTY slot_prop =
00306 ISA_EXEC_Slot_Prop(itemplate, slot);
00307
00308 if (slot_prop==ISA_EXEC_PROPERTY_M_Unit){
00309 Set_OP_m_unit(op);
00310 }
00311 else{
00312 Reset_OP_m_unit(op);
00313 }
00314 }
00315
00316 void GROUP_ASSEMBLE::Group_End(OP *op)
00317 {
00318 if (op == NULL) op = OPS_last(&_op_list);
00319 SetStartGroup(op);
00320 SetEndGroup(op);
00321 }
00322
00323 void GROUP_ASSEMBLE::InsertAfter(BB *bb, OP *position)
00324 {
00325 OP *op, *next;
00326 for (op = OPS_first(&_op_list); op && op != OP_next(OPS_last(&_op_list));
00327 op = next){
00328 next = OP_next(op);
00329 RemoveOP(op);
00330 mUINT16 old_map_idx = OP_map_idx(op);
00331 if (position){
00332 BB_Insert_Op_After(bb, position, op);
00333 }
00334 else{
00335 BB_Prepend_Op(bb,op);
00336 }
00337 if (!OP_noop(op)){
00338 op->map_idx = old_map_idx;
00339 }
00340 position = op;
00341 }
00342 }
00343 OP *GROUP_ASSEMBLE::EmitNop(INT itemplate, INT slot)
00344 {
00345 OP *op = MakeNop2Slot(itemplate, slot);
00346 InsertOP(op);
00347 Bundle_OP_End(op, itemplate, slot);
00348 return op;
00349 }
00350 void GROUP_ASSEMBLE::EmitOp(OP *op, INT itemplate, INT slot)
00351 {
00352 ConvertSimulatedOP(op, itemplate, slot);
00353 InsertOP(op);
00354 Bundle_OP_End(op, itemplate, slot);
00355 }