// PReadCompressedTrace.h #ifndef PREADCOMPRESSEDTRACE_H #define PREADCOMPRESSEDTRACE_H extern "C" { #include } #include "driver.h" #include "Branch.h" #include "traceFile.h" #include "BranchProducer.h" #include "HashedBranch2uint16.h" /* This class supports the BranchProducer interface by implementing the getNextBranch() method. PReadCompressedTrace is the class that reads a compressed RichBranch trace file representation. This representation consists of a pair of files, .map and .br. .map holds the correspondences between BRANCH:data and a unique id (Index). The .br file is a series of "logical Branch's", except that each BRANCH:data is actually represented by an Index, and not a real BRANCH:data. PReadCompressedTrace internalizes the .map file, and then sequentially Reads from the .br file, translating an Index into the associated BRANCH:data. */ class PReadCompressedTrace : public BranchProducer { private: FILE *openTraceFile(char *, char *); void readMap(); void readProf(); Bool profileAvailable; // if no profile, fill in 0 HashedBranch2uint16::elementType * branchdataMap; RichBranch::profdata * branchprofMap; //to insure backward compatibility w old (no sparccode, no frequeny) traces Bool oldData; // do we have an old trace ? HashedBranch2uint16::oldElementType * oldBranchdataMap; uint32 lowLimit; uint32 highLimit; uint32 branchesPassed; // matches index to branchdata uint32 nr_of_branches; // nr of branches in trace uint16 nr_of_branchindices; // nr of different indices trace uint16 * branchTrace; // the branchtrace indices char *fTraceFile; // root name of trace file FILE *branchStream;// stream for .br file RichBranch result; bool traceFromStdin; uint32 expectedNrOfBranches; public: HashedBranch2uint16::elementType * getBranchdataMap(); uint16 getNrOfTargets(); // traceFile is of the file pair .br // and .map. PReadCompressedTrace(char *traceFile, uint32 lowLimit, uint32 highLimit, bool traceFromStdin); virtual ~PReadCompressedTrace(); void init(); // ignore all except indirect branches // (inherited functionality, not implemented) void traceIndirectBranches(); // trace all branches void traceAllBranches(); // trace all instructoins void traceAllInstructions(); void start(); virtual RichBranch *getNextBranch(); //virtual int getNextNBranch(); /* get n branches */ void end(); }; #endif // PREADCOMPRESSEDTRACE_H