regfile.cc revision 10934:5af8f40d8f2c
15222Sksewell@umich.edu/* 25222Sksewell@umich.edu * Copyright (c) 2004-2005 The Regents of The University of Michigan 35222Sksewell@umich.edu * Copyright (c) 2013 Advanced Micro Devices, Inc. 45222Sksewell@umich.edu * All rights reserved. 55222Sksewell@umich.edu * 65222Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 75222Sksewell@umich.edu * modification, are permitted provided that the following conditions are 85222Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 95222Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 105222Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 115222Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 125222Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 135222Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 145222Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 155222Sksewell@umich.edu * this software without specific prior written permission. 165222Sksewell@umich.edu * 175222Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185222Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195222Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205222Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215222Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225222Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235222Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245222Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255222Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265222Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275222Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285222Sksewell@umich.edu * 295222Sksewell@umich.edu * Authors: Kevin Lim 305222Sksewell@umich.edu * Gabe Black 3111793Sbrandon.potter@amd.com * Steve Reinhardt 3211793Sbrandon.potter@amd.com */ 335541Snate@binkert.org 345541Snate@binkert.org#include "cpu/o3/free_list.hh" 355222Sksewell@umich.edu#include "cpu/o3/regfile.hh" 365222Sksewell@umich.edu 375222Sksewell@umich.edu 3811793Sbrandon.potter@amd.comPhysRegFile::PhysRegFile(unsigned _numPhysicalIntRegs, 395222Sksewell@umich.edu unsigned _numPhysicalFloatRegs, 408706Sandreas.hansson@arm.com unsigned _numPhysicalCCRegs, 415222Sksewell@umich.edu unsigned _numPhysicalVectorRegs) 425222Sksewell@umich.edu : intRegFile(_numPhysicalIntRegs), 435541Snate@binkert.org floatRegFile(_numPhysicalFloatRegs), 445541Snate@binkert.org ccRegFile(_numPhysicalCCRegs), 455541Snate@binkert.org vectorRegFile(_numPhysicalVectorRegs), 465541Snate@binkert.org baseFloatRegIndex(_numPhysicalIntRegs), 475541Snate@binkert.org baseCCRegIndex(_numPhysicalIntRegs + _numPhysicalFloatRegs), 485541Snate@binkert.org baseVectorRegIndex(_numPhysicalIntRegs + _numPhysicalFloatRegs 495222Sksewell@umich.edu + _numPhysicalCCRegs), 505222Sksewell@umich.edu totalNumRegs(_numPhysicalIntRegs 515222Sksewell@umich.edu + _numPhysicalFloatRegs 525222Sksewell@umich.edu + _numPhysicalCCRegs 535541Snate@binkert.org + _numPhysicalVectorRegs) 545541Snate@binkert.org{ 555541Snate@binkert.org if (TheISA::NumCCRegs == 0 && _numPhysicalCCRegs != 0) { 565222Sksewell@umich.edu // Just make this a warning and go ahead and allocate them 575222Sksewell@umich.edu // anyway, to keep from having to add checks everywhere 585222Sksewell@umich.edu warn("Non-zero number of physical CC regs specified, even though\n" 595222Sksewell@umich.edu " ISA does not use them.\n"); 609086Sandreas.hansson@arm.com } 619086Sandreas.hansson@arm.com 625222Sksewell@umich.edu if (TheISA::NumVectorRegs == 0 && _numPhysicalVectorRegs != 0) { 635222Sksewell@umich.edu // Just make this a warning and go ahead and allocate them 645222Sksewell@umich.edu // anyway, to keep from having to add checks everywhere 658852Sandreas.hansson@arm.com warn("Non-zero number of physical vector regs specified, even though\n" 665222Sksewell@umich.edu " ISA does not use them.\n"); 675541Snate@binkert.org } 685541Snate@binkert.org} 695541Snate@binkert.org 705541Snate@binkert.org 715545Snate@binkert.orgvoid 725545Snate@binkert.orgPhysRegFile::initFreeList(UnifiedFreeList *freeList) 735545Snate@binkert.org{ 745541Snate@binkert.org // Initialize the free lists. 755541Snate@binkert.org PhysRegIndex reg_idx = 0; 765541Snate@binkert.org 7714010Sgabeblack@google.com // The initial batch of registers are the integer ones 785222Sksewell@umich.edu while (reg_idx < baseFloatRegIndex) { 795222Sksewell@umich.edu freeList->addIntReg(reg_idx++); 805222Sksewell@umich.edu } 815222Sksewell@umich.edu 825541Snate@binkert.org // The next batch of the registers are the floating-point physical 835541Snate@binkert.org // registers; put them onto the floating-point free list. 845541Snate@binkert.org while (reg_idx < baseCCRegIndex) { 855222Sksewell@umich.edu freeList->addFloatReg(reg_idx++); 865541Snate@binkert.org } 875541Snate@binkert.org 885541Snate@binkert.org // The next batch of registers are the condition-code physical 895541Snate@binkert.org // registers; put them onto the condition-code free list. 905541Snate@binkert.org while (reg_idx < baseVectorRegIndex) { 915541Snate@binkert.org freeList->addCCReg(reg_idx++); 925222Sksewell@umich.edu } 935541Snate@binkert.org 945541Snate@binkert.org // The rest of the registers are the vector physical 955541Snate@binkert.org // registers; put them onto the vector free list. 965541Snate@binkert.org while (reg_idx < totalNumRegs) { 975541Snate@binkert.org freeList->addVectorReg(reg_idx++); 985541Snate@binkert.org } 995541Snate@binkert.org} 1005541Snate@binkert.org