isa.cc revision 6313:95f69a436c82
12381SN/A/*
28853Sandreas.hansson@arm.com * Copyright (c) 2009 The Regents of The University of Michigan
38711Sandreas.hansson@arm.com * All rights reserved.
48711Sandreas.hansson@arm.com *
58711Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
68711Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
78711Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
88711Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
98711Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
108711Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
118711Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
128711Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
138711Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
142381SN/A * this software without specific prior written permission.
152381SN/A *
162381SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272381SN/A *
282381SN/A * Authors: Gabe Black
292381SN/A */
302381SN/A
312381SN/A#include "arch/x86/isa.hh"
322381SN/A#include "arch/x86/floatregs.hh"
332381SN/A#include "cpu/thread_context.hh"
342381SN/A
352381SN/Anamespace X86ISA
362381SN/A{
372381SN/A
382381SN/Avoid
392665Ssaidi@eecs.umich.eduISA::clear()
402665Ssaidi@eecs.umich.edu{
418853Sandreas.hansson@arm.com    miscRegFile.clear();
428922Swilliam.wang@arm.com}
432381SN/A
442381SN/AMiscReg
452381SN/AISA::readMiscRegNoEffect(int miscReg)
462381SN/A{
478922Swilliam.wang@arm.com    return miscRegFile.readRegNoEffect((MiscRegIndex)miscReg);
482381SN/A}
492381SN/A
502381SN/AMiscReg
512381SN/AISA::readMiscReg(int miscReg, ThreadContext *tc)
522381SN/A{
532381SN/A    return miscRegFile.readReg((MiscRegIndex)miscReg, tc);
542381SN/A}
552381SN/A
562381SN/Avoid
572381SN/AISA::setMiscRegNoEffect(int miscReg, const MiscReg val)
588922Swilliam.wang@arm.com{
598922Swilliam.wang@arm.com    miscRegFile.setRegNoEffect((MiscRegIndex)miscReg, val);
602407SN/A}
612407SN/A
622407SN/Avoid
632407SN/AISA::setMiscReg(int miscReg, const MiscReg val, ThreadContext *tc)
642407SN/A{
652407SN/A    miscRegFile.setReg((MiscRegIndex)miscReg, val, tc);
662521SN/A}
672407SN/A
683401Sktlim@umich.eduint
693401Sktlim@umich.eduISA::flattenIntIndex(int reg)
702381SN/A{
718922Swilliam.wang@arm.com    //If we need to fold over the index to match byte semantics, do that.
728922Swilliam.wang@arm.com    //Otherwise, just strip off any extra bits and pass it through.
739087Sandreas.hansson@arm.com    if (reg & (1 << 6))
742381SN/A        return (reg & (~(1 << 6) - 0x4));
758708Sandreas.hansson@arm.com    else
762381SN/A        return (reg & ~(1 << 6));
778922Swilliam.wang@arm.com}
788922Swilliam.wang@arm.com
798922Swilliam.wang@arm.comint
808922Swilliam.wang@arm.comISA::flattenFloatIndex(int reg)
818922Swilliam.wang@arm.com{
828922Swilliam.wang@arm.com    if (reg >= NUM_FLOATREGS) {
835476Snate@binkert.org        int top = miscRegFile.readRegNoEffect(MISCREG_X87_TOP);
842640Sstever@eecs.umich.edu        reg = FLOATREG_STACK(reg - NUM_FLOATREGS, top);
858965Sandreas.hansson@arm.com    }
868965Sandreas.hansson@arm.com    return reg;
879031Sandreas.hansson@arm.com}
888965Sandreas.hansson@arm.com
899031Sandreas.hansson@arm.comvoid
908965Sandreas.hansson@arm.comISA::serialize(EventManager *em, std::ostream &os)
918922Swilliam.wang@arm.com{
928922Swilliam.wang@arm.com    miscRegFile.serialize(os);
938922Swilliam.wang@arm.com}
948922Swilliam.wang@arm.com
958922Swilliam.wang@arm.comvoid
968922Swilliam.wang@arm.comISA::unserialize(EventManager *em, Checkpoint *cp, const std::string &section)
978922Swilliam.wang@arm.com{
988922Swilliam.wang@arm.com    miscRegFile.unserialize(cp, section);
998965Sandreas.hansson@arm.com}
1008922Swilliam.wang@arm.com
1019031Sandreas.hansson@arm.com}
1028922Swilliam.wang@arm.com