00001 #define TV_A_COLOR "black" 00002 #define TV_T_COLOR "darkgreen" 00003 #define TV_F_COLOR "red" 00004 #define TV_ANY_COLOR "magenta" 00005 00006 #define HOST_BORDER_COLOR "black" 00007 #define GUEST_BORDER_COLOR "blue" 00008 #define NRT_GUEST_COLOR "lightyellow" 00009 #define RT_GUEST_COLOR "yellow" 00010 #define HOST_BORDER_WIDTH 2 00011 #define GUEST_BORDER_WIDTH 6 00012 00013 #define PADDING_COLOR "lightgrey" 00014 #define GUARD_COLOR "purple" 00015 #define FUSION_COLOR "lightgreen" 00016 #define COCALL_COLOR "lightmagenta" 00017 00018 00019 #define CODE_COLOR "white" 00020 #define LOOP_COLOR "lightred" 00021 #define BIO_LOOP_COLOR "red" 00022 #define IRRLOOP_COLOR "magenta" 00023 #define PRED_COLOR "cyan" 00024 #define CALL_COLOR "magenta" 00025 #define PROC_COLOR "lightblue" 00026 #define MULTIPRED_COLOR "magenta" 00027 00028 #define VCG_CM_BLACK 31 00029 #define NUM_CM_ENTRIES 32 00030 00031 #include "integrate.h" 00032 00033 class CInstrumentation { 00034 private: 00035 int orig_instr_cnt, reg_alloc_instr_cnt, integration_instr_cnt, 00036 code_gen_instr_cnt, final_instr_cnt, prev; 00037 CTimeRange orig_duration, final_duration; 00038 public: 00039 CInstrumentation( void ) { 00040 orig_instr_cnt = reg_alloc_instr_cnt = integration_instr_cnt = 00041 code_gen_instr_cnt = prev = 0; 00042 // durations should be initalized automatically in constructor 00043 } 00044 void Mark_Original_Code_Loaded() { 00045 orig_instr_cnt = instructions_created; 00046 }; 00047 00048 void Mark_Host_STA_Done(CTimeRange * dur) { 00049 orig_duration.Set(dur); 00050 prev = instructions_created; 00051 }; 00052 void Mark_Regs_Reallocated( void ) { 00053 reg_alloc_instr_cnt = instructions_created - prev; 00054 prev = instructions_created; 00055 }; 00056 void Mark_Integration_Done( void ) { 00057 integration_instr_cnt = instructions_created - prev 00058 - padding_instructions_created 00059 - instructions_destroyed; 00060 prev = instructions_created - instructions_destroyed; 00061 }; 00062 void Mark_Code_Generated( CTimeRange * dur ) { 00063 final_duration.Set(dur); 00064 code_gen_instr_cnt = instructions_created - prev; 00065 final_instr_cnt = instructions_created; 00066 }; 00067 void Dump( void ) { 00068 cout << "Original instruction count " << orig_instr_cnt << endl; 00069 cout << "Register allocation instrs " << reg_alloc_instr_cnt << endl; 00070 cout << "Integration instrs " << integration_instr_cnt << endl; 00071 cout << "Padding instrs " << padding_instructions_created << endl; 00072 cout << "Code generation instrs " << code_gen_instr_cnt << endl; 00073 cout << "Final instruction count " << final_instr_cnt << endl; 00074 00075 cout << "Original duration " << orig_duration.Get_Best() 00076 << " " << orig_duration.Get_Worst() << endl; 00077 cout << "Final duration " << final_duration.Get_Best() 00078 << " " << final_duration.Get_Worst() << endl; 00079 }; 00080 void Log( CIntegrationData * id ) { 00081 // Note: lame version! only does the first guest directive! 00082 // And it doesn't handle loops! 00083 char fname[LONG_STR_SIZE]; 00084 strcpy(fname, root_filename); 00085 strcat(fname, ".instlog"); 00086 ofstream log_stream; 00087 log_stream.open(fname, ios::app); 00088 if (!log_stream) { 00089 cout << "unable to open file " << fname << " for logging\n"; 00090 exit (EXIT_FAILURE); 00091 } 00092 00093 CGuestDir * gd = id->Get_IntDir(); 00094 if (!gd) 00095 return; 00096 log_stream << "*** "; 00097 // Info on target times, tols 00098 if (gd->Is_Loop()) 00099 log_stream << " ta " << 0 << " to " << 0; 00100 else 00101 log_stream << " ta " << gd->Get_StartCy() 00102 << " to " << gd->Get_Tolerance(); 00103 00104 // Info on instruction counts 00105 log_stream << " o " << orig_instr_cnt 00106 << " r " << reg_alloc_instr_cnt 00107 << " i " << integration_instr_cnt 00108 << " p " << padding_instructions_created 00109 << " g " << code_gen_instr_cnt 00110 << " f " << final_instr_cnt; 00111 // Info on durations 00112 log_stream << " od " << orig_duration.Get_Best() << " " 00113 << orig_duration.Get_Worst() 00114 << " fd " << final_duration.Get_Best() << " " 00115 << final_duration.Get_Worst(); 00116 log_stream << endl; 00117 log_stream.close(); 00118 }; 00119 };
1.3.6