/[bison]/bison/lib/bitset_stats.c
ViewVC logotype

Diff of /bison/lib/bitset_stats.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by eggert, Mon Aug 12 14:16:49 2002 UTC revision 1.3 by akim, Mon Sep 30 12:50:49 2002 UTC
# Line 118  int bitset_stats_enabled = 0; Line 118  int bitset_stats_enabled = 0;
118    
119  static void bitset_stats_set PARAMS ((bitset, bitset_bindex));  static void bitset_stats_set PARAMS ((bitset, bitset_bindex));
120  static void bitset_stats_reset PARAMS ((bitset, bitset_bindex));  static void bitset_stats_reset PARAMS ((bitset, bitset_bindex));
121    static int bitset_stats_toggle PARAMS ((bitset, bitset_bindex));
122  static int bitset_stats_test PARAMS ((bitset, bitset_bindex));  static int bitset_stats_test PARAMS ((bitset, bitset_bindex));
123  static int bitset_stats_size PARAMS ((bitset));  static int bitset_stats_size PARAMS ((bitset));
 static int bitset_stats_op1 PARAMS ((bitset, enum bitset_ops));  
 static int bitset_stats_op2 PARAMS ((bitset, bitset, enum bitset_ops));  
 static int bitset_stats_op3 PARAMS ((bitset, bitset, bitset, enum bitset_ops));  
 static int bitset_stats_op4 PARAMS ((bitset, bitset, bitset, bitset,  
                                      enum bitset_ops));  
