00001
00002 #ifndef INSTRUCTIONINFO_H
00003 #define INSTRUCTIONINFO_H
00004
00005 #include <OpteronDefs.h>
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 class InstructionInfo
00016 {
00017 public:
00018 enum OperandSize { OPSIZE8 = 1, OPSIZE16 = 2, OPSIZE32 = 4, OPSIZE64 = 8, OPSIZE128 = 16 };
00019 enum DataDirection {
00020 IREG2IREG = 1, IREG2MEM = 2, IREG2FREG = 4,
00021 FREG2FREG = 8, FREG2MEM = 16, FREG2IREG = 32,
00022 MEM2IREG = 64, MEM2MEM = 128, MEM2FREG = 256 };
00023
00024 InstructionInfo();
00025 ~InstructionInfo();
00026 void dumpDebugInfo();
00027 void initStaticInfo(char *name, char *operands, char *operation, char *decodeUnit,
00028 char *execUnits, char *category);
00029 void initTimings(unsigned int baseLatency, unsigned int memLatency,
00030 unsigned int throughputNum, unsigned int throughputDem);
00031 void initProbabilities(double occurProb, double loadProb, double storeProb,
00032 double useHistogram[]);
00033 void accumProbabilities(double occurProb, unsigned long long occurs,
00034 unsigned long long loads, unsigned long long stores,
00035 double useHistogram[]);
00036 InstructionInfo* findInstructionRecord(const char *mnemonic, unsigned int iOpSize);
00037 unsigned int getUseDistance(double prob);
00038 bool isConditionalJump() {return conditionalJump;}
00039 char* getName() {return name;}
00040 InstructionInfo* getNext() {return next;}
00041 void setNext(InstructionInfo *other) {next = other;}
00042 Category getCategory() {return category;}
00043 unsigned int getLatency() {return latency;}
00044 double getOccurProb() {return occurProbability;}
00045 double getLoadProb() {return loadProbability;}
00046 double getStoreProb() {return storeProbability;}
00047 bool handlesLoad() {return (allowedDataDirs & (MEM2IREG|MEM2MEM|MEM2FREG)) != 0;}
00048 bool handlesStore() {return (allowedDataDirs & (IREG2MEM|FREG2MEM|MEM2MEM)) != 0;}
00049 bool needsLoadAddress() {return (!stackOp || loadProbability < 0.99);}
00050 bool needsStoreAddress() {return (!stackOp || storeProbability < 0.99);}
00051 bool needsFunctionalUnit(FunctionalUnitTypes fut) { return (execUnitMask & fut);}
00052 bool isFPUInstruction() {return execUnitMask & (FADD|FMUL|FSTORE);}
00053 unsigned long long getSimulationCount() {return actualOccurs;}
00054 void incSimulationCount() {actualOccurs++;}
00055 unsigned int throughput() {return throughputDem;}
00056 static InstructionInfo* createFromString(char* infoString);
00057 private:
00058 char* operands;
00059 char* operation;
00060 char* decodeUnit;
00061 char* execUnits;
00062
00063 Category category;
00064 double occurProbability;
00065 double loadProbability;
00066 double storeProbability;
00067 char *name;
00068 unsigned long long actualOccurs;
00069 unsigned long execUnitMask;
00070 unsigned int latency;
00071 unsigned int throughputDem;
00072 bool stackOp;
00073 bool conditionalJump;
00074
00075 unsigned int opSize;
00076 unsigned int allowedDataDirs;
00077 unsigned long long totalOccurs;
00078 unsigned int memLatency;
00079 unsigned int throughputNum;
00080 double toUseHistogram[HISTOGRAMSIZE];
00081 class InstructionInfo *next;
00082 };
00083
00084 #endif