rename_map.hh revision 12109
11689SN/A/*
212106SRekai.GonzalezAlberquilla@arm.com * Copyright (c) 2015-2016 ARM Limited
310715SRekai.GonzalezAlberquilla@arm.com * All rights reserved.
410715SRekai.GonzalezAlberquilla@arm.com *
510715SRekai.GonzalezAlberquilla@arm.com * The license below extends only to copyright in the software and shall
610715SRekai.GonzalezAlberquilla@arm.com * not be construed as granting a license to any other intellectual
710715SRekai.GonzalezAlberquilla@arm.com * property including but not limited to intellectual property relating
810715SRekai.GonzalezAlberquilla@arm.com * to a hardware implementation of the functionality of the software
910715SRekai.GonzalezAlberquilla@arm.com * licensed hereunder.  You may use the software subject to the license
1010715SRekai.GonzalezAlberquilla@arm.com * terms below provided that you ensure that this notice is replicated
1110715SRekai.GonzalezAlberquilla@arm.com * unmodified and in its entirety in all distributions of the software,
1210715SRekai.GonzalezAlberquilla@arm.com * modified or unmodified, in source code or in binary form.
1310715SRekai.GonzalezAlberquilla@arm.com *
141689SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
159919Ssteve.reinhardt@amd.com * Copyright (c) 2013 Advanced Micro Devices, Inc.
161689SN/A * All rights reserved.
171689SN/A *
181689SN/A * Redistribution and use in source and binary forms, with or without
191689SN/A * modification, are permitted provided that the following conditions are
201689SN/A * met: redistributions of source code must retain the above copyright
211689SN/A * notice, this list of conditions and the following disclaimer;
221689SN/A * redistributions in binary form must reproduce the above copyright
231689SN/A * notice, this list of conditions and the following disclaimer in the
241689SN/A * documentation and/or other materials provided with the distribution;
251689SN/A * neither the name of the copyright holders nor the names of its
261689SN/A * contributors may be used to endorse or promote products derived from
271689SN/A * this software without specific prior written permission.
281689SN/A *
291689SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
301689SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
311689SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
321689SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
331689SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
341689SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
351689SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
361689SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
371689SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
381689SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
391689SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
402665Ssaidi@eecs.umich.edu *
412665Ssaidi@eecs.umich.edu * Authors: Kevin Lim
429919Ssteve.reinhardt@amd.com *          Steve Reinhardt
431689SN/A */
441689SN/A
452292SN/A#ifndef __CPU_O3_RENAME_MAP_HH__
462292SN/A#define __CPU_O3_RENAME_MAP_HH__
471060SN/A
481060SN/A#include <iostream>
491461SN/A#include <utility>
501060SN/A#include <vector>
511060SN/A
526658Snate@binkert.org#include "arch/types.hh"
536658Snate@binkert.org#include "config/the_isa.hh"
541717SN/A#include "cpu/o3/free_list.hh"
559919Ssteve.reinhardt@amd.com#include "cpu/o3/regfile.hh"
569919Ssteve.reinhardt@amd.com#include "cpu/reg_class.hh"
5712109SRekai.GonzalezAlberquilla@arm.com#include "enums/VecRegRenameMode.hh"
581060SN/A
599919Ssteve.reinhardt@amd.com/**
609919Ssteve.reinhardt@amd.com * Register rename map for a single class of registers (e.g., integer
619919Ssteve.reinhardt@amd.com * or floating point).  Because the register class is implicitly
629919Ssteve.reinhardt@amd.com * determined by the rename map instance being accessed, all
639919Ssteve.reinhardt@amd.com * architectural register index parameters and values in this class
649919Ssteve.reinhardt@amd.com * are relative (e.g., %fp2 is just index 2).
659919Ssteve.reinhardt@amd.com */
661060SN/Aclass SimpleRenameMap
671060SN/A{
689919Ssteve.reinhardt@amd.com  private:
6912106SRekai.GonzalezAlberquilla@arm.com    using Arch2PhysMap = std::vector<PhysRegIdPtr>;
709919Ssteve.reinhardt@amd.com    /** The acutal arch-to-phys register map */
7112106SRekai.GonzalezAlberquilla@arm.com    Arch2PhysMap map;
7212109SRekai.GonzalezAlberquilla@arm.com  public:
7312109SRekai.GonzalezAlberquilla@arm.com    using iterator = Arch2PhysMap::iterator;
7412109SRekai.GonzalezAlberquilla@arm.com    using const_iterator = Arch2PhysMap::const_iterator;
7512109SRekai.GonzalezAlberquilla@arm.com  private:
769919Ssteve.reinhardt@amd.com
779919Ssteve.reinhardt@amd.com    /**
789919Ssteve.reinhardt@amd.com     * Pointer to the free list from which new physical registers
799919Ssteve.reinhardt@amd.com     * should be allocated in rename()
809919Ssteve.reinhardt@amd.com     */
819919Ssteve.reinhardt@amd.com    SimpleFreeList *freeList;
829919Ssteve.reinhardt@amd.com
839919Ssteve.reinhardt@amd.com    /**
849919Ssteve.reinhardt@amd.com     * The architectural index of the zero register. This register is
859919Ssteve.reinhardt@amd.com     * mapped but read-only, so we ignore attempts to rename it via
869919Ssteve.reinhardt@amd.com     * the rename() method.  If there is no such register for this map
879919Ssteve.reinhardt@amd.com     * table, it should be set to an invalid index so that it never
889919Ssteve.reinhardt@amd.com     * matches.
899919Ssteve.reinhardt@amd.com     */
9012106SRekai.GonzalezAlberquilla@arm.com    RegId zeroReg;
919919Ssteve.reinhardt@amd.com
921060SN/A  public:
939919Ssteve.reinhardt@amd.com
949919Ssteve.reinhardt@amd.com    SimpleRenameMap();
959919Ssteve.reinhardt@amd.com
969919Ssteve.reinhardt@amd.com    ~SimpleRenameMap() {};
979919Ssteve.reinhardt@amd.com
981060SN/A    /**
999919Ssteve.reinhardt@amd.com     * Because we have an array of rename maps (one per thread) in the CPU,
1009919Ssteve.reinhardt@amd.com     * it's awkward to initialize this object via the constructor.
1019919Ssteve.reinhardt@amd.com     * Instead, this method is used for initialization.
1021060SN/A     */
1039919Ssteve.reinhardt@amd.com    void init(unsigned size, SimpleFreeList *_freeList, RegIndex _zeroReg);
1041060SN/A
1051060SN/A    /**
1061060SN/A     * Pair of a physical register and a physical register.  Used to
1071060SN/A     * return the physical register that a logical register has been
1081060SN/A     * renamed to, and the previous physical register that the same
1091060SN/A     * logical register was previously mapped to.
1101060SN/A     */
11112105Snathanael.premillieu@arm.com    typedef std::pair<PhysRegIdPtr, PhysRegIdPtr> RenameInfo;
1121060SN/A
1139919Ssteve.reinhardt@amd.com    /**
1149919Ssteve.reinhardt@amd.com     * Tell rename map to get a new free physical register to remap
1159919Ssteve.reinhardt@amd.com     * the specified architectural register.
1169919Ssteve.reinhardt@amd.com     * @param arch_reg The architectural register to remap.
1179919Ssteve.reinhardt@amd.com     * @return A RenameInfo pair indicating both the new and previous
1189919Ssteve.reinhardt@amd.com     * physical registers.
1199919Ssteve.reinhardt@amd.com     */
12012106SRekai.GonzalezAlberquilla@arm.com    RenameInfo rename(const RegId& arch_reg);
1219919Ssteve.reinhardt@amd.com
1229919Ssteve.reinhardt@amd.com    /**
1239919Ssteve.reinhardt@amd.com     * Look up the physical register mapped to an architectural register.
1249919Ssteve.reinhardt@amd.com     * @param arch_reg The architectural register to look up.
1259919Ssteve.reinhardt@amd.com     * @return The physical register it is currently mapped to.
1269919Ssteve.reinhardt@amd.com     */
12712106SRekai.GonzalezAlberquilla@arm.com    PhysRegIdPtr lookup(const RegId& arch_reg) const
1289919Ssteve.reinhardt@amd.com    {
12912106SRekai.GonzalezAlberquilla@arm.com        assert(arch_reg.flatIndex() <= map.size());
13012106SRekai.GonzalezAlberquilla@arm.com        return map[arch_reg.flatIndex()];
1319919Ssteve.reinhardt@amd.com    }
1329919Ssteve.reinhardt@amd.com
1339919Ssteve.reinhardt@amd.com    /**
1349919Ssteve.reinhardt@amd.com     * Update rename map with a specific mapping.  Generally used to
1359919Ssteve.reinhardt@amd.com     * roll back to old mappings on a squash.
1369919Ssteve.reinhardt@amd.com     * @param arch_reg The architectural register to remap.
1379919Ssteve.reinhardt@amd.com     * @param phys_reg The physical register to remap it to.
1389919Ssteve.reinhardt@amd.com     */
13912106SRekai.GonzalezAlberquilla@arm.com    void setEntry(const RegId& arch_reg, PhysRegIdPtr phys_reg)
1409919Ssteve.reinhardt@amd.com    {
14112106SRekai.GonzalezAlberquilla@arm.com        assert(arch_reg.flatIndex() <= map.size());
14212106SRekai.GonzalezAlberquilla@arm.com        map[arch_reg.flatIndex()] = phys_reg;
1439919Ssteve.reinhardt@amd.com    }
1449919Ssteve.reinhardt@amd.com
1459919Ssteve.reinhardt@amd.com    /** Return the number of free entries on the associated free list. */
1469919Ssteve.reinhardt@amd.com    unsigned numFreeEntries() const { return freeList->numFreeRegs(); }
14712109SRekai.GonzalezAlberquilla@arm.com
14812109SRekai.GonzalezAlberquilla@arm.com    /** Forward begin/cbegin to the map. */
14912109SRekai.GonzalezAlberquilla@arm.com    /** @{ */
15012109SRekai.GonzalezAlberquilla@arm.com    iterator begin() { return map.begin(); }
15112109SRekai.GonzalezAlberquilla@arm.com    const_iterator begin() const { return map.begin(); }
15212109SRekai.GonzalezAlberquilla@arm.com    const_iterator cbegin() const { return map.cbegin(); }
15312109SRekai.GonzalezAlberquilla@arm.com    /** @} */
15412109SRekai.GonzalezAlberquilla@arm.com
15512109SRekai.GonzalezAlberquilla@arm.com    /** Forward end/cend to the map. */
15612109SRekai.GonzalezAlberquilla@arm.com    /** @{ */
15712109SRekai.GonzalezAlberquilla@arm.com    iterator end() { return map.end(); }
15812109SRekai.GonzalezAlberquilla@arm.com    const_iterator end() const { return map.end(); }
15912109SRekai.GonzalezAlberquilla@arm.com    const_iterator cend() const { return map.cend(); }
16012109SRekai.GonzalezAlberquilla@arm.com    /** @} */
1619919Ssteve.reinhardt@amd.com};
1629919Ssteve.reinhardt@amd.com
1639919Ssteve.reinhardt@amd.com
1649919Ssteve.reinhardt@amd.com/**
1659919Ssteve.reinhardt@amd.com * Unified register rename map for all classes of registers.  Wraps a
1669919Ssteve.reinhardt@amd.com * set of class-specific rename maps.  Methods that do not specify a
16712104Snathanael.premillieu@arm.com * register class (e.g., rename()) take register ids,
1689919Ssteve.reinhardt@amd.com * while methods that do specify a register class (e.g., renameInt())
16912104Snathanael.premillieu@arm.com * take register indices.
1709919Ssteve.reinhardt@amd.com */
1719919Ssteve.reinhardt@amd.comclass UnifiedRenameMap
1729919Ssteve.reinhardt@amd.com{
1739919Ssteve.reinhardt@amd.com  private:
17412109SRekai.GonzalezAlberquilla@arm.com    static constexpr uint32_t NVecElems = TheISA::NumVecElemPerVecReg;
17512109SRekai.GonzalezAlberquilla@arm.com    using VecReg = TheISA::VecReg;
1769919Ssteve.reinhardt@amd.com
1779919Ssteve.reinhardt@amd.com    /** The integer register rename map */
1789919Ssteve.reinhardt@amd.com    SimpleRenameMap intMap;
1799919Ssteve.reinhardt@amd.com
1809919Ssteve.reinhardt@amd.com    /** The floating-point register rename map */
1819919Ssteve.reinhardt@amd.com    SimpleRenameMap floatMap;
1829919Ssteve.reinhardt@amd.com
18312105Snathanael.premillieu@arm.com    /** The condition-code register rename map */
18412105Snathanael.premillieu@arm.com    SimpleRenameMap ccMap;
18512105Snathanael.premillieu@arm.com
18612109SRekai.GonzalezAlberquilla@arm.com    /** The vector register rename map */
18712109SRekai.GonzalezAlberquilla@arm.com    SimpleRenameMap vecMap;
18812109SRekai.GonzalezAlberquilla@arm.com
18912109SRekai.GonzalezAlberquilla@arm.com    /** The vector element register rename map */
19012109SRekai.GonzalezAlberquilla@arm.com    SimpleRenameMap vecElemMap;
19112109SRekai.GonzalezAlberquilla@arm.com
19212109SRekai.GonzalezAlberquilla@arm.com    using VecMode = Enums::VecRegRenameMode;
19312109SRekai.GonzalezAlberquilla@arm.com    VecMode vecMode;
19412109SRekai.GonzalezAlberquilla@arm.com
1959919Ssteve.reinhardt@amd.com    /**
19612105Snathanael.premillieu@arm.com     * The register file object is used only to get PhysRegIdPtr
19712105Snathanael.premillieu@arm.com     * on MiscRegs, as they are stored in it.
1989919Ssteve.reinhardt@amd.com     */
1999919Ssteve.reinhardt@amd.com    PhysRegFile *regFile;
2009919Ssteve.reinhardt@amd.com
2011060SN/A  public:
2029919Ssteve.reinhardt@amd.com
2039919Ssteve.reinhardt@amd.com    typedef SimpleRenameMap::RenameInfo RenameInfo;
2049919Ssteve.reinhardt@amd.com
2052348SN/A    /** Default constructor.  init() must be called prior to use. */
20610537Sandreas.hansson@arm.com    UnifiedRenameMap() : regFile(nullptr) {};
2071060SN/A
2081061SN/A    /** Destructor. */
2099919Ssteve.reinhardt@amd.com    ~UnifiedRenameMap() {};
2101061SN/A
2112348SN/A    /** Initializes rename map with given parameters. */
2129919Ssteve.reinhardt@amd.com    void init(PhysRegFile *_regFile,
2132292SN/A              RegIndex _intZeroReg,
2142292SN/A              RegIndex _floatZeroReg,
21512109SRekai.GonzalezAlberquilla@arm.com              UnifiedFreeList *freeList,
21612109SRekai.GonzalezAlberquilla@arm.com              VecMode _mode);
2172292SN/A
2189919Ssteve.reinhardt@amd.com    /**
2199919Ssteve.reinhardt@amd.com     * Tell rename map to get a new free physical register to remap
22012104Snathanael.premillieu@arm.com     * the specified architectural register. This version takes a
22112106SRekai.GonzalezAlberquilla@arm.com     * RegId and reads the  appropriate class-specific rename table.
22212106SRekai.GonzalezAlberquilla@arm.com     * @param arch_reg The architectural register id to remap.
2239919Ssteve.reinhardt@amd.com     * @return A RenameInfo pair indicating both the new and previous
2249919Ssteve.reinhardt@amd.com     * physical registers.
2259919Ssteve.reinhardt@amd.com     */
22612106SRekai.GonzalezAlberquilla@arm.com    RenameInfo rename(const RegId& arch_reg)
22712106SRekai.GonzalezAlberquilla@arm.com    {
22812106SRekai.GonzalezAlberquilla@arm.com        switch (arch_reg.classValue()) {
22912106SRekai.GonzalezAlberquilla@arm.com          case IntRegClass:
23012106SRekai.GonzalezAlberquilla@arm.com            return intMap.rename(arch_reg);
23112106SRekai.GonzalezAlberquilla@arm.com          case FloatRegClass:
23212106SRekai.GonzalezAlberquilla@arm.com            return floatMap.rename(arch_reg);
23312109SRekai.GonzalezAlberquilla@arm.com          case VecRegClass:
23412109SRekai.GonzalezAlberquilla@arm.com            assert(vecMode == Enums::Full);
23512109SRekai.GonzalezAlberquilla@arm.com            return vecMap.rename(arch_reg);
23612109SRekai.GonzalezAlberquilla@arm.com          case VecElemClass:
23712109SRekai.GonzalezAlberquilla@arm.com            assert(vecMode == Enums::Elem);
23812109SRekai.GonzalezAlberquilla@arm.com            return vecElemMap.rename(arch_reg);
23912106SRekai.GonzalezAlberquilla@arm.com          case CCRegClass:
24012106SRekai.GonzalezAlberquilla@arm.com            return ccMap.rename(arch_reg);
24112106SRekai.GonzalezAlberquilla@arm.com          case MiscRegClass:
24212106SRekai.GonzalezAlberquilla@arm.com            {
24312106SRekai.GonzalezAlberquilla@arm.com            // misc regs aren't really renamed, just remapped
24412106SRekai.GonzalezAlberquilla@arm.com            PhysRegIdPtr phys_reg = lookup(arch_reg);
24512106SRekai.GonzalezAlberquilla@arm.com            // Set the new register to the previous one to keep the same
24612106SRekai.GonzalezAlberquilla@arm.com            // mapping throughout the execution.
24712106SRekai.GonzalezAlberquilla@arm.com            return RenameInfo(phys_reg, phys_reg);
24812106SRekai.GonzalezAlberquilla@arm.com            }
2491060SN/A
25012106SRekai.GonzalezAlberquilla@arm.com          default:
25112106SRekai.GonzalezAlberquilla@arm.com            panic("rename rename(): unknown reg class %s\n",
25212106SRekai.GonzalezAlberquilla@arm.com                  arch_reg.className());
25312106SRekai.GonzalezAlberquilla@arm.com        }
2549919Ssteve.reinhardt@amd.com    }
2551060SN/A
2561060SN/A    /**
2579919Ssteve.reinhardt@amd.com     * Look up the physical register mapped to an architectural register.
25812104Snathanael.premillieu@arm.com     * This version takes a flattened architectural register id
2599919Ssteve.reinhardt@amd.com     * and calls the appropriate class-specific rename table.
26012104Snathanael.premillieu@arm.com     * @param arch_reg The architectural register to look up.
2619919Ssteve.reinhardt@amd.com     * @return The physical register it is currently mapped to.
2629919Ssteve.reinhardt@amd.com     */
26312106SRekai.GonzalezAlberquilla@arm.com    PhysRegIdPtr lookup(const RegId& arch_reg) const
26412106SRekai.GonzalezAlberquilla@arm.com    {
26512106SRekai.GonzalezAlberquilla@arm.com        switch (arch_reg.classValue()) {
26612106SRekai.GonzalezAlberquilla@arm.com          case IntRegClass:
26712106SRekai.GonzalezAlberquilla@arm.com            return intMap.lookup(arch_reg);
2681060SN/A
26912106SRekai.GonzalezAlberquilla@arm.com          case FloatRegClass:
27012106SRekai.GonzalezAlberquilla@arm.com            return  floatMap.lookup(arch_reg);
2711060SN/A
27212109SRekai.GonzalezAlberquilla@arm.com          case VecRegClass:
27312109SRekai.GonzalezAlberquilla@arm.com            assert(vecMode == Enums::Full);
27412109SRekai.GonzalezAlberquilla@arm.com            return  vecMap.lookup(arch_reg);
27512109SRekai.GonzalezAlberquilla@arm.com
27612109SRekai.GonzalezAlberquilla@arm.com          case VecElemClass:
27712109SRekai.GonzalezAlberquilla@arm.com            assert(vecMode == Enums::Elem);
27812109SRekai.GonzalezAlberquilla@arm.com            return  vecElemMap.lookup(arch_reg);
27912109SRekai.GonzalezAlberquilla@arm.com
28012106SRekai.GonzalezAlberquilla@arm.com          case CCRegClass:
28112106SRekai.GonzalezAlberquilla@arm.com            return ccMap.lookup(arch_reg);
2821060SN/A
28312106SRekai.GonzalezAlberquilla@arm.com          case MiscRegClass:
28412106SRekai.GonzalezAlberquilla@arm.com            // misc regs aren't really renamed, they keep the same
28512106SRekai.GonzalezAlberquilla@arm.com            // mapping throughout the execution.
28612106SRekai.GonzalezAlberquilla@arm.com            return regFile->getMiscRegId(arch_reg.flatIndex());
2879920Syasuko.eckert@amd.com
28812106SRekai.GonzalezAlberquilla@arm.com          default:
28912106SRekai.GonzalezAlberquilla@arm.com            panic("rename lookup(): unknown reg class %s\n",
29012106SRekai.GonzalezAlberquilla@arm.com                  arch_reg.className());
29112106SRekai.GonzalezAlberquilla@arm.com        }
2929919Ssteve.reinhardt@amd.com    }
2931060SN/A
2949919Ssteve.reinhardt@amd.com    /**
2959919Ssteve.reinhardt@amd.com     * Update rename map with a specific mapping.  Generally used to
2969919Ssteve.reinhardt@amd.com     * roll back to old mappings on a squash.  This version takes a
29712104Snathanael.premillieu@arm.com     * flattened architectural register id and calls the
2989919Ssteve.reinhardt@amd.com     * appropriate class-specific rename table.
29912104Snathanael.premillieu@arm.com     * @param arch_reg The architectural register to remap.
3009919Ssteve.reinhardt@amd.com     * @param phys_reg The physical register to remap it to.
3019919Ssteve.reinhardt@amd.com     */
30212106SRekai.GonzalezAlberquilla@arm.com    void setEntry(const RegId& arch_reg, PhysRegIdPtr phys_reg)
30312106SRekai.GonzalezAlberquilla@arm.com    {
30412106SRekai.GonzalezAlberquilla@arm.com        switch (arch_reg.classValue()) {
30512106SRekai.GonzalezAlberquilla@arm.com          case IntRegClass:
30612106SRekai.GonzalezAlberquilla@arm.com            assert(phys_reg->isIntPhysReg());
30712106SRekai.GonzalezAlberquilla@arm.com            return intMap.setEntry(arch_reg, phys_reg);
3081060SN/A
30912106SRekai.GonzalezAlberquilla@arm.com          case FloatRegClass:
31012106SRekai.GonzalezAlberquilla@arm.com            assert(phys_reg->isFloatPhysReg());
31112106SRekai.GonzalezAlberquilla@arm.com            return floatMap.setEntry(arch_reg, phys_reg);
3121060SN/A
31312109SRekai.GonzalezAlberquilla@arm.com          case VecRegClass:
31412109SRekai.GonzalezAlberquilla@arm.com            assert(phys_reg->isVectorPhysReg());
31512109SRekai.GonzalezAlberquilla@arm.com            assert(vecMode == Enums::Full);
31612109SRekai.GonzalezAlberquilla@arm.com            return vecMap.setEntry(arch_reg, phys_reg);
31712109SRekai.GonzalezAlberquilla@arm.com
31812109SRekai.GonzalezAlberquilla@arm.com          case VecElemClass:
31912109SRekai.GonzalezAlberquilla@arm.com            assert(phys_reg->isVectorPhysElem());
32012109SRekai.GonzalezAlberquilla@arm.com            assert(vecMode == Enums::Elem);
32112109SRekai.GonzalezAlberquilla@arm.com            return vecElemMap.setEntry(arch_reg, phys_reg);
32212109SRekai.GonzalezAlberquilla@arm.com
32312106SRekai.GonzalezAlberquilla@arm.com          case CCRegClass:
32412106SRekai.GonzalezAlberquilla@arm.com            assert(phys_reg->isCCPhysReg());
32512106SRekai.GonzalezAlberquilla@arm.com            return ccMap.setEntry(arch_reg, phys_reg);
3261060SN/A
32712106SRekai.GonzalezAlberquilla@arm.com          case MiscRegClass:
32812106SRekai.GonzalezAlberquilla@arm.com            // Misc registers do not actually rename, so don't change
32912106SRekai.GonzalezAlberquilla@arm.com            // their mappings.  We end up here when a commit or squash
33012106SRekai.GonzalezAlberquilla@arm.com            // tries to update or undo a hardwired misc reg nmapping,
33112106SRekai.GonzalezAlberquilla@arm.com            // which should always be setting it to what it already is.
33212106SRekai.GonzalezAlberquilla@arm.com            assert(phys_reg == lookup(arch_reg));
33312106SRekai.GonzalezAlberquilla@arm.com            return;
33412106SRekai.GonzalezAlberquilla@arm.com
33512106SRekai.GonzalezAlberquilla@arm.com          default:
33612106SRekai.GonzalezAlberquilla@arm.com            panic("rename setEntry(): unknown reg class %s\n",
33712106SRekai.GonzalezAlberquilla@arm.com                  arch_reg.className());
33812106SRekai.GonzalezAlberquilla@arm.com        }
3399920Syasuko.eckert@amd.com    }
3409920Syasuko.eckert@amd.com
3419920Syasuko.eckert@amd.com    /**
3429919Ssteve.reinhardt@amd.com     * Return the minimum number of free entries across all of the
3439919Ssteve.reinhardt@amd.com     * register classes.  The minimum is used so we guarantee that
3449919Ssteve.reinhardt@amd.com     * this number of entries is available regardless of which class
3459919Ssteve.reinhardt@amd.com     * of registers is requested.
3461060SN/A     */
3479919Ssteve.reinhardt@amd.com    unsigned numFreeEntries() const
3481060SN/A    {
34912109SRekai.GonzalezAlberquilla@arm.com        return std::min(
35012109SRekai.GonzalezAlberquilla@arm.com                std::min(intMap.numFreeEntries(), floatMap.numFreeEntries()),
35112109SRekai.GonzalezAlberquilla@arm.com                vecMode == Enums::Full ? vecMap.numFreeEntries()
35212109SRekai.GonzalezAlberquilla@arm.com                                    : vecElemMap.numFreeEntries());
3539919Ssteve.reinhardt@amd.com    }
35410715SRekai.GonzalezAlberquilla@arm.com
35512109SRekai.GonzalezAlberquilla@arm.com    unsigned numFreeIntEntries() const { return intMap.numFreeEntries(); }
35612109SRekai.GonzalezAlberquilla@arm.com    unsigned numFreeFloatEntries() const { return floatMap.numFreeEntries(); }
35712109SRekai.GonzalezAlberquilla@arm.com    unsigned numFreeVecEntries() const
35812109SRekai.GonzalezAlberquilla@arm.com    {
35912109SRekai.GonzalezAlberquilla@arm.com        return vecMode == Enums::Full
36012109SRekai.GonzalezAlberquilla@arm.com                ? vecMap.numFreeEntries()
36112109SRekai.GonzalezAlberquilla@arm.com                : vecElemMap.numFreeEntries();
36212109SRekai.GonzalezAlberquilla@arm.com    }
36312109SRekai.GonzalezAlberquilla@arm.com    unsigned numFreeCCEntries() const { return ccMap.numFreeEntries(); }
36412109SRekai.GonzalezAlberquilla@arm.com
36510715SRekai.GonzalezAlberquilla@arm.com    /**
36610715SRekai.GonzalezAlberquilla@arm.com     * Return whether there are enough registers to serve the request.
36710715SRekai.GonzalezAlberquilla@arm.com     */
36812109SRekai.GonzalezAlberquilla@arm.com    bool canRename(uint32_t intRegs, uint32_t floatRegs, uint32_t vectorRegs,
36912109SRekai.GonzalezAlberquilla@arm.com                    uint32_t vecElemRegs, uint32_t ccRegs) const
37010715SRekai.GonzalezAlberquilla@arm.com    {
37110715SRekai.GonzalezAlberquilla@arm.com        return intRegs <= intMap.numFreeEntries() &&
37210715SRekai.GonzalezAlberquilla@arm.com            floatRegs <= floatMap.numFreeEntries() &&
37312109SRekai.GonzalezAlberquilla@arm.com            vectorRegs <= vecMap.numFreeEntries() &&
37412109SRekai.GonzalezAlberquilla@arm.com            vecElemRegs <= vecElemMap.numFreeEntries() &&
37510935Snilay@cs.wisc.edu            ccRegs <= ccMap.numFreeEntries();
37610715SRekai.GonzalezAlberquilla@arm.com    }
37712109SRekai.GonzalezAlberquilla@arm.com    /**
37812109SRekai.GonzalezAlberquilla@arm.com     * Set vector mode to Full or Elem.
37912109SRekai.GonzalezAlberquilla@arm.com     * Ignore 'silent' modifications.
38012109SRekai.GonzalezAlberquilla@arm.com     */
38112109SRekai.GonzalezAlberquilla@arm.com    void switchMode(VecMode newVecMode, UnifiedFreeList* freeList);
38210715SRekai.GonzalezAlberquilla@arm.com
3831060SN/A};
3841060SN/A
3852292SN/A#endif //__CPU_O3_RENAME_MAP_HH__
386