1/*************************************************************************************** 2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3* Copyright (c) 2020-2021 Peng Cheng Laboratory 4* 5* XiangShan is licensed under Mulan PSL v2. 6* You can use this software according to the terms and conditions of the Mulan PSL v2. 7* You may obtain a copy of Mulan PSL v2 at: 8* http://license.coscl.org.cn/MulanPSL2 9* 10* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13* 14* See the Mulan PSL v2 for more details. 15***************************************************************************************/ 16 17package xiangshan.backend.rename 18 19import chipsalliance.rocketchip.config.Parameters 20import chisel3._ 21import chisel3.util._ 22import xiangshan._ 23import utils._ 24import xiangshan.backend.roq.RoqPtr 25import xiangshan.backend.dispatch.PreDispatchInfo 26 27class RenameBypassInfo(implicit p: Parameters) extends XSBundle { 28 val lsrc1_bypass = MixedVec(List.tabulate(RenameWidth-1)(i => UInt((i+1).W))) 29 val lsrc2_bypass = MixedVec(List.tabulate(RenameWidth-1)(i => UInt((i+1).W))) 30 val lsrc3_bypass = MixedVec(List.tabulate(RenameWidth-1)(i => UInt((i+1).W))) 31 val ldest_bypass = MixedVec(List.tabulate(RenameWidth-1)(i => UInt((i+1).W))) 32} 33 34class Rename(implicit p: Parameters) extends XSModule { 35 val io = IO(new Bundle() { 36 val redirect = Flipped(ValidIO(new Redirect)) 37 val flush = Input(Bool()) 38 val roqCommits = Flipped(new RoqCommitIO) 39 // from decode buffer 40 val in = Vec(RenameWidth, Flipped(DecoupledIO(new CfCtrl))) 41 // to dispatch1 42 val out = Vec(RenameWidth, DecoupledIO(new MicroOp)) 43 val renameBypass = Output(new RenameBypassInfo) 44 val dispatchInfo = Output(new PreDispatchInfo) 45 // for debug printing 46 val debug_int_rat = Vec(32, Output(UInt(PhyRegIdxWidth.W))) 47 val debug_fp_rat = Vec(32, Output(UInt(PhyRegIdxWidth.W))) 48 }) 49 50 // create free list and rat 51 val intFreeList = Module(if (EnableIntMoveElim) new freelist.MEFreeList else new freelist.StdFreeList) 52 val fpFreeList = Module(new freelist.StdFreeList) 53 54 val intRat = Module(new RenameTable(float = false)) 55 val fpRat = Module(new RenameTable(float = true)) 56 57 // connect flush and redirect ports for rat 58 Seq(intRat, fpRat) foreach { case rat => 59 rat.io.redirect := io.redirect.valid 60 rat.io.flush := io.flush 61 rat.io.walkWen := io.roqCommits.isWalk 62 } 63 64 // decide if given instruction needs allocating a new physical register (CfCtrl: from decode; RoqCommitInfo: from roq) 65 def needDestReg[T <: CfCtrl](fp: Boolean, x: T): Bool = { 66 {if(fp) x.ctrl.fpWen else x.ctrl.rfWen && (x.ctrl.ldest =/= 0.U)} 67 } 68 def needDestRegCommit[T <: RoqCommitInfo](fp: Boolean, x: T): Bool = { 69 {if(fp) x.fpWen else x.rfWen && (x.ldest =/= 0.U)} 70 } 71 72 // connect [flush + redirect + walk] ports for __float point__ & __integer__ free list 73 Seq((fpFreeList, true), (intFreeList, false)).foreach{ case (fl, isFp) => 74 fl.flush := io.flush 75 fl.redirect := io.redirect.valid 76 fl.walk := io.roqCommits.isWalk 77 // when isWalk, use stepBack to restore head pointer of free list 78 // (if ME enabled, stepBack of intFreeList should be useless thus optimized out) 79 fl.stepBack := PopCount(io.roqCommits.valid.zip(io.roqCommits.info).map{case (v, i) => v && needDestRegCommit(isFp, i)}) 80 } 81 // walk has higher priority than allocation and thus we don't use isWalk here 82 // only when both fp and int free list and dispatch1 has enough space can we do allocation 83 intFreeList.doAllocate := fpFreeList.canAllocate && io.out(0).ready 84 fpFreeList.doAllocate := intFreeList.canAllocate && io.out(0).ready 85 86 // dispatch1 ready ++ float point free list ready ++ int free list ready ++ not walk 87 val canOut = io.out(0).ready && fpFreeList.canAllocate && intFreeList.canAllocate && !io.roqCommits.isWalk 88 89 90 // speculatively assign the instruction with an roqIdx 91 val validCount = PopCount(io.in.map(_.valid)) // number of instructions waiting to enter roq (from decode) 92 val roqIdxHead = RegInit(0.U.asTypeOf(new RoqPtr)) 93 val lastCycleMisprediction = RegNext(io.redirect.valid && !io.redirect.bits.flushItself()) 94 val roqIdxHeadNext = Mux(io.flush, 0.U.asTypeOf(new RoqPtr), // flush: clear roq 95 Mux(io.redirect.valid, io.redirect.bits.roqIdx, // redirect: move ptr to given roq index (flush itself) 96 Mux(lastCycleMisprediction, roqIdxHead + 1.U, // mis-predict: not flush roqIdx itself 97 Mux(canOut, roqIdxHead + validCount, // instructions successfully entered next stage: increase roqIdx 98 /* default */ roqIdxHead)))) // no instructions passed by this cycle: stick to old value 99 roqIdxHead := roqIdxHeadNext 100 101 102 /** 103 * Rename: allocate free physical register and update rename table 104 */ 105 val uops = Wire(Vec(RenameWidth, new MicroOp)) 106 uops.foreach( uop => { 107 uop.srcState(0) := DontCare 108 uop.srcState(1) := DontCare 109 uop.srcState(2) := DontCare 110 uop.roqIdx := DontCare 111 uop.diffTestDebugLrScValid := DontCare 112 uop.debugInfo := DontCare 113 uop.lqIdx := DontCare 114 uop.sqIdx := DontCare 115 }) 116 117 val needFpDest = Wire(Vec(RenameWidth, Bool())) 118 val needIntDest = Wire(Vec(RenameWidth, Bool())) 119 val hasValid = Cat(io.in.map(_.valid)).orR 120 121 val isMove = io.in.map(_.bits.ctrl.isMove) 122 val isMax = if (EnableIntMoveElim) Some(intFreeList.asInstanceOf[freelist.MEFreeList].maxVec) else None 123 val meEnable = WireInit(VecInit(Seq.fill(RenameWidth)(false.B))) 124 val psrc_cmp = Wire(MixedVec(List.tabulate(RenameWidth-1)(i => UInt((i+1).W)))) 125 126 val intSpecWen = Wire(Vec(RenameWidth, Bool())) 127 val fpSpecWen = Wire(Vec(RenameWidth, Bool())) 128 129 // uop calculation 130 for (i <- 0 until RenameWidth) { 131 uops(i).cf := io.in(i).bits.cf 132 uops(i).ctrl := io.in(i).bits.ctrl 133 134 val inValid = io.in(i).valid 135 136 // alloc a new phy reg 137 needFpDest(i) := inValid && needDestReg(fp = true, io.in(i).bits) 138 needIntDest(i) := inValid && needDestReg(fp = false, io.in(i).bits) 139 fpFreeList.allocateReq(i) := needFpDest(i) 140 intFreeList.allocateReq(i) := needIntDest(i) 141 142 // no valid instruction from decode stage || all resources (dispatch1 + both free lists) ready 143 io.in(i).ready := !hasValid || canOut 144 145 // do checkpoints when a branch inst come 146 // for(fl <- Seq(fpFreeList, intFreeList)){ 147 // fl.cpReqs(i).valid := inValid 148 // fl.cpReqs(i).bits := io.in(i).bits.brTag 149 // } 150 151 152 uops(i).roqIdx := roqIdxHead + PopCount(io.in.take(i).map(_.valid)) 153 154 io.out(i).valid := io.in(i).valid && intFreeList.canAllocate && fpFreeList.canAllocate && !io.roqCommits.isWalk 155 io.out(i).bits := uops(i) 156 157 158 // read rename table 159 def readRat(lsrcList: List[UInt], ldest: UInt, fp: Boolean) = { 160 val rat = if(fp) fpRat else intRat 161 val srcCnt = lsrcList.size 162 val psrcVec = Wire(Vec(srcCnt, UInt(PhyRegIdxWidth.W))) 163 val old_pdest = Wire(UInt(PhyRegIdxWidth.W)) 164 for(k <- 0 until srcCnt+1){ 165 val rportIdx = i * (srcCnt+1) + k 166 if(k != srcCnt){ 167 rat.io.readPorts(rportIdx).addr := lsrcList(k) 168 psrcVec(k) := rat.io.readPorts(rportIdx).rdata 169 } else { 170 rat.io.readPorts(rportIdx).addr := ldest 171 old_pdest := rat.io.readPorts(rportIdx).rdata 172 } 173 } 174 (psrcVec, old_pdest) 175 } 176 val lsrcList = List(uops(i).ctrl.lsrc(0), uops(i).ctrl.lsrc(1), uops(i).ctrl.lsrc(2)) 177 val ldest = uops(i).ctrl.ldest 178 val (intPhySrcVec, intOldPdest) = readRat(lsrcList.take(2), ldest, fp = false) 179 val (fpPhySrcVec, fpOldPdest) = readRat(lsrcList, ldest, fp = true) 180 uops(i).psrc(0) := Mux(uops(i).ctrl.srcType(0) === SrcType.reg, intPhySrcVec(0), fpPhySrcVec(0)) 181 uops(i).psrc(1) := Mux(uops(i).ctrl.srcType(1) === SrcType.reg, intPhySrcVec(1), fpPhySrcVec(1)) 182 uops(i).psrc(2) := fpPhySrcVec(2) 183 uops(i).old_pdest := Mux(uops(i).ctrl.rfWen, intOldPdest, fpOldPdest) 184 185 if (EnableIntMoveElim) { 186 187 if (i == 0) { 188 // calculate meEnable 189 meEnable(i) := isMove(i) && (!isMax.get(uops(i).psrc(0)) || uops(i).ctrl.lsrc(0) === 0.U) 190 } else { 191 // compare psrc0 192 psrc_cmp(i-1) := Cat((0 until i).map(j => { 193 uops(i).psrc(0) === uops(j).psrc(0) && io.in(i).bits.ctrl.isMove && io.in(j).bits.ctrl.isMove 194 }) /* reverse is not necessary here */) 195 196 // calculate meEnable 197 meEnable(i) := isMove(i) && (!(io.renameBypass.lsrc1_bypass(i-1).orR | psrc_cmp(i-1).orR | isMax.get(uops(i).psrc(0))) || uops(i).ctrl.lsrc(0) === 0.U) 198 } 199 uops(i).eliminatedMove := meEnable(i) || (uops(i).ctrl.isMove && uops(i).ctrl.ldest === 0.U) 200 201 // send psrc of eliminated move instructions to free list and label them as eliminated 202 when (meEnable(i)) { 203 intFreeList.asInstanceOf[freelist.MEFreeList].psrcOfMove(i).valid := true.B 204 intFreeList.asInstanceOf[freelist.MEFreeList].psrcOfMove(i).bits := uops(i).psrc(0) 205 XSInfo(io.in(i).valid && io.out(i).valid, p"Move instruction ${Hexadecimal(io.in(i).bits.cf.pc)} eliminated successfully! psrc:${uops(i).psrc(0)}\n") 206 } .otherwise { 207 intFreeList.asInstanceOf[freelist.MEFreeList].psrcOfMove(i).valid := false.B 208 intFreeList.asInstanceOf[freelist.MEFreeList].psrcOfMove(i).bits := DontCare 209 XSInfo(io.in(i).valid && io.out(i).valid && isMove(i), p"Move instruction ${Hexadecimal(io.in(i).bits.cf.pc)} failed to be eliminated! psrc:${uops(i).psrc(0)}\n") 210 } 211 212 // update pdest 213 uops(i).pdest := Mux(meEnable(i), uops(i).psrc(0), // move eliminated 214 Mux(needIntDest(i), intFreeList.allocatePhyReg(i), // normal int inst 215 Mux(uops(i).ctrl.ldest===0.U && uops(i).ctrl.rfWen, 0.U // int inst with dst=r0 216 /* default */, fpFreeList.allocatePhyReg(i)))) // normal fp inst 217 } else { 218 uops(i).eliminatedMove := DontCare 219 psrc_cmp.foreach(_ := DontCare) 220 // update pdest 221 uops(i).pdest := Mux(needIntDest(i), intFreeList.allocatePhyReg(i), // normal int inst 222 Mux(uops(i).ctrl.ldest===0.U && uops(i).ctrl.rfWen, 0.U // int inst with dst=r0 223 /* default */, fpFreeList.allocatePhyReg(i))) // normal fp inst 224 } 225 226 // write speculative rename table 227 // we update rat later inside commit code 228 intSpecWen(i) := intFreeList.allocateReq(i) && intFreeList.canAllocate && intFreeList.doAllocate && !io.roqCommits.isWalk 229 fpSpecWen(i) := fpFreeList.allocateReq(i) && fpFreeList.canAllocate && fpFreeList.doAllocate && !io.roqCommits.isWalk 230 } 231 232 // We don't bypass the old_pdest from valid instructions with the same ldest currently in rename stage. 233 // Instead, we determine whether there're some dependencies between the valid instructions. 234 for (i <- 1 until RenameWidth) { 235 io.renameBypass.lsrc1_bypass(i-1) := Cat((0 until i).map(j => { 236 val fpMatch = needFpDest(j) && io.in(i).bits.ctrl.srcType(0) === SrcType.fp 237 val intMatch = needIntDest(j) && io.in(i).bits.ctrl.srcType(0) === SrcType.reg 238 (fpMatch || intMatch) && io.in(j).bits.ctrl.ldest === io.in(i).bits.ctrl.lsrc(0) 239 }).reverse) 240 io.renameBypass.lsrc2_bypass(i-1) := Cat((0 until i).map(j => { 241 val fpMatch = needFpDest(j) && io.in(i).bits.ctrl.srcType(1) === SrcType.fp 242 val intMatch = needIntDest(j) && io.in(i).bits.ctrl.srcType(1) === SrcType.reg 243 (fpMatch || intMatch) && io.in(j).bits.ctrl.ldest === io.in(i).bits.ctrl.lsrc(1) 244 }).reverse) 245 io.renameBypass.lsrc3_bypass(i-1) := Cat((0 until i).map(j => { 246 val fpMatch = needFpDest(j) && io.in(i).bits.ctrl.srcType(2) === SrcType.fp 247 val intMatch = needIntDest(j) && io.in(i).bits.ctrl.srcType(2) === SrcType.reg 248 (fpMatch || intMatch) && io.in(j).bits.ctrl.ldest === io.in(i).bits.ctrl.lsrc(2) 249 }).reverse) 250 io.renameBypass.ldest_bypass(i-1) := Cat((0 until i).map(j => { 251 val fpMatch = needFpDest(j) && needFpDest(i) 252 val intMatch = needIntDest(j) && needIntDest(i) 253 (fpMatch || intMatch) && io.in(j).bits.ctrl.ldest === io.in(i).bits.ctrl.ldest 254 }).reverse) 255 } 256 257 // calculate lsq space requirement 258 val isLs = VecInit(uops.map(uop => FuType.isLoadStore(uop.ctrl.fuType))) 259 val isStore = VecInit(uops.map(uop => FuType.isStoreExu(uop.ctrl.fuType))) 260 val isAMO = VecInit(uops.map(uop => FuType.isAMO(uop.ctrl.fuType))) 261 io.dispatchInfo.lsqNeedAlloc := VecInit((0 until RenameWidth).map(i => 262 Mux(isLs(i), Mux(isStore(i) && !isAMO(i), 2.U, 1.U), 0.U))) 263 264 /** 265 * Instructions commit: update freelist and rename table 266 */ 267 for (i <- 0 until CommitWidth) { 268 269 Seq((intRat, false), (fpRat, true)) foreach { case (rat, fp) => 270 // is valid commit req and given instruction has destination register 271 val commitDestValid = io.roqCommits.valid(i) && needDestRegCommit(fp, io.roqCommits.info(i)) 272 XSDebug(p"isFp[${fp}]index[$i]-commitDestValid:$commitDestValid,isWalk:${io.roqCommits.isWalk}\n") 273 274 /* 275 I. RAT Update 276 */ 277 278 // walk back write - restore spec state : ldest => old_pdest 279 if (fp && i < RenameWidth) { 280 rat.io.specWritePorts(i).wen := (commitDestValid && io.roqCommits.isWalk) || fpSpecWen(i) 281 rat.io.specWritePorts(i).addr := Mux(fpSpecWen(i), uops(i).ctrl.ldest, io.roqCommits.info(i).ldest) 282 rat.io.specWritePorts(i).wdata := Mux(fpSpecWen(i), fpFreeList.allocatePhyReg(i), io.roqCommits.info(i).old_pdest) 283 } else if (!fp && i < RenameWidth) { 284 rat.io.specWritePorts(i).wen := (commitDestValid && io.roqCommits.isWalk) || intSpecWen(i) 285 rat.io.specWritePorts(i).addr := Mux(intSpecWen(i), uops(i).ctrl.ldest, io.roqCommits.info(i).ldest) 286 if (EnableIntMoveElim) { 287 rat.io.specWritePorts(i).wdata := 288 Mux(intSpecWen(i), Mux(meEnable(i), uops(i).psrc(0), intFreeList.allocatePhyReg(i)), io.roqCommits.info(i).old_pdest) 289 } else { 290 rat.io.specWritePorts(i).wdata := 291 Mux(intSpecWen(i), intFreeList.allocatePhyReg(i), io.roqCommits.info(i).old_pdest) 292 } 293 // when i >= RenameWidth, this write must happens during WALK process 294 } else if (i >= RenameWidth) { 295 rat.io.specWritePorts(i).wen := commitDestValid && io.roqCommits.isWalk 296 rat.io.specWritePorts(i).addr := io.roqCommits.info(i).ldest 297 rat.io.specWritePorts(i).wdata := io.roqCommits.info(i).old_pdest 298 } 299 300 when (commitDestValid && io.roqCommits.isWalk) { 301 XSInfo({if(fp) p"[fp" else p"[int"} + p" walk] " + 302 p"ldest:${rat.io.specWritePorts(i).addr} -> old_pdest:${rat.io.specWritePorts(i).wdata}\n") 303 } 304 305 // normal write - update arch state (serve as initialization) 306 rat.io.archWritePorts(i).wen := commitDestValid && !io.roqCommits.isWalk 307 rat.io.archWritePorts(i).addr := io.roqCommits.info(i).ldest 308 rat.io.archWritePorts(i).wdata := io.roqCommits.info(i).pdest 309 310 XSInfo(rat.io.archWritePorts(i).wen, 311 {if(fp) p"[fp" else p"[int"} + p" arch rat update] ldest:${rat.io.archWritePorts(i).addr} ->" + 312 p" pdest:${rat.io.archWritePorts(i).wdata}\n" 313 ) 314 315 316 /* 317 II. Free List Update 318 */ 319 320 if (fp) { // Float Point free list 321 fpFreeList.freeReq(i) := commitDestValid && !io.roqCommits.isWalk 322 fpFreeList.freePhyReg(i) := io.roqCommits.info(i).old_pdest 323 } else if (EnableIntMoveElim) { // Integer free list 324 325 // during walk process: 326 // 1. for normal inst, free pdest + revert rat from ldest->pdest to ldest->old_pdest 327 // 2. for ME inst, free pdest(commit counter++) + revert rat 328 329 // conclusion: 330 // a. rat recovery has nothing to do with ME or not 331 // b. treat walk as normal commit except replace old_pdests with pdests and set io.walk to true 332 // c. ignore pdests port when walking 333 334 intFreeList.freeReq(i) := commitDestValid // walk or not walk 335 intFreeList.freePhyReg(i) := Mux(io.roqCommits.isWalk, io.roqCommits.info(i).pdest, io.roqCommits.info(i).old_pdest) 336 intFreeList.asInstanceOf[freelist.MEFreeList].eliminatedMove(i) := io.roqCommits.info(i).eliminatedMove 337 intFreeList.asInstanceOf[freelist.MEFreeList].multiRefPhyReg(i) := io.roqCommits.info(i).pdest 338 } else { 339 intFreeList.freeReq(i) := commitDestValid && !io.roqCommits.isWalk 340 intFreeList.freePhyReg(i) := io.roqCommits.info(i).old_pdest 341 } 342 } 343 } 344 345 346 /* 347 Debug and performance counter 348 */ 349 350 def printRenameInfo(in: DecoupledIO[CfCtrl], out: DecoupledIO[MicroOp]) = { 351 XSInfo( 352 in.valid && in.ready, 353 p"pc:${Hexadecimal(in.bits.cf.pc)} in v:${in.valid} in rdy:${in.ready} " + 354 p"lsrc(0):${in.bits.ctrl.lsrc(0)} -> psrc(0):${out.bits.psrc(0)} " + 355 p"lsrc(1):${in.bits.ctrl.lsrc(1)} -> psrc(1):${out.bits.psrc(1)} " + 356 p"lsrc(2):${in.bits.ctrl.lsrc(2)} -> psrc(2):${out.bits.psrc(2)} " + 357 p"ldest:${in.bits.ctrl.ldest} -> pdest:${out.bits.pdest} " + 358 p"old_pdest:${out.bits.old_pdest} " + 359 p"out v:${out.valid} r:${out.ready}\n" 360 ) 361 } 362 363 for((x,y) <- io.in.zip(io.out)){ 364 printRenameInfo(x, y) 365 } 366 367 XSDebug(io.roqCommits.isWalk, p"Walk Recovery Enabled\n") 368 XSDebug(io.roqCommits.isWalk, p"validVec:${Binary(io.roqCommits.valid.asUInt)}\n") 369 for (i <- 0 until CommitWidth) { 370 val info = io.roqCommits.info(i) 371 XSDebug(io.roqCommits.isWalk && io.roqCommits.valid(i), p"[#$i walk info] pc:${Hexadecimal(info.pc)} " + 372 p"ldest:${info.ldest} rfWen:${info.rfWen} fpWen:${info.fpWen} " + { if (EnableIntMoveElim) p"eliminatedMove:${info.eliminatedMove} " else p"" } + 373 p"pdest:${info.pdest} old_pdest:${info.old_pdest}\n") 374 } 375 376 XSDebug(p"inValidVec: ${Binary(Cat(io.in.map(_.valid)))}\n") 377 XSInfo(!canOut, p"stall at rename, hasValid:${hasValid}, fpCanAlloc:${fpFreeList.canAllocate}, intCanAlloc:${intFreeList.canAllocate} dispatch1ready:${io.out(0).ready}, isWalk:${io.roqCommits.isWalk}\n") 378 379 intRat.io.debug_rdata <> io.debug_int_rat 380 fpRat.io.debug_rdata <> io.debug_fp_rat 381 382 XSDebug(p"Arch Int RAT:" + io.debug_int_rat.zipWithIndex.map{ case (r, i) => p"#$i:$r " }.reduceLeft(_ + _) + p"\n") 383 384 XSPerfAccumulate("in", Mux(RegNext(io.in(0).ready), PopCount(io.in.map(_.valid)), 0.U)) 385 XSPerfAccumulate("utilization", PopCount(io.in.map(_.valid))) 386 XSPerfAccumulate("waitInstr", PopCount((0 until RenameWidth).map(i => io.in(i).valid && !io.in(i).ready))) 387 XSPerfAccumulate("stall_cycle_dispatch", hasValid && !io.out(0).ready && fpFreeList.canAllocate && intFreeList.canAllocate && !io.roqCommits.isWalk) 388 XSPerfAccumulate("stall_cycle_fp", hasValid && io.out(0).ready && !fpFreeList.canAllocate && intFreeList.canAllocate && !io.roqCommits.isWalk) 389 XSPerfAccumulate("stall_cycle_int", hasValid && io.out(0).ready && fpFreeList.canAllocate && !intFreeList.canAllocate && !io.roqCommits.isWalk) 390 XSPerfAccumulate("stall_cycle_walk", hasValid && io.out(0).ready && fpFreeList.canAllocate && intFreeList.canAllocate && io.roqCommits.isWalk) 391 if (!env.FPGAPlatform) { 392 ExcitingUtils.addSource(io.roqCommits.isWalk, "TMA_backendiswalk") 393 } 394 395 if (EnableIntMoveElim) { 396 XSPerfAccumulate("move_instr_count", PopCount(Seq.tabulate(RenameWidth)(i => io.out(i).fire() && io.in(i).bits.ctrl.isMove))) 397 XSPerfAccumulate("move_elim_enabled", PopCount(Seq.tabulate(RenameWidth)(i => io.out(i).fire() && meEnable(i)))) 398 XSPerfAccumulate("move_elim_cancelled", PopCount(Seq.tabulate(RenameWidth)(i => io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i)))) 399 XSPerfAccumulate("move_elim_cancelled_psrc_bypass", PopCount(Seq.tabulate(RenameWidth)(i => io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i) && { if (i == 0) false.B else io.renameBypass.lsrc1_bypass(i-1).orR }))) 400 XSPerfAccumulate("move_elim_cancelled_cnt_limit", PopCount(Seq.tabulate(RenameWidth)(i => io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i) && isMax.get(io.out(i).bits.psrc(0))))) 401 XSPerfAccumulate("move_elim_cancelled_inc_more_than_one", PopCount(Seq.tabulate(RenameWidth)(i => io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i) && { if (i == 0) false.B else psrc_cmp(i-1).orR }))) 402 403 // to make sure meEnable functions as expected 404 for (i <- 0 until RenameWidth) { 405 XSDebug(io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i) && isMax.get(io.out(i).bits.psrc(0)), 406 p"ME_CANCELLED: ref counter hits max value (pc:0x${Hexadecimal(io.in(i).bits.cf.pc)})\n") 407 XSDebug(io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i) && { if (i == 0) false.B else io.renameBypass.lsrc1_bypass(i-1).orR }, 408 p"ME_CANCELLED: RAW dependency (pc:0x${Hexadecimal(io.in(i).bits.cf.pc)})\n") 409 XSDebug(io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i) && { if (i == 0) false.B else psrc_cmp(i-1).orR }, 410 p"ME_CANCELLED: psrc duplicates with former instruction (pc:0x${Hexadecimal(io.in(i).bits.cf.pc)})\n") 411 } 412 XSDebug(VecInit(Seq.tabulate(RenameWidth)(i => io.out(i).fire() && io.in(i).bits.ctrl.isMove && !meEnable(i))).asUInt().orR, 413 p"ME_CANCELLED: pc group [ " + (0 until RenameWidth).map(i => p"fire:${io.out(i).fire()},pc:0x${Hexadecimal(io.in(i).bits.cf.pc)} ").reduceLeft(_ + _) + p"]\n") 414 XSInfo(meEnable.asUInt().orR(), p"meEnableVec:${Binary(meEnable.asUInt)}\n") 415 } 416} 417