00001 /* 00002 * Copyright (C) 1996-2001, The University of Queensland 00003 * Copyright (C) 2001, Sun Microsystems, Inc 00004 * 00005 * See the file "LICENSE.TERMS" for information on usage and 00006 * redistribution of this file, and for a DISCLAIMER OF ALL 00007 * WARRANTIES. 00008 * 00009 */ 00010 00011 /*============================================================================== 00012 * FILE: sparcdecoder.h 00013 * OVERVIEW: The implementation of the instruction decoder for Sparc. 00014 *============================================================================*/ 00015 00016 /* 00017 * $Revision: 1.7 $ // 1.6.6.2 00018 * 00019 * 06 Jun 02 - Trent: Created. 00020 * 04 Dec 02 - Mike: Added dis_RegLhs() and dis_RegRhs() 00021 */ 00022 00023 #ifndef SPARCDECODER 00024 #define SPARCDECODER 00025 00026 class Prog; 00027 class NJMCDecoder; 00028 struct DecodeResult; 00029 00030 class SparcDecoder : public NJMCDecoder 00031 { 00032 public: 00033 /* Constructor 00034 */ 00035 SparcDecoder(Prog* prog); 00036 00037 00038 /* 00039 * Decodes the machine instruction at pc and returns an RTL instance for 00040 * the instruction. 00041 */ 00042 virtual DecodeResult& decodeInstruction (ADDRESS pc, int delta); 00043 00044 /* 00045 * Disassembles the machine instruction at pc and returns the number of 00046 * bytes disassembled. Assembler output goes to global _assembly 00047 */ 00048 virtual int decodeAssemblyInstruction (ADDRESS pc, int delta); 00049 00050 /* 00051 * Indicates whether the instruction at the given address is a restore instruction. 00052 */ 00053 bool isRestore(ADDRESS hostPC); 00054 private: 00055 /* 00056 * Various functions to decode the operands of an instruction into 00057 * a SemStr representation. 00058 */ 00059 Exp* dis_Eaddr(ADDRESS pc, int size = 0); 00060 Exp* dis_RegImm(ADDRESS pc); 00061 Exp* dis_RegLhs(unsigned r); 00062 Exp* dis_RegRhs(unsigned r); 00063 00064 void unused(int x); 00065 RTL* createBranchRtl(ADDRESS pc, std::list<Statement*>* stmts, const char* name); 00066 bool isFuncPrologue(ADDRESS hostPC); 00067 DWord getDword(ADDRESS lc); 00068 00069 }; 00070 00071 #endif