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 #include <assert.h>
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <memory.h>
00032
00033 #include <vector>
00034 #include "targ_isa_bundle.h"
00035 #include "targ_issue_port.h"
00036 #include "targ_proc.h"
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 # define FmtAssert(Cond,ParmList) \
00068 ( Cond ? (void) 1 : \
00069 ( fprintf(stderr, "Assertion Failed at %s:%d ", __FILE__, __LINE__), \
00070 fprintf(stderr, ParmList), \
00071 fprintf(stderr, "\n"), \
00072 assert(false) ) )
00073
00074 #define Is_True FmtAssert
00075
00076 static ISSUE_PORT Find_Issue_Port( INT already_reserved,
00077 ISA_EXEC_UNIT slot_kind,
00078 mINT16 bundle_sequence,
00079 mINT8 slot_sequence);
00080
00081
00082
00083
00084
00085
00086 struct PATTERN_TYPE{
00087 mBOOL start_in_bundle;
00088 mBOOL end_in_bundle;
00089 mINT16 bundle[ISA_MAX_ISSUE_BUNDLES];
00090
00091
00092 PATTERN_TYPE(void) : start_in_bundle(FALSE), end_in_bundle(FALSE)
00093 {
00094 for (mINT16 i=0; i<ISA_MAX_ISSUE_BUNDLES; i++){
00095 bundle[i] = ISA_MAX_BUNDLES;
00096 }
00097 }
00098
00099 PATTERN_TYPE( const PATTERN_TYPE& ptn)
00100 {
00101 start_in_bundle = ptn.start_in_bundle;
00102 end_in_bundle = ptn.end_in_bundle;
00103 for (INT i=0; i< ISA_MAX_ISSUE_BUNDLES; i++)
00104 bundle[i] = ptn.bundle[i];
00105 }
00106
00107 INT Count_Slot(void);
00108 BOOL Has_Multbranch_Template (void);
00109
00110 PATTERN_TYPE& operator=(const PATTERN_TYPE& ptn);
00111 BOOL operator == (const PATTERN_TYPE ptn) const ;
00112 mINT16& operator[](const INT i) { return bundle[i]; }
00113 };
00114
00115 PATTERN_TYPE& PATTERN_TYPE::operator=(const PATTERN_TYPE& ptn)
00116 {
00117 start_in_bundle = ptn.start_in_bundle;
00118 end_in_bundle = ptn.end_in_bundle;
00119 for (INT i=0; i< ISA_MAX_ISSUE_BUNDLES; i++)
00120 bundle[i] = ptn.bundle[i];
00121 return *this;
00122 }
00123
00124 BOOL PATTERN_TYPE::operator == (const PATTERN_TYPE ptn) const
00125 {
00126 for (INT i=0; i< ISA_MAX_ISSUE_BUNDLES; i++){
00127 if (bundle[i] != ptn.bundle[i])
00128 return false;
00129 }
00130 return ((start_in_bundle == ptn.start_in_bundle)
00131 && (end_in_bundle == ptn.end_in_bundle));
00132 }
00133
00134 INT PATTERN_TYPE::Count_Slot(void)
00135 {
00136 INT count=0;
00137 BOOL first_stop_meet = FALSE;
00138
00139 for (INT i=0; i<ISA_MAX_ISSUE_BUNDLES; i++)
00140 {
00141 if (bundle[i] == ISA_MAX_BUNDLES) break;
00142 for (INT j=0; j<ISA_MAX_SLOTS; j++)
00143 {
00144 if (start_in_bundle&&!first_stop_meet){
00145 if (ISA_EXEC_Stop((INT)bundle[i], j) ){
00146 first_stop_meet = TRUE;
00147 }
00148 continue;
00149 }
00150 count++;
00151 if (end_in_bundle && ISA_EXEC_Stop((INT)bundle[i], j)){
00152 return count;
00153 }
00154 }
00155
00156 }
00157 return count;
00158 }
00159
00160
00161 BOOL
00162 PATTERN_TYPE::Has_Multbranch_Template (void) {
00163
00164 for (INT i=0; i<ISA_MAX_ISSUE_BUNDLES; i++) {
00165
00166 if (bundle[i] == ISA_MAX_BUNDLES) return FALSE;
00167
00168 int b_slot_num = 0;
00169
00170 for (INT slot = 0; slot < ISA_MAX_SLOTS; slot++) {
00171 ISA_EXEC_UNIT_PROPERTY prop =
00172 ISA_EXEC_Slot_Prop (bundle[i],slot);
00173
00174 if (prop & ISA_EXEC_PROPERTY_B_Unit) {
00175 ++ b_slot_num ; continue;
00176 }
00177
00178 if (prop & ISA_EXEC_PROPERTY_B2_Unit) {
00179 ++ b_slot_num;
00180 }
00181 }
00182
00183 if (b_slot_num >= 2) { return TRUE ; }
00184 }
00185
00186 return FALSE;
00187 }
00188
00189 PATTERN_TYPE empty_ptn;
00190
00191 typedef std::vector<PATTERN_TYPE> PTN_TABLE_LINE;
00192
00193 typedef std::vector<PATTERN_TYPE> PTN_VECTOR;
00194
00195 INT PTN_TABLE_SIZE=(1<<ip_number);
00196
00197 PTN_TABLE_LINE* PTN_table;
00198 INT max_ptn_line_size = 0;
00199
00200
00201
00202
00203
00204 void MCK_Dispersal_Rule(PORT_SET *old_ports, ISA_EXEC_UNIT slot_type)
00205 {
00206 if ( PROCESSOR_Version == 2 ) {
00207
00208
00209
00210 if (slot_type == ISA_EXEC_M_Unit)
00211 *old_ports = M_PORTS;
00212 }
00213 }
00214
00215
00216
00217
00218
00219 void Print_PTN( PATTERN_TYPE ptn, FILE *cxxfile)
00220 {
00221 mINT16 bundle;
00222
00223
00224 fprintf(cxxfile, "{ %d, %d, {",
00225 ptn.start_in_bundle, ptn.end_in_bundle);
00226 for (bundle=0; bundle<ISA_MAX_ISSUE_BUNDLES; bundle++){
00227 if (bundle!=0)
00228 fprintf(cxxfile, ",");
00229 fprintf(cxxfile, " %d", ptn[bundle]);
00230 }
00231 fprintf(cxxfile, "} }");
00232
00233
00234 fprintf(cxxfile, "\t/*");
00235 if (ptn.start_in_bundle)
00236 fprintf(cxxfile, "->");
00237 for (bundle=0; bundle<ISA_MAX_ISSUE_BUNDLES; bundle++){
00238 fprintf(cxxfile, "%s ",ISA_EXEC_Name(ptn[bundle]));
00239 }
00240
00241 INT ip_issued=0;
00242 ISSUE_PORT pos = ip_invalid;
00243 for (bundle=0; bundle<ISA_MAX_ISSUE_BUNDLES; bundle++){
00244 for (INT slot=0; slot <ISA_MAX_SLOTS; slot++){
00245 ISA_EXEC_UNIT slot_type = ISA_EXEC_Unit(ptn[bundle]%ISA_MAX_BUNDLES, slot);
00246 pos = Find_Issue_Port( ip_issued, slot_type , bundle, slot);
00247
00248
00249 PORT_SET ports;
00250 ports = ports + pos;
00251
00252
00253 MCK_Dispersal_Rule(&ports, slot_type);
00254 if(ptn[bundle] < ISA_MAX_BUNDLES) {
00255 ports.Print(cxxfile, "|");
00256 fprintf(cxxfile, " ");
00257 }
00258 ip_issued |= 1 << pos;
00259 if (ISA_EXEC_Stop(ptn[bundle], slot))
00260 ip_issued = 0;
00261 }
00262 }
00263
00264 fprintf(cxxfile, "*/");
00265 }
00266
00267 void Print_Table_Line( PTN_TABLE_LINE table_line,
00268 INT request_bv, FILE *cxxfile)
00269 {
00270 fprintf(cxxfile, "/* ================================================================\n");
00271 fprintf(cxxfile, " * Request bit vector: %d ", request_bv);
00272
00273 INT bv = request_bv;
00274 for (INT ip=0; ip<ip_number; ip++){
00275 if (bv&1)
00276 fprintf(cxxfile, "%s ", Issue_Port_Name((const ISSUE_PORT)ip));
00277 bv >>= 1;
00278 }
00279 fprintf(cxxfile, "*/\n");
00280 if (table_line.size()==0){
00281 fprintf(cxxfile, "\n");
00282 return;
00283 }
00284
00285 fprintf(cxxfile, "PATTERN_TYPE ptn%d[] = {", request_bv);
00286 for (UINT i=0; i<table_line.size(); i++){
00287 if (i!=0)
00288 fprintf(cxxfile, ",");
00289 fprintf(cxxfile, "\n\t");
00290 Print_PTN( table_line[i], cxxfile );
00291 }
00292 fprintf(cxxfile, "\n};\n\n");
00293 }
00294
00295
00296
00297
00298
00299
00300 void Gen_Table_Map_n_Body(FILE *cxxfile)
00301 {
00302 INT index;
00303 INT value = 0;
00304
00305 fprintf(cxxfile, "INT PTN_table_map[] = {\n\t");
00306 for (index=0; index < PTN_TABLE_SIZE; index++){
00307 if (index != 0)
00308 fprintf(cxxfile, ",\n\t");
00309 if (PTN_table[index].size() == 0)
00310 fprintf(cxxfile, "invalid_PTN_TABLE_entry");
00311 else{
00312 fprintf(cxxfile, "%d", value++);
00313 }
00314 fprintf(cxxfile, "/* index %d */", index);
00315 }
00316 fprintf(cxxfile, "\n};\n\n");
00317
00318 value = 0;
00319 fprintf(cxxfile, "PTN_TABLE_LINE PTN_table_body[] = {\n\t");
00320 BOOL first = true;
00321 for (index=0; index < PTN_TABLE_SIZE; index++){
00322 if (PTN_table[index].size() != 0){
00323 if (!first)
00324 fprintf(cxxfile, ",\n\t");
00325 first = false;
00326 fprintf(cxxfile, "{%d, ptn%d} /* position %d */",
00327 (INT)PTN_table[index].size(), index, value++);
00328 }
00329 }
00330 fprintf(cxxfile, "\n};\n\n");
00331
00332 }
00333
00334 void Print_PTN_Table_Def(FILE *cxxfile)
00335 {
00336 fprintf(cxxfile, "const PTN_TABLE_TYPE PTN_table = {\n");
00337 fprintf(cxxfile, "\tPTN_table_map, PTN_table_body");
00338 fprintf(cxxfile, "\n};\n\n");
00339 }
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 static ISSUE_PORT Find_Issue_Port( INT already_reserved,
00365 ISA_EXEC_UNIT slot_kind,
00366 mINT16 bundle_sequence,
00367 mINT8 slot_sequence)
00368 {
00369 ISSUE_PORT pos = ip_invalid;
00370
00371 Is_True( bundle_sequence<ISA_MAX_ISSUE_BUNDLES,
00372 ("Exceed Max Bundle Number!"));
00373 Is_True( slot_sequence < ISA_MAX_SLOTS, ("Exceed Max Slots!") );
00374
00375 switch (slot_kind){
00376 case ISA_EXEC_M_Unit:
00377 for (ISSUE_PORT p=ip_M0; M_PORTS.In(p); p=(ISSUE_PORT)(p+1)){
00378 if (!( (1<<p) & already_reserved) ){
00379 pos = p;
00380 break;
00381 }
00382 }
00383 break;
00384 case ISA_EXEC_I_Unit:
00385 X_Unit:
00386 if ( (slot_sequence==2) && (bundle_sequence >=1) )
00387 {
00388 if (!((1<<(ip_I0+bundle_sequence)) & already_reserved) ){
00389
00390 pos = (ISSUE_PORT)(ip_I0+bundle_sequence);
00391 }
00392 break;
00393 }
00394 for (ISSUE_PORT p=ip_I0; I_PORTS.In(p); p=(ISSUE_PORT)(p+1)){
00395 if (!( (1<<p) & already_reserved) ){
00396 pos = p;
00397 break;
00398 }
00399 }
00400 break;
00401 case ISA_EXEC_B_Unit:
00402 if ((slot_sequence==0) && !((1<<ip_B0)&already_reserved))
00403
00404 pos = ip_B0;
00405 else if ((slot_sequence==1) && !( (1<<ip_B1) & already_reserved))
00406
00407 pos = ip_B1;
00408 else if ( (slot_sequence==2) && !( (1<<ip_B2) & already_reserved) )
00409
00410 pos = ip_B2;
00411 break;
00412 case ISA_EXEC_L_Unit:
00413
00414
00415
00416 if (slot_sequence == 2)
00417 goto X_Unit;
00418 case ISA_EXEC_F_Unit:
00419
00420 if (!((1<<(ip_F0+bundle_sequence)) & already_reserved) ){
00421
00422 pos = (ISSUE_PORT)(ip_F0+bundle_sequence);
00423 }
00424 break;
00425 case ISA_EXEC_R_Unit:
00426 break;
00427 default:
00428 Is_True(false, ("Unknow slot type in template table!"));
00429 break;
00430 }
00431 return pos;
00432 }
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 class PTN_SORT_BUF;
00447
00448 class PTN_SORT_BUF{
00449
00450 protected:
00451 enum BUCKET_TYPE{
00452 partial_in_both_end =0,
00453 partial_in_front,
00454 partial_in_back,
00455 complete_bundles,
00456 kinds_of_bucket
00457 };
00458
00459
00460 PTN_VECTOR _ptns[ISA_MAX_ISSUE_BUNDLES * kinds_of_bucket];
00461
00462 public:
00463
00464 void Clear(void);
00465
00466
00467 void Insert(PATTERN_TYPE ptn, mINT16 num_bundles);
00468
00469
00470 void Output(PTN_VECTOR * dest);
00471 };
00472
00473 void PTN_SORT_BUF::Clear(void)
00474 {
00475 for (int i=0; i<ISA_MAX_ISSUE_BUNDLES * kinds_of_bucket; i++){
00476 _ptns[i].clear();
00477 }
00478 }
00479
00480 void PTN_SORT_BUF::Insert(PATTERN_TYPE ptn, mINT16 num_bundles)
00481 {
00482 PTN_VECTOR::iterator iter;
00483 INT index = num_bundles * kinds_of_bucket;
00484
00485 if (ptn.start_in_bundle){
00486 if (ptn.end_in_bundle)
00487 index += partial_in_both_end;
00488 else index += partial_in_front;
00489 }
00490 else{
00491 if (ptn.end_in_bundle)
00492 index += partial_in_back;
00493 else index += complete_bundles;
00494 }
00495
00496
00497 for(iter=_ptns[index].begin(); iter!=_ptns[index].end(); iter++)
00498 {
00499 INT delta = ptn.Count_Slot () - iter->Count_Slot ();
00500 if (delta < 0) {
00501 break;
00502 } else if (delta == 0) {
00503 if (iter->Has_Multbranch_Template ()) {
00504 break;
00505 }
00506 }
00507 }
00508 _ptns[index].insert(iter, ptn);
00509 }
00510
00511 void PTN_SORT_BUF::Output(PTN_VECTOR * dest)
00512 {
00513
00514 for (UINT i=0; i<ISA_MAX_ISSUE_BUNDLES * kinds_of_bucket; i++){
00515 for (UINT j=0; j<_ptns[i].size(); j++){
00516 dest->push_back(_ptns[i][j]);
00517 }
00518 }
00519 }
00520
00521 PTN_SORT_BUF pattern_buffer;
00522
00523 void Find_PTN(INT request_bv,
00524 INT satisfied_bv,
00525 PATTERN_TYPE cur_ptn,
00526 mINT16 cur_bdSeq);
00527
00528
00529 void Gen_PTN_Table(FILE *cxxfile)
00530 {
00531 INT bv;
00532 for (bv=1; bv < (PTN_TABLE_SIZE); bv++) {
00533 pattern_buffer.Clear();
00534
00535 Find_PTN(bv, 0, empty_ptn, 0);
00536
00537 pattern_buffer.Output(&PTN_table[bv]);
00538 if (PTN_table[bv].size()>max_ptn_line_size)
00539 max_ptn_line_size = PTN_table[bv].size();
00540
00541 Print_Table_Line( PTN_table[bv], bv, cxxfile);
00542 }
00543 Gen_Table_Map_n_Body(cxxfile);
00544 Print_PTN_Table_Def(cxxfile);
00545 }
00546 INT bv_count(INT bv)
00547 {
00548 INT count = 0;
00549 for(INT i=0; i<ip_invalid; i++) {
00550 if (bv & 1 << i) count++;
00551 }
00552
00553 return count;
00554 }
00555
00556
00557
00558
00559
00560
00561
00562 BOOL bv_is_cover(INT satisfied_bv, INT request_bv)
00563 {
00564 if ( PROCESSOR_Version == 2 ) {
00565 BOOL is_cover = !(~(satisfied_bv | M_PORTS.Body()) & request_bv);
00566 if (is_cover) {
00567
00568 INT s_count = bv_count(satisfied_bv & M_PORTS.Body());
00569 INT r_count = bv_count(request_bv & M_PORTS.Body());
00570 if(s_count >= r_count) return TRUE;
00571
00572 }
00573 return FALSE;
00574 } else {
00575 return !(~satisfied_bv & request_bv);
00576 }
00577 }
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598 void Find_PTN(INT request_bv, INT satisfied_bv,
00599 PATTERN_TYPE cur_ptn, mINT16 cur_bdSeq)
00600 {
00601
00602
00603
00604
00605 static BOOL useTail;
00606
00607 Is_True( cur_bdSeq < ISA_MAX_ISSUE_BUNDLES,
00608 ("Exceed max bundle when finding pattern.") );
00609
00610 if (bv_is_cover(satisfied_bv, request_bv))
00611 return;
00612
00613 for (mINT16 template_index=0; template_index<ISA_MAX_BUNDLES; template_index++)
00614 {
00615
00616 if (cur_bdSeq == 0)
00617 useTail = false;
00618 else if (ISA_EXEC_Stop_Before(template_index)){
00619
00620
00621 continue;
00622 }
00623
00624 BOOL success = true;
00625 BOOL stop_bit_encountered = false;
00626 INT bv_buffer = 0;
00627
00628 for (INT slot_index=0; slot_index < ISA_MAX_SLOTS; slot_index++){
00629
00630 ISSUE_PORT pos = Find_Issue_Port(satisfied_bv | bv_buffer,
00631 ISA_EXEC_Unit(template_index, slot_index),
00632 cur_bdSeq, slot_index);
00633
00634 if (pos == ip_invalid){
00635 success = false;
00636 break;
00637 }
00638 bv_buffer |= 1 << pos;
00639
00640 if (ISA_EXEC_Stop(template_index, slot_index))
00641 {
00642
00643 stop_bit_encountered = true;
00644
00645 if (bv_is_cover(bv_buffer|satisfied_bv, request_bv)){
00646
00647
00648
00649
00650
00651 cur_ptn[cur_bdSeq] = template_index;
00652 cur_ptn.end_in_bundle = true;
00653 cur_ptn.start_in_bundle = useTail;
00654
00655
00656 pattern_buffer.Insert(cur_ptn, cur_bdSeq);
00657
00658 cur_ptn[cur_bdSeq] = ISA_MAX_BUNDLES;
00659 cur_ptn.end_in_bundle = false;
00660 cur_ptn.start_in_bundle = false;
00661
00662
00663
00664
00665 }
00666 if (cur_bdSeq != 0)
00667
00668 break;
00669
00670
00671
00672
00673
00674 Is_True( (satisfied_bv == 0) && (cur_ptn == empty_ptn),
00675 ("Failed to clear issue ports when finding patterns."));
00676 bv_buffer = 0;
00677 stop_bit_encountered = 0;
00678 useTail = true;
00679 }
00680 }
00681
00682 if (stop_bit_encountered)
00683 continue;
00684
00685 if (success){
00686 cur_ptn[cur_bdSeq] = template_index;
00687 INT saved = satisfied_bv;
00688 satisfied_bv |= bv_buffer;
00689
00690 if (bv_is_cover(satisfied_bv,request_bv)){
00691
00692
00693 cur_ptn.start_in_bundle = useTail;
00694 cur_ptn.end_in_bundle = false;
00695 pattern_buffer.Insert(cur_ptn, cur_bdSeq);
00696 }
00697 else{
00698 if ( (cur_bdSeq < ISA_MAX_ISSUE_BUNDLES-1)
00699 && (!ISA_EXEC_Stop_After(template_index)) ){
00700
00701
00702
00703 Find_PTN(request_bv, satisfied_bv, cur_ptn, cur_bdSeq+1);
00704 }
00705 }
00706
00707 cur_ptn[cur_bdSeq] = ISA_MAX_BUNDLES;
00708 cur_ptn.end_in_bundle = false;
00709 cur_ptn.start_in_bundle = false;
00710 satisfied_bv = saved;
00711 }
00712
00713 }
00714 }
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724 struct DISPERSAL_TARG{
00725 PORT_SET port[ISA_MAX_SLOTS*ISA_MAX_ISSUE_BUNDLES];
00726 PORT_SET& operator[](int i) { return port[i]; }
00727 };
00728
00729 class DISPERSAL_TARG_TABLE{
00730 protected:
00731 UINT _size;
00732 DISPERSAL_TARG *_body;
00733
00734 public:
00735
00736 DISPERSAL_TARG_TABLE(void);
00737 ~DISPERSAL_TARG_TABLE(void);
00738
00739
00740 void Gen_Table(void);
00741
00742 void Dump(FILE * dest_file) const;
00743 };
00744
00745 DISPERSAL_TARG_TABLE::DISPERSAL_TARG_TABLE(void)
00746 {
00747 _body = NULL;
00748 _size = 1;
00749 for (int i=0; i<ISA_MAX_ISSUE_BUNDLES; i++){
00750 _size = _size * ISA_MAX_BUNDLES;
00751 }
00752
00753 _body = (DISPERSAL_TARG *) malloc(_size * sizeof(DISPERSAL_TARG));
00754 FmtAssert(_body, ("Not enough memory for dispersal table!"));
00755 }
00756
00757 DISPERSAL_TARG_TABLE::~DISPERSAL_TARG_TABLE(void)
00758 {
00759 free(_body);
00760 _body = NULL;
00761 _size = 0;
00762 }
00763
00764 void DISPERSAL_TARG_TABLE::Gen_Table(void)
00765 {
00766 UINT index;
00767 for (index = 0; index <_size; index++){
00768 UINT ptn_index = index;
00769 UINT template_index = ptn_index % ISA_MAX_BUNDLES;
00770 INT fu_issued = 0;
00771 UINT sl = 0;
00772 for (INT bundle=0; bundle<ISA_MAX_ISSUE_BUNDLES; bundle++){
00773 for (INT slot=0; slot <ISA_MAX_SLOTS; slot++){
00774 ISSUE_PORT pos= Find_Issue_Port( fu_issued,
00775 ISA_EXEC_Unit(template_index, slot), bundle, slot);
00776
00777
00778 PORT_SET ports;
00779 ports = ports + pos;
00780 MCK_Dispersal_Rule(&ports, ISA_EXEC_Unit(template_index, slot));
00781 _body[index][sl] = ports;
00782
00783 fu_issued |= 1<< pos;
00784 if (ISA_EXEC_Stop(template_index, slot))
00785 fu_issued = 0;
00786 sl++;
00787 }
00788 ptn_index /= ISA_MAX_BUNDLES;
00789 template_index = ptn_index % ISA_MAX_BUNDLES;
00790 }
00791 }
00792 }
00793
00794
00795 void DISPERSAL_TARG_TABLE::Dump(FILE * dest_file) const
00796 {
00797 fprintf(dest_file, "UINT dispersal_table_size = %d;\n",
00798 _size);
00799 fprintf(dest_file, "DISPERSAL_TARG dispersal_table_body[]={\n");
00800
00801 for (UINT i=0; i<_size; i++){
00802 if (i!=0)
00803 fprintf(dest_file, ",\n");
00804 fprintf(dest_file, " {");
00805 for (int j=0; j<ISA_MAX_SLOTS*ISA_MAX_ISSUE_BUNDLES; j++){
00806 if (j!=0)
00807 fprintf(dest_file, ",");
00808
00809
00810 fprintf(dest_file, " 0x%x", _body[i][j].Body());
00811 }
00812 fprintf(dest_file, "}");
00813
00814
00815 fprintf(dest_file, "/* ");
00816 UINT ptn_index = i;
00817 UINT template_index = ptn_index % ISA_MAX_BUNDLES;
00818 for (INT bundle=0; bundle<ISA_MAX_ISSUE_BUNDLES; bundle++){
00819 fprintf(dest_file, "%s ",ISA_EXEC_Name(template_index));
00820 ptn_index /= ISA_MAX_BUNDLES;
00821 if (ptn_index == ISA_MAX_BUNDLES) {
00822
00823 break;
00824 }
00825 template_index = ptn_index % ISA_MAX_BUNDLES;
00826 }
00827 fprintf(dest_file, "*/");
00828 }
00829
00830 fprintf(dest_file, "\n};\n\n");
00831 fprintf(dest_file, "const DISPERSAL_TARG_TABLE dispersal_table =\n");
00832 fprintf(dest_file, " { dispersal_table_size, dispersal_table_body };\n\n");
00833 fprintf(dest_file, "INT MAX_PTN_TABLE_LINE_SIZE = %d; \n", max_ptn_line_size);
00834 }
00835
00836
00837
00838
00839 void Dump_Headerfile(FILE *headerfile)
00840 {
00841 fprintf(headerfile,
00842 "//-*-c++-*-\n"
00843 "\n"
00844 "#ifndef cggrp_ptn_table_INCLUDED\n"
00845 "#define cggrp_ptn_table_INCLUDED\n"
00846 "\n"
00847 "#include \"cggrp_ptn.h\"\n\n"
00848 );
00849
00850 fprintf(headerfile, "extern INT MAX_PTN_TABLE_LINE_SIZE;\n");
00851
00852 fprintf(headerfile,
00853 "\n#endif // cggrp_ptn_table_INCLUDED\n"
00854 "// End of file\n"
00855 );
00856 }
00857 void Init_Memory()
00858 {
00859 PTN_table = (PTN_TABLE_LINE *)malloc(sizeof(PTN_TABLE_LINE) * PTN_TABLE_SIZE);
00860 }
00861 void Free_Memory()
00862 {
00863 free(PTN_table);
00864 }
00865 int main(void)
00866 {
00867 char *OFFLINE_TABLE_FILE_NAME ="cggrp_ptn_table";
00868
00869
00870 char buf[1000];
00871 FILE *cxxfile = NULL;
00872 FILE *hfile = NULL;
00873
00874 if (PROCESSOR_Version == 2)
00875 sprintf(buf, "%s_mck.cxx", OFFLINE_TABLE_FILE_NAME);
00876 else
00877 sprintf(buf, "%s.cxx", OFFLINE_TABLE_FILE_NAME);
00878
00879 cxxfile = fopen(buf, "wt");
00880 Is_True(cxxfile, ("Can not open offline table file!"));
00881
00882 fprintf(cxxfile, "//-*-c++-*-\n");
00883 fprintf(cxxfile, "#include \"defs.h\"\n");
00884 fprintf(cxxfile, "#include \"errors.h\"\n");
00885 fprintf(cxxfile, "#include \"targ_isa_bundle.h\"\n");
00886 fprintf(cxxfile, "#include \"%s.h\"\n", OFFLINE_TABLE_FILE_NAME);
00887
00888 Init_Memory();
00889 Gen_PTN_Table(cxxfile);
00890 DISPERSAL_TARG_TABLE dispersal_table;
00891 dispersal_table.Gen_Table();
00892 dispersal_table.Dump(cxxfile);
00893
00894 fprintf(cxxfile, "/* End of Generated Offline Table Definition.*/\n");
00895 fclose(cxxfile);
00896
00897 if (PROCESSOR_Version == 2)
00898 sprintf(buf, "%s_mck.h", OFFLINE_TABLE_FILE_NAME);
00899 else
00900 sprintf(buf, "%s.h", OFFLINE_TABLE_FILE_NAME);
00901
00902 hfile = fopen(buf, "wt");
00903 Is_True(hfile, ("Can not open offline table file!"));
00904
00905 Dump_Headerfile(hfile);
00906 fclose(hfile);
00907 Free_Memory();
00908 return 0;
00909 }
00910