source: vis_dev/vl2mv-2.3/src/parser/dataflow.c @ 18

Last change on this file since 18 was 18, checked in by cecile, 13 years ago

vl2mv added

File size: 3.3 KB
Line 
1/*
2
3  Copyright (c) 1992, 1993
4        Regents of the University of California
5  All rights reserved.
6
7  Use and copying of this software and preparation of derivative works
8  based upon this software are permitted.  However, any distribution of
9  this software or derivative works must include the above copyright
10  notice.
11
12  This software is made available AS IS, and neither the Electronics
13  Research Laboratory or the Universify of California make any
14  warranty about the software, its performance or its conformity to
15  any specification.
16
17  Author: Szu-Tsung Cheng, stcheng@ic.Berkeley.EDU
18          10/92
19          10/93
20
21  $Header: /projects/development/hsv/CVSRepository/vl2mv/src/parser/dataflow.c,v 1.1.1.1 2001/07/09 23:22:38 fabio Exp $
22
23
24*/
25
26
27#include "util.h"
28#include "st.h"
29#include "list.h"
30#include "array.h"
31#include "set.h"
32#include "stack.h"
33#include "vl_types.h"
34#include "vl_defs.h"
35#include "vlr_int.h"
36#include "dataflow.h"
37#include "verilog.h"
38
39int dflow_analysis = 0;
40int dflow_context = 0;
41lsList init_var_stack;
42
43void dataflow_init()
44{
45    init_var_stack = lsCreate();
46    push_stack(init_var_stack, set_empty());
47}
48
49void dataflow_end()
50{
51    lsGen gen;
52    lsHandle handle;
53    set_t *set;
54
55    gen = lsStart(init_var_stack);
56    while (lsNext(gen, (lsGeneric*)&set, &handle) != LS_NOMORE) {
57        set_destroy(set);
58    }
59    lsFinish(gen);
60    lsDestroy(init_var_stack, 0);
61    init_var_stack = 0;
62}
63
64
65void dataflow_analysis(analysis_type, id_sym, gen, kill) 
66int analysis_type;
67vl_id_range *id_sym;
68int gen;
69int kill;
70{
71    if (gen && kill) {
72        char buf[MAXSTRLEN];
73
74        sprintf("dataflow analysis: GEN and KILL '%s' at the same time",
75                id_sym->name);
76        internal_error(buf);
77    }
78
79    if (vl_currentModule) {
80
81        if (analysis_type & DF_UninitVar &&
82            (dflow_context & DFLOW_Always)) {
83            if (gen) 
84                record_uninitialized_var(id_sym);
85            else if (kill)
86                record_initialized_var(id_sym);
87        }
88
89    }
90
91}
92
93void dataflow_dup_set()
94{
95    if (!init_var_stack) return;
96    push_stack(init_var_stack, (void*)set_dup(top_stack(init_var_stack)));
97}
98
99set_t *dataflow_pop_set()
100{
101    set_t *retval;
102
103    if (!init_var_stack) return NIL(set_t);
104    pop_stack(init_var_stack, (void**)&retval);
105    return retval;
106}
107
108void dataflow_replace_set(new_set)
109set_t *new_set;
110{
111    set_t *top_set;
112
113    if (!init_var_stack) return;
114    pop_stack(init_var_stack, (void**)&top_set);
115    push_stack(init_var_stack, new_set);
116    set_destroy(top_set);
117}
118
119set_t *dataflow_merge_set(set1, set2)
120set_t *set1, *set2;
121{
122    set_t *retval;
123
124    if (!init_var_stack) return NIL(set_t);
125    retval = set_intersect(set1, set2);
126    return retval;
127}
128
129void dataflow_free_set(set)
130set_t *set;
131{
132    if (set) set_destroy(set);
133}
134
135void record_uninitialized_var(id_sym)
136vl_id_range *id_sym;
137{
138    if (!init_var_stack) return;
139
140    if (!set_find(id_sym->name, (set_t*)top_stack(init_var_stack))) {
141        if (!set_find(id_sym->name, vl_currentModule->uninit_set)) {
142            vl_id_range *id_range;
143
144            if (st_lookup(vl_currentModule->sig_st, 
145                          id_sym->name, (char**)&id_range)) {
146                id_range->flags |= UninitializeVar;
147                set_add(id_range->name, vl_currentModule->uninit_set);
148            } 
149        }
150    }
151}
152
153void record_initialized_var(id_sym)
154vl_id_range *id_sym;
155{
156    if (!init_var_stack) return;
157
158    if (!set_find(id_sym->name, (set_t*)top_stack(init_var_stack))) {
159        set_add(id_sym->name, (set_t*)top_stack(init_var_stack));
160    }
161}
162
163
164
Note: See TracBrowser for help on using the repository browser.