utility.hh revision 3120
12447SN/A/* 22447SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32447SN/A * All rights reserved. 42447SN/A * 52447SN/A * Redistribution and use in source and binary forms, with or without 62447SN/A * modification, are permitted provided that the following conditions are 72447SN/A * met: redistributions of source code must retain the above copyright 82447SN/A * notice, this list of conditions and the following disclaimer; 92447SN/A * redistributions in binary form must reproduce the above copyright 102447SN/A * notice, this list of conditions and the following disclaimer in the 112447SN/A * documentation and/or other materials provided with the distribution; 122447SN/A * neither the name of the copyright holders nor the names of its 132447SN/A * contributors may be used to endorse or promote products derived from 142447SN/A * this software without specific prior written permission. 152447SN/A * 162447SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172447SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182447SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192447SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202447SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212447SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222447SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232447SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242447SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252447SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262447SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272632Sstever@eecs.umich.edu * 282632Sstever@eecs.umich.edu * Authors: Nathan Binkert 292632Sstever@eecs.umich.edu * Steve Reinhardt 302447SN/A */ 312447SN/A 322447SN/A#ifndef __ARCH_MIPS_UTILITY_HH__ 332447SN/A#define __ARCH_MIPS_UTILITY_HH__ 342447SN/A 352597SN/A#include "arch/mips/types.hh" 362597SN/A#include "base/misc.hh" 372980Sgblack@eecs.umich.edu#include "config/full_system.hh" 383120Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 392972Sgblack@eecs.umich.edu//XXX This is needed for size_t. We should use something other than size_t 402980Sgblack@eecs.umich.edu//#include "kern/linux/linux.hh" 412597SN/A#include "sim/host.hh" 422597SN/A 432980Sgblack@eecs.umich.educlass ThreadContext; 442980Sgblack@eecs.umich.edu 452597SN/Anamespace MipsISA { 462597SN/A 472686Sksewell@umich.edu //Floating Point Utility Functions 482686Sksewell@umich.edu uint64_t fpConvert(ConvertType cvt_type, double fp_val); 492686Sksewell@umich.edu double roundFP(double val, int digits); 502686Sksewell@umich.edu double truncFP(double val); 512686Sksewell@umich.edu 522686Sksewell@umich.edu bool getCondCode(uint32_t fcsr, int cc); 532686Sksewell@umich.edu uint32_t genCCVector(uint32_t fcsr, int num, uint32_t cc_val); 542686Sksewell@umich.edu uint32_t genInvalidVector(uint32_t fcsr); 552686Sksewell@umich.edu 562686Sksewell@umich.edu bool isNan(void *val_ptr, int size); 572686Sksewell@umich.edu bool isQnan(void *val_ptr, int size); 582686Sksewell@umich.edu bool isSnan(void *val_ptr, int size); 592972Sgblack@eecs.umich.edu 602972Sgblack@eecs.umich.edu /** 612972Sgblack@eecs.umich.edu * Function to insure ISA semantics about 0 registers. 622972Sgblack@eecs.umich.edu * @param tc The thread context. 632972Sgblack@eecs.umich.edu */ 642972Sgblack@eecs.umich.edu template <class TC> 652972Sgblack@eecs.umich.edu void zeroRegisters(TC *tc); 662972Sgblack@eecs.umich.edu 672972Sgblack@eecs.umich.edu void copyRegs(ThreadContext *src, ThreadContext *dest); 682972Sgblack@eecs.umich.edu 692972Sgblack@eecs.umich.edu // Instruction address compression hooks 702972Sgblack@eecs.umich.edu static inline Addr realPCToFetchPC(const Addr &addr) { 712972Sgblack@eecs.umich.edu return addr; 722972Sgblack@eecs.umich.edu } 732972Sgblack@eecs.umich.edu 742972Sgblack@eecs.umich.edu static inline Addr fetchPCToRealPC(const Addr &addr) { 752972Sgblack@eecs.umich.edu return addr; 762972Sgblack@eecs.umich.edu } 772972Sgblack@eecs.umich.edu 782972Sgblack@eecs.umich.edu // the size of "fetched" instructions (not necessarily the size 792972Sgblack@eecs.umich.edu // of real instructions for PISA) 802972Sgblack@eecs.umich.edu static inline size_t fetchInstSize() { 812972Sgblack@eecs.umich.edu return sizeof(MachInst); 822972Sgblack@eecs.umich.edu } 832972Sgblack@eecs.umich.edu 842972Sgblack@eecs.umich.edu static inline MachInst makeRegisterCopy(int dest, int src) { 852972Sgblack@eecs.umich.edu panic("makeRegisterCopy not implemented"); 862972Sgblack@eecs.umich.edu return 0; 872972Sgblack@eecs.umich.edu } 882972Sgblack@eecs.umich.edu 892972Sgblack@eecs.umich.edu static inline ExtMachInst 903120Sgblack@eecs.umich.edu makeExtMI(MachInst inst, ThreadContext * xc) { 912972Sgblack@eecs.umich.edu#if FULL_SYSTEM 922972Sgblack@eecs.umich.edu ExtMachInst ext_inst = inst; 933120Sgblack@eecs.umich.edu if (xc->readPC() && 0x1) 943120Sgblack@eecs.umich.edu return ext_inst|=(static_cast<ExtMachInst>(xc->readPC() & 0x1) << 32); 952972Sgblack@eecs.umich.edu else 962972Sgblack@eecs.umich.edu return ext_inst; 972972Sgblack@eecs.umich.edu#else 982972Sgblack@eecs.umich.edu return ExtMachInst(inst); 992972Sgblack@eecs.umich.edu#endif 1002972Sgblack@eecs.umich.edu } 1012597SN/A}; 1022447SN/A 1032686Sksewell@umich.edu 1042447SN/A#endif 105