thread_context.hh revision 13865
12817Sksewell@umich.edu/*
213610Sgiacomo.gabrielli@arm.com * Copyright (c) 2011-2012, 2016-2018 ARM Limited
39920Syasuko.eckert@amd.com * Copyright (c) 2013 Advanced Micro Devices, Inc.
48733Sgeoffrey.blake@arm.com * All rights reserved
58733Sgeoffrey.blake@arm.com *
68733Sgeoffrey.blake@arm.com * The license below extends only to copyright in the software and shall
78733Sgeoffrey.blake@arm.com * not be construed as granting a license to any other intellectual
88733Sgeoffrey.blake@arm.com * property including but not limited to intellectual property relating
98733Sgeoffrey.blake@arm.com * to a hardware implementation of the functionality of the software
108733Sgeoffrey.blake@arm.com * licensed hereunder.  You may use the software subject to the license
118733Sgeoffrey.blake@arm.com * terms below provided that you ensure that this notice is replicated
128733Sgeoffrey.blake@arm.com * unmodified and in its entirety in all distributions of the software,
138733Sgeoffrey.blake@arm.com * modified or unmodified, in source code or in binary form.
148733Sgeoffrey.blake@arm.com *
152817Sksewell@umich.edu * Copyright (c) 2004-2006 The Regents of The University of Michigan
162817Sksewell@umich.edu * All rights reserved.
172817Sksewell@umich.edu *
182817Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
192817Sksewell@umich.edu * modification, are permitted provided that the following conditions are
202817Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
212817Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
222817Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
232817Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
242817Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
252817Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
262817Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
272817Sksewell@umich.edu * this software without specific prior written permission.
282817Sksewell@umich.edu *
292817Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
302817Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
312817Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
322817Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
332817Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
342817Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
352817Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
362817Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
372817Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
382817Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
392817Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
402817Sksewell@umich.edu *
412817Sksewell@umich.edu * Authors: Kevin Lim
422817Sksewell@umich.edu */
432817Sksewell@umich.edu
442817Sksewell@umich.edu#ifndef __CPU_O3_THREAD_CONTEXT_HH__
452817Sksewell@umich.edu#define __CPU_O3_THREAD_CONTEXT_HH__
462817Sksewell@umich.edu
476658Snate@binkert.org#include "config/the_isa.hh"
488229Snate@binkert.org#include "cpu/o3/isa_specific.hh"
492935Sksewell@umich.edu#include "cpu/thread_context.hh"
502817Sksewell@umich.edu
512834Sksewell@umich.educlass EndQuiesceEvent;
522834Sksewell@umich.edunamespace Kernel {
532834Sksewell@umich.edu    class Statistics;
548902Sandreas.hansson@arm.com}
552834Sksewell@umich.edu
562817Sksewell@umich.edu/**
572817Sksewell@umich.edu * Derived ThreadContext class for use with the O3CPU.  It
582817Sksewell@umich.edu * provides the interface for any external objects to access a
592817Sksewell@umich.edu * single thread's state and some general CPU state.  Any time
602817Sksewell@umich.edu * external objects try to update state through this interface,
612817Sksewell@umich.edu * the CPU will create an event to squash all in-flight
622817Sksewell@umich.edu * instructions in order to ensure state is maintained correctly.
632817Sksewell@umich.edu * It must be defined specifically for the O3CPU because
642817Sksewell@umich.edu * not all architectural state is located within the O3ThreadState
652817Sksewell@umich.edu * (such as the commit PC, and registers), and specific actions
662817Sksewell@umich.edu * must be taken when using this interface (such as squashing all
672817Sksewell@umich.edu * in-flight instructions when doing a write to this interface).
682817Sksewell@umich.edu */
692817Sksewell@umich.edutemplate <class Impl>
702817Sksewell@umich.educlass O3ThreadContext : public ThreadContext
712817Sksewell@umich.edu{
722817Sksewell@umich.edu  public:
732817Sksewell@umich.edu    typedef typename Impl::O3CPU O3CPU;
742817Sksewell@umich.edu
752817Sksewell@umich.edu   /** Pointer to the CPU. */
762817Sksewell@umich.edu    O3CPU *cpu;
772817Sksewell@umich.edu
782817Sksewell@umich.edu    /** Pointer to the thread state that this TC corrseponds to. */
792817Sksewell@umich.edu    O3ThreadState<Impl> *thread;
802817Sksewell@umich.edu
813784Sgblack@eecs.umich.edu    /** Returns a pointer to the ITB. */
8213628SAndrea.Mondelli@ucf.edu    BaseTLB *getITBPtr() override { return cpu->itb; }
833784Sgblack@eecs.umich.edu
843784Sgblack@eecs.umich.edu    /** Returns a pointer to the DTB. */
8513628SAndrea.Mondelli@ucf.edu    BaseTLB *getDTBPtr() override { return cpu->dtb; }
863784Sgblack@eecs.umich.edu
8713628SAndrea.Mondelli@ucf.edu    CheckerCPU *getCheckerCpuPtr() override { return NULL; }
888733Sgeoffrey.blake@arm.com
8913693Sgiacomo.gabrielli@arm.com    TheISA::ISA *
9013693Sgiacomo.gabrielli@arm.com    getIsaPtr() override
9113693Sgiacomo.gabrielli@arm.com    {
9213693Sgiacomo.gabrielli@arm.com        return cpu->isa[thread->threadId()];
9313693Sgiacomo.gabrielli@arm.com    }
9413693Sgiacomo.gabrielli@arm.com
959023Sgblack@eecs.umich.edu    TheISA::Decoder *
9613628SAndrea.Mondelli@ucf.edu    getDecoderPtr() override
979023Sgblack@eecs.umich.edu    {
989023Sgblack@eecs.umich.edu        return cpu->fetch.decoder[thread->threadId()];
999023Sgblack@eecs.umich.edu    }
1008541Sgblack@eecs.umich.edu
1012817Sksewell@umich.edu    /** Returns a pointer to this CPU. */
10213865Sgabeblack@google.com    BaseCPU *getCpuPtr() override { return cpu; }
1032817Sksewell@umich.edu
1042817Sksewell@umich.edu    /** Reads this CPU's ID. */
10513865Sgabeblack@google.com    int cpuId() const override { return cpu->cpuId(); }
1062817Sksewell@umich.edu
10710190Sakash.bagdia@arm.com    /** Reads this CPU's Socket ID. */
10813865Sgabeblack@google.com    uint32_t socketId() const override { return cpu->socketId(); }
10910190Sakash.bagdia@arm.com
11013865Sgabeblack@google.com    ContextID contextId() const override { return thread->contextId(); }
1115714Shsul@eecs.umich.edu
11213865Sgabeblack@google.com    void setContextId(ContextID id) override { thread->setContextId(id); }
1135714Shsul@eecs.umich.edu
1145715Shsul@eecs.umich.edu    /** Returns this thread's ID number. */
11513865Sgabeblack@google.com    int threadId() const override { return thread->threadId(); }
11613865Sgabeblack@google.com    void setThreadId(int id) override { return thread->setThreadId(id); }
1175715Shsul@eecs.umich.edu
1182817Sksewell@umich.edu    /** Returns a pointer to the system. */
11913865Sgabeblack@google.com    System *getSystemPtr() override { return cpu->system; }
1202817Sksewell@umich.edu
1212817Sksewell@umich.edu    /** Returns a pointer to this thread's kernel statistics. */
12213865Sgabeblack@google.com    TheISA::Kernel::Statistics *
12313865Sgabeblack@google.com    getKernelStats() override
12413865Sgabeblack@google.com    {
12513865Sgabeblack@google.com        return thread->kernelStats;
12613865Sgabeblack@google.com    }
1272817Sksewell@umich.edu
1288541Sgblack@eecs.umich.edu    /** Returns a pointer to this thread's process. */
12913865Sgabeblack@google.com    Process *getProcessPtr() override { return thread->getProcessPtr(); }
1308754Sgblack@eecs.umich.edu
13113865Sgabeblack@google.com    void setProcessPtr(Process *p) override { thread->setProcessPtr(p); }
13211886Sbrandon.potter@amd.com
13313865Sgabeblack@google.com    PortProxy &getPhysProxy() override { return thread->getPhysProxy(); }
1342817Sksewell@umich.edu
13513865Sgabeblack@google.com    FSTranslatingPortProxy &getVirtProxy() override;
1363675Sktlim@umich.edu
13713865Sgabeblack@google.com    void
13813865Sgabeblack@google.com    initMemProxies(ThreadContext *tc) override
13913865Sgabeblack@google.com    {
14013865Sgabeblack@google.com        thread->initMemProxies(tc);
14113865Sgabeblack@google.com    }
1428799Sgblack@eecs.umich.edu
14313865Sgabeblack@google.com    SETranslatingPortProxy &
14413865Sgabeblack@google.com    getMemProxy() override
14513865Sgabeblack@google.com    {
14613865Sgabeblack@google.com        return thread->getMemProxy();
14713865Sgabeblack@google.com    }
1482817Sksewell@umich.edu
1492817Sksewell@umich.edu    /** Returns this thread's status. */
15013865Sgabeblack@google.com    Status status() const override { return thread->status(); }
1512817Sksewell@umich.edu
1522817Sksewell@umich.edu    /** Sets this thread's status. */
15313865Sgabeblack@google.com    void
15413865Sgabeblack@google.com    setStatus(Status new_status) override
15513865Sgabeblack@google.com    {
15613865Sgabeblack@google.com        thread->setStatus(new_status);
15713865Sgabeblack@google.com    }
1582817Sksewell@umich.edu
15910407Smitch.hayenga@arm.com    /** Set the status to Active. */
16013865Sgabeblack@google.com    void activate() override;
1612817Sksewell@umich.edu
1622817Sksewell@umich.edu    /** Set the status to Suspended. */
16313865Sgabeblack@google.com    void suspend() override;
1642817Sksewell@umich.edu
1652817Sksewell@umich.edu    /** Set the status to Halted. */
16613865Sgabeblack@google.com    void halt() override;
1672817Sksewell@umich.edu
1682817Sksewell@umich.edu    /** Dumps the function profiling information.
1692817Sksewell@umich.edu     * @todo: Implement.
1702817Sksewell@umich.edu     */
17113865Sgabeblack@google.com    void dumpFuncProfile() override;
1728777Sgblack@eecs.umich.edu
1732817Sksewell@umich.edu    /** Takes over execution of a thread from another CPU. */
17413865Sgabeblack@google.com    void takeOverFrom(ThreadContext *old_context) override;
1752817Sksewell@umich.edu
1762817Sksewell@umich.edu    /** Registers statistics associated with this TC. */
17713865Sgabeblack@google.com    void regStats(const std::string &name) override;
1782817Sksewell@umich.edu
1792817Sksewell@umich.edu    /** Reads the last tick that this thread was activated on. */
18013865Sgabeblack@google.com    Tick readLastActivate() override;
1812817Sksewell@umich.edu    /** Reads the last tick that this thread was suspended on. */
18213865Sgabeblack@google.com    Tick readLastSuspend() override;
1832817Sksewell@umich.edu
1842817Sksewell@umich.edu    /** Clears the function profiling information. */
18513865Sgabeblack@google.com    void profileClear() override;
1862817Sksewell@umich.edu    /** Samples the function profiling information. */
18713865Sgabeblack@google.com    void profileSample() override;
1882817Sksewell@umich.edu
1892817Sksewell@umich.edu    /** Copies the architectural registers from another TC into this TC. */
19013865Sgabeblack@google.com    void copyArchRegs(ThreadContext *tc) override;
1912817Sksewell@umich.edu
1922817Sksewell@umich.edu    /** Resets all architectural registers to 0. */
19313865Sgabeblack@google.com    void clearArchRegs() override;
1942817Sksewell@umich.edu
1952817Sksewell@umich.edu    /** Reads an integer register. */
19613865Sgabeblack@google.com    RegVal
19713865Sgabeblack@google.com    readReg(RegIndex reg_idx)
19813557Sgabeblack@google.com    {
19912106SRekai.GonzalezAlberquilla@arm.com        return readIntRegFlat(flattenRegId(RegId(IntRegClass,
20012106SRekai.GonzalezAlberquilla@arm.com                                                 reg_idx)).index());
20112106SRekai.GonzalezAlberquilla@arm.com    }
20213865Sgabeblack@google.com    RegVal
20313865Sgabeblack@google.com    readIntReg(RegIndex reg_idx) const override
20413557Sgabeblack@google.com    {
20512106SRekai.GonzalezAlberquilla@arm.com        return readIntRegFlat(flattenRegId(RegId(IntRegClass,
20612106SRekai.GonzalezAlberquilla@arm.com                                                 reg_idx)).index());
2079426SAndreas.Sandberg@ARM.com    }
2082817Sksewell@umich.edu
20913865Sgabeblack@google.com    RegVal
21013865Sgabeblack@google.com    readFloatReg(RegIndex reg_idx) const override
21113557Sgabeblack@google.com    {
21213611Sgabeblack@google.com        return readFloatRegFlat(flattenRegId(RegId(FloatRegClass,
21313611Sgabeblack@google.com                                             reg_idx)).index());
2149426SAndreas.Sandberg@ARM.com    }
2152817Sksewell@umich.edu
21613865Sgabeblack@google.com    const VecRegContainer &
21713628SAndrea.Mondelli@ucf.edu    readVecReg(const RegId& id) const override
21813557Sgabeblack@google.com    {
21912109SRekai.GonzalezAlberquilla@arm.com        return readVecRegFlat(flattenRegId(id).index());
22012109SRekai.GonzalezAlberquilla@arm.com    }
22112109SRekai.GonzalezAlberquilla@arm.com
22212109SRekai.GonzalezAlberquilla@arm.com    /**
22312109SRekai.GonzalezAlberquilla@arm.com     * Read vector register operand for modification, hierarchical indexing.
22412109SRekai.GonzalezAlberquilla@arm.com     */
22513865Sgabeblack@google.com    VecRegContainer &
22613628SAndrea.Mondelli@ucf.edu    getWritableVecReg(const RegId& id) override
22713557Sgabeblack@google.com    {
22812109SRekai.GonzalezAlberquilla@arm.com        return getWritableVecRegFlat(flattenRegId(id).index());
22912109SRekai.GonzalezAlberquilla@arm.com    }
23012109SRekai.GonzalezAlberquilla@arm.com
23112109SRekai.GonzalezAlberquilla@arm.com    /** Vector Register Lane Interfaces. */
23212109SRekai.GonzalezAlberquilla@arm.com    /** @{ */
23312109SRekai.GonzalezAlberquilla@arm.com    /** Reads source vector 8bit operand. */
23413865Sgabeblack@google.com    ConstVecLane8
23513628SAndrea.Mondelli@ucf.edu    readVec8BitLaneReg(const RegId& id) const override
23612109SRekai.GonzalezAlberquilla@arm.com    {
23712109SRekai.GonzalezAlberquilla@arm.com        return readVecLaneFlat<uint8_t>(flattenRegId(id).index(),
23812109SRekai.GonzalezAlberquilla@arm.com                    id.elemIndex());
23912109SRekai.GonzalezAlberquilla@arm.com    }
24012109SRekai.GonzalezAlberquilla@arm.com
24112109SRekai.GonzalezAlberquilla@arm.com    /** Reads source vector 16bit operand. */
24213865Sgabeblack@google.com    ConstVecLane16
24313628SAndrea.Mondelli@ucf.edu    readVec16BitLaneReg(const RegId& id) const override
24412109SRekai.GonzalezAlberquilla@arm.com    {
24512109SRekai.GonzalezAlberquilla@arm.com        return readVecLaneFlat<uint16_t>(flattenRegId(id).index(),
24612109SRekai.GonzalezAlberquilla@arm.com                    id.elemIndex());
24712109SRekai.GonzalezAlberquilla@arm.com    }
24812109SRekai.GonzalezAlberquilla@arm.com
24912109SRekai.GonzalezAlberquilla@arm.com    /** Reads source vector 32bit operand. */
25013865Sgabeblack@google.com    ConstVecLane32
25113628SAndrea.Mondelli@ucf.edu    readVec32BitLaneReg(const RegId& id) const override
25212109SRekai.GonzalezAlberquilla@arm.com    {
25312109SRekai.GonzalezAlberquilla@arm.com        return readVecLaneFlat<uint32_t>(flattenRegId(id).index(),
25412109SRekai.GonzalezAlberquilla@arm.com                    id.elemIndex());
25512109SRekai.GonzalezAlberquilla@arm.com    }
25612109SRekai.GonzalezAlberquilla@arm.com
25712109SRekai.GonzalezAlberquilla@arm.com    /** Reads source vector 64bit operand. */
25813865Sgabeblack@google.com    ConstVecLane64
25913628SAndrea.Mondelli@ucf.edu    readVec64BitLaneReg(const RegId& id) const override
26012109SRekai.GonzalezAlberquilla@arm.com    {
26112109SRekai.GonzalezAlberquilla@arm.com        return readVecLaneFlat<uint64_t>(flattenRegId(id).index(),
26212109SRekai.GonzalezAlberquilla@arm.com                    id.elemIndex());
26312109SRekai.GonzalezAlberquilla@arm.com    }
26412109SRekai.GonzalezAlberquilla@arm.com
26512109SRekai.GonzalezAlberquilla@arm.com    /** Write a lane of the destination vector register. */
26613865Sgabeblack@google.com    void
26713865Sgabeblack@google.com    setVecLane(const RegId& reg,
26813865Sgabeblack@google.com               const LaneData<LaneSize::Byte>& val) override
26913865Sgabeblack@google.com    {
27013865Sgabeblack@google.com        return setVecLaneFlat(flattenRegId(reg).index(), reg.elemIndex(), val);
27113865Sgabeblack@google.com    }
27213865Sgabeblack@google.com    void
27313865Sgabeblack@google.com    setVecLane(const RegId& reg,
27413865Sgabeblack@google.com               const LaneData<LaneSize::TwoByte>& val) override
27513865Sgabeblack@google.com    {
27613865Sgabeblack@google.com        return setVecLaneFlat(flattenRegId(reg).index(), reg.elemIndex(), val);
27713865Sgabeblack@google.com    }
27813865Sgabeblack@google.com    void
27913865Sgabeblack@google.com    setVecLane(const RegId& reg,
28013865Sgabeblack@google.com               const LaneData<LaneSize::FourByte>& val) override
28113865Sgabeblack@google.com    {
28213865Sgabeblack@google.com        return setVecLaneFlat(flattenRegId(reg).index(), reg.elemIndex(), val);
28313865Sgabeblack@google.com    }
28413865Sgabeblack@google.com    void
28513865Sgabeblack@google.com    setVecLane(const RegId& reg,
28613865Sgabeblack@google.com               const LaneData<LaneSize::EightByte>& val) override
28713865Sgabeblack@google.com    {
28813865Sgabeblack@google.com        return setVecLaneFlat(flattenRegId(reg).index(), reg.elemIndex(), val);
28913865Sgabeblack@google.com    }
29012109SRekai.GonzalezAlberquilla@arm.com    /** @} */
29112109SRekai.GonzalezAlberquilla@arm.com
29213865Sgabeblack@google.com    const VecElem &
29313865Sgabeblack@google.com    readVecElem(const RegId& reg) const override
29413865Sgabeblack@google.com    {
29512109SRekai.GonzalezAlberquilla@arm.com        return readVecElemFlat(flattenRegId(reg).index(), reg.elemIndex());
29612109SRekai.GonzalezAlberquilla@arm.com    }
29712109SRekai.GonzalezAlberquilla@arm.com
29813865Sgabeblack@google.com    const VecPredRegContainer &
29913865Sgabeblack@google.com    readVecPredReg(const RegId& id) const override
30013865Sgabeblack@google.com    {
30113610Sgiacomo.gabrielli@arm.com        return readVecPredRegFlat(flattenRegId(id).index());
30213610Sgiacomo.gabrielli@arm.com    }
30313610Sgiacomo.gabrielli@arm.com
30413865Sgabeblack@google.com    VecPredRegContainer&
30513865Sgabeblack@google.com    getWritableVecPredReg(const RegId& id) override
30613865Sgabeblack@google.com    {
30713610Sgiacomo.gabrielli@arm.com        return getWritableVecPredRegFlat(flattenRegId(id).index());
30813610Sgiacomo.gabrielli@arm.com    }
30913610Sgiacomo.gabrielli@arm.com
31013865Sgabeblack@google.com    RegVal
31113865Sgabeblack@google.com    readCCReg(RegIndex reg_idx) const override
31213622Sgabeblack@google.com    {
31312106SRekai.GonzalezAlberquilla@arm.com        return readCCRegFlat(flattenRegId(RegId(CCRegClass,
31412106SRekai.GonzalezAlberquilla@arm.com                                                 reg_idx)).index());
3159920Syasuko.eckert@amd.com    }
3169920Syasuko.eckert@amd.com
3172817Sksewell@umich.edu    /** Sets an integer register to a value. */
31813865Sgabeblack@google.com    void
31913865Sgabeblack@google.com    setIntReg(RegIndex reg_idx, RegVal val) override
32013557Sgabeblack@google.com    {
32112106SRekai.GonzalezAlberquilla@arm.com        setIntRegFlat(flattenRegId(RegId(IntRegClass, reg_idx)).index(), val);
3229426SAndreas.Sandberg@ARM.com    }
3232817Sksewell@umich.edu
32413865Sgabeblack@google.com    void
32513865Sgabeblack@google.com    setFloatReg(RegIndex reg_idx, RegVal val) override
32613557Sgabeblack@google.com    {
32713611Sgabeblack@google.com        setFloatRegFlat(flattenRegId(RegId(FloatRegClass,
32813611Sgabeblack@google.com                                           reg_idx)).index(), val);
3299426SAndreas.Sandberg@ARM.com    }
3302817Sksewell@umich.edu
33113865Sgabeblack@google.com    void
33213628SAndrea.Mondelli@ucf.edu    setVecReg(const RegId& reg, const VecRegContainer& val) override
33313557Sgabeblack@google.com    {
33412109SRekai.GonzalezAlberquilla@arm.com        setVecRegFlat(flattenRegId(reg).index(), val);
33512109SRekai.GonzalezAlberquilla@arm.com    }
33612109SRekai.GonzalezAlberquilla@arm.com
33713865Sgabeblack@google.com    void
33813628SAndrea.Mondelli@ucf.edu    setVecElem(const RegId& reg, const VecElem& val) override
33913557Sgabeblack@google.com    {
34012109SRekai.GonzalezAlberquilla@arm.com        setVecElemFlat(flattenRegId(reg).index(), reg.elemIndex(), val);
34112109SRekai.GonzalezAlberquilla@arm.com    }
34212109SRekai.GonzalezAlberquilla@arm.com
34313865Sgabeblack@google.com    void
34413610Sgiacomo.gabrielli@arm.com    setVecPredReg(const RegId& reg,
34513628SAndrea.Mondelli@ucf.edu                  const VecPredRegContainer& val) override
34613610Sgiacomo.gabrielli@arm.com    {
34713610Sgiacomo.gabrielli@arm.com        setVecPredRegFlat(flattenRegId(reg).index(), val);
34813610Sgiacomo.gabrielli@arm.com    }
34913610Sgiacomo.gabrielli@arm.com
35013865Sgabeblack@google.com    void
35113865Sgabeblack@google.com    setCCReg(RegIndex reg_idx, RegVal val) override
35213557Sgabeblack@google.com    {
35312106SRekai.GonzalezAlberquilla@arm.com        setCCRegFlat(flattenRegId(RegId(CCRegClass, reg_idx)).index(), val);
3549920Syasuko.eckert@amd.com    }
3559920Syasuko.eckert@amd.com
3567720Sgblack@eecs.umich.edu    /** Reads this thread's PC state. */
35713865Sgabeblack@google.com    TheISA::PCState
35813865Sgabeblack@google.com    pcState() const override
35913865Sgabeblack@google.com    {
36013865Sgabeblack@google.com        return cpu->pcState(thread->threadId());
36113865Sgabeblack@google.com    }
3627720Sgblack@eecs.umich.edu
3637720Sgblack@eecs.umich.edu    /** Sets this thread's PC state. */
36413865Sgabeblack@google.com    void pcState(const TheISA::PCState &val) override;
3657720Sgblack@eecs.umich.edu
36613865Sgabeblack@google.com    void pcStateNoRecord(const TheISA::PCState &val) override;
3678733Sgeoffrey.blake@arm.com
3682817Sksewell@umich.edu    /** Reads this thread's PC. */
36913865Sgabeblack@google.com    Addr
37013865Sgabeblack@google.com    instAddr() const override
37113865Sgabeblack@google.com    {
37213865Sgabeblack@google.com        return cpu->instAddr(thread->threadId());
37313865Sgabeblack@google.com    }
3742817Sksewell@umich.edu
3752817Sksewell@umich.edu    /** Reads this thread's next PC. */
37613865Sgabeblack@google.com    Addr
37713865Sgabeblack@google.com    nextInstAddr() const override
37813865Sgabeblack@google.com    {
37913865Sgabeblack@google.com        return cpu->nextInstAddr(thread->threadId());
38013865Sgabeblack@google.com    }
3812817Sksewell@umich.edu
3827720Sgblack@eecs.umich.edu    /** Reads this thread's next PC. */
38313865Sgabeblack@google.com    MicroPC
38413865Sgabeblack@google.com    microPC() const override
38513865Sgabeblack@google.com    {
38613865Sgabeblack@google.com        return cpu->microPC(thread->threadId());
38713865Sgabeblack@google.com    }
3885259Sksewell@umich.edu
3892817Sksewell@umich.edu    /** Reads a miscellaneous register. */
39013865Sgabeblack@google.com    RegVal
39113865Sgabeblack@google.com    readMiscRegNoEffect(RegIndex misc_reg) const override
39213865Sgabeblack@google.com    {
39313865Sgabeblack@google.com        return cpu->readMiscRegNoEffect(misc_reg, thread->threadId());
39413865Sgabeblack@google.com    }
3954172Ssaidi@eecs.umich.edu
3964172Ssaidi@eecs.umich.edu    /** Reads a misc. register, including any side-effects the
3974172Ssaidi@eecs.umich.edu     * read might have as defined by the architecture. */
39813865Sgabeblack@google.com    RegVal
39913865Sgabeblack@google.com    readMiscReg(RegIndex misc_reg) override
40013865Sgabeblack@google.com    {
40113865Sgabeblack@google.com        return cpu->readMiscReg(misc_reg, thread->threadId());
40213865Sgabeblack@google.com    }
4032817Sksewell@umich.edu
4042817Sksewell@umich.edu    /** Sets a misc. register. */
40513865Sgabeblack@google.com    void setMiscRegNoEffect(RegIndex misc_reg, RegVal val) override;
4062817Sksewell@umich.edu
4072817Sksewell@umich.edu    /** Sets a misc. register, including any side-effects the
4082817Sksewell@umich.edu     * write might have as defined by the architecture. */
40913865Sgabeblack@google.com    void setMiscReg(RegIndex misc_reg, RegVal val) override;
4102817Sksewell@umich.edu
41113865Sgabeblack@google.com    RegId flattenRegId(const RegId& regId) const override;
4126313Sgblack@eecs.umich.edu
4132817Sksewell@umich.edu    /** Returns the number of consecutive store conditional failures. */
4142817Sksewell@umich.edu    // @todo: Figure out where these store cond failures should go.
41513865Sgabeblack@google.com    unsigned
41613865Sgabeblack@google.com    readStCondFailures() const override
41713865Sgabeblack@google.com    {
41813865Sgabeblack@google.com        return thread->storeCondFailures;
41913865Sgabeblack@google.com    }
4202817Sksewell@umich.edu
4212817Sksewell@umich.edu    /** Sets the number of consecutive store conditional failures. */
42213865Sgabeblack@google.com    void
42313865Sgabeblack@google.com    setStCondFailures(unsigned sc_failures) override
42413865Sgabeblack@google.com    {
42513865Sgabeblack@google.com        thread->storeCondFailures = sc_failures;
42613865Sgabeblack@google.com    }
4272817Sksewell@umich.edu
4282817Sksewell@umich.edu    /** Executes a syscall in SE mode. */
42913865Sgabeblack@google.com    void
43013865Sgabeblack@google.com    syscall(int64_t callnum, Fault *fault) override
43113865Sgabeblack@google.com    {
43213865Sgabeblack@google.com        return cpu->syscall(callnum, thread->threadId(), fault);
43313865Sgabeblack@google.com    }
4342817Sksewell@umich.edu
4352817Sksewell@umich.edu    /** Reads the funcExeInst counter. */
43613865Sgabeblack@google.com    Counter readFuncExeInst() const override { return thread->funcExeInst; }
4378777Sgblack@eecs.umich.edu
4385595Sgblack@eecs.umich.edu    /** Returns pointer to the quiesce event. */
43913865Sgabeblack@google.com    EndQuiesceEvent *
44013628SAndrea.Mondelli@ucf.edu    getQuiesceEvent() override
4415595Sgblack@eecs.umich.edu    {
4425595Sgblack@eecs.umich.edu        return this->thread->quiesceEvent;
4435595Sgblack@eecs.umich.edu    }
4449382SAli.Saidi@ARM.com    /** check if the cpu is currently in state update mode and squash if not.
4459382SAli.Saidi@ARM.com     * This function will return true if a trap is pending or if a fault or
4469382SAli.Saidi@ARM.com     * similar is currently writing to the thread context and doesn't want
4479382SAli.Saidi@ARM.com     * reset all the state (see noSquashFromTC).
4489382SAli.Saidi@ARM.com     */
44913557Sgabeblack@google.com    inline void
45013557Sgabeblack@google.com    conditionalSquash()
4519382SAli.Saidi@ARM.com    {
4529382SAli.Saidi@ARM.com        if (!thread->trapPending && !thread->noSquashFromTC)
4539382SAli.Saidi@ARM.com            cpu->squashFromTC(thread->threadId());
4549382SAli.Saidi@ARM.com    }
4555595Sgblack@eecs.umich.edu
45613865Sgabeblack@google.com    RegVal readIntRegFlat(RegIndex idx) const override;
45713865Sgabeblack@google.com    void setIntRegFlat(RegIndex idx, RegVal val) override;
4589426SAndreas.Sandberg@ARM.com
45913865Sgabeblack@google.com    RegVal readFloatRegFlat(RegIndex idx) const override;
46013865Sgabeblack@google.com    void setFloatRegFlat(RegIndex idx, RegVal val) override;
4619920Syasuko.eckert@amd.com
46213865Sgabeblack@google.com    const VecRegContainer& readVecRegFlat(RegIndex idx) const override;
46312109SRekai.GonzalezAlberquilla@arm.com    /** Read vector register operand for modification, flat indexing. */
46413865Sgabeblack@google.com    VecRegContainer& getWritableVecRegFlat(RegIndex idx) override;
46513865Sgabeblack@google.com    void setVecRegFlat(RegIndex idx, const VecRegContainer& val) override;
46612109SRekai.GonzalezAlberquilla@arm.com
46712109SRekai.GonzalezAlberquilla@arm.com    template <typename VecElem>
46813557Sgabeblack@google.com    VecLaneT<VecElem, true>
46913865Sgabeblack@google.com    readVecLaneFlat(RegIndex idx, int lId) const
47012109SRekai.GonzalezAlberquilla@arm.com    {
47112109SRekai.GonzalezAlberquilla@arm.com        return cpu->template readArchVecLane<VecElem>(idx, lId,
47212109SRekai.GonzalezAlberquilla@arm.com                thread->threadId());
47312109SRekai.GonzalezAlberquilla@arm.com    }
47412109SRekai.GonzalezAlberquilla@arm.com
47512109SRekai.GonzalezAlberquilla@arm.com    template <typename LD>
47613865Sgabeblack@google.com    void
47713865Sgabeblack@google.com    setVecLaneFlat(int idx, int lId, const LD& val)
47812109SRekai.GonzalezAlberquilla@arm.com    {
47912109SRekai.GonzalezAlberquilla@arm.com        cpu->template setArchVecLane(idx, lId, thread->threadId(), val);
48012109SRekai.GonzalezAlberquilla@arm.com    }
48112109SRekai.GonzalezAlberquilla@arm.com
48213865Sgabeblack@google.com    const VecElem &readVecElemFlat(RegIndex idx,
48313865Sgabeblack@google.com                                   const ElemIndex& elemIndex) const override;
48413865Sgabeblack@google.com    void setVecElemFlat(RegIndex idx, const ElemIndex& elemIdx,
48513865Sgabeblack@google.com                        const VecElem& val) override;
48612109SRekai.GonzalezAlberquilla@arm.com
48713865Sgabeblack@google.com    const VecPredRegContainer& readVecPredRegFlat(RegIndex idx) const override;
48813865Sgabeblack@google.com    VecPredRegContainer& getWritableVecPredRegFlat(RegIndex idx) override;
48913865Sgabeblack@google.com    void setVecPredRegFlat(RegIndex idx,
49013865Sgabeblack@google.com                           const VecPredRegContainer& val) override;
49113610Sgiacomo.gabrielli@arm.com
49213865Sgabeblack@google.com    RegVal readCCRegFlat(RegIndex idx) const override;
49313865Sgabeblack@google.com    void setCCRegFlat(RegIndex idx, RegVal val) override;
4942817Sksewell@umich.edu};
4952817Sksewell@umich.edu
4962817Sksewell@umich.edu#endif
497