st20frontend.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1998-2001, The University of Queensland
00003  * Copyright (C) 2000-2001, Sun Microsystems, Inc
00004  * Copyright (C) 2002, Trent Waddington
00005  *
00006  * See the file "LICENSE.TERMS" for information on usage and
00007  * redistribution of this file, and for a DISCLAIMER OF ALL
00008  * WARRANTIES.
00009  *
00010  */
00011 
00012 /*==============================================================================
00013  * FILE:       frontend/sparcfrontend.cpp
00014  * OVERVIEW:   This file contains routines to manage the decoding of sparc
00015  *             instructions and the instantiation to RTLs, removing sparc
00016  *             dependent features such as delay slots in the process. These
00017  *             functions replace Frontend.cc for decoding sparc instructions.
00018  *============================================================================*/
00019 /*
00020  * $Revision: 1.4 $ // 1.2.2.2
00021  */
00022 /*==============================================================================
00023  * Dependencies.
00024  *============================================================================*/
00025 
00026 #include <assert.h>
00027 #include <iomanip>          // For setfill etc
00028 #include <sstream>
00029 #if defined(_MSC_VER) && _MSC_VER <= 1200
00030 #pragma warning(disable:4786)
00031 #endif
00032 
00033 #include "exp.h"
00034 #include "register.h"
00035 #include "rtl.h"
00036 #include "cfg.h"
00037 #include "proc.h"
00038 #include "prog.h"
00039 #include "decoder.h"
00040 #include "st20decoder.h"
00041 #include "BinaryFile.h"
00042 #include "frontend.h"
00043 #include "st20frontend.h"
00044 #include "BinaryFile.h"     // E.g. IsDynamicallyLinkedProc
00045 #include "boomerang.h"
00046 #include "signature.h"
00047 
00048 ST20FrontEnd::ST20FrontEnd(BinaryFile *pBF, Prog* prog, BinaryFileFactory* pbff) : FrontEnd(pBF, prog, pbff) {
00049     decoder = new ST20Decoder();
00050 }
00051 
00052 
00053 // destructor
00054 ST20FrontEnd::~ST20FrontEnd()
00055 {
00056 }
00057 
00058 
00059 std::vector<Exp*> &ST20FrontEnd::getDefaultParams()
00060 {
00061     static std::vector<Exp*> params;
00062     if (params.size() == 0) {
00063 #if 0
00064         for (int r=0; r<=2; r++) {
00065             params.push_back(Location::regOf(r));
00066         }
00067 #endif
00068         params.push_back(Location::memOf(Location::regOf(3)));
00069     }
00070     return params;
00071 }
00072 
00073 std::vector<Exp*> &ST20FrontEnd::getDefaultReturns()
00074 {
00075     static std::vector<Exp*> returns;
00076     if (returns.size() == 0) {
00077         returns.push_back(Location::regOf(0));
00078         returns.push_back(Location::regOf(3));
00079 //      returns.push_back(new Terminal(opPC));
00080     }
00081     return returns;
00082 }
00083 
00084 ADDRESS ST20FrontEnd::getMainEntryPoint( bool &gotMain ) 
00085 {
00086     gotMain = true;
00087     ADDRESS start = pBF->GetMainEntryPoint();
00088     if( start != NO_ADDRESS ) return start;
00089 
00090     start = pBF->GetEntryPoint();
00091     gotMain = false;
00092     if( start == NO_ADDRESS ) return NO_ADDRESS;
00093 
00094     gotMain = true;
00095     return start;
00096 }
00097 
00098 
00099 bool ST20FrontEnd::processProc(ADDRESS uAddr, UserProc* pProc, std::ofstream &os, bool frag /* = false */,
00100         bool spec /* = false */) {
00101 
00102     // Call the base class to do most of the work
00103     if (!FrontEnd::processProc(uAddr, pProc, os, frag, spec))
00104         return false;
00105     // This will get done twice; no harm
00106     pProc->setEntryBB();
00107 
00108     return true;
00109 }

Generated on Tue Sep 19 21:18:33 2006 for Boomerang by  doxygen 1.4.6