예제 #1
0
/*
 *  ======== MessageQ_count ========
 */
Int MessageQ_count(MessageQ_Handle handle)
{
    Int              count = 0;
    UInt             key;
    List_Elem       *tempMsg = NULL;
    List_Handle      listHandle;
    ti_sdo_ipc_MessageQ_Object *obj = (ti_sdo_ipc_MessageQ_Object *)handle;

    /* lock */
    key = Hwi_disable();
    
    /* Get the list */
    listHandle = ti_sdo_ipc_MessageQ_Instance_State_highList(obj);
        
    /* Loop through and count the messages */
    while ((tempMsg = List_next(listHandle, tempMsg)) != NULL) {
        count++;
    }
    
    listHandle = ti_sdo_ipc_MessageQ_Instance_State_normalList(obj);
        
    /* Loop through and count the messages */
    while ((tempMsg = List_next(listHandle, tempMsg)) != NULL) {
        count++;
    }

    /* unlock scheduler */
    Hwi_restore(key);    
    
    return (count);
}
예제 #2
0
static int *
get_exonlengths (int **exonmatches, int *nexons, List_T pairs, bool bysizep) {
  int *exonlengths;
  Intlist_T list = NULL, matchlist = NULL;
  Pair_T firstpair, pair;
  int querypos, nmatches = 0;
#ifdef DEBUG
  int i;
#endif

  firstpair = List_head(pairs);
  querypos = firstpair->querypos;

  while (pairs != NULL) {
    pair = List_head(pairs);
    if (pair->gapp == true && big_gap_p(pair,bysizep) == true) {
      list = Intlist_push(list,querypos-firstpair->querypos+1);
      matchlist = Intlist_push(matchlist,nmatches);

      pairs = List_next(pairs);
      if (pairs != NULL) {
	firstpair = List_head(pairs);
	querypos = firstpair->querypos;
	nmatches = 0;
      }
    } else {
      querypos = pair->querypos;
      if (pair->comp == MATCH_COMP || pair->comp == DYNPROG_MATCH_COMP) {
	nmatches++;
      }
      pairs = List_next(pairs);
    }
  }

  list = Intlist_push(list,querypos-firstpair->querypos+1);
  list = Intlist_reverse(list);
  matchlist = Intlist_push(matchlist,nmatches);
  matchlist = Intlist_reverse(matchlist);

  exonlengths = Intlist_to_array(&(*nexons),list);
  *exonmatches = Intlist_to_array(&(*nexons),matchlist);
  debug(
	printf("%d exons: ",*nexons);
	for (i = 0; i < *nexons; i++) {
	  printf("%d (%d matches),",exonlengths[i],(*exonmatches)[i]);
	}
	printf("\n");
	);
예제 #3
0
PSS_TarSCC
PSS_Get_SCC (PSS_TarLoop tloop, Expr expr)
{
    PSS_TarSCC scc;
    PSS_TarNode tnode;

    if (expr->opcode != OP_assign)
    {
        P_warn("Find_TarNode_Expr: searching for tnode for expr that is not OP_assign");
        return NULL;
    }

    for (scc = tloop->sccs; scc; scc = scc->next)
    {
        if (scc->tnode_list == NULL)  /* List might be empty */
            continue;
        List_start (scc->tnode_list);
        while ((tnode = (PSS_TarNode) List_next(scc->tnode_list)))
        {
            if (expr == tnode->expr)
                return scc;
        }
    }
    return NULL;
}
Int SystemCfg_detachHook(UArg userCtx, UInt16 remoteProcId)
{
    Int                 status;
    List_Elem *         elem = NULL;
    SystemCfg_Object *  obj = NULL;
    IArg                key;

    /* find object on module list */
    key = GateH_enter(Mod_gate);

    while ((elem = List_next(Mod_objList, elem)) != NULL) {
        obj = (SystemCfg_Object *)elem;
        if (obj->remoteProcId == remoteProcId) {
            break;
        }
        obj = NULL;
    }

    GateH_leave(Mod_gate, key);

    if (obj != NULL) {
        status = Notify_unregisterEvent(remoteProcId, SystemCfg_NotifyLineId,
            SystemCfg_HostDspEvtNum, SystemCfg_notifyCB, (UArg)obj);

        if (status < 0) {
            Log_error1(FXNN": Notify_unregisterEvent() error %d", (IArg)status);
        }
    }

    return(status);
}
static void
SE_free_effects()
{
  effect_t            *effect;
#if HISTORY
  IPA_HTAB_ITER       iter;
#endif

#if HISTORY
  IPA_HTAB_START(iter, effect_htab);
  IPA_HTAB_LOOP(iter)
    {
      effect = IPA_HTAB_CUR(iter);
      free(effect);
    }

  IPA_htab_free(effect_htab);
  effect_htab = NULL;
#else
  List_start(effect_hist);
  while ((effect = List_next(effect_hist)))
    {
      free(effect);
    }
  List_reset(effect_hist);
  effect_hist = NULL;
#endif
}
예제 #6
0
static int
PD_ExprsMayAlias (Expr expr1, Expr expr2)
{
  P_memdep_t md1, md2;
  List mem_obj_list1, mem_obj_list2;
  P_memdep_core_t mem_obj1, mem_obj2;

  if (!(md1 = P_GetMemDep (expr1)) ||
      !(md2 = P_GetMemDep (expr2)))
    return 0;

  if (md1 == md2)
    return 1;

  mem_obj_list1 = md1->deps;
  mem_obj_list2 = md2->deps;

  List_start (mem_obj_list1);
  while ((mem_obj1 = List_next (mem_obj_list1)))
    {
      List_start (mem_obj_list2);
      while ((mem_obj2 = List_next (mem_obj_list2)))
	{
	  if ((mem_obj1->id != mem_obj2->id) || 
	      (mem_obj1->version != mem_obj2->version))
	    continue;

	  if (mem_obj1->size == -1 || mem_obj2->size == -1)
	    {
	      /* Sizes non-descriptive */
	      return 1;
	    }
	  else
	    {
	      int o1 = mem_obj1->offset, o2 = mem_obj2->offset,
		s1 = mem_obj1->size, s2 = mem_obj2->size;

	      /* Determine if accesses overlap */
	      if ((o1 <= o2 && (o1 + s1) > o2) ||
		  (o2 < o1 && (o2 + s2) > o1))
		return 1;
	    }
	}
    }

  return 0;
}
예제 #7
0
/**
 * Asteroid_update_list
 * Runs asteroid_update() on a list of asteroids with the given length.
 */
void Asteroid_update_list(List* asteroids, float screen_width) {
    List_start_iteration(asteroids);
    Asteroid* asteroid;
    while ((asteroid = (Asteroid*) List_next(asteroids)))
    {
        Asteroid_update(asteroid, screen_width);
    }
}
예제 #8
0
/**
 * Asteroid_draw_list
 * Takes a list of asteroids and draws all of them.
 */
void Asteroid_draw_list(List* asteroids) {
    List_start_iteration(asteroids);
    Asteroid* asteroid;
    while ((asteroid = (Asteroid*) List_next(asteroids)))
    {
        Asteroid_draw(asteroid);
    }
}
/*!
 *  @brief  Find a node inside the Translation Table which da matches
 *
 *  @params da      Device address
 *
 *  @sa     _SysLinkMemUtils_insertMapElement, _SysLinkMemUtils_removeMapElement
 */
static AddrNode *
_SysLinkMemUtils_findNode (Ptr da)
{
    AddrNode  * node;

    GT_1trace (curTrace, GT_ENTER, "_SysLinkMemUtils_findNode", da);

    for (node = List_next (SysLinkMemUtils_module->addrTable, NULL);
        node != NULL; node = List_next (SysLinkMemUtils_module->addrTable,
            &node->elem)) {
        if (da == node->da) {
            break;
        }
    }

    GT_1trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_findNode", node);

    return node;
}
예제 #10
0
void
Pairpool_free (T *old) {
  List_T p;
  struct Pair_T *pairptr;
  struct List_T *listcellptr;

  if (*old) {
    for (p = (*old)->pairchunks; p != NULL; p = List_next(p)) {
      pairptr = (struct Pair_T *) List_head(p);
      FREE(pairptr);
    }
    List_free(&(*old)->pairchunks);
    for (p = (*old)->listcellchunks; p != NULL; p = List_next(p)) {
      listcellptr = (struct List_T *) List_head(p);
      FREE(listcellptr);
    }
    List_free(&(*old)->listcellchunks);
    FREE(*old);
  }
  return;
}
예제 #11
0
static int
Pin_find_stack_size (VarList var_list)
{
  int size = 0;
  VarDcl var;

  List_start (var_list);
  while ((var = (VarDcl) List_next (var_list)))
    size += PSI_GetTypeSize (var->type);

  return size;
}
예제 #12
0
void
Matchpool_free (T *old) {
  List_T p;
  struct Match_T *matchptr;
  struct List_T *listcellptr;

  if (*old) {
    for (p = (*old)->matchchunks; p != NULL; p = List_next(p)) {
      matchptr = (struct Match_T *) List_head(p);
      FREE(matchptr);
    }
    List_free(&(*old)->matchchunks);
    for (p = (*old)->listcellchunks; p != NULL; p = List_next(p)) {
      listcellptr = (struct List_T *) List_head(p);
      FREE(listcellptr);
    }
    List_free(&(*old)->listcellchunks);
    FREE(*old);
  }
  return;
}
예제 #13
0
파일: diagpool.c 프로젝트: djinnome/JAMg-1
void
Diagpool_free (T *old) {
  List_T p;
  struct Diag_T *diagptr;
  struct List_T *listcellptr;

  if (*old) {
    for (p = (*old)->diagchunks; p != NULL; p = List_next(p)) {
      diagptr = (struct Diag_T *) List_head(p);
      FREE(diagptr);
    }
    List_free(&(*old)->diagchunks);
    for (p = (*old)->listcellchunks; p != NULL; p = List_next(p)) {
      listcellptr = (struct List_T *) List_head(p);
      FREE(listcellptr);
    }
    List_free(&(*old)->listcellchunks);
    FREE(*old);
  }
  return;
}
예제 #14
0
/*
 *  ======== ti_sdo_ipc_Notify_execMany ========
 */
Void ti_sdo_ipc_Notify_execMany(UInt16 procId, UInt16 lineId, UInt32 eventId,
                                UArg arg, UInt32 payload)
{
    ti_sdo_ipc_Notify_Object *obj = (ti_sdo_ipc_Notify_Object *)arg;
    List_Handle eventList;
    ti_sdo_ipc_Notify_EventListener *listener;

    /* Both loopback and the the event itself are enabled */
    eventList = List_Object_get(obj->eventList, eventId);

    /* Use "NULL" to get the first EventListener on the list */
    listener = (ti_sdo_ipc_Notify_EventListener *)List_next(eventList, NULL);
    while (listener != NULL) {
        /* Execute the callback function */
        listener->callback.fnNotifyCbck(procId, lineId,
                                        eventId, listener->callback.cbckArg, payload);

        listener = (ti_sdo_ipc_Notify_EventListener *)List_next(eventList,
                   (List_Elem *)listener);
    }
}
예제 #15
0
파일: List.c 프로젝트: stevenlr/GrandPrix
void List_insertSorted(List list, void* ptr, List_compare ptrList_compare){
	Node node, current;
	int beforeTail = 1;
	int isHead = 1;

	assert(list);

	node = Node_new();

	if(node == NULL)
		return;

	node->ptr = ptr;

	if(list->current == NULL)
	{
		list->current = node;
		list->head = node;
		list->tail = node;
		return;
	}

	List_head(list);
	if(list->current->ptr == ptr)
		List_remove(list);

	while ((*ptrList_compare)(list->current->ptr, ptr) && beforeTail) {
		isHead = 0;
		beforeTail = List_next(list);
		if(list->current->ptr == ptr)
			List_remove(list);
	}

	current = list->current;
	list->size++;

	if(beforeTail){
		node->next = current;
		if(isHead)
			list->head = node;
		else{
			node->prev = current->prev;
			current->prev->next = node;
		}
		current->prev = node;
	}
	else{
		current->next = node;
		node->prev = current;
		list->tail = node;
	}
}
예제 #16
0
void
PSS_PrintSCC(PSS_TarSCC scc)
{
    PSS_TarNode tnode;

    fprintf(debug_file_id, "SCC (%d) - loop %d - func %s - type:",
            scc->id, scc->tloop->pcloop->ID, scc->tloop->cfg->func->name);
    PSS_PrintSCCType(debug_file_id, scc);
    fprintf(debug_file_id, "\n");

    List_start(scc->tnode_list);
    while ((tnode = List_next(scc->tnode_list)))
        Print_TarNode(tnode);
}
예제 #17
0
void
DD_DependenceTest (FuncDcl func)
{
  List expr_list;
  Expr expr1, expr2;

  /* 
   * JWS: There is no reason to do this for the whole function at once.
   * Why not do it for one loop nest at a time?
   */

  /* 
   * Find all the expressions which access memory. The resulting list
   * is stored in expr_list.  
   */

  if (!(expr_list = FindAllExprWithMemAcc (func)))
    return;			/* no expressions to examine */

  if (DD_DEBUG_OMEGA)
    fprintf (stderr, "DD_DependenceTest func=%s\n", func->name);

  DD_Preprocess (func);

  initializeOmega ();

  /* do pairwise comparison between expressions which access memory. */

  List_start (expr_list);
  while ((expr1 = List_first (expr_list)))
    {
      expr_list = List_delete_current (expr_list);

      while ((expr2 = List_next (expr_list)))
	{
	  if ((PD_IsMemWriteExpr (expr1) || 
	       PD_IsMemWriteExpr (expr2)) &&
	      PD_ExprsMayAlias (expr1, expr2))
	    PD_produce_cyclic_sync_arc (expr1, expr2);
	}
    }

  expr_list = List_reset (expr_list);

  if (DD_DEBUG_OMEGA)
    DD_PrintFuncDepInfo (stderr, func);

  return;
}
static int LB_mark_ncycle_regions(LB_TraceRegion_Header *header) {
    LB_TraceRegion *tr;
    int found = 0;

    List_start(header->traceregions);
    while ((tr = List_next(header->traceregions))) {
        Set tr_set = LB_return_cbs_region_as_set(tr);
        if (LB_hb_region_contains_cycle(tr_set, tr->header)) {
            tr->flags |= L_TRACEREGION_FLAG_NESTED_CYCLE;
            found++;
        }
        Set_dispose(tr_set);
    }

    return found;
}
예제 #19
0
/*! \brief determine if an expression is part of an SCC in a given loop
 *
 * \param tloop
 *   The Loop whose SCCs we want to search through
 *
 * \param expr
 *   The Expression we want to search for.  This can either be of type
 *   OP_assign or OP_var
 *
 * \param type
 *   The type of SCC that you want to search for.  Use type ANY
 *   if any type of SCC will do.  You can also do | of different
 *   types as PSS_TarSCC_Type is a bitfield
 *
 * \return
 *   the linear SCC it is *first* found in or NULL if not found
 *
 * This routine searches through the SCC's in a tarloop and determines
 * if one of them (of type "type") contains the definition of the expression
 * "expr" that is passed to the function.  If one is found, the scc is
 * returned.  The expression can either be of type OP_assign or OP_var.
 * If an OP_assign is passed, it will be search for directly.  If an
 * OP_var is passed, its SSA_Def will be found and that will be searched
 * for.  If the expr is of a different type, a warning will go off and
 * NULL will be returned.
 */
static PSS_TarSCC
Find_Expr_SCC(PSS_TarLoop tloop, Expr expr, PSS_TarSCC_Type type)
{
    PSS_TarSCC scc;
    PSS_TarNode tnode;
    Expr search_expr;

    if (expr->opcode == OP_assign)
    {
        search_expr = expr;
    }
    else if (expr->opcode == OP_var && expr->value.var.ssa)
    {
        search_expr = expr->value.var.ssa->var->parentexpr;
    }
    else
    {
        P_warn ("Find_Expr_SCC: searching for expression that is not OP_var"
                " or OP_assign\n");
        return NULL;
    }

    /* sanity check */
    if (search_expr->opcode != OP_assign)
        P_punt("Find_Expr_SCC: search_expr should be of type OP_assign\n");

    /* loop through the SCCs */
    for (scc = tloop->sccs; scc; scc = scc->next)
    {
        if (scc->type & type)
        {
            /* loop through the SCC's expressions */
            List_start(scc->tnode_list);
            while ((tnode = List_next(scc->tnode_list)))
            {
                if (tnode->expr == search_expr)
                {
                    return scc;
                }
            }
        }
    }
    return NULL;
}
예제 #20
0
void
I_BDD_print_minterms (List mins, int terms)
{
  char *minterm;
  int indx;

  List_start (mins);
  while ((minterm = (char *) List_next (mins)))
    {
      for (indx = 0; indx < terms; indx++)
        {
          if (minterm[indx] == 2)
            printf ("-");
          else
            printf ("%d", (int) minterm[indx]);
        }
      printf ("\n");
    }
}
static void
LB_clear_cb_visit_flags (L_Func * fn, LB_TraceRegion_Header * header)
{
  L_Cb *cb;
  LB_TraceRegion *tr;

  /* Clear all the visited flags for all cbs */
  for (cb = fn->first_cb; cb; cb = cb->next_cb)
    cb->flags = L_CLR_BIT_FLAG (cb->flags, L_CB_VISITED);

  List_start (header->traceregions);
  while ((tr = (LB_TraceRegion *) List_next (header->traceregions)))
    {
      Graph_dfs_topo_sort (tr->flow_graph);
      List_start (tr->flow_graph->topo_list);
      while ((cb = LB_next_cb_in_region (tr)))
	cb->flags = L_SET_BIT_FLAG (cb->flags, L_CB_VISITED);
    }
  return;
}
Int SystemCfg_delete(SystemCfg_Object **objPtr)
{
    Int                 bufSize;
    List_Elem *         elem = NULL;
    SystemCfg_Object *  obj;
    IArg                key;


    Log_print0(Diags_ENTRY, "--> "FXNN": ()");

    /* remove object from module list */
    key = GateH_enter(Mod_gate);

    while ((elem = List_next(Mod_objList, elem)) != NULL) {
        obj = (SystemCfg_Object *)elem;

        if (obj == *objPtr) {
            List_remove(Mod_objList, elem);
            break;
        }
    }

    GateH_leave(Mod_gate, key);

    /* delete sync object */
    if ((*objPtr)->semH != NULL) {
        Semaphore_destruct(&(*objPtr)->semObj);
        (*objPtr)->semH = NULL;
    }

    /* free the name buffer */
    bufSize = strlen((*objPtr)->remoteProcName) + 1;
    xdc_runtime_Memory_free(NULL, (Ptr)((*objPtr)->remoteProcName), bufSize);

    /* free the object memory */
    xdc_runtime_Memory_free(NULL, (Ptr)(*objPtr), sizeof(SystemCfg_Object));
    *objPtr = NULL;

    Log_print1(Diags_EXIT, "<-- "FXNN": %d", (IArg)SystemCfg_S_SUCCESS);
    return(SystemCfg_S_SUCCESS);
}
예제 #23
0
static void
PD_print_mem_access (FILE * out_file, Expr expr)
{
  P_memdep_t md;
  List mem_obj_list;
  P_memdep_core_t mem_obj;

  md = P_GetMemDep (expr);
  assert (md);
  mem_obj_list = md->deps;
  assert (List_size (mem_obj_list) > 0);
  fprintf (stderr, "%5s {(id, offset, size)} = { ",
	   PD_IsMemWriteExpr (expr) ? "write" : "read");
  List_start (mem_obj_list);
  while ((mem_obj = List_next (mem_obj_list)))
    fprintf (stderr, "(%5d,%5d,%5d) ", mem_obj->id, mem_obj->offset,
	     mem_obj->size);
  fprintf (stderr, "}");

  return;
}
예제 #24
0
파일: srcfile.c 프로젝트: meesokim/z88dk
/* check for recursive includes, call error callback and return FALSE abort if found
   returns TRUE if callback not defined */
static Bool check_recursive_include( SrcFile *self, char *filename )
{
	ListElem *iter;
    FileStackElem *elem;
	
	if ( incl_recursion_err_cb != NULL )
	{
		for ( iter = List_first( self->file_stack ) ; iter != NULL ;
			iter = List_next( iter ) )
		{
			elem = iter->data;
			if ( elem->filename != NULL &&
				 strcmp( filename, elem->filename ) == 0 )
			{
				incl_recursion_err_cb( filename );
				return FALSE;
			}
		}
	}
	return TRUE;
}
예제 #25
0
/*! \brief determine if geometric IV
 *
 * \param scc
 *   SCC to check
 *
 * \return
 *   1 if classified
 *
 * SCC must be made up of additions and subtractions of loop invariants,
 * linear induction variables, and/or other polynomial IVs.  SCC must contain
 * at least 1 multiplication of the sequence variable by a loop invariant.
 * Must contain exactly 1 mu node.
 */
static int
Classify_Geometric(PSS_TarSCC scc)
{
#if 0
    PSS_TarNode tnode;
    int arith_op, num_arith = 0;

    if (scc->mu_nodes != 1)
        return 0;

    /* loop through all the nodes in the SCC */
    List_start(scc->tnode_list);

    while ((tnode = List_next(scc->tnode_list)))
    {
        arith_op = 0;
        if (!Geom_Expr_Test(scc, tnode->expr, &arith_op))
            return 0;
        num_arith += (arith_op ? 1 : 0);
    }

    if (num_arith == 0)
        return 0;

    if (scc->phi_nodes == 0)
    {
        scc->type = GEOMETRIC;
        STATS.scc_type.geometric++;
    }
    else
    {
        scc->type = GEOMETRIC_MONOTONIC;
        STATS.scc_type.geometric_monotonic++;
    }
    PSS_PrintSCC(scc);
    return 1;
#else
    return 0;
#endif
}
예제 #26
0
void
IPA_funcsymbol_free (IPA_prog_info_t * info, IPA_funcsymbol_info_t * fninfo)
{
  IPA_callsite_t *cs;

  IPA_interface_free (fninfo->iface);
  /*List_reset(fninfo->tmp_var_ids); */

  List_start (fninfo->callsites);
  while ((cs = List_next (fninfo->callsites)))
    {
      IPA_callsite_free (info, cs);
    }
  List_reset (fninfo->callsites);

  /* Remove from info list */
  info->fninfos = List_remove (info->fninfos, fninfo);

  IPA_cg_cgraph_free (fninfo->consg);
  if (fninfo->lsum_consg != fninfo->consg)
    IPA_cg_cgraph_free (fninfo->lsum_consg);

  {
    IPA_summary_info_t     *sum_info;
    IPA_summary_info_t     *nxt_info;
    for (sum_info = fninfo->sum_info; sum_info;
	 sum_info = nxt_info)
    {
      nxt_info = sum_info->nxt;
      List_reset(sum_info->sum_nodes);
      free(sum_info);
    }
    fninfo->sum_info = NULL;
  }

  free (fninfo);
}
예제 #27
0
/*! \brief determine if linear IV
 *
 * \param scc
 *   SCC to check
 *
 * \return
 *   1 if classified
 *
 * SCC must be made up of additions and subtractoins of loop invariants
 * and / or other linear induction variables
 *
 * SCC must contain exactly 1 mu node
 *
 * SCC must contain 0 phi nodes or be classified as monotonic
 */
static int
Classify_Linear(PSS_TarSCC scc)
{
    PSS_TarNode tnode;
    int arith_op, num_arith = 0;

    if (scc->mu_nodes != 1)
        return 0;

    /* loop through all the nodes in the SCC */
    List_start(scc->tnode_list);

    while ((tnode = List_next(scc->tnode_list)))
    {
        arith_op = 0;
        if (!Linear_Expr_Test(scc, tnode->expr, &arith_op))
            return 0;
        num_arith += (arith_op ? 1 : 0);
    }

    /* If there are no arithmetic ops, can't be linear. */
    if (num_arith == 0)
        return 0;

    if (scc->phi_nodes == 0)
    {
        scc->type = LINEAR;
        STATS.scc_type.linear++;
    }
    else
    {
        scc->type = LINEAR_MONOTONIC;
        STATS.scc_type.linear_monotonic++;
    }
    PSS_PrintSCC(scc);
    return 1;
}
예제 #28
0
/*! \brief determine if pointer IV
 *
 * \param scc
 *   SCC to check
 *
 * \return
 *   1 if classified
 *
 * SCC must be made up of additions and subtractions of loop invariants,
 * linear induction variables, and an OP_arrow
 */
static int
Classify_Pointer(PSS_TarSCC scc)
{
    PSS_TarNode tnode;
    int pointer_op, num_pointer = 0;

    if (scc->mu_nodes != 1)
        return 0;

    /* loop through all the nodes in the SCC */
    List_start(scc->tnode_list);

    while ((tnode = List_next(scc->tnode_list)))
    {
        pointer_op = 0;
        if (!Pointer_Expr_Test(scc, tnode->expr, &pointer_op))
            return 0;
        num_pointer += (pointer_op ? 1 : 0);
    }

    if (num_pointer == 0)
        return 0;

    if (scc->phi_nodes == 0)
    {
        scc->type = POINTER;
        STATS.scc_type.pointer++;
    }
    else
    {
        scc->type = POINTER_MONOTONIC;
        STATS.scc_type.pointer_monotonic++;
    }
    PSS_PrintSCC(scc);
    return 1;
}
예제 #29
0
/*! \brief determine if polynomial IV
 *
 * \param scc
 *   SCC to check
 *
 * \return
 *   1 if classified
 *
 * SCC must be made up of additions and subtractions of loop invariants,
 * linear induction variables, and/or other polynomial IVs.  Must contain
 * exactly 1 mu node.
 */
static int
Classify_Polynomial(PSS_TarSCC scc)
{
    PSS_TarNode tnode;
    int arith_op, num_arith = 0;

    if (scc->mu_nodes != 1)
        return 0;

    /* loop through all the nodes in the SCC */
    List_start(scc->tnode_list);

    while ((tnode = List_next(scc->tnode_list)))
    {
        arith_op = 0;
        if (!Poly_Expr_Test(scc, tnode->expr, &arith_op))
            return 0;
        num_arith += (arith_op ? 1 : 0);
    }

    if (num_arith == 0)
        return 0;

    if (scc->phi_nodes == 0)
    {
        scc->type = POLYNOMIAL;
        STATS.scc_type.polynomial++;
    }
    else
    {
        scc->type = POLYNOMIAL_MONOTONIC;
        STATS.scc_type.polynomial_monotonic++;
    }
    PSS_PrintSCC(scc);
    return 1;
}
void
LB_superblock_formation (L_Func * fn)
{
  LB_TraceRegion_Header *header;
  LB_TraceRegion *tr_index;
  Heap *tr_heap;
  int list_size, i, code_size = 0, max_code_size, growth, do_frp;

  if (fn->n_cb == 0)
    return;

  do_frp = !strcmp (LB_predicate_formation_type, "frp");

  header = LB_function_init (fn);

  L_partial_dead_code_removal (fn);
  L_do_flow_analysis (fn, DOMINATOR_CB|SUPPRESS_PG);
  L_loop_detection (fn, 0);

  L_compute_oper_weight (fn, 0, 1);
  LB_convert_to_strict_basic_block_code (fn,
		     L_CB_SUPERBLOCK | L_CB_HYPERBLOCK |
		     L_CB_ENTRANCE_BOUNDARY | L_CB_EXIT_BOUNDARY);

  L_do_flow_analysis (fn, DOMINATOR_CB);
  L_compute_oper_weight (fn, 0, 1);

  LB_mark_jrg_flag (fn);

  LB_make_traceregions (fn, TRUE, header);
  LB_order_traceregions (fn, header);
  LB_layout_function (fn, header);

  tr_heap = Heap_Create (HEAP_MAX);

  List_start (header->traceregions);
  while ((tr_index = (LB_TraceRegion *) List_next (header->traceregions)))
    {
      code_size += LB_traceregion_code_size (tr_index);
      Graph_dfs_topo_sort (tr_index->flow_graph);
      if ((tr_index->weight >= LB_minimum_superblock_weight) &&
	  !(tr_index->flags & 
	    (L_TRACEREGION_HYPERBLOCK | L_TRACEREGION_SUPERBLOCK)) &&
	  (tr_index->header != LB_last_cb_in_region (tr_index)))
	Heap_Insert (tr_heap, tr_index, tr_index->weight);
    }

  max_code_size = (int) (LB_maximum_code_growth * code_size);

  LB_predicate_init ();

  while ((tr_heap->size > 0) && (code_size < max_code_size))
    {
      tr_index = (LB_TraceRegion *) Heap_ExtractTop (tr_heap);

      growth = LB_tail_duplication (fn, tr_index, LB_DUP_INSIDE_REGION, 1);

      if ((code_size + growth) > max_code_size)
	continue;

      code_size += LB_tail_duplication (fn, tr_index, LB_DUP_INSIDE_REGION, 0);

      LB_predicate_traceregion (fn, tr_index, do_frp);
      L_set_hb_no_fallthru_flag (fn);
      L_check_func (fn);

      tr_index->flags |= L_TRACEREGION_SUPERBLOCK;

      L_rebuild_src_flow (fn);
      LB_mark_jrg_flag (fn);

      /* Make traces with the new end cb's */
      list_size = List_size (header->traceregions);
      LB_make_traceregions (fn, FALSE, header);
      LB_order_traceregions (fn, header);
      LB_layout_function (fn, header);

      i = 0;
      while ((tr_index = (LB_TraceRegion *) List_next (header->traceregions)))
	{
	  if (++i <= list_size)
	    continue;

	  Graph_dfs_topo_sort (tr_index->flow_graph);

	  if ((tr_index->weight >= LB_minimum_superblock_weight) &&
	      !(tr_index->flags & (L_TRACEREGION_HYPERBLOCK |
				   L_TRACEREGION_SUPERBLOCK)) &&
	      (tr_index->header != LB_last_cb_in_region (tr_index)))
	    Heap_Insert (tr_heap, tr_index, tr_index->weight);
	}
    }

  tr_heap = Heap_Dispose (tr_heap, NULL);

  LB_predicate_deinit (fn);

  fn->flags = L_SET_BIT_FLAG (fn->flags, L_FUNC_SUPERBLOCK);
  L_rebuild_src_flow (fn);

  if (do_frp || LB_hb_do_combine_exits)
    {
      L_create_uncond_pred_defines (fn);
      L_combine_pred_defines (fn);
    }

  /* For each source code function we process deinit */
  LB_function_deinit (header);
  return;
}