// Branch.h #ifndef BRANCH_H #define BRANCH_H #include #include typedef unsigned int uint32; /* "Branch" -- Branch Branches as seen by a Consumer and Produced by a Producer are of type Branch. */ class Branch { public: enum BRANCH_TYPE { UNCONDITIONAL, CONDITIONAL, INDIRECT, VIRTUAL, RETURN, SWITCH, // JMP on sparc UNDEFINED // keep this one last }; #define NR_OF_BRANCHTYPES (Branch::UNDEFINED + 1) enum OUTCOME { TAKEN, NOT_TAKEN, UNDEF }; char * name(); static char * typeName(BRANCH_TYPE t); virtual void writeOneLineText (FILE * f); Branch::Branch(); // Wrapping all data per-struct allows for easy // computation of starting-address/length. (note that there is // no current requirement for this, but it is here // for flexibility. // struct data { uint32 address; /* branch address */ uint32 target; /* effective target address */ Branch::BRANCH_TYPE type; /* type of branch */ Branch::OUTCOME prediction; /* prediction bit */ Branch::OUTCOME outcome; /* branch outcome */ }; struct data d; // the data-to-write }; // frequency and sparccode added class RichBranch: public Branch { public: RichBranch::RichBranch(); struct rdata { uint32 address; /* branch address */ uint32 target; /* effective target address */ uint32 sparccode; /* sparc instruction code */ uint32 frequency; /* nr of times executed */ Branch::BRANCH_TYPE type; /* type of branch */ Branch::OUTCOME prediction; /* prediction bit */ Branch::OUTCOME outcome; /* branch outcome */ }; struct profdata { uint32 frequency; // # executions of this branch uint32 switchfreq; // # times branch target switches uint32 nrTargets; // # different targets of the branch }; virtual void writeOneLineText (FILE * f); struct rdata d; // the data-to-write struct profdata p; // the profile-data-to-write }; char * branchTypeName(Branch::BRANCH_TYPE t); #endif /* BRANCH_H */