ppcfrontend.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  * Dependencies.
00021  *============================================================================*/
00022 
00023 #include <assert.h>
00024 #include <iomanip>          // For setfill etc
00025 #include <sstream>
00026 #if defined(_MSC_VER) && _MSC_VER <= 1200
00027 #pragma warning(disable:4786)
00028 #endif
00029 
00030 #include "exp.h"
00031 #include "register.h"
00032 #include "rtl.h"
00033 #include "cfg.h"
00034 #include "proc.h"
00035 #include "prog.h"
00036 #include "decoder.h"
00037 #include "ppcdecoder.h"
00038 #include "BinaryFile.h"
00039 #include "frontend.h"
00040 #include "ppcfrontend.h"
00041 #include "BinaryFile.h"     // E.g. IsDynamicallyLinkedProc
00042 #include "boomerang.h"
00043 #include "signature.h"
00044 
00045 PPCFrontEnd::PPCFrontEnd(BinaryFile *pBF, Prog* prog, BinaryFileFactory* pbff) : FrontEnd(pBF, prog, pbff)
00046 {
00047     decoder = new PPCDecoder(prog);
00048 }
00049 
00050 
00051 // destructor
00052 PPCFrontEnd::~PPCFrontEnd()
00053 {
00054 }
00055 
00056 
00057 std::vector<Exp*> &PPCFrontEnd::getDefaultParams()
00058 {
00059     static std::vector<Exp*> params;
00060     if (params.size() == 0) {
00061         for (int r=31; r>=0; r--) {
00062             params.push_back(Location::regOf(r));
00063         }
00064     }
00065     return params;
00066 }
00067 
00068 std::vector<Exp*> &PPCFrontEnd::getDefaultReturns()
00069 {
00070     static std::vector<Exp*> returns;
00071     if (returns.size() == 0) {
00072         for (int r=31; r>=0; r--) {
00073             returns.push_back(Location::regOf(r));
00074         }
00075 
00076     }
00077     return returns;
00078 }
00079 
00080 ADDRESS PPCFrontEnd::getMainEntryPoint( bool &gotMain ) 
00081 {
00082     gotMain = true;
00083     ADDRESS start = pBF->GetMainEntryPoint();
00084     if( start != NO_ADDRESS ) return start;
00085 
00086     start = pBF->GetEntryPoint();
00087     gotMain = false;
00088     if( start == NO_ADDRESS ) return NO_ADDRESS;
00089 
00090     gotMain = true;
00091     return start;
00092 }
00093 
00094 
00095 bool PPCFrontEnd::processProc(ADDRESS uAddr, UserProc* pProc, std::ofstream &os, bool frag /* = false */,
00096         bool spec /* = false */) {
00097 
00098     // Call the base class to do most of the work
00099     if (!FrontEnd::processProc(uAddr, pProc, os, frag, spec))
00100         return false;
00101     // This will get done twice; no harm
00102     pProc->setEntryBB();
00103 
00104     return true;
00105 }

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