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 #include <stdio.h>
00028
00029 #include <conio.h>
00030
00031 #include <stdlib.h>
00032
00033 #include <string.h>
00034 #include "kapi.h"
00035
00036 #include "kapi_debug.h"
00037
00038 #include "kapi_ia64.h"
00039 #include "kapi_save_source_ia64.h"
00040
00041
00042
00043 static void Test_bv128Rtns();
00044 static void Test_bv64Rtns();
00045 static void Test_bv32Rtns();
00046 extern int trying123;
00047 extern int ttt;
00048 void *pKmapiInfo;
00049
00050
00051
00052 #if 0
00053 void dump_instruction_fus(FILE *fp, void *pknobs)
00054
00055 {
00056
00057 int num_of_insts,iid,dummy;
00058 kapi_fu_t fu;
00059 knobs_t *pIknobs;
00060
00061 typedef struct {
00062 int x;
00063 int *ix;
00064 char *gogo;
00065 int nx[2];
00066 } xtest;
00067 typedef struct {
00068 int nxs;
00069 xtest *pxtest;
00070 xtest *ppx[2];
00071 char *dx;
00072 } ytest;
00073
00074 static int yy[]={5,5};
00075
00076
00077 static xtest xx[]= {{2,yy,"gogo",{0,0}},
00078 {2,yy,"gogo",{0,0}}};
00079 static xtest zz[2]= {{2,yy,"gogo",{0,0}},
00080 {2,yy,"gogo",{0,0}}};
00081
00082 static ytest ylast={2,
00083 &(zz[1]),
00084 {xx,zz},
00085 "gugunza",
00086 };
00087
00088 char *str;
00089 char *cIdx;
00090 char buffer[100];
00091 int idx;
00092 int iVal;
00093 FILE *fpTab=fopen("tryTab.c","w");
00094 int expressions=KAPI_EnumCardinality(pknobs,"expressions");
00095 int i0,i1,m0,m1;
00096 i0=KAPI_EnumIndex(pknobs,"port_t","portI0");
00097 i1=KAPI_EnumIndex(pknobs,"port_t","portI1");
00098 m0=KAPI_EnumIndex(pknobs,"port_t","portM0");
00099 m1=KAPI_EnumIndex(pknobs,"port_t","portM1");
00100 dummy=KAPI_cportMask4ut(pknobs,0,kapi_utI);
00101 iVal=(1 << i0) | (1 << i1);
00102
00103 dummy=KAPI_cportMask4ut(pknobs,0,kapi_utM);
00104 iVal=(1 << m0) | (1 << m1);
00105 dummy=KAPI_cportMask4ut(pknobs,0,kapi_utF);
00106 dummy=KAPI_cportMask4ut(pknobs,0,kapi_utB);
00107
00108
00109 dummy=KAPI_fuCount(pknobs);
00110 num_of_insts=KAPI_iidCount(pknobs);
00111 _strset(buffer,0);
00112 str="#include \"tryhead.h\"\n\ninst_info_tab_t infoTab[] = {\n";
00113 fwrite(str,sizeof(char),strlen(str),fp);
00114 for (iid=0;iid<num_of_insts;iid++)
00115 {
00116 _strset(buffer,0);
00117 str=KAPI_iid2uniqueName(pknobs,iid,dummy);
00118 fwrite(str,sizeof(char),strlen(str),fp);
00119 fwrite(",",sizeof(char),1,fp);
00120 fu=KAPI_iid2fu(pknobs,iid,dummy);
00121 strcat(buffer,"/* ");
00122 strcat(buffer,KAPI_fu2fuName(pknobs,fu,dummy));
00123 strcat(buffer," */");
00124 fwrite(buffer,sizeof(char),strlen(buffer),fp);
00125 *buffer='\0';
00126 _itoa(fu,buffer,10);
00127 fwrite(buffer,sizeof(char),strlen(buffer),fp);
00128 fwrite(",",sizeof(char),1,fp);
00129 fwrite("\n",sizeof(char),1,fp);
00130 }
00131 _strset(buffer,0);
00132 str="0,0\n};\n/*";
00133 fwrite(str,sizeof(char),strlen(str),fp);
00134
00135 for (idx=0;idx<expressions;idx++)
00136 {
00137 *buffer='\0';
00138 cIdx=KAPI_EnumName(pknobs,idx,"expressions");
00139 iVal=KAPI_GetIntegerVariable(pknobs,"expr",idx);
00140 sprintf(buffer,"[%s] = %d\n",cIdx,iVal);
00141 fwrite(buffer,sizeof(char),strlen(buffer),fp);
00142 }
00143 _strset(buffer,0);
00144 str="*/\n\n";
00145 fwrite(str,sizeof(char),strlen(str),fp);
00146 printf("finished Try\n");
00147 fclose(fp);
00148 fp=fopen("T1.c","w");
00149 KAPI_save_as_header_all_IA64_info( fp, pknobs , "trying123");
00150 printf("finished T1\n");
00151 fclose(fp);
00152 fclose(fpTab);
00153
00154 fp=fopen("T2.c","w");
00155 KAPI_save_as_header_all_IA64_info( fp, pknobs , "trying123");
00156 fclose(fp);
00157 printf("finished T2\n");
00158
00159
00160 if (pKmapiInfo!=NULL)
00161 printf("Kmapi initialized!\n");
00162 else
00163 {
00164 printf("Kmapi Initialization Failed!\n");
00165 }
00166
00167 }
00168
00169 #endif
00170
00171 int main( int argc, char *argv[] )
00172 {
00173 void *pvoid1;
00174 FILE *fp1=NULL,*fp2=NULL;
00175 FILE *outp=NULL;
00176 FILE *Ferr=NULL;
00177
00178 char *toolname;
00179
00180
00181
00182 if (( (toolname=strrchr(argv[ 0],'\\')) ==NULL) &&
00183 ( (toolname=strrchr(argv[ 0],'/')) ==NULL) )
00184 toolname=argv[ 0];
00185
00186
00187
00188
00189 if ( argc < 2 ) {
00190 printf("%s knobs toolname [delta knobs]\n", toolname );
00191 exit(1);
00192 }
00193
00194 if ( 5 <= argc )
00195 freopen(argv[4],"w",stderr);
00196 if ( 4 <= argc )
00197 fp2 = fopen( argv[ 3 ], "r" );
00198 fp1 = fopen( argv[ 1 ], "r" );
00199 outp = fopen( "try.c", "w" );
00200 if ((fp1==NULL) && (fp2==NULL))
00201 {
00202 printf("Could not open knobsfiles!\n");
00203 return 2;
00204 }
00205 pvoid1 = KAPI_Initialize( fp2, fp1, argv[ 2 ]);
00206 fclose( fp1 );
00207 if (pvoid1!=NULL)
00208 pvoid1=KAPI_ia64_Initialize(pvoid1);
00209
00210 if (NULL!=fp2) fclose( fp2 );
00211 if ((5 <=argc ) && (NULL!=Ferr)) fclose( Ferr );
00212
00213 if ( pvoid1 ) {
00214 int fuLD,tmp;
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 fuLD = KAPI_EnumIndex( pvoid1, "fu_t", "fuLD" );
00228 tmp = KAPI_IntraClusterBypass(pvoid1,0
00229 ,0,0,0,0,
00230 7,0,0,0);
00231
00232
00233
00234 KAPI_Finalize( pvoid1 );
00235 } else {
00236 fprintf( stderr, "KAPI_Initialize failed\n" );
00237 }
00238
00239 #if 0
00240 Test_bv128Rtns();
00241 Test_bv64Rtns();
00242 Test_bv32Rtns();
00243 #endif
00244
00245 return 0;
00246 }
00247
00248 static void
00249 Test_bv32Rtns()
00250 {
00251 }
00252
00253 static void
00254 Test_bv64Rtns()
00255 {
00256 bv64_t bv64Tmp, bv64Tmp2;
00257 char mpch[ 200 ];
00258 int i;
00259
00260
00261 for ( i=0; i<=64; i++ ) {
00262 ZERO_bv64( bv64Tmp );
00263 SETBIT_bv64( bv64Tmp, i );
00264 printf("Bit %2d = %s\n", i, bv642pch( bv64Tmp, mpch ) );
00265 }
00266
00267
00268 for ( i=0; i<=64; i++ ) {
00269 ZERO_bv64( bv64Tmp );
00270 ONES_bv64( bv64Tmp, 4 );
00271 SHL_bv64( bv64Tmp2, bv64Tmp, i );
00272 printf("Bit %2d = %s\n", i, bv642pch( bv64Tmp2, mpch ) );
00273 }
00274
00275
00276 for ( i=0; i<=64; i++ ) {
00277 ZERO_bv64( bv64Tmp );
00278 ONES_bv64( bv64Tmp, 20 );
00279 SHL_bv64( bv64Tmp2, bv64Tmp, i );
00280 printf("Bit %2d = %s\n", i, bv642pch( bv64Tmp2, mpch ) );
00281 }
00282
00283
00284 for ( i=0; i<=64; i++ ) {
00285 ZERO_bv64( bv64Tmp );
00286 ONES_bv64( bv64Tmp, 40 );
00287 SHL_bv64( bv64Tmp2, bv64Tmp, i );
00288 printf("Bit %2d = %s\n", i, bv642pch( bv64Tmp2, mpch ) );
00289 }
00290
00291
00292 for ( i=0; i<=64; i++ ) {
00293 ZERO_bv64( bv64Tmp );
00294 ONES_bv64( bv64Tmp, 4 );
00295 SHL_bv64( bv64Tmp2, bv64Tmp, 60 );
00296 SHRL_bv64( bv64Tmp, bv64Tmp2, i );
00297 printf("Bit %2d = %s\n", i, bv642pch( bv64Tmp, mpch ) );
00298 }
00299
00300
00301 for ( i=0; i<=64; i++ ) {
00302 ZERO_bv64( bv64Tmp );
00303 ONES_bv64( bv64Tmp, 20 );
00304 SHL_bv64( bv64Tmp2, bv64Tmp, 44 );
00305 SHRL_bv64( bv64Tmp, bv64Tmp2, i );
00306 printf("Bit %2d = %s\n", i, bv642pch( bv64Tmp, mpch ) );
00307 }
00308
00309
00310 for ( i=0; i<=64; i++ ) {
00311 ZERO_bv64( bv64Tmp );
00312 ONES_bv64( bv64Tmp, 40 );
00313 SHL_bv64( bv64Tmp2, bv64Tmp, 24 );
00314 SHRL_bv64( bv64Tmp, bv64Tmp2, i );
00315 printf("Bit %2d = %s\n", i, bv642pch( bv64Tmp, mpch ) );
00316 }
00317
00318
00319 ZERO_bv64( bv64Tmp );
00320 ONES_bv64( bv64Tmp, 8 );
00321 SHL_bv64( bv64Tmp2, bv64Tmp, 28 );
00322 printf("Initial string %s\n", bv642pch( bv64Tmp2, mpch ) );
00323 for ( i=0; i<=64; i++ ) {
00324 ZERO_bv64( bv64Tmp );
00325 ONES_bv64( bv64Tmp, 8 );
00326 SHL_bv64( bv64Tmp2, bv64Tmp, 28 );
00327 EXTRACTU_bv64( bv64Tmp, bv64Tmp2, 4, i );
00328 printf("Extract len=%d pos %2d = %s\n", 4, i, bv642pch( bv64Tmp, mpch ) );
00329 }
00330 }
00331
00332 static void
00333 Test_bv128Rtns()
00334 {
00335 }