/* remove a link from the list `list' */ extern t_list * removeElementLink(t_list *list, t_list *element) { t_list *current_elem; /* preconditions */ if (list == NULL || element == NULL) return list; if ((LPREV(element) == NULL) && (element != list)) return list; /* intialize the value of `current_elem' */ current_elem = list; while( (LDATA(current_elem) != LDATA(element)) || (LPREV(current_elem) != LPREV(element)) || (LNEXT(current_elem) != LNEXT(element)) ) { /* retrieve the next element from the list */ current_elem = LNEXT(current_elem); /* test if we reached the end of the list */ if (current_elem == NULL) return list; } if (LPREV(element) == NULL) { assert(list == element); if (LNEXT(element) != NULL) { list = LNEXT(element); SET_PREV(LNEXT(element), NULL); } else list = NULL; /* remove the allocated memory of element */ _FREE_FUNCTION(element); return list; } /* we found the element */ if (LPREV(element) != NULL) { /* we found the element, and it is the top of the list */ SET_NEXT(LPREV(element), LNEXT(element)); } if (LNEXT(element) != NULL) SET_PREV(LNEXT(element), LPREV(element)); /* remove the allocated memory of element */ _FREE_FUNCTION(element); /* return the new top of the list */ return list; }
t_axe_variable * getVariable (t_program_infos *program, char *ID) { t_axe_variable search_pattern; t_list *elementFound; /* preconditions */ if (program == NULL) notifyError(AXE_PROGRAM_NOT_INITIALIZED); if (ID == NULL) notifyError(AXE_VARIABLE_ID_UNSPECIFIED); /* initialize the pattern */ search_pattern.ID = ID; /* search inside the list of variables */ elementFound = CustomfindElement (program->variables, &search_pattern, compareVariables); /* if the element is found return it to the caller. Otherwise return NULL. */ if (elementFound != NULL) return (t_axe_variable *) LDATA(elementFound); return NULL; }
/* find a label with a given `ID' */ t_asm_label * findLabel(t_translation_infos *infos, char *ID, int *asm_errorcode) { t_asm_label pattern; t_list *label_element; /* preconditions */ if (infos == NULL && asm_errorcode != NULL) (*asm_errorcode) = ASM_NOT_INITIALIZED_INFO; if (ID == NULL && asm_errorcode != NULL) (*asm_errorcode) = ASM_INVALID_LABEL_FOUND; /* initialize the value of `asm_errorcode' */ (*asm_errorcode) = ASM_OK; /* initialize `pattern' */ pattern.ID = ID; pattern.data = NULL; /* search the label */ label_element = CustomfindElement(infos->labels, &pattern, compareLabels); /* if not found return a NULL pointer */ if (label_element == NULL) return NULL; /* return the label found */ return (t_asm_label *) LDATA(label_element); }
void finalizeVariables(t_list *variables) { t_list *current_element; t_axe_variable *current_var; if (variables == NULL) return; /* initialize the `current_element' */ current_element = variables; while(current_element != NULL) { current_var = (t_axe_variable *) LDATA(current_element); if (current_var != NULL) { if (current_var->ID != NULL) free(current_var->ID); _AXE_FREE_FUNCTION(current_var); } current_element = LNEXT(current_element); } /* free the list of variables */ freeList(variables); }
/* free the memory associated with a given basic block */ void finalizeBasicBlock(t_basic_block *block) { t_list *current_element; t_cflow_Node *current_node; if (block == NULL) return; if (block->pred != NULL) freeList(block->pred); if (block->succ != NULL) freeList(block->succ); /* initialize current_element */ current_element = block->nodes; while (current_element != NULL) { /* retrieve the current node */ current_node = (t_cflow_Node *) LDATA(current_element); /* free the memory associated with the current node */ finalizeNode(current_node); /* retrieve the next node in the list */ current_element = LNEXT(current_element); } freeList(block->nodes); /* free the memory associated with this basic block */ _AXE_FREE_FUNCTION(block); }
/* add sorted */ t_list * addSorted(t_list *list, void * data , int (*compareFunc)(void *a, void *b)) { t_list *current_element; void *current_data; int counter; /* preconditions */ if (list == NULL) return addFirst(list, data); counter = 0; current_element = list; while(current_element != NULL) { /* get the current interval informations */ current_data = LDATA(current_element); assert(current_data != NULL); if (compareFunc(current_data, data) >= 0) { list = addElement(list, data, counter); return list; } /* retrieve the next element */ current_element = LNEXT(current_element); /* update the value of counter */ counter++; } return addElement(list, data, -1); }
/* finalize an instance of `t_axe_label_manager' */ void finalize_label_manager(t_axe_label_manager *lmanager) { t_list *current_element; t_axe_label *current_label; /* preconditions */ if (lmanager == NULL) return; /* initialize `current_element' to the head of the list * of labels */ current_element = lmanager->labels; while (current_element != NULL) { /* retrieve the current label */ current_label = (t_axe_label *) LDATA(current_element); assert(current_label != NULL); /* free the memory associated with the current label */ _AXE_FREE_FUNCTION(current_label); /* fetch the next label */ current_element = LNEXT(current_element); } /* free the memory associated to the list of labels */ freeList(lmanager->labels); _AXE_FREE_FUNCTION(lmanager); }
t_list * addList(t_list *list, t_list *elements) { t_list *current_element; void *current_data; /* if the list of elements is null, this function * will return `list' unmodified */ if (elements == NULL) return list; /* initialize the value of `current_element' */ current_element = elements; while (current_element != NULL) { /* retrieve the data associated with the current element */ current_data = LDATA(current_element); list = addElement(list, current_data, -1); /* retrieve the next element in the list */ current_element = LNEXT(current_element); } /* return the new list */ return list; }
t_list * addListToSet(t_list *list, t_list *elements , int (*compareFunc)(void *a, void *b), int *modified) { t_list *current_element; void *current_data; /* if the list of elements is NULL returns the current list */ if (elements == NULL) return list; /* initialize the value of `current_element' */ current_element = elements; while (current_element != NULL) { /* retrieve the data associated with the current element */ current_data = LDATA(current_element); /* Test if the element was already inserted. */ if (CustomfindElement(list, current_data, compareFunc) == NULL) { list = addElement(list, current_data, -1); if (modified != NULL) (* modified) = 1; } /* retrieve the next element in the list */ current_element = LNEXT(current_element); } /* return the new list */ return list; }
t_list * cloneList(t_list *list) { t_list *result; t_list *current_element; /* initialize the local variables */ result = NULL; current_element = list; /* preconditions */ if (current_element == NULL) return result; while(current_element != NULL) { /* add an element to the new list */ result = addElement(result, LDATA(current_element), -1); /* retrieve the next element of the list */ current_element = LNEXT(current_element); } /* return the new list */ return result; }
/* find an element inside the list `list'. */ t_list * CustomfindElement(t_list *list, void *data , int (*compareFunc)(void *a, void *b)) { t_list *current_elem; /* preconditions */ if (compareFunc == NULL) return findElement(list, data); if (list == NULL) return NULL; /* intialize the value of `current_elem' */ current_elem = list; while (current_elem != NULL) { void *other_Data; other_Data = LDATA(current_elem); if (compareFunc(other_Data, data)) break; current_elem = LNEXT(current_elem); } /* postconditions */ return current_elem; }
void printGraphInfos(t_cflow_Graph *graph, FILE *fout, int verbose) { int counter; t_list *current_element; t_basic_block *current_bblock; /* preconditions */ if (graph == NULL) return; if (fout == NULL) return; /* initialization of the local variables */ counter = 1; fprintf(fout,"NOTE : Temporary registers are considered as\n" " variables of the intermediate language. \n"); #if CFLOW_ALWAYS_LIVEIN_R0 == (1) fprintf(fout," Variable \'R0\' (that refers to the \n" " physical register \'RO\') is always \n" " considered LIVE-IN for each node of \n" " a basic block. \n" " Thus, in the following control flow graph, \n" " \'R0\' will never appear as LIVE-IN or LIVE-OUT\n" " variable for a statement.\n\n" " If you want to consider \'R0\' as\n" " a normal variable, you have to set\n" " to 0 the value of the macro CFLOW_ALWAYS_LIVEIN_R0\n" " defined in \"cflow_constants.h\".\n\n"); #endif fprintf(fout,"\n"); fprintf(fout,"**************************\n"); fprintf(fout," CONTROL FLOW GRAPH \n"); fprintf(fout,"**************************\n"); fprintf(fout,"NUMBER OF BASIC BLOCKS : %d \n" , getLength(graph->blocks)); fprintf(fout,"NUMBER OF USED VARIABLES : %d \n" , getLength(graph->cflow_variables)); fprintf(fout,"--------------------------\n"); fprintf(fout,"START BASIC BLOCK INFOS. \n"); fprintf(fout,"--------------------------\n"); /* initialize `current_block' */ current_element = graph->blocks; while(current_element != NULL) { current_bblock = (t_basic_block *) LDATA(current_element); fprintf(fout,"[BLOCK %d] \n", counter); printBBlockInfos(current_bblock, fout, verbose); if (LNEXT(current_element) != NULL) fprintf(fout,"--------------------------\n"); else fprintf(fout,"**************************\n"); counter++; current_element = LNEXT(current_element); } fprintf(fout,"\n\n"); }
/* finalize the memory associated with the given control flow graph */ void finalizeGraph(t_cflow_Graph *graph) { t_list *current_element; t_basic_block *current_block; if (graph == NULL) return; current_element = graph->blocks; while (current_element != NULL) { /* retrieve the current node */ current_block = (t_basic_block *) LDATA(current_element); assert(current_block != NULL); finalizeBasicBlock(current_block); current_element = LNEXT(current_element); } if (graph->blocks != NULL) freeList(graph->blocks); if (graph->endingBlock != NULL) finalizeBasicBlock(graph->endingBlock); if (graph->cflow_variables != NULL) { t_list *current_element; t_cflow_var *current_variable; current_element = graph->cflow_variables; while (current_element != NULL) { current_variable = (t_cflow_var *) LDATA(current_element); if (current_variable != NULL) _AXE_FREE_FUNCTION(current_variable); /* retrieve the next variable in the list */ current_element = LNEXT(current_element); } freeList(graph->cflow_variables); } _AXE_FREE_FUNCTION(graph); }
/* finalization of the `infos' structure */ int finalizeStructures(t_translation_infos *infos) { if (infos == NULL) return ASM_NOT_INITIALIZED_INFO; if (infos->code != NULL) { t_list *current_element; t_asm_instruction *current_instr; /* initialize `data' */ current_element = infos->code; while ((current_element != NULL) && (infos->codesize > 0) ) { current_instr = (t_asm_instruction *) LDATA(current_element); /* free memory associated with the current instruction */ freeInstruction(current_instr); /* update the value of `current_element' */ current_element = LNEXT(current_element); infos->codesize --; } while (current_element != NULL) { /* free memory associated with the current data info. */ freeData((t_asm_data *) LDATA(current_element)); /* update the value of `current_element' */ current_element = LNEXT(current_element); } /* free the code and data segment infos */ freeList(infos->code); } /* remove labels */ finalizeLabels(infos->labels); /* free the memory block associated with `infos' */ _ASM_FREE_FUNCTION(infos); return ASM_OK; }
/* look up for a label inside the graph */ t_basic_block * searchLabel(t_cflow_Graph *graph, t_axe_label *label) { t_list *current_element; t_basic_block *bblock; t_cflow_Node *current_node; /* preconditions: graph should not be a NULL pointer */ if (graph == NULL){ cflow_errorcode = CFLOW_GRAPH_UNDEFINED; return NULL; } /* test if we haven't to search for a label */ if (label == NULL) return NULL; /* initialize `bblock' */ bblock = NULL; current_element = graph->blocks; while(current_element != NULL) { bblock = (t_basic_block *) LDATA(current_element); assert(bblock != NULL); assert(bblock->nodes != NULL); /* retrieve the first node of the basic block */ current_node = (t_cflow_Node *) LDATA(bblock->nodes); assert(current_node != NULL); /* if the first node holds a label information, we * have to verify if we have found the right label */ if ((current_node->instr)->labelID != NULL) { if (compareLabels((current_node->instr)->labelID, label)) /* we found the correct basic block */ break; } /* retrieve the next element */ current_element = LNEXT(current_element); } return bblock; }
int performLivenessIteration(t_cflow_Graph *graph) { int modified; t_list *current_element; t_basic_block *current_bblock; /* initialize the value of the local variable `modified' */ modified = 0; /* test the preconditions */ if (graph == NULL) { cflow_errorcode = CFLOW_GRAPH_UNDEFINED; return modified; } /* test if `graph->endingBlock' is valid */ if (graph->endingBlock == NULL) { cflow_errorcode = CFLOW_INVALID_BBLOCK; return modified; } /* retrieve the last basic block in the list */ current_element = getLastElement(graph->blocks); while(current_element != NULL) { t_list *live_out_vars; current_bblock = (t_basic_block *) LDATA(current_element); assert(current_bblock != NULL); /* retrieve the variables that will be live out from this block */ live_out_vars = computeLiveOutVars(graph, current_bblock); /* test if an error occurred */ if (cflow_errorcode != CFLOW_OK) return modified; /* retrieve the liveness informations for the current bblock */ if (performLivenessOnBlock(current_bblock, live_out_vars)) modified = 1; /* remove the list `out' */ freeList(live_out_vars); /* test if an error occurred */ if (cflow_errorcode != CFLOW_OK) { return modified; } /* retrieve the previous element in the list */ current_element = LPREV(current_element); } /* return 1 if another liveness iteration is required */ return modified; }
void printBBlockInfos(t_basic_block *block, FILE *fout, int verbose) { t_list *current_element; t_cflow_Node *current_node; int count; /* preconditions */ if (block == NULL) return; if (fout == NULL) return; fprintf(fout,"NUMBER OF PREDECESSORS : %d \n" , getLength(block->pred) ); fprintf(fout,"NUMBER OF SUCCESSORS : %d \n" , getLength(block->succ) ); fprintf(fout,"NUMBER OF INSTRUCTIONS : %d \n" , getLength(block->nodes) ); count = 1; current_element = block->nodes; while(current_element != NULL) { current_node = (t_cflow_Node *) LDATA(current_element); fprintf(fout,"\t%d. ", count); debug_printInstruction(current_node->instr, fout); if (verbose != 0) { if (current_node->def != NULL) fprintf(fout, "\n\t\t\tDEF = [R%d]", (current_node->def)->ID); if (current_node->uses[0] != NULL) { fprintf(fout, "\n\t\t\tUSES = [R%d", ((current_node->uses)[0])->ID); if (current_node->uses[1] != NULL) fprintf(fout, ", R%d", ((current_node->uses)[1])->ID); if (current_node->uses[2] != NULL) fprintf(fout, ", R%d", ((current_node->uses)[2])->ID); fprintf(fout, "]"); } fprintf(fout, "\n\t\t\tLIVE IN = ["); printListOfVariables(current_node->in, fout); fprintf(fout, "]"); fprintf(fout, "\n\t\t\tLIVE OUT = ["); printListOfVariables(current_node->out, fout); fprintf(fout, "]"); } fprintf(fout, "\n"); count++; current_element = LNEXT(current_element); } }
/* remove an element from the list */ t_list * removeElement(t_list *list, void * data) { t_list *current_elem; /* preconditions: the list shouldn't be empty */ if (list == NULL) return NULL; /* intialize the value of `current_elem' */ current_elem = list; while ( (current_elem != NULL) && (LDATA(current_elem) != data)) { current_elem = LNEXT(current_elem); } /* the value hasn't been found */ if (current_elem == NULL) return list; /* the value is found */ if (LPREV(current_elem) != NULL) { SET_NEXT(LPREV(current_elem), LNEXT(current_elem)); if (LNEXT(current_elem) != NULL) SET_PREV(LNEXT(current_elem), LPREV(current_elem)); _FREE_FUNCTION(current_elem); } else { /* check the preconditions */ assert(list == current_elem); if (LNEXT(current_elem) != NULL) { SET_PREV(LNEXT(current_elem), NULL); /* update the new head of the list */ list = LNEXT(current_elem); } else list = NULL; _FREE_FUNCTION(current_elem); } /* postconditions: return the new head of the list */ return list; }
void test_dsa160(const struct dsa_public_key *pub, const struct dsa_private_key *key, const struct dsa_signature *expected) { struct sha1_ctx sha1; struct dsa_signature signature; struct knuth_lfib_ctx lfib; sha1_init(&sha1); dsa_signature_init(&signature); knuth_lfib_init(&lfib, 1111); sha1_update(&sha1, LDATA("The magic words are squeamish ossifrage")); ASSERT (dsa_sha1_sign(pub, key, &lfib, (nettle_random_func *) knuth_lfib_random, &sha1, &signature)); if (verbose) { fprintf(stderr, "dsa160 signature: "); mpz_out_str(stderr, 16, signature.r); fprintf(stderr, ", "); mpz_out_str(stderr, 16, signature.s); fprintf(stderr, "\n"); } if (expected) ASSERT (mpz_cmp (signature.r, expected->r) == 0 && mpz_cmp (signature.s, expected->s) == 0); /* Try bad data */ ASSERT (!DSA_VERIFY(pub, sha1, "The magick words are squeamish ossifrage", &signature)); /* Try correct data */ ASSERT (DSA_VERIFY(pub, sha1, "The magic words are squeamish ossifrage", &signature)); /* Try bad signature */ mpz_togglebit(signature.r, 17); ASSERT (!DSA_VERIFY(pub, sha1, "The magic words are squeamish ossifrage", &signature)); dsa_signature_clear(&signature); }
t_list * getLiveINVars(t_basic_block *bblock) { t_cflow_Node *firstNode; if (bblock == NULL) return NULL; if (bblock->nodes == NULL) return NULL; firstNode = (t_cflow_Node *) LDATA(bblock->nodes); assert(firstNode != NULL); /* return a copy of the list of variables live in * input to the current basic block */ return cloneList(firstNode->in); }
t_list * computeLiveOutVars(t_cflow_Graph *graph, t_basic_block *block) { t_list *current_elem; t_basic_block *current_succ; t_list *result; t_list *liveINVars; /* preconditions */ if (block == NULL) return NULL; if (graph == NULL) { cflow_errorcode = CFLOW_GRAPH_UNDEFINED; return NULL; } /* initialize `current_elem' */ current_elem = block->succ; /* initialize `result' */ result = NULL; while(current_elem != NULL) { current_succ = (t_basic_block *) LDATA(current_elem); assert(current_succ != NULL); if (current_succ != graph->endingBlock) { liveINVars = getLiveINVars(current_succ); /* update the value of `result' */ result = addListToSet(result , liveINVars, NULL, NULL); /* free the temporary list of live intervals */ freeList(liveINVars); } current_elem = LNEXT(current_elem); } /* postconditions */ return result; }
/* find an element inside the list `list'. The current implementation calls the * CustomfindElement' passing a NULL reference as `func' */ t_list * findElement(t_list *list, void *data) { t_list *current_elem; /* if the list is empty returns a NULL pointer */ if (list == NULL) return NULL; /* intialize the value of `current_elem' */ current_elem = list; while ( (current_elem != NULL) && ( LDATA(current_elem) != data) ) { current_elem = LNEXT(current_elem); } /* postconditions */ return current_elem; }
/* alloc a variable identifier */ t_cflow_var * allocVariable (t_cflow_Graph *graph, int identifier) { t_cflow_var * result; t_list *elementFound; if (graph == NULL) { cflow_errorcode = CFLOW_GRAPH_UNDEFINED; return NULL; } /* alloc memory for a variable information */ result = _AXE_ALLOC_FUNCTION(sizeof(t_cflow_var)); if (result == NULL) { cflow_errorcode = CFLOW_OUT_OF_MEMORY; return NULL; } /* update the value of result */ result->ID = identifier; /* test if a variable with the same identifier was already present */ elementFound = CustomfindElement (graph->cflow_variables, result, compare_CFLOW_Variables); if (elementFound == NULL) { /* update the set of variables */ graph->cflow_variables = addElement (graph->cflow_variables, result, -1); } else { _AXE_FREE_FUNCTION(result); result = (t_cflow_var *) LDATA(elementFound); assert(result != NULL); assert(result->ID == identifier); } /* return a new var identifier */ return result; }
t_list * getLiveOUTVars(t_basic_block *bblock) { t_list *last_Element; t_cflow_Node *lastNode; if (bblock == NULL) return NULL; if (bblock->nodes == NULL) return NULL; last_Element = getLastElement(bblock->nodes); lastNode = (t_cflow_Node *) LDATA(last_Element); assert(lastNode != NULL); /* return a copy of the list of variables live in * input to the current basic block */ return cloneList(lastNode->out); }
void printListOfVariables(t_list *variables, FILE *fout) { t_list *current_element; t_cflow_var *current_variable; if (variables == NULL) return; if (fout == NULL) return; current_element = variables; while(current_element != NULL) { current_variable = (t_cflow_var *) LDATA(current_element); fprintf(fout, "R%d", current_variable->ID); if (LNEXT(current_element) != NULL) fprintf(fout, ", "); current_element = LNEXT(current_element); } }
void finalizeDataSegment(t_list *dataDirectives) { t_list *current_element; t_axe_data *current_data; /* nothing to finalize */ if (dataDirectives == NULL) return; current_element = dataDirectives; while(current_element != NULL) { /* retrieve the current instruction */ current_data = (t_axe_data *) LDATA(current_element); if (current_data != NULL) free_Data(current_data); current_element = LNEXT(current_element); } /* free the list of instructions */ freeList(dataDirectives); }
void finalizeInstructions(t_list *instructions) { t_list *current_element; t_axe_instruction *current_instr; /* nothing to finalize */ if (instructions == NULL) return; current_element = instructions; while(current_element != NULL) { /* retrieve the current instruction */ current_instr = (t_axe_instruction *) LDATA(current_element); if (current_instr != NULL) free_Instruction(current_instr); current_element = LNEXT(current_element); } /* free the list of instructions */ freeList(instructions); }
void printLiveIntervals(t_list *intervals, FILE *fout) { t_list *current_element; t_live_interval *interval; /* precondition */ if (fout == NULL) return; fprintf(fout, "LIVE_INTERVALS:\n"); /* retireve the first element of the list */ current_element = intervals; while (current_element != NULL) { interval = (t_live_interval *) LDATA(current_element); fprintf(fout, "\tLIVE_INTERVAL of T%d : [%d, %d] \n" , interval->varID, interval->startPoint, interval->endPoint); /* retrieve the next element in the list of intervals */ current_element = LNEXT(current_element); } }
void finalizeLabels(t_list *labels) { t_list *current_element; t_asm_label *current_label; if (labels == NULL) return; current_element = labels; while(current_element != NULL) { current_label = (t_asm_label *) LDATA(current_element); if (current_label != NULL) { if (current_label->ID != NULL) free(current_label->ID); _ASM_FREE_FUNCTION(current_label); } current_element = LNEXT(current_element); } freeList(labels); }
int performLivenessOnBlock(t_basic_block *bblock, t_list *out) { t_list *current_element; t_list *cloned_list; t_cflow_Node *next_node; t_cflow_Node *current_node; int modified; /* initialize the local variables */ modified = 0; if (bblock == NULL || bblock->nodes == NULL) { cflow_errorcode = CFLOW_INVALID_BBLOCK; return modified; } current_element = getLastElement(bblock->nodes); current_node = (t_cflow_Node *) LDATA(current_element); assert(current_node != NULL); /* update the out set */ current_node->out = addListToSet (current_node->out, out, NULL, &modified); /* update the in list */ cloned_list = cloneList(current_node->out); #if CFLOW_ALWAYS_LIVEIN_R0 == (1) if ((current_node->uses)[0] != NULL && (current_node->uses)[0]->ID != REG_0) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[0], NULL); if ((current_node->uses)[1] != NULL && (current_node->uses)[1]->ID != REG_0) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[1], NULL); if ((current_node->uses)[2] != NULL && (current_node->uses)[2]->ID != REG_0) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[2], NULL); #else if ((current_node->uses)[0] != NULL) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[0], NULL); if ((current_node->uses)[1] != NULL) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[1], NULL); if ((current_node->uses)[2] != NULL) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[2], NULL); #endif #if CFLOW_ALWAYS_LIVEIN_R0 == (1) if (current_node->def != NULL && (current_node->def)->ID != REG_0) #else if (current_node->def != NULL) #endif { int found = 0; int current_use_idx = 0; do { if ((current_node->uses)[current_use_idx] != NULL) { if ((current_node->uses)[current_use_idx]->ID == current_node->def->ID) found = 1; } current_use_idx++; } while((found == 0) && (current_use_idx < 3)); if (!found) cloned_list = removeElement(cloned_list, current_node->def); } current_node->in = addListToSet (current_node->in, cloned_list, NULL, &modified); /* remove the cloned list */ freeList(cloned_list); /* set the new value of next_node */ next_node = current_node; current_element = LPREV(current_element); while (current_element != NULL) { /* take a new node */ current_node = (t_cflow_Node *) LDATA(current_element); assert(current_node != NULL); /* clone the `in' list of the next_node */ cloned_list = cloneList(next_node->in); /* update the out list */ current_node->out = addListToSet (current_node->out, cloned_list, NULL, &modified); /* remove the cloned list */ freeList(cloned_list); /* clone the `in' list of the next_node */ cloned_list = cloneList(current_node->out); /* update the in list */ #if CFLOW_ALWAYS_LIVEIN_R0 == (1) if ((current_node->uses)[0] != NULL && (current_node->uses)[0]->ID != REG_0) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[0], NULL); if ((current_node->uses)[1] != NULL && (current_node->uses)[1]->ID != REG_0) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[1], NULL); if ((current_node->uses)[2] != NULL && (current_node->uses)[2]->ID != REG_0) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[2], NULL); #else if ((current_node->uses)[0] != NULL) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[0], NULL); if ((current_node->uses)[1] != NULL) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[1], NULL); if ((current_node->uses)[2] != NULL) cloned_list = addVariableToSet (cloned_list, (current_node->uses)[2], NULL); #endif #if CFLOW_ALWAYS_LIVEIN_R0 == (1) if (current_node->def != NULL && (current_node->def)->ID != REG_0) #else if (current_node->def != NULL) #endif { int found = 0; int current_use_idx = 0; do { if ((current_node->uses)[current_use_idx] != NULL) { if ((current_node->uses)[current_use_idx]->ID == current_node->def->ID) { found = 1; } } current_use_idx++; } while((found == 0) && (current_use_idx < 3)); if (!found) cloned_list = removeElement(cloned_list, current_node->def); } current_node->in = addListToSet (current_node->in, cloned_list, NULL, &modified); /* remove the cloned list */ freeList(cloned_list); /* update the loop control informations */ current_element = LPREV(current_element); next_node = current_node; } /* return the `modified' value */ return modified; }