124  static int bitset_stats_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,  static int bitset_stats_list PARAMS ((bitset, bitset_bindex *, bitset_bindex,
125                                        bitset_bindex *));                                        bitset_bindex *));
126  static int bitset_stats_reverse_list  static int bitset_stats_list_reverse
127  PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));  PARAMS ((bitset, bitset_bindex *, bitset_bindex, bitset_bindex *));
128  static void bitset_stats_free PARAMS ((bitset));  static void bitset_stats_free PARAMS ((bitset));
129  static void bitset_percent_histogram_print PARAMS ((FILE *, const char *,  static void bitset_percent_histogram_print PARAMS ((FILE *, const char *,
# Line 183  bitset_log_histogram_print (file, name, Line 179  bitset_log_histogram_print (file, name,
179    unsigned int i;    unsigned int i;
180    unsigned int total;    unsigned int total;
181    unsigned int max_width;    unsigned int max_width;
   unsigned int last_bin;  
182    
183    total = 0;    total = 0;
184    for (i = 0; i < n_bins; i++)    for (i = 0; i < n_bins; i++)
# Line 192  bitset_log_histogram_print (file, name, Line 187  bitset_log_histogram_print (file, name,
187    if (!total)    if (!total)
188      return;      return;
189    
190      /* Determine number of useful bins.  */
191    for (i = n_bins; i > 3 && ! bins[i - 1]; i--)    for (i = n_bins; i > 3 && ! bins[i - 1]; i--)
192       continue;       continue;
193    last_bin = i - 1;    n_bins = i;
194    
195    /* 2 * ceil (log10 (2) * (N - 1)) + 1.  */    /* 2 * ceil (log10 (2) * (N - 1)) + 1.  */
196    max_width = 2 * (unsigned int) (0.30103 * (n_bins - 1) + 0.9999) + 1;    max_width = 2 * (unsigned int) (0.30103 * (n_bins - 1) + 0.9999) + 1;
# Line 204  bitset_log_histogram_print (file, name, Line 200  bitset_log_histogram_print (file, name,
200      fprintf (file, "%*d\t%8d (%5.1f%%)\n",      fprintf (file, "%*d\t%8d (%5.1f%%)\n",
201               max_width, i, bins[i], 100.0 * bins[i] / total);               max_width, i, bins[i], 100.0 * bins[i] / total);
202    
203    for (; i <= last_bin; i++)    for (; i < n_bins; i++)
204      fprintf (file, "%*d-%d\t%8d (%5.1f%%)\n",      fprintf (file, "%*d-%d\t%8d (%5.1f%%)\n",
205               max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),               max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
206               1 << (i - 1), (1 << i) - 1, bins[i],               1 << (i - 1), (1 << i) - 1, bins[i],
# Line 256  bitset_stats_print (file, verbose) Line 252  bitset_stats_print (file, verbose)
252       int verbose ATTRIBUTE_UNUSED;       int verbose ATTRIBUTE_UNUSED;
253  {  {
254    int i;    int i;
   static const char *names[] = BITSET_TYPE_NAMES;  
255    
256    if (!bitset_stats_info)    if (!bitset_stats_info)
257      return;      return;
# Line 267  bitset_stats_print (file, verbose) Line 262  bitset_stats_print (file, verbose)
262      fprintf (file, _("Accumulated runs = %d\n"), bitset_stats_info->runs);      fprintf (file, _("Accumulated runs = %d\n"), bitset_stats_info->runs);
263    
264    for (i = 0; i < BITSET_TYPE_NUM; i++)    for (i = 0; i < BITSET_TYPE_NUM; i++)
265      bitset_stats_print_1 (file, names[i], &bitset_stats_info->types[i]);      bitset_stats_print_1 (file, bitset_type_names[i],
266                              &bitset_stats_info->types[i]);
267  }  }
268    
269    
# Line 405  bitset_stats_reset (dst, bitno) Line 401  bitset_stats_reset (dst, bitno)
401    
402    
403  static int  static int
404    bitset_stats_toggle (src, bitno)
405         bitset src;
406         bitset_bindex bitno;
407    {
408        return BITSET_TOGGLE_ (src->s.bset, bitno);
409    }
410    
411    
412    static int
413  bitset_stats_test (src, bitno)  bitset_stats_test (src, bitno)
414       bitset src;       bitset src;
415       bitset_bindex bitno;       bitset_bindex bitno;
# Line 434  bitset_stats_size (src) Line 439  bitset_stats_size (src)
439    
440    
441  static int  static int
442  bitset_stats_op1 (dst, op)  bitset_stats_count (src)
443         bitset src;
444    {
445      return BITSET_COUNT_ (src->s.bset);
446    }
447    
448    
449    static int
450    bitset_stats_empty_p (dst)
451         bitset dst;
452    {
453      return BITSET_EMPTY_P_ (dst->s.bset);
454    }
455    
456    
457    static void
458    bitset_stats_ones (dst)
459         bitset dst;
460    {
461      BITSET_ONES_ (dst->s.bset);
462    }
463    
464    
465    static void
466    bitset_stats_zero (dst)
467         bitset dst;
468    {
469      BITSET_ZERO_ (dst->s.bset);
470    }
471    
472    
473    static void
474    bitset_stats_copy (dst, src)
475         bitset dst;
476         bitset src;
477    {
478      BITSET_CHECK2_ (dst, src);
479      BITSET_COPY_ (dst->s.bset, src->s.bset);
480    }
481    
482    
483    static int
484    bitset_stats_disjoint_p (dst, src)
485       bitset dst;       bitset dst;
486       enum bitset_ops op;       bitset src;
487  {  {
488    return BITSET_OP1_ (dst->s.bset, op);    BITSET_CHECK2_ (dst, src);
489      return BITSET_DISJOINT_P_ (dst->s.bset, src->s.bset);
490  }  }
491    
492    
493  static int  static int
494  bitset_stats_op2 (dst, src, op)  bitset_stats_equal_p (dst, src)
495       bitset dst;       bitset dst;
496       bitset src;       bitset src;
      enum bitset_ops op;  
497  {  {
498    BITSET_CHECK2_ (dst, src);    BITSET_CHECK2_ (dst, src);
499    return BITSET_OP2_ (dst->s.bset, src->s.bset, op);    return BITSET_EQUAL_P_ (dst->s.bset, src->s.bset);
500    }
501    
502    
503    static void
504    bitset_stats_not (dst, src)
505         bitset dst;
506         bitset src;
507    {
508      BITSET_CHECK2_ (dst, src);
509      BITSET_NOT_ (dst->s.bset, src->s.bset);
510    }
511    
512    
513    static int
514    bitset_stats_subset_p (dst, src)
515         bitset dst;
516         bitset src;
517    {
518      BITSET_CHECK2_ (dst, src);
519      return BITSET_SUBSET_P_ (dst->s.bset, src->s.bset);
520    }
521    
522    
523    static void
524    bitset_stats_and (dst, src1, src2)
525         bitset dst;
526         bitset src1;
527         bitset src2;
528    {
529      BITSET_CHECK3_ (dst, src1, src2);
530      BITSET_AND_ (dst->s.bset, src1->s.bset, src2->s.bset);
531    }
532    
533    
534    static int
535    bitset_stats_and_cmp (dst, src1, src2)
536         bitset dst;
537         bitset src1;
538         bitset src2;
539    {
540      BITSET_CHECK3_ (dst, src1, src2);
541      return BITSET_AND_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
542    }
543    
544    
545    static void
546    bitset_stats_andn (dst, src1, src2)
547         bitset dst;
548         bitset src1;
549         bitset src2;
550    {
551      BITSET_CHECK3_ (dst, src1, src2);
552      BITSET_ANDN_ (dst->s.bset, src1->s.bset, src2->s.bset);
553    }
554    
555    
556    static int
557    bitset_stats_andn_cmp (dst, src1, src2)
558         bitset dst;
559         bitset src1;
560         bitset src2;
561    {
562      BITSET_CHECK3_ (dst, src1, src2);
563      return BITSET_ANDN_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
564    }
565    
566    
567    static void
568    bitset_stats_or (dst, src1, src2)
569         bitset dst;
570         bitset src1;
571         bitset src2;
572    {
573      BITSET_CHECK3_ (dst, src1, src2);
574      BITSET_OR_ (dst->s.bset, src1->s.bset, src2->s.bset);
575    }
576    
577    
578    static int
579    bitset_stats_or_cmp (dst, src1, src2)
580         bitset dst;
581         bitset src1;
582         bitset src2;
583    {
584      BITSET_CHECK3_ (dst, src1, src2);
585      return BITSET_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
586    }
587    
588    
589    static void
590    bitset_stats_xor (dst, src1, src2)
591         bitset dst;
592         bitset src1;
593         bitset src2;
594    {
595      BITSET_CHECK3_ (dst, src1, src2);
596      BITSET_XOR_ (dst->s.bset, src1->s.bset, src2->s.bset);
597  }  }
598    
599    
600  static int  static int
601  bitset_stats_op3 (dst, src1, src2, op)  bitset_stats_xor_cmp (dst, src1, src2)
602       bitset dst;       bitset dst;
603       bitset src1;       bitset src1;
604       bitset src2;       bitset src2;
      enum bitset_ops op;  
605  {  {
606    BITSET_CHECK3_ (dst, src1, src2);    BITSET_CHECK3_ (dst, src1, src2);
607    return BITSET_OP3_ (dst->s.bset, src1->s.bset, src2->s.bset, op);    return BITSET_XOR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset);
608    }
609    
610    
611    static void
612    bitset_stats_and_or (dst, src1, src2, src3)
613         bitset dst;
614         bitset src1;
615         bitset src2;
616         bitset src3;
617    {
618      BITSET_CHECK4_ (dst, src1, src2, src3);
619    
620      BITSET_AND_OR_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
621  }  }
622    
623    
624  static int  static int
625  bitset_stats_op4 (dst, src1, src2, src3, op)  bitset_stats_and_or_cmp (dst, src1, src2, src3)
626       bitset dst;       bitset dst;
627       bitset src1;       bitset src1;
628       bitset src2;       bitset src2;
629       bitset src3;       bitset src3;
      enum bitset_ops op;  
630  {  {
631    BITSET_CHECK4_ (dst, src1, src2, src3);    BITSET_CHECK4_ (dst, src1, src2, src3);
632    
633    /* This is a bit of a hack.  If the implementation handles    return BITSET_AND_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
634       a four operand operation then vector to it, passing  }
635       the enclosed bitsets.  Otherwise use the fallback  
636       bitset_op4 routine.  */  
637    if (dst->s.bset->b.ops->op4 != bitset_op4)  static void
638       return BITSET_OP4_ (dst->s.bset, src1->s.bset, src2->s.bset,  bitset_stats_andn_or (dst, src1, src2, src3)
639                           src3->s.bset, op);       bitset dst;
640         bitset src1;
641         bitset src2;
642         bitset src3;
643    {
644      BITSET_CHECK4_ (dst, src1, src2, src3);
645    
646      BITSET_ANDN_OR_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
647    }
648    
649    
650    static int
651    bitset_stats_andn_or_cmp (dst, src1, src2, src3)
652         bitset dst;
653         bitset src1;
654         bitset src2;
655         bitset src3;
656    {
657      BITSET_CHECK4_ (dst, src1, src2, src3);
658    
659      return BITSET_ANDN_OR_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
660    }
661    
662    
663    static void
664    bitset_stats_or_and (dst, src1, src2, src3)
665         bitset dst;
666         bitset src1;
667         bitset src2;
668         bitset src3;
669    {
670      BITSET_CHECK4_ (dst, src1, src2, src3);
671    
672      BITSET_OR_AND_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
673    }
674    
675    
676    static int
677    bitset_stats_or_and_cmp (dst, src1, src2, src3)
678         bitset dst;
679         bitset src1;
680         bitset src2;
681         bitset src3;
682    {
683      BITSET_CHECK4_ (dst, src1, src2, src3);
684    
685    return bitset_op4 (dst, src1, src2, src3, op);    return BITSET_OR_AND_CMP_ (dst->s.bset, src1->s.bset, src2->s.bset, src3->s.bset);
686  }  }
687    
688    
# Line 530  bitset_stats_list (bset, list, num, next Line 729  bitset_stats_list (bset, list, num, next
729    
730    
731  static int  static int
732  bitset_stats_reverse_list (bset, list, num, next)  bitset_stats_list_reverse (bset, list, num, next)
733       bitset bset;       bitset bset;
734       bitset_bindex *list;       bitset_bindex *list;
735       bitset_bindex num;       bitset_bindex num;
736       bitset_bindex *next;       bitset_bindex *next;
737  {  {
738    return BITSET_REVERSE_LIST_ (bset->s.bset, list, num, next);    return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
739  }  }
740    
741    
# Line 549  bitset_stats_free (bset) Line 748  bitset_stats_free (bset)
748  }  }
749    
750    
751  struct bitset_ops_struct bitset_stats_ops = {  struct bitset_vtable bitset_stats_vtable = {
752    bitset_stats_set,    bitset_stats_set,
753    bitset_stats_reset,    bitset_stats_reset,
754      bitset_stats_toggle,
755    bitset_stats_test,    bitset_stats_test,
756    bitset_stats_size,    bitset_stats_size,
757    bitset_stats_op1,    bitset_stats_count,
758    bitset_stats_op2,    bitset_stats_empty_p,
759    bitset_stats_op3,    bitset_stats_ones,
760    bitset_stats_op4,    bitset_stats_zero,
761      bitset_stats_copy,
762      bitset_stats_disjoint_p,
763      bitset_stats_equal_p,
764      bitset_stats_not,
765      bitset_stats_subset_p,
766      bitset_stats_and,
767      bitset_stats_and_cmp,
768      bitset_stats_andn,
769      bitset_stats_andn_cmp,
770      bitset_stats_or,
771      bitset_stats_or_cmp,
772      bitset_stats_xor,
773      bitset_stats_xor_cmp,
774      bitset_stats_and_or,
775      bitset_stats_and_or_cmp,
776      bitset_stats_andn_or,
777      bitset_stats_andn_or_cmp,
778      bitset_stats_or_and,
779      bitset_stats_or_and_cmp,
780    bitset_stats_list,    bitset_stats_list,
781    bitset_stats_reverse_list,    bitset_stats_list_reverse,
782    bitset_stats_free,    bitset_stats_free,
783    BITSET_STATS    BITSET_STATS
784  };  };
# Line 589  bitset_stats_init (bset, n_bits, type) Line 808  bitset_stats_init (bset, n_bits, type)
808    unsigned int bytes;    unsigned int bytes;
809    bitset sbset;    bitset sbset;
810    
811    bset->b.ops = &bitset_stats_ops;    bset->b.vtable = &bitset_stats_vtable;
812    
813    /* Disable cache.  */    /* Disable cache.  */
814    bset->b.cindex = 0;    bset->b.cindex = 0;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26