rename_map.cc revision 12106
11689SN/A/* 21689SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan 39919Ssteve.reinhardt@amd.com * Copyright (c) 2013 Advanced Micro Devices, Inc. 41689SN/A * All rights reserved. 51689SN/A * 61689SN/A * Redistribution and use in source and binary forms, with or without 71689SN/A * modification, are permitted provided that the following conditions are 81689SN/A * met: redistributions of source code must retain the above copyright 91689SN/A * notice, this list of conditions and the following disclaimer; 101689SN/A * redistributions in binary form must reproduce the above copyright 111689SN/A * notice, this list of conditions and the following disclaimer in the 121689SN/A * documentation and/or other materials provided with the distribution; 131689SN/A * neither the name of the copyright holders nor the names of its 141689SN/A * contributors may be used to endorse or promote products derived from 151689SN/A * this software without specific prior written permission. 161689SN/A * 171689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 181689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 191689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 201689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 211689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 221689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 231689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 241689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 251689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 261689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 271689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu * 292665Ssaidi@eecs.umich.edu * Authors: Kevin Lim 301689SN/A */ 311464SN/A 3211793Sbrandon.potter@amd.com#include "cpu/o3/rename_map.hh" 3311793Sbrandon.potter@amd.com 341464SN/A#include <vector> 351060SN/A 3612106SRekai.GonzalezAlberquilla@arm.com#include "cpu/reg_class_impl.hh" 378232Snate@binkert.org#include "debug/Rename.hh" 381060SN/A 391464SN/Ausing namespace std; 401464SN/A 419919Ssteve.reinhardt@amd.com/**** SimpleRenameMap methods ****/ 421060SN/A 439919Ssteve.reinhardt@amd.comSimpleRenameMap::SimpleRenameMap() 4412106SRekai.GonzalezAlberquilla@arm.com : freeList(NULL), zeroReg(IntRegClass,0) 451060SN/A{ 462292SN/A} 472292SN/A 481061SN/A 491060SN/Avoid 509919Ssteve.reinhardt@amd.comSimpleRenameMap::init(unsigned size, SimpleFreeList *_freeList, 519919Ssteve.reinhardt@amd.com RegIndex _zeroReg) 521060SN/A{ 539919Ssteve.reinhardt@amd.com assert(freeList == NULL); 549919Ssteve.reinhardt@amd.com assert(map.empty()); 559919Ssteve.reinhardt@amd.com 569919Ssteve.reinhardt@amd.com map.resize(size); 579919Ssteve.reinhardt@amd.com freeList = _freeList; 5812106SRekai.GonzalezAlberquilla@arm.com zeroReg = RegId(IntRegClass, _zeroReg); 591060SN/A} 601060SN/A 611060SN/ASimpleRenameMap::RenameInfo 6212106SRekai.GonzalezAlberquilla@arm.comSimpleRenameMap::rename(const RegId& arch_reg) 631060SN/A{ 6412105Snathanael.premillieu@arm.com PhysRegIdPtr renamed_reg; 659919Ssteve.reinhardt@amd.com // Record the current physical register that is renamed to the 669919Ssteve.reinhardt@amd.com // requested architected register. 6712106SRekai.GonzalezAlberquilla@arm.com PhysRegIdPtr prev_reg = map[arch_reg.index()]; 681060SN/A 699919Ssteve.reinhardt@amd.com // If it's not referencing the zero register, then rename the 709919Ssteve.reinhardt@amd.com // register. 719919Ssteve.reinhardt@amd.com if (arch_reg != zeroReg) { 729919Ssteve.reinhardt@amd.com renamed_reg = freeList->getReg(); 731060SN/A 7412106SRekai.GonzalezAlberquilla@arm.com map[arch_reg.index()] = renamed_reg; 751060SN/A } else { 769919Ssteve.reinhardt@amd.com // Otherwise return the zero register so nothing bad happens. 7712105Snathanael.premillieu@arm.com assert(prev_reg->isZeroReg()); 7812105Snathanael.premillieu@arm.com renamed_reg = prev_reg; 791060SN/A } 801060SN/A 8112105Snathanael.premillieu@arm.com DPRINTF(Rename, "Renamed reg %d to physical reg %d (%d) old mapping was" 8212105Snathanael.premillieu@arm.com " %d (%d)\n", 8312106SRekai.GonzalezAlberquilla@arm.com arch_reg, renamed_reg->index(), renamed_reg->flatIndex(), 8412106SRekai.GonzalezAlberquilla@arm.com prev_reg->index(), prev_reg->flatIndex()); 853867Sbinkertn@umich.edu 861060SN/A return RenameInfo(renamed_reg, prev_reg); 871060SN/A} 881060SN/A 899919Ssteve.reinhardt@amd.com 909919Ssteve.reinhardt@amd.com/**** UnifiedRenameMap methods ****/ 919919Ssteve.reinhardt@amd.com 929919Ssteve.reinhardt@amd.comvoid 939919Ssteve.reinhardt@amd.comUnifiedRenameMap::init(PhysRegFile *_regFile, 949919Ssteve.reinhardt@amd.com RegIndex _intZeroReg, 959919Ssteve.reinhardt@amd.com RegIndex _floatZeroReg, 969919Ssteve.reinhardt@amd.com UnifiedFreeList *freeList) 979919Ssteve.reinhardt@amd.com{ 989919Ssteve.reinhardt@amd.com regFile = _regFile; 999919Ssteve.reinhardt@amd.com 1009919Ssteve.reinhardt@amd.com intMap.init(TheISA::NumIntRegs, &(freeList->intList), _intZeroReg); 1019919Ssteve.reinhardt@amd.com 1029919Ssteve.reinhardt@amd.com floatMap.init(TheISA::NumFloatRegs, &(freeList->floatList), _floatZeroReg); 1039920Syasuko.eckert@amd.com 10410897Snilay@cs.wisc.edu ccMap.init(TheISA::NumCCRegs, &(freeList->ccList), (RegIndex)-1); 10512105Snathanael.premillieu@arm.com 1069919Ssteve.reinhardt@amd.com} 1079919Ssteve.reinhardt@amd.com 108