extern void Generate_Tlog( const char* phase_name, const char* trans_name, SRCPOS srcpos, const char* keyword, const char* input_string, const char* output_string, const char* aux_info_string ) { if (Tlog_File==NULL) return; FmtAssert(phase_name!=NULL,("Null phase name !!")); FmtAssert(trans_name!=NULL,("Null transformation name !!")); if (keyword[0]=='\0') keyword=dummy_word; fprintf(Tlog_File, "\n%s %s %llu %s\n", phase_name, trans_name, srcpos, keyword); fprintf(Tlog_File, "{ %s }\n", input_string); fprintf(Tlog_File, "{ %s }\n", output_string); fprintf(Tlog_File, "{ %s }\n", aux_info_string); }
/* ======================================================================= * * PRQ_Top * * See interface description. * * ======================================================================= */ void* PRQ_Top( PRQ* prq ) { FmtAssert(PRQ_size(prq) > 0,("Topping empty queue")); return PRQ_Ith(prq,1); }
/* ======================================================================= * * PRQ_Upheap * * Sifts the heap_element at position 'index' in the heap (1-based) up to * its appropriate position in the heap. If the heap element should not * move closer to the root ("up"), it is not moved. The the new index of * the heap_element is returned. * * ======================================================================= */ static INT32 PRQ_Upheap( PRQ* prq, INT32 index ) { void* element; FmtAssert(index <= PRQ_size(prq) && index > 0, ("PRQ_Upheap: index %d out of bounds %d", index,PRQ_size(prq))); element = PRQ_Ith(prq,index); /* Note we do not perform a complete interchange in the body of the * loop. We wait until we have found the correct position for * 'element' before setting it. */ while ( index > 1 ) { INT32 parent_index = index / 2; void* parent = PRQ_Ith(prq,parent_index); if ( ! PRQ_comparison_fn(prq)(element,parent) ) break; PRQ_Set_Ith(prq,index,parent); index = parent_index; } PRQ_Set_Ith(prq,index,element); return index; }
/* ======================================================================= * * PRQ_Downheap * * Sifts the heap element at position 'index' in the heap (1-based) down * to its appropriate position in the heap. If the heap element should * not move further from the root ("down"), it is not moved. The the new * index of the heap_element is returned. * * ======================================================================= */ static INT32 PRQ_Downheap( PRQ* prq, INT32 index ) { void* element; FmtAssert(index <= PRQ_size(prq) && index > 0, ("PRQ_down: index %d out of bounds %d", index,PRQ_size(prq))); element = PRQ_Ith(prq,index); /* Note we do not perform a complete interchange in the body of the * loop. We wait until we have found the correct position for * 'element' before setting it. */ for(;;) { void* left_child; INT32 left_child_index = index * 2; INT32 right_child_index = left_child_index + 1; if ( left_child_index > PRQ_size(prq) ) break; left_child = PRQ_Ith(prq,left_child_index); /* If the right child is in the heap, and is "larger" than the left, * try to interchange 'element' with the right child. If the * interchange test fails, 'index' is the correct position for * element. */ if ( right_child_index <= PRQ_size(prq) && PRQ_comparison_fn(prq)(PRQ_Ith(prq,right_child_index), left_child) ) { void* right_child = PRQ_Ith(prq,right_child_index); if ( PRQ_comparison_fn(prq)(right_child,element) ) { PRQ_Set_Ith(prq,index,right_child); index = right_child_index; } else break; } else if ( PRQ_comparison_fn(prq)(left_child,element) ) { /* interchange with left child */ PRQ_Set_Ith(prq,index,left_child); index = left_child_index; } else break; } PRQ_Set_Ith(prq,index,element); return index; }
/* ======================================================================= * * PRQ_DeleteTop * * See interface description. * * ======================================================================= */ void* PRQ_Delete_Top( PRQ* prq ) { void* top_element; FmtAssert(PRQ_size(prq) > 0,("Deleting from empty heap")); top_element = PRQ_Ith(prq,1); if ( PRQ_size(prq) == 1 ) PRQ_size(prq) = 0; else { /* Move the bottom element to the top nad sift it down to its proper * position in the heap. */ void* bottom_element = PRQ_Ith(prq,PRQ_size(prq)); --PRQ_size(prq); PRQ_Set_Ith(prq,1,bottom_element); (void) PRQ_Downheap(prq,1); } return top_element; }
BOOL Validate_List ( LNK_LST *lst ) { INT32 count = LST_Len(lst); LST_ITM *p; for ( p=LST_first(lst); p!=NULL; p=LST_next(p) ) { if ( --count < 0 ) break; } if ( count != 0 ) { if ( Get_Trace ( TKIND_INFO, TINFO_HARD, 0 ) ) { fprintf ( TFile, "##### Validate_List: Invalid count #####\n" ); count = 10*LST_Len(lst); for ( p=LST_first(lst); p!=NULL; p=LST_next(p) ) { if ( --count < 0 ) break; fprintf ( TFile, " 0x%08x: %d\n", p, LST_val(p) ); } } FmtAssert ( FALSE, ( "Validate_List: invalid count %d", LST_Len(lst) ) ); return FALSE; } return TRUE; }
//******************************************************* // Process the cc1 command line arguments. //******************************************************* void Process_Cc1_Command_Line(gs_t arg_list) { INT i, j; char *cp; INT Src_Count = 0; BOOL opt_set = FALSE; INT argc = gs_length(arg_list); char *argv; // determine if it is C or C++ and set lang_cplus accordingly argv = gs_s(gs_index(arg_list, 0)); char *command = Last_Pathname_Component(argv); //printf("%s\n", command); #ifdef FE_GNU_4_2_0 lang_cplus = !strcmp(command, "cc1plus42"); #else lang_cplus = !strcmp(command, "cc1plus"); #endif if (lang_cplus) key_exceptions = 1; for (i = 1; i < argc; i++) { argv = gs_s(gs_index(arg_list, i)); // printf("%s\n", argv); if ( *argv == '-' ) { cp = argv+1; /* Pointer to next flag character */ switch ( *cp++ ) { case 'a': if (!strcmp( cp, "uxbase" )) i++; break; case 'd': if (!strcmp( cp, "umpbase" )) { i++; Orig_Src_File_Name = gs_s(gs_index(arg_list, i)); } break; case 'e': if (lang_cplus && !strcmp( cp, "xceptions" )) key_exceptions = TRUE; break; case 'f': if (!strcmp( cp, "no-exceptions" )) { key_exceptions = FALSE; } else if (lang_cplus && !strcmp( cp, "exceptions" )) { key_exceptions = TRUE; } else if (!strcmp( cp, "no-gnu-exceptions")) { // GNU exceptions off, turn off exception here also. key_exceptions = FALSE; } else if (!lang_cplus && !strcmp( cp, "no-c-omit-external")) { c_omit_external = FALSE; } else if (!lang_cplus && !strcmp( cp, "c-omit-external")) { c_omit_external = TRUE; } #ifdef FE_GNU_4_2_0 else if (!strcmp( cp, "no-cxx-openmp")) { enable_cxx_openmp = FALSE; } else if (lang_cplus && !strcmp( cp, "cxx-openmp")) { enable_cxx_openmp = TRUE; } #endif break; case 'g': /* Debug level: */ Debug_Level = Get_Numeric_Flag (&cp, 0, MAX_DEBUG_LEVEL, 2, argv); if (Debug_Level > 1 && !opt_set) Opt_Level = 0; break; case 'i': if (!strcmp( cp, "prefix" )) i++; break; case 'm': #ifndef TARG_MIPS if (!strcmp( cp, "32" )) { TARGET_64BIT = FALSE; } else if (!strcmp( cp, "64" )) { TARGET_64BIT = TRUE; } else if (!strncmp( cp, "regparm=", 8 )) { cp += 8; Reg_Parm_Count = Get_Numeric_Flag (&cp, 0, 3, 0, argv ); } else if (!strcmp( cp, "sseregparm" )) { SSE_Reg_Parm = TRUE; } #else // 11953: MIPS expects -mabi=n32 or -mabi=64 if (!strcmp( cp, "abi=n32" )) { TARGET_64BIT = FALSE; } else if (!strcmp( cp, "abi=64" )) { TARGET_64BIT = TRUE; } #endif break; case 'o': if (*cp == 0) i++; break; case 'p': if (!strcmp( cp, "static_as_global" )) { pstatic_as_global = TRUE; } break; case 'O': /* Optimization level: */ Opt_Level = Get_Numeric_Flag (&cp, 0, MAX_OPT_LEVEL, DEF_O_LEVEL, argv ); opt_set = TRUE; break; case 's': if (!strcmp( cp, "pinfile" )) i++; break; case 'v': Show_Progress = TRUE; break; default: /* What's this? */ break; } } else if (argv != NULL) { Src_Count++; FmtAssert(Src_Count == 1, ("wgen passed more than one source file in command line")); Src_File_Name = argv; if (Orig_Src_File_Name == NULL) Orig_Src_File_Name = argv; } } }
/* ==================================================================== * * TI_RES_RES_Resources_Relevant * * See interface description * * ==================================================================== */ BOOL TI_RES_RES_Resources_Relevant( TI_RES_RES *res, TOP opcode1, TOP opcode2, INT offset ) { INT length1, length2, i; const INT32 length = TI_RES_RES_length(res); const SI_RESOURCE_ID_SET *const res_ids1 = TSI_II_Cycle_Resource_Ids_Used(opcode1,length); const SI_RESOURCE_ID_SET *const res_ids2 = TSI_II_Cycle_Resource_Ids_Used(opcode2,length); const INT rr1_length = SI_RR_Length(TSI_II_Resource_Requirement(opcode1,length)); const INT rr2_length = SI_RR_Length(TSI_II_Resource_Requirement(opcode2,length)); const INT offset_mod_ii = Cycle_Mod_II(offset,length); const SI_RESOURCE_ID_SET *const uncommon_res_ids = TI_RES_RES_uncommon_res_ids(res); FmtAssert (TI_RES_RES_cyclic(res), ("TI_RES_RES_Resources_Relevant not applicable to non-cyclic schedules")); /* Check from the start of rr2 until either the end of rr2 or the end of * rr1 + offset (which cannot be greater than II-1.) */ length1 = rr1_length - offset_mod_ii; if ( rr2_length < length1 ) length1 = rr2_length; for ( i = 0; i < length1; ++i ) { if ( SI_RESOURCE_ID_SET_Intersection4_Non_Empty( res_ids1[i + offset_mod_ii], uncommon_res_ids[i + offset_mod_ii], res_ids2[i], uncommon_res_ids[i] ) ) { return TRUE; } } /* The resource requirements for opcode1 (rr1) and opcode2 (rr2) * are already modulo the II. But we are comparing rr2 at an offset * from rr1, therefore we may have some cycles and the end of rr2 * that wrap around to the beginning of rr1. If that is the case, * check those cycles. Note that rr2 can only wrap once (because * we have use the offset mod II), and some cycles in the middle * of rr2 may not need to be checked against rr1 (because rr1 might * consume no resource in those cycles). */ length2 = (rr2_length + offset_mod_ii) - length; if ( length > 0 ) { if ( rr1_length < length2 ) length2 = rr1_length; for ( i = 0; i < length2; ++i ) { if ( SI_RESOURCE_ID_SET_Intersection4_Non_Empty( res_ids1[i], uncommon_res_ids[i], res_ids2[i + length - offset_mod_ii], uncommon_res_ids[i + length - offset_mod_ii] ) ) { return TRUE; } } } return FALSE; }