00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef LEGORFORM_HYPERBLOCK_HEADER
00010 #define LEGORFORM_HYPERBLOCK_HEADER
00011
00012 #include <values.h>
00013 #include "TinkerKnobs.H"
00014
00015
00016
00017
00018
00019
00020
00021 class hyper_stats
00022 {
00023
00024 #ifndef WTSIZE
00025 #define WTSIZE (10000)
00026 #endif
00027
00028 struct idpair
00029 {
00030 int i;
00031 double d;
00032 };
00033
00034 public:
00035 char *filename;
00036 long super_count;
00037 long td_count;
00038 struct idpair td_stats[WTSIZE];
00039 long op_count;
00040 struct idpair op_stats[WTSIZE];
00041 double total_weight;
00042
00043
00044 hyper_stats (char *fn)
00045 {
00046 int i;
00047
00048 filename = new char [strlen (fn) + 1];
00049 strcpy (filename, fn);
00050 super_count = td_count = op_count = 0;
00051 for (i = 0; i < WTSIZE; i++)
00052 {
00053 td_stats[i].i = op_stats[i].i = 0;
00054 td_stats[i].d = op_stats[i].d = 0.0;
00055 }
00056 total_weight = 0.0;
00057 }
00058 void dump (FILE *out)
00059 {
00060 int i;
00061
00062 fprintf (out, "%s\t%ld\t", filename, super_count);
00063 fprintf (out, "%lf\t",
00064 ((double) td_count) / ((double) super_count));
00065 fprintf (out, "%lf\n",
00066 ((double) op_count) / ((double) super_count));
00067
00068 if (super_count > 0 && td_count != 0)
00069 {
00070 for (i = 0; i < WTSIZE; i++)
00071 if (td_stats[i].i != 0)
00072 fprintf (out, "\t%d\t%d\t%lf\n", i, td_stats[i].i,
00073 td_stats[i].d / total_weight);
00074 fprintf (out, "\n");
00075 for (i = 0; i < WTSIZE; i++)
00076 if (op_stats[i].i != 0)
00077 fprintf (out, "\t%d\t%d\t%lf\n", i, op_stats[i].i,
00078 op_stats[i].d / total_weight);
00079 }
00080 fprintf (out, "\n");
00081 return;
00082 }
00083 };
00084
00085
00086
00087
00088
00089
00090
00091
00092 class hammock_info
00093 {
00094 public:
00095 legoRegion *S;
00096 legoRegion *T;
00097 legoRegion *E;
00098 legoRegion *J;
00099
00100 hammock_info() {S = T = E = J = NULL;}
00101 int HammockDetected (void) {return (S != NULL);}
00102 int IsDelta (void) {return (E == NULL);}
00103 };
00104
00105
00106
00107
00108
00109
00110 class hammock_stats
00111 {
00112 public:
00113 int numdelta;
00114 int numdiamond;
00115
00116 hammock_stats() {numdelta = numdiamond = 0;}
00117 };
00118
00119
00120
00121 hammock_info *DetectHammock (legoRegion *);
00122 legoRegion *IfConvertHammock (hammock_info *, knobs *);
00123 legoRegion *DetectAndConvertHammock (legoRegion *, knobs *);
00124 int hammock (legoRegion *, int, knobs *, hammock_stats * = NULL);
00125
00126 extern int NextPredRegNum;
00127
00128 void sweepops (legoHB *, int = 0);
00129
00130 legoOp *IfConvertTreeBranch (legoOp *branchop, knobs *K);
00131 void PredicateTreeBranch (legoOp *branchop);
00132
00133 void FullyIfConvertTreeBranch (legoRegion *region, knobs *K);
00134 void FullyIfConvertTreeBranch (legoTreegion *tree, knobs *K);
00135
00136 void IfConvertAndPredicateTreeBranch (legoRegion *region, knobs *K);
00137 void IfConvertAndPredicateTreeBranch (legoTreegion *tree, knobs *K);
00138
00139 void FullyPredicateTreeBranch (legoRegion *region);
00140 void FullyPredicateTreeBranch (legoTreegion *tree);
00141
00142 #endif // LEGORFORM_HYPERBLOCK_HEADER
00143