00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <malloc.h>
00043 #include "ekapi_ia64.h"
00044 #include "ekapi_util.h"
00045
00046
00047
00048 int EKAPI_GetMaxSlot(void *pknobs)
00049 {
00050 return KAPI_GetIntegerVariable(pknobs, "MaxSlot",-1);
00051 }
00052
00053
00054 int EKAPI_GetBundleWidth(void *pknobs)
00055 {
00056 return KAPI_GetIntegerVariable(pknobs, "BundleWidth", -1);
00057 }
00058
00059
00060 int EKAPI_ExecUnitCount(void *pknobs)
00061 {
00062 return KAPI_EnumCardinality(pknobs, "eun_t");
00063 }
00064
00065
00066 int EKAPI_TemplateCount(void *pknobs)
00067 {
00068 return KAPI_EnumCardinality(pknobs, "bid_t");
00069 }
00070
00071
00072 char *EKAPI_TemplateName(void *pknobs, int index)
00073 {
00074
00075
00076 char *buf = KAPI_EnumName(pknobs, index, "bid_t");
00077 buf = StrLower(buf+3);
00078 return buf;
00079 }
00080
00081
00082 char *EKAPI_TemplateAsmName(void *pknobs, int index)
00083 {
00084
00085
00086 char *buf = KAPI_EnumName(pknobs, index, "bid_t");
00087 buf = StrLower(buf+2);
00088 *buf = '.';
00089 buf = StrClean(buf);
00090 return buf;
00091 }
00092
00093
00094 char *EKAPI_ExecUnitName(void *pknobs, int index)
00095 {
00096 return KAPI_EnumName(pknobs, index, "eun_t");
00097 }
00098
00099
00100 int EKAPI_EunName2id(void *pknobs, char *name)
00101 {
00102 return KAPI_EnumIndex(pknobs, "eun_t", name);
00103 }
00104
00105
00106 void EKAPI_BundleType4bid(void *pknobs, kapi_bid_t bid, int *slt)
00107 {
00108 int max_slot;
00109 int i;
00110 kapi_syl_t *mpslt;
00111
00112 max_slot = EKAPI_GetMaxSlot(pknobs);
00113 FmtAssert(max_slot>=3,
00114 ("max_slot:%d is smaller than 3", max_slot)
00115 );
00116 mpslt = (kapi_syl_t *)malloc(max_slot * sizeof(kapi_syl_t));
00117 FmtAssert(mpslt,
00118 ("Malloc mpslt space failed.")
00119 );
00120
00121 if (KAPI_isReserved_bid(pknobs, bid)) {
00122 for(i=0; i<max_slot; i++)
00123 {
00124 slt[i] = EKAPI_EunName2id(pknobs, "R_Unit");
00125 }
00126 }
00127 else {
00128 KAPI_SylOrder_bid(pknobs, bid, mpslt);
00129
00130 for (i=0; i<max_slot; i++)
00131 {
00132 slt[i] = Syl2Eun(pknobs, mpslt[i]);
00133
00134 if ( (i==max_slot-1) && (slt[i]==EKAPI_EunName2id(pknobs, "B_Unit")) ) {
00135 slt[i] = EKAPI_EunName2id(pknobs, "B2_Unit");
00136 }
00137
00138
00139 if ( (i==max_slot-1) && (slt[i-1]==EKAPI_EunName2id(pknobs, "L_Unit")) ){
00140 slt[i] = EKAPI_EunName2id(pknobs, "L_Unit");
00141 }
00142 }
00143 }
00144 free(mpslt);
00145 }
00146
00147
00148 int Syl2Eun(void *pknobs, int sylid)
00149 {
00150 int eunid = -1, order;
00151 char *sylname;
00152 char *buf;
00153
00154 sylname = KAPI_EnumName(pknobs, sylid, "syl_t");
00155 buf = (char*)malloc(strlen(sylname)+2);
00156 FmtAssert(buf, ("Memory Allocation Failure!\n"));
00157
00158
00159
00160 buf[0]='%';
00161 strcpy(buf+1, sylname);
00162 order = KAPI_ArrayIndex(pknobs, "eun_sylt", buf);
00163 eunid = KAPI_GetEnumVariable(pknobs, "eun_sylt", order);
00164
00165 free(buf);
00166 free(sylname);
00167 return eunid;
00168 }
00169
00170
00171 bv32_t EKAPI_EunMask4op(void *pknobs, int opid)
00172 {
00173 bv_t *bv;
00174 char op[100]="%";
00175 BOOL b;
00176 int j, iknob;
00177 UINT64 flag=0;
00178 char errmsg[200];
00179
00180 strcat(op,EKAPI_OpName4id(pknobs, opid));
00181
00182
00183 iknob = KAPI_ArrayIndex(pknobs, "unitprop", op);
00184 sprintf( errmsg, "Op %s properties not exist!", op);
00185 Is_True(iknob>=0, (errmsg));
00186
00187 bv = KAPI_GetBvVariable(pknobs,"unitprop", iknob);
00188
00189
00190 for ( j=0; j<bv->n32Chunks * 32; j++ ) {
00191 b = ( 0 != isbvBITSET( bv, j ) );
00192 if (b) {
00193 flag |= 1ULL << j ;
00194 }
00195 }
00196 return flag;
00197 }
00198
00199
00200 int EKAPI_BundleCompCount(void *pknobs)
00201 {
00202 return KAPI_EnumCardinality(pknobs, "bidcomp_t");
00203 }
00204
00205
00206 char *EKAPI_BundleCompName(void *pknobs, int index)
00207 {
00208 char *str;
00209 str = KAPI_EnumName(pknobs, index, "bidcomp_t");
00210 FmtAssert(str,
00211 ("bidcomp_t or index %d is not existed.", index )
00212 );
00213
00214 return str;
00215 }
00216
00217
00218 int EKAPI_BundleCompWidth(void *pknobs, int index)
00219 {
00220 return KAPI_GetIntegerVariable(pknobs, "bidcomp_width", index);
00221 }
00222
00223
00224 BOOL EKAPI_Split_Before_Bundle(void *pknobs, int index)
00225 {
00226 char *line, *line_bf, *line_af;
00227 int bid_id;
00228
00229 Is_True(index<=EKAPI_TemplateCount(pknobs),
00230 ("index %d of bid_t is not existed", index));
00231 int count = KAPI_count4attribute(pknobs, "IMPLICIT_STOP_BEFORE");
00232 char *name = EKAPI_TemplateName(pknobs, index);
00233
00234 for(int i=0; i<count; i++)
00235 {
00236 line = KAPI_attribute4index(pknobs, "IMPLICIT_STOP_BEFORE", i);
00237 line_bf = StrTrim(strtok(line, ":"));
00238 line_af = StrTrim(strtok(NULL, ":"));
00239 bid_id = KAPI_EnumIndex(pknobs, "bid_t", line_af);
00240 if ((bid_id == index) && (strcmp(line_bf,"bid_t") == 0)) {
00241 return true;
00242 }
00243 }
00244 return false;
00245 }
00246
00247
00248 BOOL EKAPI_Split_After_Bundle(void *pknobs, int index)
00249 {
00250 char *line, *line_bf, *line_af;
00251 int bid_id;
00252
00253 Is_True(index<=EKAPI_TemplateCount(pknobs),
00254 ("index %d of bid_t is not existed", index));
00255 int count = KAPI_count4attribute(pknobs, "IMPLICIT_STOP_AFTER");
00256 char *name = EKAPI_TemplateName(pknobs, index);
00257
00258 for(int i=0; i<count; i++)
00259 {
00260 line = KAPI_attribute4index(pknobs, "IMPLICIT_STOP_AFTER", i);
00261 line_bf = StrTrim(strtok(line, ":"));
00262 line_af = StrTrim(strtok(NULL, ":"));
00263 bid_id = KAPI_EnumIndex(pknobs, "bid_t", line_af);
00264 if ((bid_id == index) && (strcmp(line_bf,"bid_t") == 0)) {
00265 return true;
00266 }
00267 }
00268 return false;
00269 }