1/* 2 * Copyright (c) 2004-2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 17 unchanged lines hidden (view full) --- 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Kevin Lim 29 * Korey Sewell 30 */ 31 32#include <list> 33 |
34#include "arch/isa_traits.hh" 35#include "arch/regfile.hh" |
36#include "config/full_system.hh" 37#include "cpu/o3/rename.hh" 38 39template <class Impl> 40DefaultRename<Impl>::DefaultRename(Params *params) 41 : iewToRenameDelay(params->iewToRenameDelay), 42 decodeToRenameDelay(params->decodeToRenameDelay), 43 commitToRenameDelay(params->commitToRenameDelay), 44 renameWidth(params->renameWidth), 45 commitWidth(params->commitWidth), |
46 resumeSerialize(false), 47 resumeUnblocking(false), |
48 numThreads(params->numberOfThreads), 49 maxPhysicalRegs(params->numPhysIntRegs + params->numPhysFloatRegs) 50{ 51 _status = Inactive; 52 53 for (int i=0; i< numThreads; i++) { 54 renameStatus[i] = Idle; 55 --- 275 unchanged lines hidden (view full) --- 331DefaultRename<Impl>::squash(const InstSeqNum &squash_seq_num, unsigned tid) 332{ 333 DPRINTF(Rename, "[tid:%u]: Squashing instructions.\n",tid); 334 335 // Clear the stall signal if rename was blocked or unblocking before. 336 // If it still needs to block, the blocking should happen the next 337 // cycle and there should be space to hold everything due to the squash. 338 if (renameStatus[tid] == Blocked || |
339 renameStatus[tid] == Unblocking) { |
340 toDecode->renameUnblock[tid] = 1; 341 |
342 resumeSerialize = false; |
343 serializeInst[tid] = NULL; |
344 } else if (renameStatus[tid] == SerializeStall) { 345 if (serializeInst[tid]->seqNum <= squash_seq_num) { 346 DPRINTF(Rename, "Rename will resume serializing after squash\n"); 347 resumeSerialize = true; 348 assert(serializeInst[tid]); 349 } else { 350 resumeSerialize = false; 351 toDecode->renameUnblock[tid] = 1; 352 353 serializeInst[tid] = NULL; 354 } |
355 } 356 357 // Set the status to Squashing. 358 renameStatus[tid] = Squashing; 359 360 // Squash any instructions from decode. 361 unsigned squashCount = 0; 362 --- 38 unchanged lines hidden (view full) --- 401 while (slist_it != skidBuffer[tid].end()) { 402 if ((*slist_it)->seqNum > squash_seq_num) { 403 (*slist_it)->setSquashed(); 404 DPRINTF(Rename, "Squashing skidbuffer instruction, [tid:%i] [sn:%i]" 405 "PC %08p.\n", tid, (*slist_it)->seqNum, (*slist_it)->PC); 406 } 407 slist_it++; 408 } |
409 resumeUnblocking = (skidBuffer[tid].size() != 0); 410 DPRINTF(Rename, "Resume unblocking set to %s\n", 411 resumeUnblocking ? "true" : "false"); |
412#else 413 skidBuffer[tid].clear(); 414#endif 415 doSquash(squash_seq_num, tid); 416} 417 418template <class Impl> 419void --- 68 unchanged lines hidden (view full) --- 488 // check if stall conditions have passed 489 490 if (renameStatus[tid] == Blocked) { 491 ++renameBlockCycles; 492 } else if (renameStatus[tid] == Squashing) { 493 ++renameSquashCycles; 494 } else if (renameStatus[tid] == SerializeStall) { 495 ++renameSerializeStallCycles; |
496 // If we are currently in SerializeStall and resumeSerialize 497 // was set, then that means that we are resuming serializing 498 // this cycle. Tell the previous stages to block. 499 if (resumeSerialize) { 500 resumeSerialize = false; 501 block(tid); 502 toDecode->renameUnblock[tid] = false; 503 } 504 } else if (renameStatus[tid] == Unblocking) { 505 if (resumeUnblocking) { 506 block(tid); 507 resumeUnblocking = false; 508 toDecode->renameUnblock[tid] = false; 509 } |
510 } 511 512 if (renameStatus[tid] == Running || 513 renameStatus[tid] == Idle) { 514 DPRINTF(Rename, "[tid:%u]: Not blocked, so attempting to run " 515 "stage.\n", tid); 516 517 renameInsts(tid); --- 249 unchanged lines hidden (view full) --- 767 "skidBuffer\n", tid, inst->seqNum, inst->readPC()); 768 769 ++renameSkidInsts; 770 771 skidBuffer[tid].push_back(inst); 772 } 773 774 if (skidBuffer[tid].size() > skidBufferMax) |
775 { 776 typename InstQueue::iterator it; 777 warn("Skidbuffer contents:\n"); 778 for(it = skidBuffer[tid].begin(); it != skidBuffer[tid].end(); it++) 779 { 780 warn("[tid:%u]: %s [sn:%i].\n", tid, 781 (*it)->staticInst->disassemble(inst->readPC()), 782 (*it)->seqNum); 783 } |
784 panic("Skidbuffer Exceeded Max Size"); |
785 } |
786} 787 788template <class Impl> 789void 790DefaultRename<Impl>::sortInsts() 791{ 792 int insts_from_decode = fromDecode->size; 793#ifdef DEBUG --- 72 unchanged lines hidden (view full) --- 866 867 // Add the current inputs onto the skid buffer, so they can be 868 // reprocessed when this stage unblocks. 869 skidInsert(tid); 870 871 // Only signal backwards to block if the previous stages do not think 872 // rename is already blocked. 873 if (renameStatus[tid] != Blocked) { |
874 // If resumeUnblocking is set, we unblocked during the squash, 875 // but now we're have unblocking status. We need to tell earlier 876 // stages to block. 877 if (resumeUnblocking || renameStatus[tid] != Unblocking) { |
878 toDecode->renameBlock[tid] = true; 879 toDecode->renameUnblock[tid] = false; 880 wroteToTimeBuffer = true; 881 } 882 883 // Rename can not go from SerializeStall to Blocked, otherwise 884 // it would not know to complete the serialize stall. 885 if (renameStatus[tid] != SerializeStall) { --- 116 unchanged lines hidden (view full) --- 1002 1003 unsigned num_src_regs = inst->numSrcRegs(); 1004 1005 // Get the architectual register numbers from the source and 1006 // destination operands, and redirect them to the right register. 1007 // Will need to mark dependencies though. 1008 for (int src_idx = 0; src_idx < num_src_regs; src_idx++) { 1009 RegIndex src_reg = inst->srcRegIdx(src_idx); |
1010 RegIndex flat_src_reg = src_reg; 1011 if (src_reg < TheISA::FP_Base_DepTag) { 1012 flat_src_reg = TheISA::flattenIntIndex(inst->tcBase(), src_reg); 1013 DPRINTF(Rename, "Flattening index %d to %d.\n", (int)src_reg, (int)flat_src_reg); 1014 } 1015 inst->flattenSrcReg(src_idx, flat_src_reg); |
1016 1017 // Look up the source registers to get the phys. register they've 1018 // been renamed to, and set the sources to those registers. |
1019 PhysRegIndex renamed_reg = renameMap[tid]->lookup(flat_src_reg); |
1020 1021 DPRINTF(Rename, "[tid:%u]: Looking up arch reg %i, got " |
1022 "physical reg %i.\n", tid, (int)flat_src_reg, |
1023 (int)renamed_reg); 1024 1025 inst->renameSrcReg(src_idx, renamed_reg); 1026 1027 // See if the register is ready or not. 1028 if (scoreboard->getReg(renamed_reg) == true) { 1029 DPRINTF(Rename, "[tid:%u]: Register is ready.\n", tid); 1030 --- 10 unchanged lines hidden (view full) --- 1041{ 1042 typename RenameMap::RenameInfo rename_result; 1043 1044 unsigned num_dest_regs = inst->numDestRegs(); 1045 1046 // Rename the destination registers. 1047 for (int dest_idx = 0; dest_idx < num_dest_regs; dest_idx++) { 1048 RegIndex dest_reg = inst->destRegIdx(dest_idx); |
1049 RegIndex flat_dest_reg = dest_reg; 1050 if (dest_reg < TheISA::FP_Base_DepTag) { 1051 flat_dest_reg = TheISA::flattenIntIndex(inst->tcBase(), dest_reg); 1052 DPRINTF(Rename, "Flattening index %d to %d.\n", (int)dest_reg, (int)flat_dest_reg); 1053 } |
1054 |
1055 inst->flattenDestReg(dest_idx, flat_dest_reg); 1056 |
1057 // Get the physical register that the destination will be 1058 // renamed to. |
1059 rename_result = renameMap[tid]->rename(flat_dest_reg); |
1060 1061 //Mark Scoreboard entry as not ready 1062 scoreboard->unsetReg(rename_result.first); 1063 1064 DPRINTF(Rename, "[tid:%u]: Renaming arch reg %i to physical " |
1065 "reg %i.\n", tid, (int)flat_dest_reg, |
1066 (int)rename_result.first); 1067 1068 // Record the rename information so that a history can be kept. |
1069 RenameHistory hb_entry(inst->seqNum, flat_dest_reg, |
1070 rename_result.first, 1071 rename_result.second); 1072 1073 historyBuffer[tid].push_front(hb_entry); 1074 1075 DPRINTF(Rename, "[tid:%u]: Adding instruction to history buffer " 1076 "(size=%i), [sn:%lli].\n",tid, 1077 historyBuffer[tid].size(), --- 207 unchanged lines hidden (view full) --- 1285 unblock(tid); 1286 1287 return true; 1288 } 1289 1290 if (renameStatus[tid] == Squashing) { 1291 // Switch status to running if rename isn't being told to block or 1292 // squash this cycle. |
1293 if (resumeSerialize) { 1294 DPRINTF(Rename, "[tid:%u]: Done squashing, switching to serialize.\n", 1295 tid); |
1296 |
1297 renameStatus[tid] = SerializeStall; 1298 return true; 1299 } else if (resumeUnblocking) { 1300 DPRINTF(Rename, "[tid:%u]: Done squashing, switching to unblocking.\n", 1301 tid); 1302 renameStatus[tid] = Unblocking; 1303 return true; 1304 } else { 1305 DPRINTF(Rename, "[tid:%u]: Done squashing, switching to running.\n", 1306 tid); |
1307 |
1308 renameStatus[tid] = Running; 1309 return false; 1310 } |
1311 } 1312 1313 if (renameStatus[tid] == SerializeStall) { 1314 // Stall ends once the ROB is free. 1315 DPRINTF(Rename, "[tid:%u]: Done with serialize stall, switching to " 1316 "unblocking.\n", tid); 1317 1318 DynInstPtr serial_inst = serializeInst[tid]; --- 85 unchanged lines hidden --- |