utility.hh revision 3278
12SN/A/* 21762SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292665Ssaidi@eecs.umich.edu */ 302SN/A 312SN/A#ifndef __ARCH_SPARC_UTILITY_HH__ 322SN/A#define __ARCH_SPARC_UTILITY_HH__ 332SN/A 342SN/A#include "arch/sparc/isa_traits.hh" 352SN/A#include "base/misc.hh" 362SN/A#include "base/bitfield.hh" 372432SN/A#include "cpu/thread_context.hh" 381147SN/A 393453Sgblack@eecs.umich.edunamespace SparcISA 402984Sgblack@eecs.umich.edu{ 412984Sgblack@eecs.umich.edu inline ExtMachInst 421147SN/A makeExtMI(MachInst inst, ThreadContext * xc) { 432517SN/A ExtMachInst emi = (unsigned MachInst) inst; 442984Sgblack@eecs.umich.edu //The I bit, bit 13, is used to figure out where the ASI 4556SN/A //should come from. Use that in the ExtMachInst. This is 462SN/A //slightly redundant, but it removes the need to put a condition 472680Sktlim@umich.edu //into all the execute functions 482SN/A if(inst & (1 << 13)) 493453Sgblack@eecs.umich.edu emi |= (static_cast<ExtMachInst>(xc->readMiscReg(MISCREG_ASI)) 502SN/A << (sizeof(MachInst) * 8)); 515004Sgblack@eecs.umich.edu else 522SN/A emi |= (static_cast<ExtMachInst>(bits(inst, 12, 5)) 533453Sgblack@eecs.umich.edu << (sizeof(MachInst) * 8)); 543453Sgblack@eecs.umich.edu return emi; 553453Sgblack@eecs.umich.edu } 563453Sgblack@eecs.umich.edu 575004Sgblack@eecs.umich.edu inline bool isCallerSaveIntegerRegister(unsigned int reg) { 582SN/A panic("register classification not implemented"); 595004Sgblack@eecs.umich.edu return false; 605004Sgblack@eecs.umich.edu } 615004Sgblack@eecs.umich.edu 622SN/A inline bool isCalleeSaveIntegerRegister(unsigned int reg) { 633453Sgblack@eecs.umich.edu panic("register classification not implemented"); 645004Sgblack@eecs.umich.edu return false; 652SN/A } 663453Sgblack@eecs.umich.edu 673453Sgblack@eecs.umich.edu inline bool isCallerSaveFloatRegister(unsigned int reg) { 683453Sgblack@eecs.umich.edu panic("register classification not implemented"); 692SN/A return false; 703453Sgblack@eecs.umich.edu } 712SN/A 725004Sgblack@eecs.umich.edu inline bool isCalleeSaveFloatRegister(unsigned int reg) { 735004Sgblack@eecs.umich.edu panic("register classification not implemented"); 742SN/A return false; 753453Sgblack@eecs.umich.edu } 763453Sgblack@eecs.umich.edu 773453Sgblack@eecs.umich.edu // Instruction address compression hooks 782SN/A inline Addr realPCToFetchPC(const Addr &addr) 793453Sgblack@eecs.umich.edu { 803453Sgblack@eecs.umich.edu return addr; 813453Sgblack@eecs.umich.edu } 823453Sgblack@eecs.umich.edu 833453Sgblack@eecs.umich.edu inline Addr fetchPCToRealPC(const Addr &addr) 843453Sgblack@eecs.umich.edu { 852SN/A return addr; 863453Sgblack@eecs.umich.edu } 872SN/A 883453Sgblack@eecs.umich.edu // the size of "fetched" instructions (not necessarily the size 893453Sgblack@eecs.umich.edu // of real instructions for PISA) 903453Sgblack@eecs.umich.edu inline size_t fetchInstSize() 914957Sacolyte@umich.edu { 924957Sacolyte@umich.edu return sizeof(MachInst); 935004Sgblack@eecs.umich.edu } 945004Sgblack@eecs.umich.edu 955004Sgblack@eecs.umich.edu /** 965004Sgblack@eecs.umich.edu * Function to insure ISA semantics about 0 registers. 975004Sgblack@eecs.umich.edu * @param tc The thread context. 985004Sgblack@eecs.umich.edu */ 995004Sgblack@eecs.umich.edu template <class TC> 1005004Sgblack@eecs.umich.edu void zeroRegisters(TC *tc); 1015004Sgblack@eecs.umich.edu 1025004Sgblack@eecs.umich.edu} // namespace SparcISA 1035004Sgblack@eecs.umich.edu 1044967Sacolyte@umich.edu#endif 1053453Sgblack@eecs.umich.edu