00001
00002 #ifndef SPARCFRONTEND_H
00003 #define SPARCFRONTEND_H
00004
00005
00006
00007
00008 #include <set>
00009 #include "decoder.h"
00010 #include "exp.h"
00011 #include "frontend.h"
00012
00013 class FrontEnd;
00014 class SparcDecoder;
00015 struct DecodeResult;
00016 class CallStatement;
00017
00018 class SparcFrontEnd : public FrontEnd
00019 {
00020 public:
00021
00022
00023
00024 SparcFrontEnd(BinaryFile *pBF, Prog* prog, BinaryFileFactory* pbff);
00025
00026
00027
00028
00029 virtual ~SparcFrontEnd();
00030
00031 virtual platform getFrontEndId() { return PLAT_SPARC; }
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 virtual bool processProc(ADDRESS uAddr, UserProc* pProc, std::ofstream &os,
00044 bool frag = false, bool spec = false);
00045
00046 virtual std::vector<Exp*> &getDefaultParams();
00047 virtual std::vector<Exp*> &getDefaultReturns();
00048
00049 virtual ADDRESS getMainEntryPoint( bool &gotMain );
00050
00051 private:
00052
00053 void warnDCTcouple(ADDRESS uAt, ADDRESS uDest);
00054 bool optimise_DelayCopy(ADDRESS src, ADDRESS dest, int delta,
00055 ADDRESS uUpper);
00056 BasicBlock* optimise_CallReturn(CallStatement* call, RTL* rtl, RTL* delay, UserProc* pProc);
00057
00058 void handleBranch(ADDRESS dest, ADDRESS hiAddress, BasicBlock*& newBB, Cfg* cfg, TargetQueue& tq);
00059 void handleCall(UserProc *proc, ADDRESS dest, BasicBlock* callBB, Cfg* cfg, ADDRESS address, int offset = 0);
00060
00061 void case_unhandled_stub(ADDRESS addr);
00062
00063 bool case_CALL(ADDRESS& address, DecodeResult& inst, DecodeResult& delay_inst, std::list<RTL*>*& BB_rtls,
00064 UserProc* proc, std::list<CallStatement*>& callList, std::ofstream &os, bool isPattern = false);
00065
00066 void case_SD(ADDRESS& address, int delta, ADDRESS hiAddress, DecodeResult& inst, DecodeResult& delay_inst,
00067 std::list<RTL*>*& BB_rtls, Cfg* cfg, TargetQueue& tq, std::ofstream &os);
00068
00069 bool case_DD(ADDRESS& address, int delta, DecodeResult& inst, DecodeResult& delay_inst,
00070 std::list<RTL*>*& BB_rtls, TargetQueue& tq, UserProc* proc, std::list<CallStatement*>& callList);
00071
00072 bool case_SCD(ADDRESS& address, int delta, ADDRESS hiAddress, DecodeResult& inst, DecodeResult& delay_inst,
00073 std::list<RTL*>*& BB_rtls, Cfg* cfg, TargetQueue& tq);
00074
00075 bool case_SCDAN(ADDRESS& address, int delta, ADDRESS hiAddress, DecodeResult& inst, DecodeResult& delay_inst,
00076 std::list<RTL*>*& BB_rtls, Cfg* cfg, TargetQueue& tq);
00077
00078 void emitNop(std::list<RTL*>* pRtls, ADDRESS uAddr);
00079 void emitCopyPC(std::list<RTL*>* pRtls, ADDRESS uAddr);
00080 unsigned fetch4(unsigned char* ptr);
00081 void appendAssignment(Exp* lhs, Exp* rhs, Type* type, ADDRESS addr, std::list<RTL*>* lrtl);
00082 void quadOperation(ADDRESS addr, std::list<RTL*>* lrtl, OPER op);
00083
00084 bool helperFunc(ADDRESS dest, ADDRESS addr, std::list<RTL*>* lrtl);
00085 void gen32op32gives64(OPER op, std::list<RTL*>* lrtl, ADDRESS addr);
00086 bool helperFuncLong(ADDRESS dest, ADDRESS addr, std::list<RTL*>* lrtl, std::string& name);
00087
00088
00089
00090 DecodeResult nop_inst;
00091
00092 };
00093
00094 #endif